Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e4b294c2 authored by Kirill A. Shutemov's avatar Kirill A. Shutemov Committed by Linus Torvalds
Browse files

mm: add fields for compound destructor and order into struct page



Currently, we use lru.next/lru.prev plus cast to access or set
destructor and order of compound page.

Let's replace it with explicit fields in struct page.

Signed-off-by: default avatarKirill A. Shutemov <kirill.shutemov@linux.intel.com>
Acked-by: default avatarJerome Marchand <jmarchan@redhat.com>
Acked-by: default avatarChristoph Lameter <cl@linux.com>
Acked-by: default avatarJohannes Weiner <hannes@cmpxchg.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent aa7ed01f
Loading
Loading
Loading
Loading
+4 −5
Original line number Original line Diff line number Diff line
@@ -627,29 +627,28 @@ int split_free_page(struct page *page);
 * prototype for that function and accessor functions.
 * prototype for that function and accessor functions.
 * These are _only_ valid on the head of a PG_compound page.
 * These are _only_ valid on the head of a PG_compound page.
 */
 */
typedef void compound_page_dtor(struct page *);


static inline void set_compound_page_dtor(struct page *page,
static inline void set_compound_page_dtor(struct page *page,
						compound_page_dtor *dtor)
						compound_page_dtor *dtor)
{
{
	page[1].lru.next = (void *)dtor;
	page[1].compound_dtor = dtor;
}
}


static inline compound_page_dtor *get_compound_page_dtor(struct page *page)
static inline compound_page_dtor *get_compound_page_dtor(struct page *page)
{
{
	return (compound_page_dtor *)page[1].lru.next;
	return page[1].compound_dtor;
}
}


static inline int compound_order(struct page *page)
static inline int compound_order(struct page *page)
{
{
	if (!PageHead(page))
	if (!PageHead(page))
		return 0;
		return 0;
	return (unsigned long)page[1].lru.prev;
	return page[1].compound_order;
}
}


static inline void set_compound_order(struct page *page, unsigned long order)
static inline void set_compound_order(struct page *page, unsigned long order)
{
{
	page[1].lru.prev = (void *)order;
	page[1].compound_order = order;
}
}


#ifdef CONFIG_MMU
#ifdef CONFIG_MMU
+8 −0
Original line number Original line Diff line number Diff line
@@ -28,6 +28,8 @@ struct mem_cgroup;
		IS_ENABLED(CONFIG_ARCH_ENABLE_SPLIT_PMD_PTLOCK))
		IS_ENABLED(CONFIG_ARCH_ENABLE_SPLIT_PMD_PTLOCK))
#define ALLOC_SPLIT_PTLOCKS	(SPINLOCK_SIZE > BITS_PER_LONG/8)
#define ALLOC_SPLIT_PTLOCKS	(SPINLOCK_SIZE > BITS_PER_LONG/8)


typedef void compound_page_dtor(struct page *);

/*
/*
 * Each physical page in the system has a struct page associated with
 * Each physical page in the system has a struct page associated with
 * it to keep track of whatever it is we are using the page for at the
 * it to keep track of whatever it is we are using the page for at the
@@ -142,6 +144,12 @@ struct page {
		struct rcu_head rcu_head;	/* Used by SLAB
		struct rcu_head rcu_head;	/* Used by SLAB
						 * when destroying via RCU
						 * when destroying via RCU
						 */
						 */
		/* First tail page of compound page */
		struct {
			compound_page_dtor *compound_dtor;
			unsigned long compound_order;
		};

#if defined(CONFIG_TRANSPARENT_HUGEPAGE) && USE_SPLIT_PMD_PTLOCKS
#if defined(CONFIG_TRANSPARENT_HUGEPAGE) && USE_SPLIT_PMD_PTLOCKS
		pgtable_t pmd_huge_pte; /* protected by page->ptl */
		pgtable_t pmd_huge_pte; /* protected by page->ptl */
#endif
#endif