Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3479274pxk; Mon, 21 Sep 2020 15:04:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw5bNdbezrAHXr+9qsE4Qy6nwWzw/n0Zksql0lHhUOrM24k5cuFT9UZGE0hzp/4Vpsc7PIl X-Received: by 2002:a17:906:170e:: with SMTP id c14mr1594765eje.275.1600725893298; Mon, 21 Sep 2020 15:04:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600725893; cv=none; d=google.com; s=arc-20160816; b=Lebtx0+mC1dHC8hAtd3VByuQozB4MIELhplGUZ4B7WEmVYZPOFqc9uLk7IcMxMRejS wzNaP4HBax+FWBtjX7iUBUbycHDyEw8V7mNbWXN4Izw1Bds8gep4JixYq8+T9QoAFovE xcElssze7Ad3nQNhpbLikRd2jUJyfBIjpHFOw2Hha/9YYuRJx60XeYa615NiElblU9rY aaiX+Q38HQQs32yH/zWG/ea4fOShtF+bVLZNpBp4ymRYKK2wMQ/h37aJb6BaLHeaHy/c KgjgTFocw98Y+SERbN6ZjvVrji6gTwQh7nE+XV0jroU9EeozIcGmg/L4jgnskkwtAKaV 0BBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date:dkim-signature; bh=i9wIfsv5rz4rfrgx+xfjmFTxPq64qmLCQPg3J+waEbE=; b=peLsZGpAq2nocGtTM91SXiT5b/J3LZZ2/VZJkjeu51AFDfsdz0wgjZeCgFZPf/+obL q2VnMlvBPerWmQsON9/V1ViUnBVXSOZzUzQNSMppujsFKGK+ho4oYsKI0ckapkdSeIAU 67lyX16NhakjKHKitJKa68eIZfhq9Kxghe1vj5TP/VhAVTuXRBFyVtdKU1vDbKBUk6+j rhbO0Lmk/f7MA3zSmT5LDTyoOn25RWcVk1INJkXjwwiaumtVxygzrDKtuLj4hbPAjffS S1pihEf+BvB/SRPIibOQp4p+6b+rTpNv553QanTnGcamzLa8LrZhHcjbJQNZKHdOSODa tdZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=DdepaFHP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s7si9240440edi.576.2020.09.21.15.04.29; Mon, 21 Sep 2020 15:04:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=DdepaFHP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728317AbgIUWDa (ORCPT + 99 others); Mon, 21 Sep 2020 18:03:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726574AbgIUWDa (ORCPT ); Mon, 21 Sep 2020 18:03:30 -0400 Received: from mail-oo1-xc41.google.com (mail-oo1-xc41.google.com [IPv6:2607:f8b0:4864:20::c41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E180C061755 for ; Mon, 21 Sep 2020 15:03:29 -0700 (PDT) Received: by mail-oo1-xc41.google.com with SMTP id h8so3644036ooc.12 for ; Mon, 21 Sep 2020 15:03:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=i9wIfsv5rz4rfrgx+xfjmFTxPq64qmLCQPg3J+waEbE=; b=DdepaFHP5SGw8u3Jxxrft7G4MFxCoXyObylHPKbacrL+cHB16NaAJhD5pIbYyNVpQd Klaaxa9m+XOEu8WCDI2BGJEh9xJjFu6wVMkxYCQs/wHlhajC7H1OK0C8z3pKFLSUutfo /O7veoCMTReFJMDGKLzCE0pM1GtuT8DTXG6yGto0omKozwErUb6rkpUMzjHeaV+XrD0t iAJga/vtnJp+LqFmK+3cqp4Jaa+9OIekQDdDnAxNz5daBoxRoUmhzN96QuWg4gkx+svY 3JdEGi8JFhwQzUsY/o2RfnpeJ3ffX8rby7q+sqiHf2n3DKWczyN8EYsw8pxVOvxpV03m UyYg== 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:in-reply-to:message-id :references:user-agent:mime-version; bh=i9wIfsv5rz4rfrgx+xfjmFTxPq64qmLCQPg3J+waEbE=; b=oFsAQ77Bvl3cc2tniHOAnu+BYSnHhuf2sT/p+1D1DLmZprmOwhki2GgBscoOQrtsbK Y9dvpJhPg0MdBjmnupZSeYQFSahfDsaQb3RPu3fRoZ60OxwV7O8LmnOm2KWrs8EtlFGX eu3z9CYF9GAIb2Cm5pzJadQcnarh8+YdHzOdhf7/m50q3x5xJS9Bma7fDdasSPTwJV13 jObMDheOI7q+8NPaEUR+100fvMGoKoHsBnK+2R89hCahyO1GpeyLFcGBHb89p4ce/WLj E04OsMBWBrI/K/wYnVUCdEKlx0To/G95qSFy65cN5X9cKk0Z3nNPAqwN0AGANDFeyEOY r9NA== X-Gm-Message-State: AOAM531r6P5H/o+tttP0CeDEsYpbkbRZWASdBNAVBd6q0tz7VzsKenFd nzzQHkp/MLez53bEC4FVQ9hiYA== X-Received: by 2002:a4a:bc90:: with SMTP id m16mr1015628oop.12.1600725808483; Mon, 21 Sep 2020 15:03:28 -0700 (PDT) Received: from eggly.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id b14sm452685oii.52.2020.09.21.15.03.25 (version=TLS1 cipher=ECDHE-ECDSA-AES128-SHA bits=128/128); Mon, 21 Sep 2020 15:03:27 -0700 (PDT) Date: Mon, 21 Sep 2020 15:03:24 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@eggly.anvils To: Alex Shi cc: akpm@linux-foundation.org, mgorman@techsingularity.net, tj@kernel.org, hughd@google.com, khlebnikov@yandex-team.ru, daniel.m.jordan@oracle.com, willy@infradead.org, hannes@cmpxchg.org, lkp@intel.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, shakeelb@google.com, iamjoonsoo.kim@lge.com, richard.weiyang@gmail.com, kirill@shutemov.name, alexander.duyck@gmail.com, rong.a.chen@intel.com, mhocko@suse.com, vdavydov.dev@gmail.com, shy828301@gmail.com Subject: Re: [PATCH v18 15/32] mm/lru: move lock into lru_note_cost In-Reply-To: Message-ID: References: <1598273705-69124-1-git-send-email-alex.shi@linux.alibaba.com> <1598273705-69124-16-git-send-email-alex.shi@linux.alibaba.com> User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 21 Sep 2020, Hugh Dickins wrote: > On Mon, 24 Aug 2020, Alex Shi wrote: > > > We have to move lru_lock into lru_note_cost, since it cycle up on memcg > > tree, for future per lruvec lru_lock replace. It's a bit ugly and may > > cost a bit more locking, but benefit from multiple memcg locking could > > cover the lost. > > > > Signed-off-by: Alex Shi > > Acked-by: Hugh Dickins > > In your lruv19 github tree, you have merged 14/32 into this one: thanks. Grr, I've only just started, and already missed some of my notes. I wanted to point out that this patch does introduce an extra unlock+lock in shrink_inactive_list(), even in a !CONFIG_MEMCG build. I think you've done the right thing for now, keeping it simple, and maybe nobody will notice the extra overhead; but I expect us to replace lru_note_cost() by lru_note_cost_unlock_irq() later on, expecting the caller to do the initial lock_irq(). lru_note_cost_page() looks redundant to me, but you're right not to delete it here, unless Johannes asks you to add that in: that's his business, and it may be dependent on the XXX at its callsite. > > > Cc: Johannes Weiner > > Cc: Andrew Morton > > Cc: linux-mm@kvack.org > > Cc: linux-kernel@vger.kernel.org > > --- > > mm/swap.c | 5 +++-- > > mm/vmscan.c | 4 +--- > > 2 files changed, 4 insertions(+), 5 deletions(-) > > > > diff --git a/mm/swap.c b/mm/swap.c > > index 906255db6006..f80ccd6f3cb4 100644 > > --- a/mm/swap.c > > +++ b/mm/swap.c > > @@ -269,7 +269,9 @@ void lru_note_cost(struct lruvec *lruvec, bool file, unsigned int nr_pages) > > { > > do { > > unsigned long lrusize; > > + struct pglist_data *pgdat = lruvec_pgdat(lruvec); > > > > + spin_lock_irq(&pgdat->lru_lock); > > /* Record cost event */ > > if (file) > > lruvec->file_cost += nr_pages; > > @@ -293,15 +295,14 @@ void lru_note_cost(struct lruvec *lruvec, bool file, unsigned int nr_pages) > > lruvec->file_cost /= 2; > > lruvec->anon_cost /= 2; > > } > > + spin_unlock_irq(&pgdat->lru_lock); > > } while ((lruvec = parent_lruvec(lruvec))); > > } > > > > void lru_note_cost_page(struct page *page) > > { > > - spin_lock_irq(&page_pgdat(page)->lru_lock); > > lru_note_cost(mem_cgroup_page_lruvec(page, page_pgdat(page)), > > page_is_file_lru(page), thp_nr_pages(page)); > > - spin_unlock_irq(&page_pgdat(page)->lru_lock); > > } > > > > static void __activate_page(struct page *page, struct lruvec *lruvec) > > diff --git a/mm/vmscan.c b/mm/vmscan.c > > index ffccb94defaf..7b7b36bd1448 100644 > > --- a/mm/vmscan.c > > +++ b/mm/vmscan.c > > @@ -1971,19 +1971,17 @@ static int current_may_throttle(void) > > &stat, false); > > > > spin_lock_irq(&pgdat->lru_lock); > > - > > move_pages_to_lru(lruvec, &page_list); > > > > __mod_node_page_state(pgdat, NR_ISOLATED_ANON + file, -nr_taken); > > - lru_note_cost(lruvec, file, stat.nr_pageout); > > item = current_is_kswapd() ? PGSTEAL_KSWAPD : PGSTEAL_DIRECT; > > if (!cgroup_reclaim(sc)) > > __count_vm_events(item, nr_reclaimed); > > __count_memcg_events(lruvec_memcg(lruvec), item, nr_reclaimed); > > __count_vm_events(PGSTEAL_ANON + file, nr_reclaimed); > > - > > spin_unlock_irq(&pgdat->lru_lock); > > > > + lru_note_cost(lruvec, file, stat.nr_pageout); > > mem_cgroup_uncharge_list(&page_list); > > free_unref_page_list(&page_list); > > > > -- > > 1.8.3.1 > > > > >