Re: [PATCH 2/2] mm: fix contiguous memmap assumptions about alloc/free pages
From: Matthew Wilcox
Date: Tue Mar 29 2022 - 09:08:40 EST
On Tue, Mar 29, 2022 at 09:09:28PM +0800, Chen Wandun wrote:
> +#define page_nth(head, tail) (page_to_pfn(tail) - page_to_pfn(head))
Could we avoid reintroducing page_nth()? It is a terrible name.
> @@ -1213,7 +1213,7 @@ static int free_tail_pages_check(struct page *head_page, struct page *page)
> ret = 0;
> goto out;
> }
> - switch (page - head_page) {
> + switch (page_nth(head_page, page)) {
> case 1:
> /* the first tail page: ->mapping may be compound_mapcount() */
> if (unlikely(compound_mapcount(page))) {
This is the only place you use it. I'd suggest free_tail_pages_check()
should take 'i' as its second parameter instead of 'page + i', then
there's no need to convert back to i.