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=-2.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,USER_AGENT_SANE_1 autolearn=no 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 06EA9C43331 for ; Wed, 13 Nov 2019 02:26:32 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A59262067B for ; Wed, 13 Nov 2019 02:26:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A59262067B 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 3D6126B0005; Tue, 12 Nov 2019 21:26:31 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 386446B0006; Tue, 12 Nov 2019 21:26:31 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 24DE26B0007; Tue, 12 Nov 2019 21:26:31 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0001.hostedemail.com [216.40.44.1]) by kanga.kvack.org (Postfix) with ESMTP id 0C6286B0005 for ; Tue, 12 Nov 2019 21:26:31 -0500 (EST) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with SMTP id 8CDAA181AEF1A for ; Wed, 13 Nov 2019 02:26:30 +0000 (UTC) X-FDA: 76149665340.01.plot59_8fff289a60d59 X-HE-Tag: plot59_8fff289a60d59 X-Filterd-Recvd-Size: 3977 Received: from out30-54.freemail.mail.aliyun.com (out30-54.freemail.mail.aliyun.com [115.124.30.54]) by imf03.hostedemail.com (Postfix) with ESMTP for ; Wed, 13 Nov 2019 02:26:29 +0000 (UTC) X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R121e4;CH=green;DM=||false|;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e01451;MF=alex.shi@linux.alibaba.com;NM=1;PH=DS;RN=29;SR=0;TI=SMTPD_---0ThwxTq0_1573611984; Received: from IT-FVFX43SYHV2H.local(mailfrom:alex.shi@linux.alibaba.com fp:SMTPD_---0ThwxTq0_1573611984) by smtp.aliyun-inc.com(127.0.0.1); Wed, 13 Nov 2019 10:26:25 +0800 Subject: Re: [PATCH v2 4/8] mm/lru: only change the lru_lock iff page's lruvec is different To: Matthew Wilcox Cc: cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org, mgorman@techsingularity.net, tj@kernel.org, hughd@google.com, khlebnikov@yandex-team.ru, daniel.m.jordan@oracle.com, yang.shi@linux.alibaba.com, Johannes Weiner , Michal Hocko , Vladimir Davydov , Roman Gushchin , Shakeel Butt , Chris Down , Thomas Gleixner , Vlastimil Babka , Andrey Ryabinin , swkhack , "Potyra, Stefan" , Jason Gunthorpe , Mauro Carvalho Chehab , Peng Fan , Nikolay Borisov , Ira Weiny , Kirill Tkhai , Yafang Shao References: <1573567588-47048-1-git-send-email-alex.shi@linux.alibaba.com> <1573567588-47048-5-git-send-email-alex.shi@linux.alibaba.com> <20191112143624.GA7934@bombadil.infradead.org> From: Alex Shi Message-ID: <297ad71c-081c-f7e1-d640-8720a0eeeeba@linux.alibaba.com> Date: Wed, 13 Nov 2019 10:26:24 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:60.0) Gecko/20100101 Thunderbird/60.9.1 MIME-Version: 1.0 In-Reply-To: <20191112143624.GA7934@bombadil.infradead.org> Content-Type: text/plain; charset=gbk 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: hi Matthew, Thanks a lot for comments! =D4=DA 2019/11/12 =CF=C2=CE=E710:36, Matthew Wilcox =D0=B4=B5=C0: > On Tue, Nov 12, 2019 at 10:06:24PM +0800, Alex Shi wrote: >> +/* Don't lock again iff page's lruvec locked */ >> +static inline struct lruvec *relock_page_lruvec_irq(struct page *page= , >> + struct lruvec *locked_lruvec) >> +{ >> + struct pglist_data *pgdat =3D page_pgdat(page); >> + struct lruvec *lruvec; >> + >> + rcu_read_lock(); >> + lruvec =3D mem_cgroup_page_lruvec(page, pgdat); >> + >> + if (locked_lruvec =3D=3D lruvec) { >> + rcu_read_unlock(); >> + return lruvec; >> + } >> + rcu_read_unlock(); >=20 > Why not simply: >=20 > rcu_read_lock(); > lruvec =3D mem_cgroup_page_lruvec(page, pgdat); > rcu_read_unlock(); >=20 > if (locked_lruvec =3D=3D lruvec) The rcu_read_unlock here is for guarding the locked_lruvec/lruvec compars= ion. Otherwise memcg/lruvec maybe changed, like, from memcg migration etc. I g= uess. =20 > return lruvec; >=20 > Also, why are you bothering to re-enable interrupts here? Surely if > you're holding lock A with interrupts disabled , you can just drop lock= A, > acquire lock B and leave the interrupts alone. That way you only need > one of this variety of function, and not the separate irq/irqsave varia= nts. >=20 Thanks for the suggestion! Yes, if only do re-lock, it's better to leave = the irq unchanging. but, when the locked_lruvec is NULL, it become a firs= t time lock which irq or irqsave are different. Thus, in combined functio= n we need a nother parameter to indicate if it do irqsaving. So comparing= to a extra/indistinct parameter, I guess 2 inline functions would be a b= it more simple/cleary?=20 Thanks a lot! Alex