Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp1790638ybc; Wed, 20 Nov 2019 04:14:29 -0800 (PST) X-Google-Smtp-Source: APXvYqxw4lQ2fS7tnyb8sK/Y9qaGEsKY3IfjIlrtDyrtTRFEb5lvuD8onE5YT8gOOhydYfifJupX X-Received: by 2002:a17:906:7e08:: with SMTP id e8mr5047759ejr.199.1574252069474; Wed, 20 Nov 2019 04:14:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574252069; cv=none; d=google.com; s=arc-20160816; b=n3+c/EAlajx0tT9rhCR77RNg5ysyPb4dm9M8Z2y+XDwj9HzhkoCrfYwoSXrlo15G7R 4JZKl9hMOivso9VLjMTJOiVZZ9/EaVFmZsYZpJGdtBXWb8M/yS+1uj7kP52Rx+K1me9d VFPukaHJ8DalOLE7NfTmXjBoTxdrVRK88a2skdh2sLNB7nWKw4pv7VOiB6ynKU3ezEjZ Pgi86e8lSw/0zXBCpJ5cu7twxnCt5VWsBUoLmNM4nOyKtiJdCxaozGYx97O/7tcssnCX yTNrOTvbgKXWhNSfRIwARK9eSTSBfw0kZ3r+SlQALwXvguyI/G0aPUEftv+it8fd0BRA a1sA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=/iNPa5SZiVovy+AlzbWyhmoDMt9tTVOq2xIaIvVNc/I=; b=pGaCZxTdFhpBMk+26lxTHe8BegxAKPh6tnWjyLYL18VVu+2YzTNZrvD3McfGKMrTJd /ILC0exyPuRHKPGMSFYWsCc1I6KY3TSZHO0NH/pea+9gL3JXJOBwKD71mAoCKFcGbjj9 TUpvgXcSuVTN57iJMSZVYxtCu/THWeds5rRN9fqzcDmxVCIS/9aMGOwx+E+Qx3OhJao4 wp7gSUs9MUFvR4vlK84djSUqSN06g8qn0d3FRQ1YNyqQqlupj9NrIy9FQx1l3h13g16z ipVlvNaJVdMrlwJ8JMOv3j/tiWekW/X52Aaj3kErQsf0CVCCj8/4nSd1WnXOkU6uzC2o hLsw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k11si15930119ejv.152.2019.11.20.04.14.04; Wed, 20 Nov 2019 04:14:29 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728770AbfKTLuo (ORCPT + 99 others); Wed, 20 Nov 2019 06:50:44 -0500 Received: from out30-130.freemail.mail.aliyun.com ([115.124.30.130]:45292 "EHLO out30-130.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727619AbfKTLun (ORCPT ); Wed, 20 Nov 2019 06:50:43 -0500 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: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ?? 2019/11/20 ????12:44, Johannes Weiner ะด??: > 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 *page, >>> + struct pglist_data *pgdat, unsigned long *flags) >>> +{ >>> + struct lruvec *lruvec = 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 passed >> to spin_unlock_irqrestore(). What you're doing here will dereference the >> pointer in _this_ function, but won't propagate the modified value back to >> the caller. I suppose you could do something like this ... > > This works because spin_lock_irqsave and local_irq_save() are > macros. It boils down to '*flags = arch_local_irq_save()' in this > function, and therefor does the right thing. > > We exploit that in quite a few places: > > $ git grep 'spin_lock_irqsave(.*\*flags' | wc -l > 39 > Yes, thank you all for point this!