From patchwork Fri Mar 17 13:44:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Hocko X-Patchwork-Id: 13179067 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 3A66DC6FD1D for ; Fri, 17 Mar 2023 13:44:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A7E386B0074; Fri, 17 Mar 2023 09:44:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A2DEA6B0075; Fri, 17 Mar 2023 09:44:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8F5C36B0078; Fri, 17 Mar 2023 09:44:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 812F66B0074 for ; Fri, 17 Mar 2023 09:44:55 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 4886B121863 for ; Fri, 17 Mar 2023 13:44:55 +0000 (UTC) X-FDA: 80578510950.24.EAB5F1C Received: from mail-ed1-f44.google.com (mail-ed1-f44.google.com [209.85.208.44]) by imf20.hostedemail.com (Postfix) with ESMTP id 8A6311C0020 for ; Fri, 17 Mar 2023 13:44:53 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=none; spf=pass (imf20.hostedemail.com: domain of mstsxfx@gmail.com designates 209.85.208.44 as permitted sender) smtp.mailfrom=mstsxfx@gmail.com; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=kernel.org (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1679060693; 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:references; bh=JJJBSnB7o70eAA7mqVir08dpO4NUXBSh7FyCL+f6E1s=; b=owanh5PjaynpEBix2UoYrtycFWaiWNTH9ApiHt7bOm353WqutMBtc1+sDnRfzDWweK0iUS mTZGm4JpVizxp8Pxe8knwAe0xTsIqWl2MjK58+gFsGXsqxMefd9/XZu1Y/nA8o9I9uFeTY kHlR+nAOyvDFe/2Pq6mVVCjlZrxIH9M= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=none; spf=pass (imf20.hostedemail.com: domain of mstsxfx@gmail.com designates 209.85.208.44 as permitted sender) smtp.mailfrom=mstsxfx@gmail.com; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=kernel.org (policy=none) ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1679060693; a=rsa-sha256; cv=none; b=JZEy5fhe0Ojb6e5xpaokUGHzq/H01p4fvMWTaJ03O5ePkdqpo+VVTPBTUpBcw/NV1L8WUT K94mCMEdkYUaBMjLIj0eaS3QoYCydhSQE64mCs8alms+PiW3rdHhSCJqOhHG9W6RIucIlY 8pxYlLQdGUMqUSDcZtRSgWVIz2ObvtQ= Received: by mail-ed1-f44.google.com with SMTP id eg48so20434614edb.13 for ; Fri, 17 Mar 2023 06:44:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679060692; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=JJJBSnB7o70eAA7mqVir08dpO4NUXBSh7FyCL+f6E1s=; b=Jqo9C++zu62I90sVXpm6jmWw8LoiXRRD+a57ysDBKaj10eb8XIsuAb0gEoqppL71iv pOLzKVG+pHkLsaFRuugmUiLExXGX7RxsrYk05LGnaq4HOq1m5WUwXTjzQYB1DW+QuAu0 eCctzUZJ5lkp8VYtBTmxuV16ms7DGox/6iIdMGnexwKU6pCjNjWsLpkyEU1p7ov3BijR HMErql1ps7lF+tGVIbYL7Xd/JNe9AiPF3RFeYurcrvRhAwgdD3R9t4M3zMkxUzsX2JiW UCRQ6OtlRskN5DtsGGU8A/pqNByotedv4TWf8GdjqpCPoXB8EJat0vXNPBeOwPy/CeH+ O1hw== X-Gm-Message-State: AO0yUKUOojT8yCeeWwifO9moysNY8KXI6L2SUutws9pZk2Nt35VgnGkv xeQCCc1kquhJPO0Fo4ozc6M= X-Google-Smtp-Source: AK7set+bv2JJPSJzrjYUiKpymvnxoVfPw+PkOH4EeukjH39GC4jd/80SFBmpwh0LjjhTCUvCkSfCtQ== X-Received: by 2002:a17:906:f85:b0:909:3c55:a1b3 with SMTP id q5-20020a1709060f8500b009093c55a1b3mr13801506ejj.38.1679060691908; Fri, 17 Mar 2023 06:44:51 -0700 (PDT) Received: from localhost.localdomain (85-160-41-201.reb.o2.cz. [85.160.41.201]) by smtp.gmail.com with ESMTPSA id gz14-20020a170906f2ce00b00923221f4062sm999273ejb.112.2023.03.17.06.44.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Mar 2023 06:44:51 -0700 (PDT) From: Michal Hocko To: Andrew Morton , Leonardo Bras Cc: Frederic Weisbecker , Peter Zijlstra , Thomas Gleixner , Marcelo Tosatti , Johannes Weiner , Roman Gushchin , Shakeel Butt , Muchun Song , LKML , Subject: [PATCH 0/2] memcg, cpuisol: do not interfere pcp cache charges draining with cpuisol workloads Date: Fri, 17 Mar 2023 14:44:46 +0100 Message-Id: <20230317134448.11082-1-mhocko@kernel.org> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Stat-Signature: nambzkr8zzxkcap9mpt8t7sud9bkj3ay X-Rspam-User: X-Rspamd-Queue-Id: 8A6311C0020 X-Rspamd-Server: rspam06 X-HE-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nyUUn83gtyjs5m25SFf2FVCzHdbVO6b5C9YOGevdlqFJb9SD7CRdxUw1/qn71EO8rjkvmrQfQTrsPoTfwINNfro6K10Ke7QFvWqEEOfRPbycBBNIiaOJ0sabJSwNsn+Yb6o4oQW7+uOU9akHMBP4CM0XyNXuvCsmC4AIC/Rc6xjFjxK0a6IemtpQEwRs16knL1fBWaD83Z9gwjIo2ZBxVIpzChQZFWyEMvTLtc1b7VG0Dd6FXutz1zWL2O59UuyYiq7sLx2rLHXaMx6jRM37Sobq/fV/3Lu/S8bXr6IYvzcVDlbXI+H+w1x/q/PU2lsMkd12w+zVzWuWohQVNkRJUu95CmHyK+ppUbCN//VRj04pDKx9x/lwKwrh+me/BPTMEeVzrSIbvGqjIYZRljLP0f7ccT/D1IXkmsejZKWBdtkiX1gFnMElcRX5a7JptBW72WcyMGVWezkvcOuWyxQhUpAVv40WUVBfbBnVJMp7+yMptDq2TARar1W/voDq4OFomjUUld30YZC8hiOq X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Leonardo has reported [1] that pcp memcg charge draining can interfere with cpu isolated workloads. The said draining is done from a WQ context with a pcp worker scheduled on each CPU which holds any cached charges for a specific memcg hierarchy. Operation is not really a common operation [2]. It can be triggered from the userspace though so some care is definitely due. Leonardo has tried to address the issue by allowing remote charge draining [3]. This approach requires an additional locking to synchronize pcp caches sync from a remote cpu from local pcp consumers. Even though the proposed lock was per-cpu there is still potential for contention and less predictable behavior. This patchset addresses the issue from a different angle. Rather than dealing with a potential synchronization, cpus which are isolated are simply never scheduled to be drained. This means that a small amount of charges could be laying around and waiting for a later use or they are flushed when a different memcg is charged from the same cpu. More details are in patch 2. The first patch from Frederic is implementing an abstraction to tell whether a specific cpu has been isolated and therefore require a special treatment. The patchset is on top of Andrew's mm-unstable tree. I am not sure which tree is the best to route both of them but unless there are any special requirements for the cpu isolation parts then pushing this via Andrew seems like the easiest choice. Frederic Weisbecker (1): sched/isolation: Add cpu_is_isolated() API Michal Hocko (1): memcg: do not drain charge pcp caches on remote isolated cpus include/linux/sched/isolation.h | 12 ++++++++++++ mm/memcontrol.c | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) [1] https://lore.kernel.org/all/20221102020243.522358-1-leobras@redhat.com/T/#u [2] https://lore.kernel.org/all/Y9LQ615H13RmG7wL@dhcp22.suse.cz/T/#u [3] https://lore.kernel.org/all/20230125073502.743446-1-leobras@redhat.com/T/#u