From patchwork Wed Dec 22 11:41:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Andrzej Siewior X-Patchwork-Id: 12691415 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 23E14C433EF for ; Wed, 22 Dec 2021 11:41:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7F9846B0074; Wed, 22 Dec 2021 06:41:22 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 79B676B0078; Wed, 22 Dec 2021 06:41:22 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 620AA6B0075; Wed, 22 Dec 2021 06:41:22 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0153.hostedemail.com [216.40.44.153]) by kanga.kvack.org (Postfix) with ESMTP id 4B45C6B0072 for ; Wed, 22 Dec 2021 06:41:22 -0500 (EST) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 09D5A180DD57F for ; Wed, 22 Dec 2021 11:41:22 +0000 (UTC) X-FDA: 78945239604.14.BD8FB4F Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by imf10.hostedemail.com (Postfix) with ESMTP id 9E42CC0022 for ; Wed, 22 Dec 2021 11:41:14 +0000 (UTC) From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1640173280; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jUscNupxAInGNFwdgPxE24F7XsB5NZIGxnYUda6WoJA=; b=bcjoPvk55c8sAaoa4q4VH8gB+SPU56a6QMGfWd0AfqBzVu3AeAt8CCDMhe16bhDtBok1UD usKttDwFRFWs1/Ezqralb/mLw6YJ0YTfpIGTBz49xbWW9wf5FKPMM3yCKn249Ktxmvk1Sc EHv3w9lS0/Hu651QBvj5pAtNn8uZxp0PFHbdmpzDB4zARDrzdsb6r9qhN1v8cpWH0JY9T3 mDjcgxykAiwCcprtHLugrtzNLyh8kGRZ+2pgh+iSFLHbP9EyFYHZlk6B3QI6F8xuNlaXFc K3GwPKRKxAMG4tsqLw7CcAab5ZOJuL9VE7sMvnVlQ4t8tyXs3kVDqAU9Fls7rQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1640173280; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jUscNupxAInGNFwdgPxE24F7XsB5NZIGxnYUda6WoJA=; b=RucXExCrOFfGkre/X3jLYZdkXqI6Sh25YhnYIuGWSVc208J6vybnoQ1tw2htJE3pia7ZJf mpOWiyHmHescuOCQ== To: cgroups@vger.kernel.org, linux-mm@kvack.org Cc: Johannes Weiner , Michal Hocko , Vladimir Davydov , Andrew Morton , Thomas Gleixner , Waiman Long , Peter Zijlstra , Sebastian Andrzej Siewior Subject: [RFC PATCH 3/3] mm/memcg: Allow the task_obj optimization only on non-PREEMPTIBLE kernels. Date: Wed, 22 Dec 2021 12:41:11 +0100 Message-Id: <20211222114111.2206248-4-bigeasy@linutronix.de> In-Reply-To: <20211222114111.2206248-1-bigeasy@linutronix.de> References: <20211222114111.2206248-1-bigeasy@linutronix.de> MIME-Version: 1.0 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 9E42CC0022 X-Stat-Signature: hut6ym5ogse3cfauhhhbdcr3wt96jfq5 Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=linutronix.de header.s=2020 header.b=bcjoPvk5; dkim=pass header.d=linutronix.de header.s=2020e header.b=RucXExCr; spf=pass (imf10.hostedemail.com: domain of bigeasy@linutronix.de designates 193.142.43.55 as permitted sender) smtp.mailfrom=bigeasy@linutronix.de; dmarc=pass (policy=none) header.from=linutronix.de X-HE-Tag: 1640173274-118459 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: Based on my understanding the optimisation with task_obj for in_task() mask sense on non-PREEMPTIBLE kernels because preempt_disable()/enable() is optimized away. This could be then restricted to !CONFIG_PREEMPTION kernel instead to only PREEMPT_RT. With CONFIG_PREEMPT_DYNAMIC a non-PREEMPTIBLE kernel can also be configured but these kernels always have preempt_disable()/enable() present so it probably makes no sense here for the optimisation. Restrict the optimisation to !CONFIG_PREEMPTION kernels. Signed-off-by: Sebastian Andrzej Siewior --- mm/memcontrol.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 1e76f26be2c15..92180f1aa9edc 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -2126,7 +2126,7 @@ struct memcg_stock_pcp { local_lock_t stock_lock; struct mem_cgroup *cached; /* this never be root cgroup */ unsigned int nr_pages; -#ifndef CONFIG_PREEMPT_RT +#ifndef CONFIG_PREEMPTION /* Protects only task_obj */ local_lock_t task_obj_lock; struct obj_stock task_obj; @@ -2139,7 +2139,7 @@ struct memcg_stock_pcp { }; static DEFINE_PER_CPU(struct memcg_stock_pcp, memcg_stock) = { .stock_lock = INIT_LOCAL_LOCK(stock_lock), -#ifndef CONFIG_PREEMPT_RT +#ifndef CONFIG_PREEMPTION .task_obj_lock = INIT_LOCAL_LOCK(task_obj_lock), #endif }; @@ -2228,7 +2228,7 @@ static void drain_local_stock(struct work_struct *dummy) * drain_stock races is that we always operate on local CPU stock * here with IRQ disabled */ -#ifndef CONFIG_PREEMPT_RT +#ifndef CONFIG_PREEMPTION local_lock(&memcg_stock.task_obj_lock); old = drain_obj_stock(&this_cpu_ptr(&memcg_stock)->task_obj, NULL); local_unlock(&memcg_stock.task_obj_lock); @@ -2837,7 +2837,7 @@ static inline struct obj_stock *get_obj_stock(unsigned long *pflags, { struct memcg_stock_pcp *stock; -#ifndef CONFIG_PREEMPT_RT +#ifndef CONFIG_PREEMPTION if (likely(in_task())) { *pflags = 0UL; *stock_pcp = NULL; @@ -2855,7 +2855,7 @@ static inline struct obj_stock *get_obj_stock(unsigned long *pflags, static inline void put_obj_stock(unsigned long flags, struct memcg_stock_pcp *stock_pcp) { -#ifndef CONFIG_PREEMPT_RT +#ifndef CONFIG_PREEMPTION if (likely(!stock_pcp)) local_unlock(&memcg_stock.task_obj_lock); else @@ -3267,7 +3267,7 @@ static bool obj_stock_flush_required(struct memcg_stock_pcp *stock, { struct mem_cgroup *memcg; -#ifndef CONFIG_PREEMPT_RT +#ifndef CONFIG_PREEMPTION if (in_task() && stock->task_obj.cached_objcg) { memcg = obj_cgroup_memcg(stock->task_obj.cached_objcg); if (memcg && mem_cgroup_is_descendant(memcg, root_memcg))