Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753523AbbG3OI3 (ORCPT ); Thu, 30 Jul 2015 10:08:29 -0400 Received: from mail-wi0-f175.google.com ([209.85.212.175]:38021 "EHLO mail-wi0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751255AbbG3OIZ convert rfc822-to-8bit (ORCPT ); Thu, 30 Jul 2015 10:08:25 -0400 From: Michal Nazarewicz To: Vlastimil Babka , Andrew Morton , linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, "minkyung88.kim" , kmk3210@gmail.com, Seungho Park , Joonsoo Kim , Minchan Kim , Laura Abbott , Naoya Horiguchi , "Kirill A. Shutemov" , Mel Gorman , Johannes Weiner Subject: Re: [PATCH 2/2] mm: rename and move get/set_freepage_migratetype In-Reply-To: <55AF8C94.6020406@suse.cz> Organization: http://mina86.com/ References: <55969822.9060907@suse.cz> <1437483218-18703-1-git-send-email-vbabka@suse.cz> <1437483218-18703-2-git-send-email-vbabka@suse.cz> <55AF8C94.6020406@suse.cz> User-Agent: Notmuch/0.19+53~g2e63a09 (http://notmuchmail.org) Emacs/25.0.50.1 (x86_64-unknown-linux-gnu) X-Face: PbkBB1w#)bOqd`iCe"Ds{e+!C7`pkC9a|f)Qo^BMQvy\q5x3?vDQJeN(DS?|-^$uMti[3D*#^_Ts"pU$jBQLq~Ud6iNwAw_r_o_4]|JO?]}P_}Nc&"p#D(ZgUb4uCNPe7~a[DbPG0T~!&c.y$Ur,=N4RT>]dNpd;KFrfMCylc}gc??'U2j,!8%xdD Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAJFBMVEWbfGlUPDDHgE57V0jUupKjgIObY0PLrom9mH4dFRK4gmjPs41MxjOgAAACQElEQVQ4jW3TMWvbQBQHcBk1xE6WyALX1069oZBMlq+ouUwpEQQ6uRjttkWP4CmBgGM0BQLBdPFZYPsyFUo6uEtKDQ7oy/U96XR2Ux8ehH/89Z6enqxBcS7Lg81jmSuujrfCZcLI/TYYvbGj+jbgFpHJ/bqQAUISj8iLyu4LuFHJTosxsucO4jSDNE0Hq3hwK/ceQ5sx97b8LcUDsILfk+ovHkOIsMbBfg43VuQ5Ln9YAGCkUdKJoXR9EclFBhixy3EGVz1K6eEkhxCAkeMMnqoAhAKwhoUJkDrCqvbecaYINlFKSRS1i12VKH1XpUd4qxL876EkMcDvHj3s5RBajHHMlA5iK32e0C7VgG0RlzFPvoYHZLRmAC0BmNcBruhkE0KsMsbEc62ZwUJDxWUdMsMhVqovoT96i/DnX/ASvz/6hbCabELLk/6FF/8PNpPCGqcZTGFcBhhAaZZDbQPaAB3+KrWWy2XgbYDNIinkdWAFcCpraDE/knwe5DBqGmgzESl1p2E4MWAz0VUPgYYzmfWb9yS4vCvgsxJriNTHoIBz5YteBvg+VGISQWUqhMiByPIPpygeDBE6elD973xWwKkEiHZAHKjhuPsFnBuArrzxtakRcISv+XMIPl4aGBUJm8Emk7qBYU8IlgNEIpiJhk/No24jHwkKTFHDWfPniR4iw5vJaw2nzSjfq2zffcE/GDjRC2dn0J0XwPAbDL84TvaFCJEU4Oml9pRyEUhR3Cl2t01AoEjRbs0sYugp14/4X5n4pU4EHHnMAAAAAElFTkSuQmCC X-PGP: 50751FF4 X-PGP-FP: AC1F 5F5C D418 88F8 CC84 5858 2060 4012 5075 1FF4 X-Hashcash: 1:20:150730:n-horiguchi@ah.jp.nec.com::oSdgQESsgMFjmwR+:0000000000000000000000000000000000000OF4 X-Hashcash: 1:20:150730:linux-kernel@vger.kernel.org::mQDRjKOIXQ+oL6eD:0000000000000000000000000000000000f5j X-Hashcash: 1:20:150730:akpm@linux-foundation.org::0+RsJ9M3UQW+Usoh:0000000000000000000000000000000000000Izd X-Hashcash: 1:20:150730:hannes@cmpxchg.org::xmgWmNKF+OUV9Vx8:00000000000000000000000000000000000000000000h6J X-Hashcash: 1:20:150730:seungho1.park@lge.com::1QHooXTif/HIq6JF:000000000000000000000000000000000000000013dL X-Hashcash: 1:20:150730:vbabka@suse.cz::h9c13rg9DyPouXwz:0002HLn X-Hashcash: 1:20:150730:kirill.shutemov@linux.intel.com::2omgKPSRzfqoEFNY:0000000000000000000000000000001+O1 X-Hashcash: 1:20:150730:minkyung88.kim@lge.com::5YhU5S6BHdodhKBd:0000000000000000000000000000000000000002dKL X-Hashcash: 1:20:150730:mgorman@suse.de::mhCQn+GPgEkxwWhI:002WP7 X-Hashcash: 1:20:150730:linux-mm@kvack.org::8aoCKYegX2deB852:00000000000000000000000000000000000000000003LtR X-Hashcash: 1:20:150730:lauraa@codeaurora.org::1OgXPF7Gp25YWvVj:000000000000000000000000000000000000000044I8 X-Hashcash: 1:20:150730:minchan@kernel.org::4WV0hoXo4FFBJKpg:000000000000000000000000000000000000000000059uK X-Hashcash: 1:20:150730:kmk3210@gmail.com::S+XqzWZgfCKa7TEf:000000000000000000000000000000000000000000004THU X-Hashcash: 1:20:150730:iamjoonsoo.kim@lge.com::B8S6b2RBJ++FIKds:0000000000000000000000000000000000000008x7v Date: Thu, 30 Jul 2015 16:08:20 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 7653 Lines: 188 On Wed, Jul 22 2015, Vlastimil Babka wrote: > Subject: mm: rename and move get/set_freepage_migratetype > > The pair of get/set_freepage_migratetype() functions are used to cache > pageblock migratetype for a page put on a pcplist, so that it does not have > to be retrieved again when the page is put on a free list (e.g. when pcplists > become full). Historically it was also assumed that the value is accurate for > pages on freelists (as the functions' names unfortunately suggest), but that > cannot be guaranteed without affecting various allocator fast paths. It is in > fact not needed and all such uses have been removed. > > The last two remaining (but pointless) usages related to pages of freelists > are removed by this patch: > - move_freepages() which operates on pages already on freelists > - __free_pages_ok() which puts a page directly to freelist, bypassing pcplists > > To prevent further confusion, rename the functions to > get/set_pcppage_migratetype() and expand their description. Since all the > users are now in mm/page_alloc.c, move the functions there from the shared > header. > > Signed-off-by: Vlastimil Babka > Acked-by: David Rientjes > Cc: Joonsoo Kim > Cc: Minchan Kim > Cc: Michal Nazarewicz Acked-by: Michal Nazarewicz > Cc: Laura Abbott > Cc: Naoya Horiguchi > Cc: Kirill A. Shutemov > Cc: Mel Gorman > Cc: Johannes Weiner > --- > include/linux/mm.h | 12 ------------ > mm/page_alloc.c | 41 ++++++++++++++++++++++++++++------------- > 2 files changed, 28 insertions(+), 25 deletions(-) > > diff --git a/include/linux/mm.h b/include/linux/mm.h > index c3a2b37..ce36145 100644 > --- a/include/linux/mm.h > +++ b/include/linux/mm.h > @@ -310,18 +310,6 @@ struct inode; > #define page_private(page) ((page)->private) > #define set_page_private(page, v) ((page)->private = (v)) > > -/* It's valid only if the page is free path or free_list */ > -static inline void set_freepage_migratetype(struct page *page, int migratetype) > -{ > - page->index = migratetype; > -} > - > -/* It's valid only if the page is free path or free_list */ > -static inline int get_freepage_migratetype(struct page *page) > -{ > - return page->index; > -} > - > /* > * FIXME: take this include out, include page-flags.h in > * files which need it (119 of them) > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index c61fef8..4b220cb 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -125,6 +125,24 @@ unsigned long dirty_balance_reserve __read_mostly; > int percpu_pagelist_fraction; > gfp_t gfp_allowed_mask __read_mostly = GFP_BOOT_MASK; > > +/* > + * A cached value of the page's pageblock's migratetype, used when the page is > + * put on a pcplist. Used to avoid the pageblock migratetype lookup when > + * freeing from pcplists in most cases, at the cost of possibly becoming stale. > + * Also the migratetype set in the page does not necessarily match the pcplist > + * index, e.g. page might have MIGRATE_CMA set but be on a pcplist with any > + * other index - this ensures that it will be put on the correct CMA freelist. > + */ > +static inline int get_pcppage_migratetype(struct page *page) > +{ > + return page->index; > +} > + > +static inline void set_pcppage_migratetype(struct page *page, int migratetype) > +{ > + page->index = migratetype; > +} > + > #ifdef CONFIG_PM_SLEEP > /* > * The following functions are used by the suspend/hibernate code to temporarily > @@ -790,7 +808,7 @@ static void free_pcppages_bulk(struct zone *zone, int count, > /* must delete as __free_one_page list manipulates */ > list_del(&page->lru); > > - mt = get_freepage_migratetype(page); > + mt = get_pcppage_migratetype(page); > /* MIGRATE_ISOLATE page should not go to pcplists */ > VM_BUG_ON_PAGE(is_migrate_isolate(mt), page); > /* Pageblock could have been isolated meanwhile */ > @@ -963,7 +981,6 @@ static void __free_pages_ok(struct page *page, unsigned int order) > migratetype = get_pfnblock_migratetype(page, pfn); > local_irq_save(flags); > __count_vm_events(PGFREE, 1 << order); > - set_freepage_migratetype(page, migratetype); > free_one_page(page_zone(page), page, pfn, order, migratetype); > local_irq_restore(flags); > } > @@ -1384,7 +1401,7 @@ struct page *__rmqueue_smallest(struct zone *zone, unsigned int order, > rmv_page_order(page); > area->nr_free--; > expand(zone, page, order, current_order, area, migratetype); > - set_freepage_migratetype(page, migratetype); > + set_pcppage_migratetype(page, migratetype); > return page; > } > > @@ -1461,7 +1478,6 @@ int move_freepages(struct zone *zone, > order = page_order(page); > list_move(&page->lru, > &zone->free_area[order].free_list[migratetype]); > - set_freepage_migratetype(page, migratetype); > page += 1 << order; > pages_moved += 1 << order; > } > @@ -1631,14 +1647,13 @@ __rmqueue_fallback(struct zone *zone, unsigned int order, int start_migratetype) > expand(zone, page, order, current_order, area, > start_migratetype); > /* > - * The freepage_migratetype may differ from pageblock's > + * The pcppage_migratetype may differ from pageblock's > * migratetype depending on the decisions in > - * try_to_steal_freepages(). This is OK as long as it > - * does not differ for MIGRATE_CMA pageblocks. For CMA > - * we need to make sure unallocated pages flushed from > - * pcp lists are returned to the correct freelist. > + * find_suitable_fallback(). This is OK as long as it does not > + * differ for MIGRATE_CMA pageblocks. Those can be used as > + * fallback only via special __rmqueue_cma_fallback() function > */ > - set_freepage_migratetype(page, start_migratetype); > + set_pcppage_migratetype(page, start_migratetype); > > trace_mm_page_alloc_extfrag(page, order, current_order, > start_migratetype, fallback_mt); > @@ -1714,7 +1729,7 @@ static int rmqueue_bulk(struct zone *zone, unsigned int order, > else > list_add_tail(&page->lru, list); > list = &page->lru; > - if (is_migrate_cma(get_freepage_migratetype(page))) > + if (is_migrate_cma(get_pcppage_migratetype(page))) > __mod_zone_page_state(zone, NR_FREE_CMA_PAGES, > -(1 << order)); > } > @@ -1911,7 +1926,7 @@ void free_hot_cold_page(struct page *page, bool cold) > return; > > migratetype = get_pfnblock_migratetype(page, pfn); > - set_freepage_migratetype(page, migratetype); > + set_pcppage_migratetype(page, migratetype); > local_irq_save(flags); > __count_vm_event(PGFREE); > > @@ -2116,7 +2131,7 @@ struct page *buffered_rmqueue(struct zone *preferred_zone, > if (!page) > goto failed; > __mod_zone_freepage_state(zone, -(1 << order), > - get_freepage_migratetype(page)); > + get_pcppage_migratetype(page)); > } > > __mod_zone_page_state(zone, NR_ALLOC_BATCH, -(1 << order)); > -- > 2.4.5 > > > -- Best regards, _ _ .o. | Liege of Serenely Enlightened Majesty of o' \,=./ `o ..o | Computer Science, Michał “mina86” Nazarewicz (o o) ooo +------ooO--(_)--Ooo-- -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/