Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp751570lqe; Sun, 7 Apr 2024 02:05:59 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWxG/ziavF/klIAMb4M9gUgllXBUe2R5ClEcd+P8zlOPWIGbP7u5FI4kHIoDXwh3QOmVY5+1oexR0EvV/TbVtAigNkY+W2437n/NNA/3Q== X-Google-Smtp-Source: AGHT+IHK3vh/8wO0ljdUxpxhet9iJmcNyoUb+qCDejTTAsEUHc30oiOb19Gs+DB/becYDOB0ZhgU X-Received: by 2002:a05:6a21:3982:b0:1a3:ae4a:930 with SMTP id ad2-20020a056a21398200b001a3ae4a0930mr6244936pzc.33.1712480758854; Sun, 07 Apr 2024 02:05:58 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712480758; cv=pass; d=google.com; s=arc-20160816; b=qbqoLDV5ViPL6sdrERxZ/00wFsavtH1sLo4eU6eyPNOCXlxO4FAfXTvcnRbfyRj0so hRRNhk20Hoc9R1KvSJxC2oaWCK62lsKuNX1TswoKOq8wl9nqjrHjB1id3iYHcSQP2WNB doT2C5hQN5TemEVEMKfrhjkatxlMdA4mwWMSmhzESwXWb1EnX8B3ccSsQ+M7Sy6ZQovb v8GsojwQO7X4in2rCPRERc8tZ4J3OnvdMDaGbZhuIgCD+6p15td66yt5EvrethkZrGUL baZQYuxmkqDpVKRqpXsGus+PrJhvZgw76PYZWFDEVVj1Qss71cf1UXuUbXykb+D57sB8 TEPQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=GpTyCyqlk6BGMCLifNqvgRTCltbDUUo/xKTC4G72UYQ=; fh=LJnHfZHg74q/YtpkjCd/DomlODy4Syumoz22S0yeY5w=; b=HpPPXEdQ73ZdX1FfYsz6WCTh2VqcH4E5X0yQB+/pMHxj1MpeYwu6yHnloOhQCpogeT wMvayLxUnp/kIMnuVk7ORJl7kq1nA1B4KI3qHkKaeDB7PRoNHFJREyTUNNZyxbauhhuI PPMHS16UFlC1+dFZdgFtT0ZD+kOJIhlEwzJSYTzjmcDv1DXaNqwl0D7rAl1Y6CkWjWJM eg3FzL8lF4cnlVEdXpFOo7vdkMNQb+0ACFfMA9V8uColqye3SL6ah5Py9/D7B11sZDDs 84iFukZZTT2XyYP+R3HEqxFUQsUSu6p6bQYe1OKnCcjk8CmlgF2FhC0mjgXXImgTZIAi urkQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=ImjrK7vQ; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-134283-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-134283-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id ds14-20020a17090b08ce00b002a2b9e53c7bsi6538596pjb.28.2024.04.07.02.05.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Apr 2024 02:05:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-134283-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=ImjrK7vQ; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-134283-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-134283-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 7EE1228367E for ; Sun, 7 Apr 2024 09:05:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6A0432DF7D; Sun, 7 Apr 2024 09:04:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ImjrK7vQ" Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 31B5717577; Sun, 7 Apr 2024 09:03:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712480639; cv=none; b=Vb9Mr5iVQZhmAW5gPQzcd2l8nySg1DlxiA6YYNne7DJVeBZNObcCcJ5w5DN5CnavQ4ZgVOmYW3UmOGFfKdPkDJ6VXWJTQOD8Taww2+IEuIbdCOmJNAuk3ymhwpDkMmNRDPkxcWq8JrgzcmmImDsi+x/72MSXWxs5yAk4tBo/C/g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712480639; c=relaxed/simple; bh=WZdyr+NknpomhAuRPc/9gTXcGeciCnFG1T1UfMulHtw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=EjTrCYLaRPpyjMOIQP+aA9i9AmyuI91mmwAEUa4ZU738RC/uaJIcdgLQKyA8CvUaESKtY7rK3oSVqMRIIPUxHp/4BYx6ixkFSXW05TEyHT94tbJelFzVT4N8A6lYrWUzWqIn7Bmy63IbwncOeNJcdRD8bKz0ddg8EM11hjM4J+Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ImjrK7vQ; arc=none smtp.client-ip=209.85.210.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-6ed2dbf3c92so10756b3a.2; Sun, 07 Apr 2024 02:03:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712480637; x=1713085437; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GpTyCyqlk6BGMCLifNqvgRTCltbDUUo/xKTC4G72UYQ=; b=ImjrK7vQ3SpazvjiazZjJRRR8QJGBogDhVeLV9OQeFoVn9OasdnrdXUXiInFZOljk4 UqZ4yt4gbev8jAjk4lnOg+S6asstT1zVdAoq9RgSTfgbHTCKiQ/D8JkADyhHXFMRcQDU AGKNMyeKmCupZxANYFv272VUFccusZlgeV7UwF8BqzxZ0swq+EpIawZXe/vIfeDExfSy hPXSRUs4bWeh9ykPjdteY24+0rlIMuhHic0JTGSBIFoQ4m+FCEgB8AXlJdGfvALWa1f8 A5VQagrCH+rPfGm9XLgFZk2UPSO/QgI18mafYq7uBqKQGOFTA12w/I9/KDYO81lTv80D jkvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712480637; x=1713085437; 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=GpTyCyqlk6BGMCLifNqvgRTCltbDUUo/xKTC4G72UYQ=; b=Aa4N5fv3wb1cDfObTghe/mtIEtISN5O+DVHxsftPitI3VCv47g1jgXpmmlSbJ/0a/F 9Rh5IGxt+IC5svdWnQJy8Qsw0wIl9cRM4i+XCGQjYVXZG1kn6THMQQgG8kl1zJhQg35W P0rghSBz1YsNUGXs2H2k+iHgbQ2fyAnY3Ook0WUSgLWOP4scrqFxWuDZlKUqg68/4ZYD SQLCBPOAnOQSF75wgSVTPMmAuefK0JMW7dC4Z3wwiv0FVutB9EGEeQzYnzRabJ1baDIU QfGVDoS3dgimrQTLuJ6NXs7LahgeRsLlprFDiaieubvldEZVy0/8nDpqzQINxVe1Tpxv NZRA== X-Gm-Message-State: AOJu0YzCbkcDlBf1ZobgZL67MNN9x5DoyrxxmMdFvifBpXep6Xv2trbe a33jXybuzXj+Wqq7WQdo6jkWQ5rrZgXYu+rqnPvxg3iVBlMQZAzvSUzdgM80 X-Received: by 2002:a05:6a20:ce4b:b0:1a1:8312:6dfb with SMTP id id11-20020a056a20ce4b00b001a183126dfbmr6281164pzb.58.1712480637225; Sun, 07 Apr 2024 02:03:57 -0700 (PDT) Received: from localhost ([47.89.225.180]) by smtp.gmail.com with ESMTPSA id s35-20020a17090a2f2600b0029baf24ee51sm6648516pjd.48.2024.04.07.02.03.56 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 07 Apr 2024 02:03:56 -0700 (PDT) From: Lai Jiangshan To: linux-kernel@vger.kernel.org Cc: rcu@vger.kernel.org, x86@kernel.org, Lai Jiangshan , "Paul E. McKenney" , Peter Zijlstra , Frederic Weisbecker , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan , Zqiang , Ingo Molnar , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider Subject: [PATCH V2 07/11] sched/core: Add rcu_preempt_switch() Date: Sun, 7 Apr 2024 17:05:54 +0800 Message-Id: <20240407090558.3395-8-jiangshanlai@gmail.com> X-Mailer: git-send-email 2.19.1.6.gb485710b In-Reply-To: <20240407090558.3395-1-jiangshanlai@gmail.com> References: <20240407090558.3395-1-jiangshanlai@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Lai Jiangshan When the per-cpu rcu_preempt_count is used, it has to be switched too on context-switching. And the instructions to switch the per-cpu rcu_preempt_count are few, so it is inlined to avoid the overhead in the scheduler. Cc: "Paul E. McKenney" Cc: Peter Zijlstra Cc: Frederic Weisbecker Signed-off-by: Lai Jiangshan --- kernel/rcu/rcu.h | 5 +++++ kernel/sched/core.c | 2 ++ 2 files changed, 7 insertions(+) diff --git a/kernel/rcu/rcu.h b/kernel/rcu/rcu.h index b17b2ed657fc..ea5ae957c687 100644 --- a/kernel/rcu/rcu.h +++ b/kernel/rcu/rcu.h @@ -668,4 +668,9 @@ int rcu_stall_notifier_call_chain(unsigned long val, void *v); static inline int rcu_stall_notifier_call_chain(unsigned long val, void *v) { return NOTIFY_DONE; } #endif // #else // #if defined(CONFIG_RCU_STALL_COMMON) && defined(CONFIG_RCU_CPU_STALL_NOTIFIER) +static inline void +rcu_preempt_switch(struct task_struct *prev, struct task_struct *next) +{ +} + #endif /* __KERNEL_RCU_H */ diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 7019a40457a6..1d9e3c51c913 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -95,6 +95,7 @@ #include "../workqueue_internal.h" #include "../../io_uring/io-wq.h" #include "../smpboot.h" +#include "../rcu/rcu.h" EXPORT_TRACEPOINT_SYMBOL_GPL(ipi_send_cpu); EXPORT_TRACEPOINT_SYMBOL_GPL(ipi_send_cpumask); @@ -6737,6 +6738,7 @@ static void __sched notrace __schedule(unsigned int sched_mode) */ ++*switch_count; + rcu_preempt_switch(prev, next); migrate_disable_switch(rq, prev); psi_sched_switch(prev, next, !task_on_rq_queued(prev)); -- 2.19.1.6.gb485710b