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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0B584C61DA3 for ; Fri, 27 Jan 2023 13:58:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 317826B0071; Fri, 27 Jan 2023 08:58:24 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2C7A16B0072; Fri, 27 Jan 2023 08:58:24 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 168706B0074; Fri, 27 Jan 2023 08:58:24 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 03BD06B0071 for ; Fri, 27 Jan 2023 08:58:24 -0500 (EST) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id B801D1A031D for ; Fri, 27 Jan 2023 13:58:23 +0000 (UTC) X-FDA: 80400733686.07.DF4A65F Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf21.hostedemail.com (Postfix) with ESMTP id C26511C000F for ; Fri, 27 Jan 2023 13:58:21 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=lvXhnHvk; spf=pass (imf21.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.29 as permitted sender) smtp.mailfrom=mhocko@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1674827902; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=oe7n6bwZh97VSySQD2WOfUI5HL86g25YRhUgfhjC8aY=; b=RbOe3cXvRtTEYrpVvAw/ic2Spe4StMz4DWGB7JU18DnnMHCbfGzY0siNHd6BfHxxnE6m0d WjnGF2X7WkwzOOKc5KCQYjFHge3/AeTqQHM/jYNOXb/s0ulYgTqM3X3ln3qLsHM75Jty4Y JfurZbYYbC2eR7w+YKKcTtvM7U1W0Hs= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=lvXhnHvk; spf=pass (imf21.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.29 as permitted sender) smtp.mailfrom=mhocko@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1674827902; a=rsa-sha256; cv=none; b=JUGsCbYSJcNE4RDHEx7m0gJX6UqvzHhFls4BzOuF1DbfULQdeVXcRuRXgW4r3zib0dgTxI eSGQU9F3Q3Pxr03NZAlGvuihX5VApYCdAquV0A2tPucoo95JIr8pFt2yBin1XXbE/6XFkc v4P0NycQPgNQvcyBFewRr7JilWCGyx0= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 3AA3820224; Fri, 27 Jan 2023 13:58:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1674827900; 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=oe7n6bwZh97VSySQD2WOfUI5HL86g25YRhUgfhjC8aY=; b=lvXhnHvkBwlkDFLQf5BCDvNwgtSPiPjHiGGUjlom9HXiJyNM1RqDZonjH8BPyJ5K2FrYA1 cA5S3O65stqWvO4kinxFIa1XwDZphQbZef95i9zZBJZdzxVkTQcFvCdc7o2YYmQBr87qB0 cjBpKCIImonJHZNZ0QC0mPlvNANSy98= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 1A39D138E3; Fri, 27 Jan 2023 13:58:20 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id h6UdBHzY02OsMwAAMHmgww (envelope-from ); Fri, 27 Jan 2023 13:58:20 +0000 Date: Fri, 27 Jan 2023 14:58:19 +0100 From: Michal Hocko To: Roman Gushchin 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-Rspam-User: X-Rspamd-Server: rspam03 X-Stat-Signature: fhtbw9iuor8mgtkmwhpiupem83ofw971 X-Rspamd-Queue-Id: C26511C000F X-HE-Tag: 1674827901-996093 X-HE-Meta: U2FsdGVkX1/HYwJWFG+/6EhKv9Bxi+em1L27WQuyB19CD53wos9aBlZwBoMMI5idnpfI+AABMZeeRsJ6kc3faal63EweNzLERbLBzHxk1qbNj2AA3nFSPFOlJAJDDi8dZxf/k8zruFHPIMPJYZtb7V5cRkE/An+ttM31tYeZaNp7eNcYRBTbu2t9Ve2AbF55cR+L7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000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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); } } -- Michal Hocko SUSE Labs