Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3466400pxk; Mon, 21 Sep 2020 14:38:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxT1AAy0Bb0yrGvr2g79/0GAkKFEi7t70l631hxyNWcrprDra6x4oBJl4BIh+2ItyKmwAGs X-Received: by 2002:aa7:d606:: with SMTP id c6mr948745edr.370.1600724314083; Mon, 21 Sep 2020 14:38:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600724314; cv=none; d=google.com; s=arc-20160816; b=gJKLgOZlOqIGwgvPy0TqwyEvD306XSBsmSXgPf6+iPz4W/GRWBfErZuOyIH9OogK3m wZEpwNg8DO9L7XYpkalczm6H0toTL7laX20NI7hTYxTsPf0dzwdpuuP2WFsmURvFyicm WXE0bIdCrHc2qI3PXyhWoLyo/PPNz4uQBOu/LL/I4QR+LKyOhSUHIfOdkfrkJrMpBYua C5Ya65WG5pYIJNwDcdZcBoF4bSffwGgKWCvEZ3w832c/9Vb/1NR7t3zgzRF1+wSLTzQq ARd0+zb0xUxqOAQBtNRGyz6lO7xgJjab9sI4VukKgewdqandHtkb03wYIImrcwpdK/y1 MeZw== 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=YEHhXiwYGhR5s4kQG6zgTm8dChdzwLCMqEBAcwVay/I=; b=GZKkJr3ilQX1VAv4d2+IuobtSGQc9wTWw78/5LEl8XWCc1k9tzZfifdK7Qm1tGbVUS WNTHre37aHdP4qBfaWy5wripny9LOocaOG+jXkcMYuZ1AogPqsjbsjiz6Z/4a6eykF9Z GHSr9sncrRHfY0/vy+WbaztuB1jc9kEmjW+7S8nC/7AM0llsFXmuWglcf94n1bhanO55 Chn4j91nyrgr72lJm2SlVX+Hll44/9QWsjCQ2ITJImIpQGT3WSWOz3kbEdWlLZkXrn7e FkUEjBq1Tb8fE43+JWRg5K5H0xcJ2TtZ+D3Vv9l9YbnkLj3w/LhpOgjtuZCAaDVnSeWl 4Usg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=FHdmoZMn; 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 r14si9165761edb.14.2020.09.21.14.38.09; Mon, 21 Sep 2020 14:38:34 -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=FHdmoZMn; 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 S1726644AbgIUVhJ (ORCPT + 99 others); Mon, 21 Sep 2020 17:37:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726471AbgIUVhJ (ORCPT ); Mon, 21 Sep 2020 17:37:09 -0400 Received: from mail-ot1-x344.google.com (mail-ot1-x344.google.com [IPv6:2607:f8b0:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 327B1C0613CF for ; Mon, 21 Sep 2020 14:37:09 -0700 (PDT) Received: by mail-ot1-x344.google.com with SMTP id h17so13774039otr.1 for ; Mon, 21 Sep 2020 14:37:09 -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=YEHhXiwYGhR5s4kQG6zgTm8dChdzwLCMqEBAcwVay/I=; b=FHdmoZMn2GtG6M6npCvulWXP2W6zbv9j1/3z4NpqqPF4CZZIAljfJOMpLr/AU2uRnh MLdveaSRjUzPSvkKU/DlErd+prAWEQjXExuohssIxy9UltoW3ysPdWIcSIUp4LyWW1Jw f9iXMdTfFs8PZRMKMKNmrEqTZxqpk0pSNflZqnROIW4x8CU5+zxWAyPrd0JTK2S8usf5 cPqbz7Dc5xC0sbOIcjVCnLcaK19VJiXht1ypF+z6GM1rUOhGT94Xfp0glBhXVfcUjwkE e+DCEVKAkYABqQqwtM6XQipNbujsVCq/177MSRg4OGLiC12Cy+yZJVoAvFcWKn21ctnh nh9A== 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=YEHhXiwYGhR5s4kQG6zgTm8dChdzwLCMqEBAcwVay/I=; b=od+pKa9V7A5I1QNHCAHl62mang53gjZ6aCX9bXa/DeJRUpb4iE1fV9mGhotOXd+4js Oad3NCT8vtqsWsZfMTQVM4244GQuD41a5+YmdGypkQCS3jVK/xjEY89MlKk+ZN5rjREj R91yyEqj56OeOrDvo7qaxyg9uwHf7MDzYo6Z45EZiGGOJH472CrTsn+VBSdISYT9FOuO JGNExdlYcoASLfvELMPVYYbpRUWbJUiR+F99ASEDHeOj4P+qHtIxuSR9clnb3GnVkQJ7 SoGpiGVkrQdoJiXLtvzkDrhPC+t2kfEAJX7pW7MOnygFdL4eIZC1GrnpWrw8oju+RZpD YQPg== X-Gm-Message-State: AOAM530fU8O9SHfQvnOLVilEPllRzob2YIaTZ/T7LkJbW3A8z/aMB6L8 DjAbaizDunn0gjh7qxUYorOwgg== X-Received: by 2002:a05:6830:2104:: with SMTP id i4mr946818otc.266.1600724228018; Mon, 21 Sep 2020 14:37:08 -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 a20sm7573611oos.13.2020.09.21.14.37.05 (version=TLS1 cipher=ECDHE-ECDSA-AES128-SHA bits=128/128); Mon, 21 Sep 2020 14:37:06 -0700 (PDT) Date: Mon, 21 Sep 2020 14:36:52 -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: <1598273705-69124-16-git-send-email-alex.shi@linux.alibaba.com> 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, 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. > 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 > >