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 1D812C74A5B for ; Sat, 18 Mar 2023 03:24:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 24B7D6B00A3; Fri, 17 Mar 2023 23:24:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1FB3B6B00A4; Fri, 17 Mar 2023 23:24:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0EB586B00A5; Fri, 17 Mar 2023 23:24:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id F3BE36B00A3 for ; Fri, 17 Mar 2023 23:24:14 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id B152080E45 for ; Sat, 18 Mar 2023 03:24:14 +0000 (UTC) X-FDA: 80580575628.03.71155B9 Received: from r3-11.sinamail.sina.com.cn (r3-11.sinamail.sina.com.cn [202.108.3.11]) by imf24.hostedemail.com (Postfix) with ESMTP id 55C0A180011 for ; Sat, 18 Mar 2023 03:24:05 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf24.hostedemail.com: domain of hdanton@sina.com designates 202.108.3.11 as permitted sender) smtp.mailfrom=hdanton@sina.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1679109853; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iwz0GD9pUJn+BIuG9FWOvTaKoWwzDx7UNoX6X4VeQYw=; b=fKoWp7OiGTn2fPeIC3OV/q2fDI8f3Ze4adjDlOMEqJ5QB8hpBbU64Q9vXR5noG5qiLYcVk sAoeUJZOlDUQCYGlGOAG0b+SDlB0UaUd9F0t82E5R1g3BEaPnmZgDuQXy2Omb70hIKaEh6 W/sPhgl7rxYYYBK2OwS/0GXwjUIzaWY= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf24.hostedemail.com: domain of hdanton@sina.com designates 202.108.3.11 as permitted sender) smtp.mailfrom=hdanton@sina.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1679109853; a=rsa-sha256; cv=none; b=I0o7yYERlQUefVyZwYGp0cxJm040yjo/fHyhGgUZ6vdJiYZPIUTvBK1VzX4nFwjUW7oHOm sF7UCmcDFy4FcbmRwwmR8XaBSdgmsExdClSWPz/fHrQvc5KWB0ixDM6fvwmMU4N1qaOLde BKi4QbJFHJxUxiDLo994j3J94W4ADjc= Received: from unknown (HELO localhost.localdomain)([114.249.61.130]) by sina.com (172.16.97.27) with ESMTP id 64152EC1000144AA; Sat, 18 Mar 2023 11:23:46 +0800 (CST) X-Sender: hdanton@sina.com X-Auth-ID: hdanton@sina.com X-SMAIL-MID: 88975649283619 From: Hillf Danton To: Michal Hocko Cc: Andrew Morton , Leonardo Bras , Frederic Weisbecker , LKML , linux-mm@kvack.org, Michal Hocko , Frederic Weisbecker Subject: Re: [PATCH 2/2] memcg: do not drain charge pcp caches on remote isolated cpus Date: Sat, 18 Mar 2023 11:23:50 +0800 Message-Id: <20230318032350.2078-1-hdanton@sina.com> In-Reply-To: <20230317134448.11082-3-mhocko@kernel.org> References: <20230317134448.11082-1-mhocko@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 55C0A180011 X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: i8qcasurrji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oVxv82Qua7jTKJR4Zchd/WIb9fdD5VMQmDcjkwnOH4YUbxGs1IU5KtHtansCozRsPvYphE4B8iG9iLTqKtQ32w5xJvsM2Km5fODMjOKvLTg/pH2kcpaOOowkKtLNHTQDrZZf77F7f7VjECYqfhs56bfi+L3Jsms2XN55ITw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000374, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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/