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 DA617C432C0 for ; Wed, 20 Nov 2019 11:50:47 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A9C4C22310 for ; Wed, 20 Nov 2019 11:50:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A9C4C22310 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 5EACC6B0273; Wed, 20 Nov 2019 06:50:47 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 575186B0274; Wed, 20 Nov 2019 06:50:47 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 463E06B0275; Wed, 20 Nov 2019 06:50:47 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0232.hostedemail.com [216.40.44.232]) by kanga.kvack.org (Postfix) with ESMTP id 2B9BF6B0273 for ; Wed, 20 Nov 2019 06:50:47 -0500 (EST) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with SMTP id BD66F4DB6 for ; Wed, 20 Nov 2019 11:50:46 +0000 (UTC) X-FDA: 76176488892.26.oil11_5dfefc966613f X-HE-Tag: oil11_5dfefc966613f X-Filterd-Recvd-Size: 3894 Received: from out30-57.freemail.mail.aliyun.com (out30-57.freemail.mail.aliyun.com [115.124.30.57]) by imf29.hostedemail.com (Postfix) with ESMTP for ; Wed, 20 Nov 2019 11:50:45 +0000 (UTC) X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R391e4;CH=green;DM=||false|;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04407;MF=alex.shi@linux.alibaba.com;NM=1;PH=DS;RN=38;SR=0;TI=SMTPD_---0Tie.JMf_1574250633; Received: from IT-FVFX43SYHV2H.local(mailfrom:alex.shi@linux.alibaba.com fp:SMTPD_---0Tie.JMf_1574250633) by smtp.aliyun-inc.com(127.0.0.1); Wed, 20 Nov 2019 19:50:35 +0800 Subject: Re: [PATCH v4 3/9] mm/lru: replace pgdat lru_lock with lruvec lock To: Johannes Weiner , 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, shakeelb@google.com, Michal Hocko , Vladimir Davydov , Roman Gushchin , Chris Down , Thomas Gleixner , Vlastimil Babka , Qian Cai , Andrey Ryabinin , "Kirill A. Shutemov" , =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= , Andrea Arcangeli , David Rientjes , "Aneesh Kumar K.V" , swkhack , "Potyra, Stefan" , Mike Rapoport , Stephen Rothwell , Colin Ian King , Jason Gunthorpe , Mauro Carvalho Chehab , Peng Fan , Nikolay Borisov , Ira Weiny , Kirill Tkhai , Yafang Shao References: <1574166203-151975-1-git-send-email-alex.shi@linux.alibaba.com> <1574166203-151975-4-git-send-email-alex.shi@linux.alibaba.com> <20191119155704.GP20752@bombadil.infradead.org> <20191119164448.GA396644@cmpxchg.org> From: Alex Shi Message-ID: Date: Wed, 20 Nov 2019 19:50:33 +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: <20191119164448.GA396644@cmpxchg.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: =D4=DA 2019/11/20 =C9=CF=CE=E712:44, Johannes Weiner =D0=B4=B5=C0: > On Tue, Nov 19, 2019 at 07:57:04AM -0800, Matthew Wilcox wrote: >> On Tue, Nov 19, 2019 at 08:23:17PM +0800, Alex Shi wrote: >>> +static inline struct lruvec *lock_page_lruvec_irqsave(struct page *p= age, >>> + struct pglist_data *pgdat, unsigned long *flags) >>> +{ >>> + struct lruvec *lruvec =3D mem_cgroup_page_lruvec(page, pgdat); >>> + >>> + spin_lock_irqsave(&lruvec->lru_lock, *flags); >>> + >>> + return lruvec; >>> +} >> >> This should be a macro, not a function. You basically can't do this; >> spin_lock_irqsave needs to write to a variable which can then be passe= d >> to spin_unlock_irqrestore(). What you're doing here will dereference = the >> pointer in _this_ function, but won't propagate the modified value bac= k to >> the caller. I suppose you could do something like this ... >=20 > This works because spin_lock_irqsave and local_irq_save() are > macros. It boils down to '*flags =3D arch_local_irq_save()' in this > function, and therefor does the right thing. >=20 > We exploit that in quite a few places: >=20 > $ git grep 'spin_lock_irqsave(.*\*flags' | wc -l > 39 >=20 Yes, thank you all for point this!