Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp6708280pxv; Thu, 29 Jul 2021 23:48:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwbBml5vrh9wHVaGV48ry99IffpZnQaME3qexAErHii6hpYf2RVk4QkWfwxr/95r8eWzYey X-Received: by 2002:a50:ee15:: with SMTP id g21mr1222291eds.88.1627627731058; Thu, 29 Jul 2021 23:48:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627627731; cv=none; d=google.com; s=arc-20160816; b=sZEBUlFVjHdvZeVyAPkqx1BGnMqmws52ILf9S73KXII5UFPwuYn1ALeWDa1XJiGY75 6L120I6PLTYOiEWCsnXmytHFX4tfEbDXewE8PFGzvr8hE6TwgYIAlHZIES42CH21CkPt SN5A1ijgHyBfIQV4FPeJZZF4Y8OypoNhX/evvCfmy7V2G5BRTHIrSfPpX8Gh1SHYu7vP xNcEaa4RbhYlKS8Cf3wmlizwqNqV036+dT/Cs2ng3Ue9aKvvY9BNJ9jtVUm5lELP0RGZ XIh68xq/NPGlX3XBzi8Wuqi7zn3PSCz+CvKSfUiPLQcGUUz7KhuPN82Ykr5eQ6OEDXme NwVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=9qUmfJ205mXFr7otIjDg3EOb6cwhRcnR91bxEVSEz+8=; b=SoS9/0j17ftBGe5HzZff/XJekkFxbhh3kaWaP3Y/PAdg8NQeTJp77MiI5kizKsSugx Y7uniVczuai4Gr1oWBxQjbHdQtYGinzs0yn9o0i9wEYFVgrDW6gw613xN+Kk3PBBAlsE XeYNWYwvPMeXNSwem4PAMovZtYcuVqwBGy7SHPdEtGAACGFTDB/av3LU98WTfgYsvQCA jWWV0PfKzLjWIsc11dUAwTJfDzoljNFITHWRfYw2biN9cA74cin0PmJpzoNXLJ8qf2qx dZMGPNoFBzD0FwfKZzAI4k/srmDgNlqQ490gjN4L3oURFjUigyxqS6sO8/xjk7o+V9VW P7vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=CJHgYMs1; 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=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i18si1017642edc.598.2021.07.29.23.48.28; Thu, 29 Jul 2021 23:48:51 -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=@suse.com header.s=susede1 header.b=CJHgYMs1; 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=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237660AbhG3Gqy (ORCPT + 99 others); Fri, 30 Jul 2021 02:46:54 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:41512 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237616AbhG3Gqx (ORCPT ); Fri, 30 Jul 2021 02:46:53 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id D83C11FDB2; Fri, 30 Jul 2021 06:46:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1627627607; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=9qUmfJ205mXFr7otIjDg3EOb6cwhRcnR91bxEVSEz+8=; b=CJHgYMs1CvZagyfxxxI3oeb8NfQGKjLgWO/PUNDHKEgTVynQASUGA8s6blb1AWsd2frYz2 sq1XsTCNSHlmJ3uSMeG9rQFwB7/EqyORaLPfg6BFw0nYMgKy8CG6RTKkqYsdspUVMww3GR C4dS7HVczMazNbEDpVhfBz2IHr8Eu48= Received: from suse.cz (unknown [10.100.201.86]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id ADEB1A3B88; Fri, 30 Jul 2021 06:46:47 +0000 (UTC) Date: Fri, 30 Jul 2021 08:46:45 +0200 From: Michal Hocko To: Miaohe Lin Cc: hannes@cmpxchg.org, vdavydov.dev@gmail.com, akpm@linux-foundation.org, shakeelb@google.com, guro@fb.com, willy@infradead.org, alexs@kernel.org, richard.weiyang@gmail.com, songmuchun@bytedance.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org Subject: Re: [PATCH 2/5] mm, memcg: narrow the scope of percpu_charge_mutex Message-ID: References: <20210729125755.16871-1-linmiaohe@huawei.com> <20210729125755.16871-3-linmiaohe@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210729125755.16871-3-linmiaohe@huawei.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu 29-07-21 20:57:52, Miaohe Lin wrote: > Since percpu_charge_mutex is only used inside drain_all_stock(), we can > narrow the scope of percpu_charge_mutex by moving it here. Makes sense and this is usually my preference as well. We used to have other caller back then so I couldn't. > Signed-off-by: Miaohe Lin Acked-by: Michal Hocko Thanks! > --- > mm/memcontrol.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/mm/memcontrol.c b/mm/memcontrol.c > index 6580c2381a3e..a03e24e57cd9 100644 > --- a/mm/memcontrol.c > +++ b/mm/memcontrol.c > @@ -2050,7 +2050,6 @@ struct memcg_stock_pcp { > #define FLUSHING_CACHED_CHARGE 0 > }; > static DEFINE_PER_CPU(struct memcg_stock_pcp, memcg_stock); > -static DEFINE_MUTEX(percpu_charge_mutex); > > #ifdef CONFIG_MEMCG_KMEM > static void drain_obj_stock(struct obj_stock *stock); > @@ -2209,6 +2208,7 @@ static void refill_stock(struct mem_cgroup *memcg, unsigned int nr_pages) > */ > static void drain_all_stock(struct mem_cgroup *root_memcg) > { > + static DEFINE_MUTEX(percpu_charge_mutex); > int cpu, curcpu; > > /* If someone's already draining, avoid adding running more workers. */ > -- > 2.23.0 -- Michal Hocko SUSE Labs