From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4EA6CC54EAA for ; Fri, 27 Jan 2023 18:19:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235267AbjA0STU (ORCPT ); Fri, 27 Jan 2023 13:19:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235250AbjA0STE (ORCPT ); Fri, 27 Jan 2023 13:19:04 -0500 Received: from out-63.mta0.migadu.com (out-63.mta0.migadu.com [91.218.175.63]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41AF387348 for ; Fri, 27 Jan 2023 10:18:18 -0800 (PST) Date: Fri, 27 Jan 2023 10:18:03 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1674843488; h=from:from:reply-to:subject:subject: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=5Oj9LUot8v9UmWs1s5SZ+IUpPrWuuoZ3XZ2hVXEhy5g=; b=VZI9VXlfrdRerdLzb6CKAsXoUkHokf3UukfdpnDvbITMbonS+ZoXjIB1MUGbIdCV2Wd8D/ 9Jh2qysBomyX24SkHR7PZ5bPyIhx8Gk5KmmwuRlYtp5/NGyXgA9UmF+kZuDmiZgZRLi2Jk aYJG8E4rLBLWxCvua/0IFHBLGxuS290= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Roman Gushchin To: Michal Hocko Cc: Marcelo Tosatti , Leonardo =?iso-8859-1?Q?Br=E1s?= , Johannes Weiner , Shakeel Butt , Muchun Song , Andrew Morton , cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Frederic Weisbecker Subject: Re: [PATCH v2 0/5] Introduce memcg_stock_pcp remote draining Message-ID: References: <20230125073502.743446-1-leobras@redhat.com> <9e61ab53e1419a144f774b95230b789244895424.camel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Migadu-Flow: FLOW_OUT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 27, 2023 at 02:58:19PM +0100, Michal Hocko wrote: > On Fri 27-01-23 08:11:04, Michal Hocko wrote: > > [Cc Frederic] > > > > On Thu 26-01-23 15:12:35, Roman Gushchin wrote: > > > On Thu, Jan 26, 2023 at 08:41:34AM +0100, Michal Hocko wrote: > > [...] > > > > > Essentially each cpu will try to grab the remains of the memory quota > > > > > and move it locally. I wonder in such circumstances if we need to disable the pcp-caching > > > > > on per-cgroup basis. > > > > > > > > I think it would be more than sufficient to disable pcp charging on an > > > > isolated cpu. > > > > > > It might have significant performance consequences. > > > > Is it really significant? > > > > > I'd rather opt out of stock draining for isolated cpus: it might slightly reduce > > > the accuracy of memory limits and slightly increase the memory footprint (all > > > those dying memcgs...), but the impact will be limited. Actually it is limited > > > by the number of cpus. > > > > Hmm, OK, I have misunderstood your proposal. Yes, the overal pcp charges > > potentially left behind should be small and that shouldn't really be a > > concern for memcg oom situations (unless the limit is very small and > > workloads on isolated cpus using small hard limits is way beyond my > > imagination). > > > > My first thought was that those charges could be left behind without any > > upper bound but in reality sooner or later something should be running > > on those cpus and if the memcg is gone the pcp cache would get refilled > > and old charges gone. > > > > So yes, this is actually a better and even simpler solution. All we need > > is something like this > > diff --git a/mm/memcontrol.c b/mm/memcontrol.c > > index ab457f0394ab..13b84bbd70ba 100644 > > --- a/mm/memcontrol.c > > +++ b/mm/memcontrol.c > > @@ -2344,6 +2344,9 @@ static void drain_all_stock(struct mem_cgroup *root_memcg) > > struct mem_cgroup *memcg; > > bool flush = false; > > > > + if (cpu_is_isolated(cpu)) > > + continue; > > + > > rcu_read_lock(); > > memcg = stock->cached; > > if (memcg && stock->nr_pages && > > Btw. this would be over pessimistic. The following should make more > sense: > diff --git a/mm/memcontrol.c b/mm/memcontrol.c > index ab457f0394ab..55e440e54504 100644 > --- a/mm/memcontrol.c > +++ b/mm/memcontrol.c > @@ -2357,7 +2357,7 @@ static void drain_all_stock(struct mem_cgroup *root_memcg) > !test_and_set_bit(FLUSHING_CACHED_CHARGE, &stock->flags)) { > if (cpu == curcpu) > drain_local_stock(&stock->work); > - else > + else if (!cpu_is_isolated(cpu)) > schedule_work_on(cpu, &stock->work); > } > } Yes, this is exactly what I was thinking of. It should solve the problem for isolated cpus well enough without introducing an overhead for everybody else. If you'll make a proper patch, please add my Acked-by: Roman Gushchin I understand the concerns regarding spurious OOMs on 256-cores machine, but I guess they are somewhat theoretical and also possible with the current code (e.g. one ooming cgroup can effectively block draining for everybody else). Thanks!