on 2022/3/29 21:08, Matthew Wilcox wrote:
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.
how about compound_index ?
@@ -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.
OK, I will send v2, but I'm not sure whether similar function like
page_nth is needed elsewhere
.