From patchwork Fri Mar 17 13:44:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Hocko X-Patchwork-Id: 13179070 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 E6125C74A5B for ; Fri, 17 Mar 2023 13:50:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6CFE56B0074; Fri, 17 Mar 2023 09:50:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 680406B0075; Fri, 17 Mar 2023 09:50:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 548996B0078; Fri, 17 Mar 2023 09:50:34 -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 456926B0074 for ; Fri, 17 Mar 2023 09:50:34 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 14C5B121867 for ; Fri, 17 Mar 2023 13:50:34 +0000 (UTC) X-FDA: 80578525188.07.EAFF698 Received: from mail-ed1-f44.google.com (mail-ed1-f44.google.com [209.85.208.44]) by imf26.hostedemail.com (Postfix) with ESMTP id 46C0C14000A for ; Fri, 17 Mar 2023 13:50:31 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=kernel.org (policy=none); spf=pass (imf26.hostedemail.com: domain of mstsxfx@gmail.com designates 209.85.208.44 as permitted sender) smtp.mailfrom=mstsxfx@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1679061032; 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=YezikHQUygm0KAkzKI4mrR3/7OjNf8PCGFqoeYhJShw=; b=MYDjxXWqCQDa4CZQlsEnF2mL5a+Liqmyk8UU328CBRbxUDsXvXaeaRceW2QjTvta0t2LvE 6/nuZpJfTIHbVLZHdOygxMvRPvfMTKvpAxMGb/Z9g+puhmvdZAzMMeYP1GDdEHQZUeZdVV 71RqUEz0Gmn9cnibP05xwtncOv0XY1Y= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=kernel.org (policy=none); spf=pass (imf26.hostedemail.com: domain of mstsxfx@gmail.com designates 209.85.208.44 as permitted sender) smtp.mailfrom=mstsxfx@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1679061032; a=rsa-sha256; cv=none; b=3v2cOTab8kXYqlcKiD4rxmML30IUm6CZJDLy4TjewoQtm/s4IxMq6DP3KMd1Nsrv4tcpgU 05bicl5l/AgL4eC6Xx9yacXj6OCVrWWfgM9+u6mIBgObfW9QVJk+kl0D5jquPtqwzhoQO5 7gK8GruTta1WWDR5gD4X6OLOnZaQKiM= Received: by mail-ed1-f44.google.com with SMTP id fd5so20596710edb.7 for ; Fri, 17 Mar 2023 06:50:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679061030; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YezikHQUygm0KAkzKI4mrR3/7OjNf8PCGFqoeYhJShw=; b=sMolyNwzysTOHa+RkYeOX1zKBU1+GXsnY3vHKvWmrLyLQJQjoi0EP7G0Yl0CkcnrQM DUTj+786MStY+zJ4uaUU2w7tM7AYr2xfNjCHFRHQYa+ao8+elhk0g2fqpES6LomPXdEc hBBgWPHdMJ8xwn7j2h5Y9hyJ0X9QHPaqD7+GHck40uZFXgrVZMz82W2tv2/rVTv5joT9 gJVlnaH3o5ptLZct3os7jWzmZ/YsuYrkDJYz+NuvaqHaa9dQaPfG1E4756OYftlDcrzg 864vSFBvgHX6ijsv5MacH+eObD0sXOksOgxH8+IcwXLv2EGLa23ah6msmIvIpjn60ad9 W1ag== X-Gm-Message-State: AO0yUKW1w9J7t9cTkEDRG51xWYATT8r6OqlJEi8PPis0QglYvZfPuMKQ YD7oeO++gfW3v/yOchetPFg/+bAQWO0= X-Google-Smtp-Source: AK7set8W6CBQK9DHME/oMj44VdHDuWDaYeldL0uT0YRT9PqS8dczD/Fs05iiv7KqmxIKgTa6EaVd8A== X-Received: by 2002:a17:906:2645:b0:882:ed4a:f23 with SMTP id i5-20020a170906264500b00882ed4a0f23mr13791775ejc.49.1679060693197; Fri, 17 Mar 2023 06:44:53 -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.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Mar 2023 06:44:52 -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 , , Frederic Weisbecker , Michal Hocko Subject: [PATCH 1/2] sched/isolation: Add cpu_is_isolated() API Date: Fri, 17 Mar 2023 14:44:47 +0100 Message-Id: <20230317134448.11082-2-mhocko@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230317134448.11082-1-mhocko@kernel.org> References: <20230317134448.11082-1-mhocko@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 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om EVL+QIzh ZXGOXsNMCnVtxH27eALilO/szUF/kfvh2Zwbpq09yKrV1++bnwBVVAjaixIQ6TAVExBxnPyPelyw5BO5UGHV8a0a3A6p1ujFnRe+qi0cfn9RR4dvlBB7oSyjmWvQlVRIrEjEnA2pNZTCjzeWp4qDws4W57qDRctuKsLb20fzBwMWMqBrk/Q7h9uLRPJUX87mUn+3VCvE86j3UeTn5y+5rZDPV1y7+tS595Y2+k+C4rhijLq8OrpTO9bV0ebEYN4za+c76TyR28Cwj1FsCYBxDinoIi3+yeKgcNjw+w3HUU4BfCtUFZz+80D3U6+noTbMbsl49O36yhEEcY4hmaLwM9H18dyQ32Mmcrjbc6xZ/RuS3wyVttdJlY2FQlUDmBcnqU3r7rxFqK8X1e4O9BJTBc0kVdiQSZj1ftORqAQym8Rk2DFjk4Rinb8/p79w9YmGt3fJ25U1t0DDNYb4bJ5PgAyyVAFIcGNjD3mKZvVxnuR10ODHeNn6SHXeqxUBPH18+AL7Q/a9in9vPbvn8j3BLxdrQ0PyUTTf7BfOqnRAqn7TX5hTPpE1DfjSFC+Rw79PdUxQrQDDMwosGAMaHfB3C7F1aoEWFq/L6x93dCV6SwgoImaJFuL5PJHIARtDvauTP5E4X 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: From: Frederic Weisbecker Provide this new API to check if a CPU has been isolated either through isolcpus= or nohz_full= kernel parameter. It aims at avoiding kernel load deemed to be safely spared on CPUs running sensitive workload that can't bear any disturbance, such as pcp cache draining. Suggested-by: Michal Hocko Signed-off-by: Frederic Weisbecker Signed-off-by: Michal Hocko --- include/linux/sched/isolation.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/linux/sched/isolation.h b/include/linux/sched/isolation.h index 8c15abd67aed..fe1a46f30d24 100644 --- a/include/linux/sched/isolation.h +++ b/include/linux/sched/isolation.h @@ -46,6 +46,12 @@ static inline bool housekeeping_enabled(enum hk_type type) static inline void housekeeping_affine(struct task_struct *t, enum hk_type type) { } + +static inline bool housekeeping_test_cpu(int cpu, enum hk_type type) +{ + return true; +} + static inline void housekeeping_init(void) { } #endif /* CONFIG_CPU_ISOLATION */ @@ -58,4 +64,10 @@ static inline bool housekeeping_cpu(int cpu, enum hk_type type) return true; } +static inline bool cpu_is_isolated(int cpu) +{ + return !housekeeping_test_cpu(cpu, HK_TYPE_DOMAIN) || + !housekeeping_test_cpu(cpu, HK_TYPE_TICK); +} + #endif /* _LINUX_SCHED_ISOLATION_H */ From patchwork Fri Mar 17 13:44:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michal Hocko X-Patchwork-Id: 13179068 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 770F7C74A5B for ; Fri, 17 Mar 2023 13:44:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 045436B0075; Fri, 17 Mar 2023 09:44:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F37626B0078; Fri, 17 Mar 2023 09:44:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DFF026B007B; Fri, 17 Mar 2023 09:44:58 -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 D30EF6B0075 for ; Fri, 17 Mar 2023 09:44:58 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 9F7D7AC292 for ; Fri, 17 Mar 2023 13:44:58 +0000 (UTC) X-FDA: 80578511076.17.458AF64 Received: from mail-ed1-f42.google.com (mail-ed1-f42.google.com [209.85.208.42]) by imf12.hostedemail.com (Postfix) with ESMTP id ACDAF4001D for ; Fri, 17 Mar 2023 13:44:55 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=kernel.org (policy=none); spf=pass (imf12.hostedemail.com: domain of mstsxfx@gmail.com designates 209.85.208.42 as permitted sender) smtp.mailfrom=mstsxfx@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1679060695; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vJPMQdWRr2R62+6qFAGrbR0pxQ+XXGNRMUC/h0VNtm0=; b=Z9DobfjYuNvkYykMtIF/NxO3NBJ5npkmdSNPUNmPqVSxXoXMOG5QbhQcIPI3K078TtjJgu PaBQ+TBtZDW6zhq1b0mwf/gbGOTTqqo/SOAOIr+TUBQjTmH02srx7DJQ74hxB59Nd3H52w crZ9kASxeMYDDCYnv8ql18Rn+sVH1wk= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=kernel.org (policy=none); spf=pass (imf12.hostedemail.com: domain of mstsxfx@gmail.com designates 209.85.208.42 as permitted sender) smtp.mailfrom=mstsxfx@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1679060695; a=rsa-sha256; cv=none; b=YK9KSQXnp8PhZD3IBrXMwT6441zCKWGw2gcaGJcyNVNGlfNHpQhhtPZJ5mEx+qZbpZAaWd kxlX6izBb1n0KgziixIUImIdHRCQkuD5tRI78/fwF7BZzC5JWEsm/Ti0DI3sqo6a6g2MQe aIW7IiOEOPTfRnr0xHw4eYRzgwIQt6M= Received: by mail-ed1-f42.google.com with SMTP id o12so20509856edb.9 for ; Fri, 17 Mar 2023 06:44:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679060694; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vJPMQdWRr2R62+6qFAGrbR0pxQ+XXGNRMUC/h0VNtm0=; b=FBWkD26qvzfcbU4bT82BzdiRhDkuPdyBoG/hdpQKXmvnbPjMUPxhgqZt6rrLiWMFuH wh+FtvVPu3Y2gObBHtkwwnIRF9RsFaVNzZzQ/yd1ZcMSmdrlHr8XqzXuJtUTuvT89AGa z/RNnsylH+hhugPvG0TLfOUhRH1nJIVe5lwDWt0YKVvMTIOHmBXyei0txLHKgtMZp0FK DmbMPIKHX6ZB6gxCnuehzkRRv4GWP1TTR45Cdz0WXPeiMzrS6+W7pdwtd3SuRecFMM/D C/St8Iu11Ik4GqUUnpRZh8I9zqLvOaViF/cLE4gcZYdXhiI/80ly9Pr2iOS0XB/9VRdY T+Tg== X-Gm-Message-State: AO0yUKVUc5MNFTzfNiSuzrM36C9cHL9JLXnV96OCdpevA6MBgx6gL2/l gxg2n0vQMXffb20CHc58WiQ= X-Google-Smtp-Source: AK7set83jXniV558MlOBbZXcyh1vr8063l9PNIhAzz51dJmEJsUiFtl0X65tzwCOY8u2W3NER4j7yg== X-Received: by 2002:a17:906:eec2:b0:92d:46f1:dc68 with SMTP id wu2-20020a170906eec200b0092d46f1dc68mr17325149ejb.67.1679060694390; Fri, 17 Mar 2023 06:44:54 -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.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Mar 2023 06:44:54 -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 , , Michal Hocko , Frederic Weisbecker Subject: [PATCH 2/2] memcg: do not drain charge pcp caches on remote isolated cpus Date: Fri, 17 Mar 2023 14:44:48 +0100 Message-Id: <20230317134448.11082-3-mhocko@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230317134448.11082-1-mhocko@kernel.org> References: <20230317134448.11082-1-mhocko@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: ACDAF4001D X-Stat-Signature: r1inac1hjp7zf4ko1efhmo3yp81zdfiu X-HE-Tag: 1679060695-196636 X-HE-Meta: U2FsdGVkX1+pDSVa9aThbiKa0VN4WlqLzaWvcoyeRyTCoSpB1kMpAxh3s4bmEf+Ro8oNFo9p1HzFg1bsmsxYA4oGLz4TFuikvMefQc5GDqZ8zBcU/dvpSZ3xFg7pQVYNcUbZzzCceEOhzGeG9Z5i/JRIItM8Rkz1XiRZQuNcVE3U5KD8b14OFIJ9v2WBgjcxnFozW6BeU52yST/6aULqWpgTjlxxk0DUvLxWYy88CJQWcoN0dlXlcgGn4CGyV5YfqHvIgO26iIFALHzkPmxSQ1+9Fu7zVy66ZErqteq1zbZcMxh680a73zHWl3/KlJT9pT0lqfetSTpdHQxe7V+e6Zb58He0o5mSohVvFohk9sP98ojpwXMUmrRuG1PvewWMyuMU9fSJ4/7jGc0pq1opGWvDFFwZf1GSuRdmOY2b8hwQZXsVFsxcbNV9UtepLNWYmYQMeni8CIhZU3M1BLh8RY1sWhcNB+yXyBEtIKQBJh+oe+w8htpR17597DdLI0VQ5GXeOI8PNBiUtj4vktw22MHWc2nTV+1DNfoiO1txquyxfjKwm9Ht7Ok83YqM+0dQycvLlX//x2jKe+//bi70LE9dyJLYc/g3ztIfij+0E5GsL4DiAfpkTaiUH7KOf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ity: 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: From: 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. Cc: Leonardo BrĂ¡s Cc: Marcelo Tosatti Cc: Shakeel Butt Cc: Muchun Song Cc: Johannes Weiner Cc: Frederic Weisbecker Reported-by: Leonardo Bras Acked-by: Roman Gushchin Suggested-by: Roman Gushchin Signed-off-by: Michal Hocko Acked-by: Shakeel Butt --- mm/memcontrol.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 0524add35cae..12559c08d976 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -2366,7 +2366,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); } }