The patch titled mm: make compound page destructor handling explicit has been added to the -mm tree. Its filename is mm-make-compound-page-destructor-handling-explicit.patch See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find out what to do about this ------------------------------------------------------ Subject: mm: make compound page destructor handling explicit From: Andy Whitcroft <apw@xxxxxxxxxxxx> Currently we we use the lru head link of the second page of a compound page to hold its destructor. This was ok when it was purely an internal implmentation detail. However, hugetlbfs overrides this destructor violating the layering. Abstract this out as explicit calls, also introduce a type for the callback function allowing them to be type checked. For each callback we pre-declare the function, causing a type error on definition rather than on use elsewhere. Signed-off-by: Andy Whitcroft <apw@xxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxx> --- include/linux/mm.h | 18 ++++++++++++++++++ mm/hugetlb.c | 4 +++- mm/page_alloc.c | 4 +++- mm/swap.c | 4 ++-- 4 files changed, 26 insertions(+), 4 deletions(-) diff -puN include/linux/mm.h~mm-make-compound-page-destructor-handling-explicit include/linux/mm.h --- a/include/linux/mm.h~mm-make-compound-page-destructor-handling-explicit +++ a/include/linux/mm.h @@ -296,6 +296,24 @@ void put_pages_list(struct list_head *pa void split_page(struct page *page, unsigned int order); /* + * Compound pages have a destructor function. Provide a + * prototype for that function and accessor functions. + * 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, + compound_page_dtor *dtor) +{ + page[1].lru.next = (void *)dtor; +} + +static inline compound_page_dtor *get_compound_page_dtor(struct page *page) +{ + return (compound_page_dtor *)page[1].lru.next; +} + +/* * Multiple processes may "see" the same page. E.g. for untouched * mappings of /dev/null, all processes see the same page full of * zeroes, and text pages of executables and shared libraries have diff -puN mm/hugetlb.c~mm-make-compound-page-destructor-handling-explicit mm/hugetlb.c --- a/mm/hugetlb.c~mm-make-compound-page-destructor-handling-explicit +++ a/mm/hugetlb.c @@ -88,6 +88,8 @@ static struct page *dequeue_huge_page(st return page; } +/* declare the destructor to catch a missmatch on definition. */ +static compound_page_dtor free_huge_page; static void free_huge_page(struct page *page) { BUG_ON(page_count(page)); @@ -109,7 +111,7 @@ static int alloc_fresh_huge_page(void) if (nid == MAX_NUMNODES) nid = first_node(node_online_map); if (page) { - page[1].lru.next = (void *)free_huge_page; /* dtor */ + set_compound_page_dtor(page, free_huge_page); spin_lock(&hugetlb_lock); nr_huge_pages++; nr_huge_pages_node[page_to_nid(page)]++; diff -puN mm/page_alloc.c~mm-make-compound-page-destructor-handling-explicit mm/page_alloc.c --- a/mm/page_alloc.c~mm-make-compound-page-destructor-handling-explicit +++ a/mm/page_alloc.c @@ -224,6 +224,8 @@ static void bad_page(struct page *page) * This usage means that zero-order pages may not be compound. */ +/* declare the destructor to catch a missmatch on definition. */ +static compound_page_dtor free_compound_page; static void free_compound_page(struct page *page) { __free_pages_ok(page, (unsigned long)page[1].lru.prev); @@ -234,7 +236,7 @@ static void prep_compound_page(struct pa int i; int nr_pages = 1 << order; - page[1].lru.next = (void *)free_compound_page; /* set dtor */ + set_compound_page_dtor(page, free_compound_page); page[1].lru.prev = (void *)order; for (i = 0; i < nr_pages; i++) { struct page *p = page + i; diff -puN mm/swap.c~mm-make-compound-page-destructor-handling-explicit mm/swap.c --- a/mm/swap.c~mm-make-compound-page-destructor-handling-explicit +++ a/mm/swap.c @@ -57,9 +57,9 @@ static void put_compound_page(struct pag { page = (struct page *)page_private(page); if (put_page_testzero(page)) { - void (*dtor)(struct page *page); + compound_page_dtor *dtor; - dtor = (void (*)(struct page *))page[1].lru.next; + dtor = get_compound_page_dtor(page); (*dtor)(page); } } _ Patches currently in -mm which might be from apw@xxxxxxxxxxxx are git-acpi.patch pci-device-ensure-sysdata-initialised-v2.patch get-rid-of-zone_table.patch deal-with-cases-of-zone_dma-meaning-the-first-zone.patch get-rid-of-zone_table-fix-3.patch optional-zone_dma-in-the-vm.patch zoneid-fix-up-calculations-for-zoneid_pgshift.patch enables-booting-a-numa-system-where-some-nodes-have-no.patch numa-node-ids-are-int-page_to_nid-and-zone_to_nid-should-return-int.patch silence-unused-pgdat-warning-from-alloc_bootmem_node-and-friends.patch mm-cleanup-indentation-on-switch-for-cpu-operations.patch mm-make-compound-page-destructor-handling-explicit.patch mm-make-compound-page-destructor-handling-explicit-tidy.patch - To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html