Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp758625ybc; Tue, 19 Nov 2019 08:48:28 -0800 (PST) X-Google-Smtp-Source: APXvYqygvjEQ0Von9JfNrY0740eHc7WfB1KnViihMQCZ2o5pl40R9rvBT4i1m9mo432zd4v48Ya8 X-Received: by 2002:a17:906:4e99:: with SMTP id v25mr36666946eju.106.1574182108206; Tue, 19 Nov 2019 08:48:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574182108; cv=none; d=google.com; s=arc-20160816; b=ZR0ceWK9KLuSpOu9VLvWQk6xSaVkRyREIJlRTvaT92P6nIrOZ98kfNs/aJXsUO0lgU sUG38PE9DQng+ds/NGJlDluRxAIsLVnm4gkX9YJeMbx1j+kZSJaEfr9CArF+63iWcHG5 uQdAat5I0kyvmK7/RgNWYkqJDybPl7EwvbiO7IU/VhYzJDr7/4qlMmY6dA0CKyfXDb6O 56I2TGHDmYPr/g+J9UQ+XnNN2STAayoradco8IANiTMwjyFPEwjBh6Sw8DKuujqOgWsx alYQG42chioz9352wdS16F8ebSXznFf/RRwX/2gsWmvG+LBbgQo+09PoV38eZDN1McNS 7Jhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=zDBiRfFmubevLJV/wK2eb+YrsoC2fdQK9RvQnh7Da5M=; b=R9r4LU/tyeyWG259TBSMEubSA5DRvfz9WcHLxKZuLgoTZMm9y9cHXcg3BR5TiJiHEp 30LF+06ChmrK6AAF2YD9iHUYxm9waLSkviocVPCV+mz30WDeHTk+QPpwsm0eB7nv4W9d 3HsNYWQKqbBOGO+w0NeXpC7glJX2YeV5xWo8UjgT0zx40ScshuXrv3U/P/+Vwovz2Oev gb7nIB8lCX0l6XH3FKTf6gPJ5lFZ0tIyz97RcyU7njj3qbjEI4h4gzip2BehO1u8WQ8U hLy9q4KTST9HTjXayd1JQYlF5XZ04GI2mRNLlnTothSBZFHQhfhjv8kjanO75L7B1x/N DNbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b=oDIPg4xC; 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=cmpxchg.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id qw23si6065787ejb.1.2019.11.19.08.48.04; Tue, 19 Nov 2019 08:48:28 -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; dkim=pass header.i=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b=oDIPg4xC; 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=cmpxchg.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728203AbfKSQov (ORCPT + 99 others); Tue, 19 Nov 2019 11:44:51 -0500 Received: from mail-qt1-f196.google.com ([209.85.160.196]:35343 "EHLO mail-qt1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727560AbfKSQov (ORCPT ); Tue, 19 Nov 2019 11:44:51 -0500 Received: by mail-qt1-f196.google.com with SMTP id n4so25373241qte.2 for ; Tue, 19 Nov 2019 08:44:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=zDBiRfFmubevLJV/wK2eb+YrsoC2fdQK9RvQnh7Da5M=; b=oDIPg4xCvt+FI8k7NV6RunpeXQu5TzDO2AQca/h0guGU4mgiq1YtDvI6V7LBxsaqq1 uwfSLg0IcO4TaXVfotXy+i7rNoLMt0PZ6I8K3ThD3VGWQID8Fjl83+9XEhUriUJx3+g0 0CzUtYPbOLTHDP3iDEv1yEzYoD7v8IpCbpfdiQsdXs/GiCDtuzmhZBqcY/rWbYwSADGR +RDSDa21cGwXkTrArBpw1fWESvOV6UzVqxuufjvGN2nrtcT8w6dlObbUyiIMeo9ilkLr Oz36AFMlb8Hm5Y3i2tJb2unF7k/PcMNsjY1DWl4W379Z/mzSC61zlxVa4JkS9/CCc4x7 M/LQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=zDBiRfFmubevLJV/wK2eb+YrsoC2fdQK9RvQnh7Da5M=; b=tHTTHRkBdf8Lct9U2krFZWqcFLoWW1LpuzlG/Tzh1uDcl4MPgQ+Ag3XBvMB9nH/Ry9 eppsdkhW33Ab8FFWEskwU8cHX/fLyKCTk/q6XtcAXQW/4ST8EN70PTCWkuJfixUGtD8k ZNnk8FbKKe4S/itJ6nIf7etPPH9OFyntqCVJcRTbtctTVzC0bpDuCzaHnm3OMhHsPd8c YFy6cuzsNdKdDQ5/PD0GjZZXQjWVWXmt346ghcc6+pNs7p/2aYxHeGTL7pZMaL8DDiBi Q1RtTGkapp7B43oYaGXB3CZ3hd4gs0adgnhWlI2VcQ62O+pa4P49MTPxy71aAfkYhLRU DaAQ== X-Gm-Message-State: APjAAAWolhtR5FH3RU+7AOn0Rkgq3snfZDq0r0VUgiVxO9mL8/f2QcYj ofzt8a9jONj7ZdneJqb7z+VRCA== X-Received: by 2002:ac8:724f:: with SMTP id l15mr34060653qtp.234.1574181890609; Tue, 19 Nov 2019 08:44:50 -0800 (PST) Received: from localhost ([2620:10d:c091:500::c7ac]) by smtp.gmail.com with ESMTPSA id j7sm10286220qkd.46.2019.11.19.08.44.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Nov 2019 08:44:49 -0800 (PST) Date: Tue, 19 Nov 2019 11:44:48 -0500 From: Johannes Weiner To: Matthew Wilcox Cc: Alex Shi , 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" , =?iso-8859-1?B?Suly9G1l?= Glisse , 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 Subject: Re: [PATCH v4 3/9] mm/lru: replace pgdat lru_lock with lruvec lock Message-ID: <20191119164448.GA396644@cmpxchg.org> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191119155704.GP20752@bombadil.infradead.org> User-Agent: Mutt/1.12.2 (2019-09-21) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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