From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.1 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 86BA5C433DF for ; Tue, 18 Aug 2020 06:51:38 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 54AE920639 for ; Tue, 18 Aug 2020 06:51:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 54AE920639 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id DB0506B0007; Tue, 18 Aug 2020 02:51:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D86028D0003; Tue, 18 Aug 2020 02:51:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C9CA56B000A; Tue, 18 Aug 2020 02:51:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0175.hostedemail.com [216.40.44.175]) by kanga.kvack.org (Postfix) with ESMTP id B62BE6B0007 for ; Tue, 18 Aug 2020 02:51:37 -0400 (EDT) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 7D81C181AC217 for ; Tue, 18 Aug 2020 06:51:37 +0000 (UTC) X-FDA: 77162768634.19.knee61_2f0f2532701d Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin19.hostedemail.com (Postfix) with ESMTP id 7B9561ACC2C for ; Tue, 18 Aug 2020 06:51:36 +0000 (UTC) X-HE-Tag: knee61_2f0f2532701d X-Filterd-Recvd-Size: 6415 Received: from out30-133.freemail.mail.aliyun.com (out30-133.freemail.mail.aliyun.com [115.124.30.133]) by imf42.hostedemail.com (Postfix) with ESMTP for ; Tue, 18 Aug 2020 06:51:34 +0000 (UTC) X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R651e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01f04427;MF=alex.shi@linux.alibaba.com;NM=1;PH=DS;RN=19;SR=0;TI=SMTPD_---0U67H.h6_1597733485; Received: from IT-FVFX43SYHV2H.local(mailfrom:alex.shi@linux.alibaba.com fp:SMTPD_---0U67H.h6_1597733485) by smtp.aliyun-inc.com(127.0.0.1); Tue, 18 Aug 2020 14:51:26 +0800 Subject: Re: [RFC PATCH 2/3] mm: Drop use of test_and_set_skip in favor of just setting skip To: Alexander Duyck Cc: yang.shi@linux.alibaba.com, lkp@intel.com, rong.a.chen@intel.com, khlebnikov@yandex-team.ru, kirill@shutemov.name, hughd@google.com, linux-kernel@vger.kernel.org, daniel.m.jordan@oracle.com, linux-mm@kvack.org, shakeelb@google.com, willy@infradead.org, hannes@cmpxchg.org, tj@kernel.org, cgroups@vger.kernel.org, akpm@linux-foundation.org, richard.weiyang@gmail.com, mgorman@techsingularity.net, iamjoonsoo.kim@lge.com References: <20200813035100.13054.25671.stgit@localhost.localdomain> <20200813040232.13054.82417.stgit@localhost.localdomain> From: Alex Shi Message-ID: <176fae1b-b95b-51c3-d8cc-4380f0972666@linux.alibaba.com> Date: Tue, 18 Aug 2020 14:50:25 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <20200813040232.13054.82417.stgit@localhost.localdomain> Content-Type: text/plain; charset=utf-8 X-Rspamd-Queue-Id: 7B9561ACC2C X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: =E5=9C=A8 2020/8/13 =E4=B8=8B=E5=8D=8812:02, Alexander Duyck =E5=86=99=E9= =81=93: > From: Alexander Duyck >=20 > The only user of test_and_set_skip was isolate_migratepages_block and i= t > was using it after a call that was testing and clearing the LRU flag. A= s > such it really didn't need to be behind the LRU lock anymore as it wasn= 't > really fulfilling its purpose. >=20 > With that being the case we can simply drop the bit and instead directl= y > just call the set_pageblock_skip function if the page we are working on= is > the valid_page at the start of the pageblock. It shouldn't be possible = for > us to encounter the bit being set since we obtained the LRU flag for th= e > first page in the pageblock which means we would have exclusive access = to > setting the skip bit. As such we don't need to worry about the abort ca= se > since no other thread will be able to call what used to be > test_and_set_skip. >=20 > Since we have dropped the late abort case we can drop the code that was > clearing the LRU flag and calling page_put since the abort case will no= w > not be holding a reference to a page. >=20 > Signed-off-by: Alexander Duyck After my false sharing remove on pageblock_flags, this patch looks fine w= ith a minor change > --- > mm/compaction.c | 50 +++++++----------------------------------------= --- > 1 file changed, 7 insertions(+), 43 deletions(-) >=20 > diff --git a/mm/compaction.c b/mm/compaction.c > index 5021a18ef722..c1e9918f9dd4 100644 > --- a/mm/compaction.c > +++ b/mm/compaction.c > @@ -399,29 +399,6 @@ void reset_isolation_suitable(pg_data_t *pgdat) > } > } > =20 > -/* > - * Sets the pageblock skip bit if it was clear. Note that this is a hi= nt as > - * locks are not required for read/writers. Returns true if it was alr= eady set. > - */ > -static bool test_and_set_skip(struct compact_control *cc, struct page = *page, > - unsigned long pfn) > -{ > - bool skip; > - > - /* Do no update if skip hint is being ignored */ > - if (cc->ignore_skip_hint) > - return false; > - > - if (!IS_ALIGNED(pfn, pageblock_nr_pages)) > - return false; > - > - skip =3D get_pageblock_skip(page); > - if (!skip && !cc->no_set_skip_hint) > - skip =3D !set_pageblock_skip(page); > - > - return skip; > -} > - > static void update_cached_migrate(struct compact_control *cc, unsigned= long pfn) > { > struct zone *zone =3D cc->zone; > @@ -480,12 +457,6 @@ static inline void update_pageblock_skip(struct co= mpact_control *cc, > static void update_cached_migrate(struct compact_control *cc, unsigned= long pfn) > { > } > - > -static bool test_and_set_skip(struct compact_control *cc, struct page = *page, > - unsigned long pfn) > -{ > - return false; > -} > #endif /* CONFIG_COMPACTION */ > =20 > /* > @@ -895,7 +866,6 @@ static bool too_many_isolated(pg_data_t *pgdat) > if (!valid_page && IS_ALIGNED(low_pfn, pageblock_nr_pages)) { > if (!cc->ignore_skip_hint && get_pageblock_skip(page)) { > low_pfn =3D end_pfn; > - page =3D NULL; > goto isolate_abort; > } > valid_page =3D page; > @@ -991,6 +961,13 @@ static bool too_many_isolated(pg_data_t *pgdat) > if (!TestClearPageLRU(page)) > goto isolate_fail_put; > =20 > + /* Indicate that we want exclusive access to this pageblock */ > + if (page =3D=3D valid_page) { > + skip_updated =3D true; > + if (!cc->ignore_skip_hint) if (!cc->ignore_skip_hint && !cc->no_set_skip_hin= t) no_set_skip_hint needs to add here. Thanks Alex > + set_pageblock_skip(page); > + } > + > /* If we already hold the lock, we can skip some rechecking */ > if (!lruvec || !lruvec_holds_page_lru_lock(page, lruvec)) { > if (lruvec) > @@ -1002,13 +979,6 @@ static bool too_many_isolated(pg_data_t *pgdat) > =20 > lruvec_memcg_debug(lruvec, page); > =20 > - /* Try get exclusive access under lock */ > - if (!skip_updated) { > - skip_updated =3D true; > - if (test_and_set_skip(cc, page, low_pfn)) > - goto isolate_abort; > - } > - > /* > * Page become compound since the non-locked check, > * and it's on LRU. It can only be a THP so the order > @@ -1094,15 +1064,9 @@ static bool too_many_isolated(pg_data_t *pgdat) > if (unlikely(low_pfn > end_pfn)) > low_pfn =3D end_pfn; > =20 > - page =3D NULL; > - > isolate_abort: > if (lruvec) > unlock_page_lruvec_irqrestore(lruvec, flags); > - if (page) { > - SetPageLRU(page); > - put_page(page); > - } > =20 > /* > * Updated the cached scanner pfn once the pageblock has been scanned >=20