From nobody Tue Dec 16 14:35:48 2025 Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) (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 8E0A916F0C1 for ; Thu, 30 May 2024 12:24:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717071874; cv=none; b=loaa+voYP5Ywq9zb31pfFv/ukqnjRHKjGq/nDNUO/HfcPxvDtTIgGroHMyElSnEU3iStja4ZmLK727EQv9xUrNBZ94W8zx5ie1lUaVy5b6ymHefd1s/wEyVdy4n01t77tJxYVkMtL7/YMNMX/5wJRto0cLGoVA4uCpdhrJUA04A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717071874; c=relaxed/simple; bh=s7Tp/gW4dylEz7+Qb9iL+PdGH5zIgATcrxvD9nLEWoE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Kk9Biu5USrspm89Y3mStjQohJT1x+YX/3T3sA8jYb6hWE7J8QBvauXEH8aScM7mrvvpd28dPdNt95wiZNNt7/IlBwYCO9r/9WGhcdEdxs4+G74AQ1bPhzR7n0MwxjZgSDuJ6h7wm/M6pH0OwoUxd3fNw6kWVcw50uzDMynejRKA= 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=Hx6IKDNp; arc=none smtp.client-ip=209.85.214.173 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Hx6IKDNp" Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-1f4a0050b9aso6799285ad.2 for ; Thu, 30 May 2024 05:24:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717071873; x=1717676673; 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=PVavlMvyMd64Xp7pg69LkDUlV3ao7rCW+YbfGdGmSAU=; b=Hx6IKDNpflohnhp8qs64jFKdqcxtCgn3EjZgta/c70awbQzxA7cPxneArMWR2zmDLi TuV16DuJ8rCKfOKOM0J6POfuljFiZWXOoBNFA7eSOZh5Qo/WNi1RWfbA950New+xihyw dCOjJFYBo6eQ8WGuaAgwl1Jsztzskskfzbtu8leIc3m6QJ8sbvyUh964ero5k9kOvJgC HfI282F4IBlrynHvpSCr7EBEVpoo6xbnyLe3Qjs6QM6w/vdPwENSBufcSgC+L0tXRBow OAyijnNfU0L9HkUY8aLOu6KjV6l8SfT2OxPE6JYpECy8XTIwJ5rtqDTgsyagQygL/sqd q4ZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717071873; x=1717676673; 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=PVavlMvyMd64Xp7pg69LkDUlV3ao7rCW+YbfGdGmSAU=; b=kv+5JHKABTQX53gR98JmB7SeDOE9bBg84xP9VKqHUflMu11Yn1iDI3DWlQTd6ZFrQR doA2m/Vy2imGeX1s77KQ5kXt6S6lC1ajnDfpYSs/WLJ2S9HClVctNeZOrYh7ZI3zvrTn QraBjwep/2JBJ8YATUQRf1hTJAchIt0MpgpSuAIey4v/hIHflH9MyD+3ZCXjnRA9Wuei hBvEFw/bmMKeO5lfGSAUYz+4aeDOfboL+CzOqmYQDBvgJ5CxEfXBOiyZsni10MsbkkYa Di0AmPmb83+SvbmLeC8VkqhUybYuoX4Jn5qimXcGUcDFkgfDAFonaPk7k5IDSoXXcmJD eveA== X-Forwarded-Encrypted: i=1; AJvYcCVzSNC0f9ttqdAC1aYpk97tOKb5zBNAN73Wi1tjqMc9Rxvya6/5h4YNcumF3FfGtOh8GKZUBCNKWwvkMyPTuiVD85Dm3cl3+v2TzGG7 X-Gm-Message-State: AOJu0YwXdCxi45xIxOkNPQoM1hQq0cWGYvSY0fFWYVuKNnHtA95HO4Ml v+9jSWgiMvJ57/4ei3VWPn2l+RvQ1QKto66ycJZAIHkOjqYnrsci X-Google-Smtp-Source: AGHT+IHfi5Yps3BwUmTiWlf6FCxS0A7pOZbcvRpj6RTg9QMe+gzPGrRzk9JVepx/IK4QLaUD9ombRA== X-Received: by 2002:a17:902:d2cc:b0:1f4:722b:9b9 with SMTP id d9443c01a7336-1f619b23bcemr25490075ad.62.1717071872757; Thu, 30 May 2024 05:24:32 -0700 (PDT) Received: from localhost.localdomain ([43.132.141.28]) by smtp.googlemail.com with ESMTPSA id d9443c01a7336-1f44c558ccdsm120548185ad.0.2024.05.30.05.24.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 May 2024 05:24:32 -0700 (PDT) From: Ze Gao X-Google-Original-From: Ze Gao To: Frederic Weisbecker , Joel Fernandes , Thomas Gleixner , Peter Zijlstra , Ingo Molnar Cc: Cruz Zhao , linux-kernel@vger.kernel.org, Ze Gao Subject: [RFC PATCH 1/2] timer: Use is_idle_task() check instead of idle_cpu() on irq exit Date: Thu, 30 May 2024 08:24:00 -0400 Message-ID: <20240530122401.3826022-2-zegao@tencent.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240530122401.3826022-1-zegao@tencent.com> References: <20240530122401.3826022-1-zegao@tencent.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" idle_cpu() was initially introduced in irq_enter()/exit() to check whether an irq interrupts an idle cpu or not since commit 79bf2bb335b8 ("[PATCH] tick-management: dyntick / highres functionality") and at that time, it's implemented via a simple check if the curr of task of that rq is idle or not. And then commit 6378ddb59215 ("time: track accurate idle time with tick_sched.idle_sleeptime") uses the same check to do accurate idle time accounting. But since commit 908a3283728d ("sched: Fix idle_cpu()"), idle_cpu() takes scheduler stats into consideration and becomes more constrained, and therefore it tells more than if we have interrupted an idle process but also whether a cpu is going to be idle or not since it takes queued tasks and queued to be woken tasks into account. However for tick user, it is too much as now we only rely on this check to do nohz idle time accounting in tick_nohz_start_idle() just in case that tick_nohz_stop_idle() is called upon irq_enter() if we actually rupture an idle cpu(process). The use of idle_cpu() simply complicates things here, and the introduction of sched_core_idle_cpu() in commit 548796e2e70b ("sched/core: introduce sched_core_idle_cpu()") proves this. The use of is_idle_task() just like in commit 0a8a2e78b7ee ("timer: Fix bad idle check on irq entry") helps to save one unnecessary fix for idle time accounting for the newly force idle state. Note this also preps for the remove of sched_core_idle_cpu() in the following patch. Signed-off-by: Ze Gao --- kernel/softirq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/softirq.c b/kernel/softirq.c index 02582017759a..24c7bf3c3f6c 100644 --- a/kernel/softirq.c +++ b/kernel/softirq.c @@ -617,7 +617,7 @@ static inline void tick_irq_exit(void) int cpu =3D smp_processor_id(); =20 /* Make sure that timer wheel updates are propagated */ - if ((sched_core_idle_cpu(cpu) && !need_resched()) || tick_nohz_full_cpu(c= pu)) { + if ((is_idle_task(current) && !need_resched()) || tick_nohz_full_cpu(cpu)= ) { if (!in_hardirq()) tick_nohz_irq_exit(); } --=20 2.41.0 From nobody Tue Dec 16 14:35:48 2025 Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) (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 0FFD61CB320 for ; Thu, 30 May 2024 12:24:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717071879; cv=none; b=NQ3eqJdWU/wqCIqJhQN0PiYuqTlpDrJ+4snc7j26sB82nJoPbfABJaDBidVsPAbDy79VN6aHPo5uq2Xvd/QKur63ndxPcVgsbTeym3kERkTEq4l9i4VZL0ylGPjl2co2dfu6AZp3jhlMYxQpwU6nO6iKlzMyXaLLsxprlg2e2yw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717071879; c=relaxed/simple; bh=c341nJ/WXptGuINcJPQ3UBxK8YzC4fSd7OjyiKpXNwM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cQ0TqxCdyYGLf01EGvHNbRnkHw/sYcyeuJApusfRV+axupZCIxLrFeuSSXP2YG+zajgBkFAd5ybAKP8uC77t5M18dzuEPjH/rNLoDc9ebpEgtRhA3ZUB5pDP12Wa+IdsBpphaOuatSTG1/DuxNEMZZqUtG+vKLK6G9oFfpCb7mg= 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=leOYbNI9; arc=none smtp.client-ip=209.85.214.173 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="leOYbNI9" Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-1f6262c0a22so1634835ad.1 for ; Thu, 30 May 2024 05:24:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717071877; x=1717676677; 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=CU/qwrYxGt9NVMt/p2uhxHpwoKeT7zg7pi77Z75VH3I=; b=leOYbNI9731PXMXplBP7wNiaLdd1IinbQw/MHQ7bNDuHz7sAEYxrLd9COdNBOg9d2X 1xC5L7CNgCTj2SfF1P3/YnGzdjOd5VPz8R0D+sc/QVZivJXwf++ThZKBrqsRdYqO5UTY uu1gMcPeMgqGVGVQsRScwmXTsdeynL5URC39orZOueO8gIqqsjNw2vEts37Aw/msBqJ7 eEnrulnxD2waaoZIuAVdBCWarsMU64vi5LV5wMnmbF0ZKDyaOBJtqS+ehJHPIE51IcBN Ewiq/v/DPtq6A5awqNtemXGO8+9xJin1Is+rLY3JJG03N2VU/UdMA7efZTyzOMY6I9jK Jhsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717071877; x=1717676677; 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=CU/qwrYxGt9NVMt/p2uhxHpwoKeT7zg7pi77Z75VH3I=; b=dmWwb3iGK6Ji9equqOp8LvBjB3jFGdXoykEJWEzbeUpCm9ELjtdATbby2Xlt7E/39b 4mY35s991dpyIED7F0IQ6QVTwzuun6eouxiBuycvc683Ue26Jcrs2Y3SCkGgcArr5viX u18vr9grvIpM8bNt5Wx/XSkkhgwfU7yAtRwlQJ8SG2Jfg3pubMVz5EaYV2YBAPb0MFn3 xwHA8zuQUn+bB1czbESQmXdtIMxLeiqIz2yBVlVOQq7hTTbds1IKvHGeKmfcDmeVnf2w SoQ60hZZfAAPIXlF2aJvNzgXtnGrkI3idEfHYPKTGONf03lEc99g1cRXQesR+Lmd4qsr elvQ== X-Forwarded-Encrypted: i=1; AJvYcCU7gj+oB7irutksgwvhnvcUQlZXScMzA2tsmoMUHRhXL+qmFguC6QRbDgpPwm50QWXi3dqGwA70eHbDYQJ+L+0TUlwAp5O49Fxm+5uZ X-Gm-Message-State: AOJu0YzcRoq9XS+LlUaltnW0YZA6fYGv1+iCBCpvfBhWcLBIyYhxOGlE bi8Ux3NDbA1cgyj7Oo8ySjmxoP81GRvC87vP9UEZF+ArYy0nWel9 X-Google-Smtp-Source: AGHT+IE7ADXNoK/kJenrb1y2YQR0elP5Pl+YgGUiCXcWKNCvmH18Ej/6BU5+Oh5J+58u7rOkzDG+5Q== X-Received: by 2002:a17:903:2292:b0:1f3:7da:b0f5 with SMTP id d9443c01a7336-1f61be85067mr28972765ad.22.1717071877158; Thu, 30 May 2024 05:24:37 -0700 (PDT) Received: from localhost.localdomain ([43.132.141.28]) by smtp.googlemail.com with ESMTPSA id d9443c01a7336-1f44c558ccdsm120548185ad.0.2024.05.30.05.24.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 May 2024 05:24:36 -0700 (PDT) From: Ze Gao X-Google-Original-From: Ze Gao To: Frederic Weisbecker , Joel Fernandes , Thomas Gleixner , Peter Zijlstra , Ingo Molnar Cc: Cruz Zhao , linux-kernel@vger.kernel.org, Ze Gao Subject: [RFC PATCH 2/2] sched/core: Remove sched_core_idle_cpu() Date: Thu, 30 May 2024 08:24:01 -0400 Message-ID: <20240530122401.3826022-3-zegao@tencent.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240530122401.3826022-1-zegao@tencent.com> References: <20240530122401.3826022-1-zegao@tencent.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Since there is no user of sched_core_idle_cpu(), delete it. Signed-off-by: Ze Gao --- include/linux/sched.h | 2 -- kernel/sched/core.c | 13 ------------- 2 files changed, 15 deletions(-) diff --git a/include/linux/sched.h b/include/linux/sched.h index 61591ac6eab6..85ef086362c9 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -2182,11 +2182,9 @@ extern void sched_core_free(struct task_struct *tsk); extern void sched_core_fork(struct task_struct *p); extern int sched_core_share_pid(unsigned int cmd, pid_t pid, enum pid_type= type, unsigned long uaddr); -extern int sched_core_idle_cpu(int cpu); #else static inline void sched_core_free(struct task_struct *tsk) { } static inline void sched_core_fork(struct task_struct *p) { } -static inline int sched_core_idle_cpu(int cpu) { return idle_cpu(cpu); } #endif =20 extern void sched_set_stop_task(int cpu, struct task_struct *stop); diff --git a/kernel/sched/core.c b/kernel/sched/core.c index bcf2c4cc0522..c42fe87e07d0 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -7453,19 +7453,6 @@ struct task_struct *idle_task(int cpu) return cpu_rq(cpu)->idle; } =20 -#ifdef CONFIG_SCHED_CORE -int sched_core_idle_cpu(int cpu) -{ - struct rq *rq =3D cpu_rq(cpu); - - if (sched_core_enabled(rq) && rq->curr =3D=3D rq->idle) - return 1; - - return idle_cpu(cpu); -} - -#endif - #ifdef CONFIG_SMP /* * This function computes an effective utilization for the given CPU, to be --=20 2.41.0