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 5A7F8C61DA4 for ; Sat, 18 Mar 2023 08:09:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B3901900003; Sat, 18 Mar 2023 04:09:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AE989900002; Sat, 18 Mar 2023 04:09:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9D7DE900003; Sat, 18 Mar 2023 04:09:01 -0400 (EDT) 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 87B3D900002 for ; Sat, 18 Mar 2023 04:09:01 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 112B61C5FF9 for ; Sat, 18 Mar 2023 08:09:01 +0000 (UTC) X-FDA: 80581293282.07.8C7A719 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf25.hostedemail.com (Postfix) with ESMTP id 20153A0018 for ; Sat, 18 Mar 2023 08:08:58 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=ADNw4VxB; dmarc=pass (policy=quarantine) header.from=suse.com; spf=pass (imf25.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.29 as permitted sender) smtp.mailfrom=mhocko@suse.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1679126939; 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=tUccHJYRpgH4e/3wFNqwUj50i3i9i3teajxIX8WxbAA=; b=58RQSAS8CrzVddFBw+bS7JM5wL3afbJnv+IlymghFcO+tdwiHQ82G7LMPq7rpTUMa/6Mjg uyoU61+Tme9uQ7LE77WdxV70Z0+GmIX3Cr9uATFOtlEdYA1yU3LPM3+HuSuhDz1UhLN0Zk w6xOKHKFdcmJu2Cq/s27WjXx8/TlzGM= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=ADNw4VxB; dmarc=pass (policy=quarantine) header.from=suse.com; spf=pass (imf25.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.29 as permitted sender) smtp.mailfrom=mhocko@suse.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1679126939; a=rsa-sha256; cv=none; b=HfNp1wGz8+UuoWhkDYb8kteVVO1cF2TRPO+g+ZYXFTNFtXPZ6eqsBYSmeGBICO/5kJgixg PTZZc7c2+cHJU+uvWBsEbmh7Bj1tH61voOW9ZlY4kaViDb3kgLOW9ZffE6SST5PxEUgoV9 rb3DpHFU6fpJSnfLIDyja70FoWb5G8I= 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 D62701FE56; Sat, 18 Mar 2023 08:08:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1679126937; 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=tUccHJYRpgH4e/3wFNqwUj50i3i9i3teajxIX8WxbAA=; b=ADNw4VxB5SAx+7vXXMK9Pyn6geo/Baw2FyCWsBVkdye1eHYkKaOohrvkLFRWz+NWOsVsIx Jg1RdrHmczlApVXMI07rOInCDqIBCcCrGhR397FWDwomvZt8OVCcoJRSpLNSNpN9osxUgx 407Ilmq2k4L3fyLY2Y/EAiffkPEqR+w= 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 B71B013A00; Sat, 18 Mar 2023 08:08:57 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id mxBfKplxFWQUOwAAMHmgww (envelope-from ); Sat, 18 Mar 2023 08:08:57 +0000 Date: Sat, 18 Mar 2023 09:08:57 +0100 From: Michal Hocko To: Hillf Danton Cc: Andrew Morton , Leonardo Bras , Frederic Weisbecker , LKML , linux-mm@kvack.org, Frederic Weisbecker Subject: Re: [PATCH 2/2] memcg: do not drain charge pcp caches on remote isolated cpus Message-ID: References: <20230317134448.11082-1-mhocko@kernel.org> <20230318032350.2078-1-hdanton@sina.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230318032350.2078-1-hdanton@sina.com> X-Rspamd-Queue-Id: 20153A0018 X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: ptepogmmspwjjeoc6awbw47jdau6fdbn X-HE-Tag: 1679126938-3337 X-HE-Meta: U2FsdGVkX1/OluL2BdWccAtK+ibEnDi12M/hwsVOR5eIjAeesi3Wy7KmXk6BYOBGuf4+PvlsrjSyh8fgX7u2TtQ1BxxxEzllXJOMBmMhbsruviSh7+QSQkSlkEzg9aDcco44Is9R+WS9aXH1PnMBAPxMPAiKd5WNLErxj/46tGKArfmYgOxnsIsUrKUqnZkTzEqpfGvn+GY5h4dmlHAhpRfar46pc5AENqRHnp5Z3eXAfTj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sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Sat 18-03-23 11:23:50, Hillf Danton wrote: > On 17 Mar 2023 14:44:48 +0100 Michal Hocko > > Leonardo Bras has noticed that pcp charge cache draining might be > > disruptive on workloads relying on 'isolated cpus', a feature commonly > > used on workloads that are sensitive to interruption and context > > switching such as vRAN and Industrial Control Systems. > > > > There are essentially two ways how to approach the issue. We can either > > allow the pcp cache to be drained on a different rather than a local cpu > > or avoid remote flushing on isolated cpus. > > > > The current pcp charge cache is really optimized for high performance > > and it always relies to stick with its cpu. That means it only requires > > local_lock (preempt_disable on !RT) and draining is handed over to pcp > > WQ to drain locally again. > > > > The former solution (remote draining) would require to add an additional > > locking to prevent local charges from racing with the draining. This > > adds an atomic operation to otherwise simple arithmetic fast path in the > > try_charge path. Another concern is that the remote draining can cause a > > lock contention for the isolated workloads and therefore interfere with > > it indirectly via user space interfaces. > > > > Another option is to avoid draining scheduling on isolated cpus > > altogether. That means that those remote cpus would keep their charges > > even after drain_all_stock returns. This is certainly not optimal either > > but it shouldn't really cause any major problems. In the worst case > > (many isolated cpus with charges - each of them with MEMCG_CHARGE_BATCH > > i.e 64 page) the memory consumption of a memcg would be artificially > > higher than can be immediately used from other cpus. > > > > Theoretically a memcg OOM killer could be triggered pre-maturely. > > Currently it is not really clear whether this is a practical problem > > though. Tight memcg limit would be really counter productive to cpu > > isolated workloads pretty much by definition because any memory > > reclaimed induced by memcg limit could break user space timing > > expectations as those usually expect execution in the userspace most of > > the time. > > > > Also charges could be left behind on memcg removal. Any future charge on > > those isolated cpus will drain that pcp cache so this won't be a > > permanent leak. > > > > Considering cons and pros of both approaches this patch is implementing > > the second option and simply do not schedule remote draining if the > > target cpu is isolated. This solution is much more simpler. It doesn't > > add any new locking and it is more more predictable from the user space > > POV. Should the pre-mature memcg OOM become a real life problem, we can > > revisit this decision. > > JFYI feel free to take a look at the non-housekeeping CPUs [1]. > > [1] https://lore.kernel.org/lkml/20230223150624.GA29739@lst.de/ Such an approach would require remote draining and I hope I have explained why that is not a preferred way in this case. Other than that I do agree with Christoph that a generic approach would be really nice. -- Michal Hocko SUSE Labs