From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754871AbbFLKSP (ORCPT ); Fri, 12 Jun 2015 06:18:15 -0400 Received: from mail-wi0-f179.google.com ([209.85.212.179]:32797 "EHLO mail-wi0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754011AbbFLKSK convert rfc822-to-8bit (ORCPT ); Fri, 12 Jun 2015 06:18:10 -0400 From: Michal Nazarewicz To: Vlastimil Babka , Andrew Morton , linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, Vlastimil Babka , Minchan Kim , Mel Gorman , Joonsoo Kim , Naoya Horiguchi , Christoph Lameter , Rik van Riel , David Rientjes Subject: Re: [PATCH 5/6] mm, compaction: skip compound pages by order in free scanner In-Reply-To: <1433928754-966-6-git-send-email-vbabka@suse.cz> Organization: http://mina86.com/ References: <1433928754-966-1-git-send-email-vbabka@suse.cz> <1433928754-966-6-git-send-email-vbabka@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:150612:mgorman@suse.de::dBK14zepLqpQZf3j:000hgU X-Hashcash: 1:20:150612:riel@redhat.com::Jf5Q2/91T5u9ZER5:001MoG X-Hashcash: 1:20:150612:linux-kernel@vger.kernel.org::PhrT04RE8Lx9EqOj:0000000000000000000000000000000001bNx X-Hashcash: 1:20:150612:linux-mm@kvack.org::WJICUHT6KniR+rtM:00000000000000000000000000000000000000000002ToN X-Hashcash: 1:20:150612:iamjoonsoo.kim@lge.com::aSGzzqcobTlrFUWF:0000000000000000000000000000000000000002K9r X-Hashcash: 1:20:150612:rientjes@google.com::EKWcj9pWtVR2H9uJ:0000000000000000000000000000000000000000003gA3 X-Hashcash: 1:20:150612:cl@linux.com::Lt9xcGhOabaJnvNH:00000360C X-Hashcash: 1:20:150612:vbabka@suse.cz::IB68PyvQCEefs9mv:0006C7Y X-Hashcash: 1:20:150612:vbabka@suse.cz::F89/ywlQcqtgidKL:0007CHD X-Hashcash: 1:20:150612:n-horiguchi@ah.jp.nec.com::XoO2UpC0+GL4TXmM:0000000000000000000000000000000000006pEa X-Hashcash: 1:20:150612:minchan@kernel.org::pEEbXIDSA5C6tQ3A:0000000000000000000000000000000000000000000FVV7 X-Hashcash: 1:20:150612:akpm@linux-foundation.org::jXQ03byGpo/CZjBx:000000000000000000000000000000000000GlPq Date: Fri, 12 Jun 2015 12:18:07 +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 On Wed, Jun 10 2015, Vlastimil Babka wrote: > The compaction free scanner is looking for PageBuddy() pages and skipping all > others. For large compound pages such as THP or hugetlbfs, we can save a lot > of iterations if we skip them at once using their compound_order(). This is > generally unsafe and we can read a bogus value of order due to a race, but if > we are careful, the only danger is skipping too much. > > When tested with stress-highalloc from mmtests on 4GB system with 1GB hugetlbfs > pages, the vmstat compact_free_scanned count decreased by at least 15%. > > Signed-off-by: Vlastimil Babka > Cc: Minchan Kim > Cc: Mel Gorman > Cc: Joonsoo Kim > Cc: Michal Nazarewicz Acked-by: Michal Nazarewicz > Cc: Naoya Horiguchi > Cc: Christoph Lameter > Cc: Rik van Riel > Cc: David Rientjes > --- > mm/compaction.c | 25 +++++++++++++++++++++++++ > 1 file changed, 25 insertions(+) > > diff --git a/mm/compaction.c b/mm/compaction.c > index e37d361..4a14084 100644 > --- a/mm/compaction.c > +++ b/mm/compaction.c > @@ -437,6 +437,24 @@ static unsigned long isolate_freepages_block(struct compact_control *cc, > > if (!valid_page) > valid_page = page; > + > + /* > + * For compound pages such as THP and hugetlbfs, we can save > + * potentially a lot of iterations if we skip them at once. > + * The check is racy, but we can consider only valid values > + * and the only danger is skipping too much. > + */ > + if (PageCompound(page)) { > + unsigned int comp_order = compound_order(page); > + > + if (comp_order > 0 && comp_order < MAX_ORDER) { + if (comp_order < MAX_ORDER) { Might produce shorter/faster code. Dunno. Maybe. So much micro-optimisations. Applies to the previous patch as well. > + blockpfn += (1UL << comp_order) - 1; > + cursor += (1UL << comp_order) - 1; > + } > + > + goto isolate_fail; > + } > + > if (!PageBuddy(page)) > goto isolate_fail; > > @@ -496,6 +514,13 @@ isolate_fail: > > } > > + /* > + * There is a tiny chance that we have read bogus compound_order(), > + * so be careful to not go outside of the pageblock. > + */ > + if (unlikely(blockpfn > end_pfn)) > + blockpfn = end_pfn; > + > trace_mm_compaction_isolate_freepages(*start_pfn, blockpfn, > nr_scanned, total_isolated); > > -- > 2.1.4 > -- Best regards, _ _ .o. | Liege of Serenely Enlightened Majesty of o' \,=./ `o ..o | Computer Science, Michał “mina86” Nazarewicz (o o) ooo +------ooO--(_)--Ooo-- From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wi0-f181.google.com (mail-wi0-f181.google.com [209.85.212.181]) by kanga.kvack.org (Postfix) with ESMTP id A7A876B0089 for ; Fri, 12 Jun 2015 06:18:11 -0400 (EDT) Received: by wiga1 with SMTP id a1so12625077wig.0 for ; Fri, 12 Jun 2015 03:18:11 -0700 (PDT) Received: from mail-wg0-x22a.google.com (mail-wg0-x22a.google.com. [2a00:1450:400c:c00::22a]) by mx.google.com with ESMTPS id h18si2541470wiw.84.2015.06.12.03.18.09 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Jun 2015 03:18:10 -0700 (PDT) Received: by wgez8 with SMTP id z8so21401567wge.0 for ; Fri, 12 Jun 2015 03:18:09 -0700 (PDT) From: Michal Nazarewicz Subject: Re: [PATCH 5/6] mm, compaction: skip compound pages by order in free scanner In-Reply-To: <1433928754-966-6-git-send-email-vbabka@suse.cz> References: <1433928754-966-1-git-send-email-vbabka@suse.cz> <1433928754-966-6-git-send-email-vbabka@suse.cz> Date: Fri, 12 Jun 2015 12:18:07 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Sender: owner-linux-mm@kvack.org List-ID: To: Vlastimil Babka , Andrew Morton , linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, Minchan Kim , Mel Gorman , Joonsoo Kim , Naoya Horiguchi , Christoph Lameter , Rik van Riel , David Rientjes On Wed, Jun 10 2015, Vlastimil Babka wrote: > The compaction free scanner is looking for PageBuddy() pages and skipping= all > others. For large compound pages such as THP or hugetlbfs, we can save a= lot > of iterations if we skip them at once using their compound_order(). This = is > generally unsafe and we can read a bogus value of order due to a race, bu= t if > we are careful, the only danger is skipping too much. > > When tested with stress-highalloc from mmtests on 4GB system with 1GB hug= etlbfs > pages, the vmstat compact_free_scanned count decreased by at least 15%. > > Signed-off-by: Vlastimil Babka > Cc: Minchan Kim > Cc: Mel Gorman > Cc: Joonsoo Kim > Cc: Michal Nazarewicz Acked-by: Michal Nazarewicz > Cc: Naoya Horiguchi > Cc: Christoph Lameter > Cc: Rik van Riel > Cc: David Rientjes > --- > mm/compaction.c | 25 +++++++++++++++++++++++++ > 1 file changed, 25 insertions(+) > > diff --git a/mm/compaction.c b/mm/compaction.c > index e37d361..4a14084 100644 > --- a/mm/compaction.c > +++ b/mm/compaction.c > @@ -437,6 +437,24 @@ static unsigned long isolate_freepages_block(struct = compact_control *cc, >=20=20 > if (!valid_page) > valid_page =3D page; > + > + /* > + * For compound pages such as THP and hugetlbfs, we can save > + * potentially a lot of iterations if we skip them at once. > + * The check is racy, but we can consider only valid values > + * and the only danger is skipping too much. > + */ > + if (PageCompound(page)) { > + unsigned int comp_order =3D compound_order(page); > + > + if (comp_order > 0 && comp_order < MAX_ORDER) { + if (comp_order < MAX_ORDER) { Might produce shorter/faster code. Dunno. Maybe. So much micro-optimisations. Applies to the previous patch as well. > + blockpfn +=3D (1UL << comp_order) - 1; > + cursor +=3D (1UL << comp_order) - 1; > + } > + > + goto isolate_fail; > + } > + > if (!PageBuddy(page)) > goto isolate_fail; >=20=20 > @@ -496,6 +514,13 @@ isolate_fail: >=20=20 > } >=20=20 > + /* > + * There is a tiny chance that we have read bogus compound_order(), > + * so be careful to not go outside of the pageblock. > + */ > + if (unlikely(blockpfn > end_pfn)) > + blockpfn =3D end_pfn; > + > trace_mm_compaction_isolate_freepages(*start_pfn, blockpfn, > nr_scanned, total_isolated); >=20=20 > --=20 > 2.1.4 > --=20 Best regards, _ _ .o. | Liege of Serenely Enlightened Majesty of o' \,=3D./ `o ..o | Computer Science, Micha=C5=82 =E2=80=9Cmina86=E2=80=9D Nazarewicz = (o o) ooo +------ooO--(_)--Ooo-- -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org