Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp1256542lqb; Thu, 30 May 2024 05:24:42 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVcol3uc1JviamPdjMoBF2u2nkiItkZ0BoIoClyf2qq6Eyma4g1Zom5uw0a7zj7wVOIfBkcLNZcLS8/429fdMmyfC/hE76bYGXcT2C70g== X-Google-Smtp-Source: AGHT+IGX4PyTIB0hnHC6cGJ1LA9bhIUUUXOge1IJkXlNpxflCbayTB8dsxKmyJfq0VtfeK87pTO8 X-Received: by 2002:a05:622a:14b:b0:43d:d7a0:3791 with SMTP id d75a77b69052e-43fe9332033mr18765551cf.67.1717071881784; Thu, 30 May 2024 05:24:41 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717071881; cv=pass; d=google.com; s=arc-20160816; b=qhl6LQt20T9g8EamgxK65nPiuPYGTUBG56Sggzp9IqdjzqZxjRCWD4+nQZI2tsU9J/ mFM81deOAsDD3rYM9JYpyE7ygRG2ZAO9WsDBg/czP+Ube4/csC/8X5bW+ClIl8c0sWBs kbIHt0kxCZeTXUOy6zH/zIA7BfySuFr8ZOqOmFPFZCG8y3WTcfg2X4+hSEkGuhg3/IS0 q8uCDJ68jfoXrf5YSRIOrd/fo9b88TAPZUzKH6ebZIaV5UgiwTV6YAbrk+LxpjRFOxdV 7PT6V1iKJSMMcsED/4IzXBSvq5TczJo6bAnX1L8rsIABRpXDTmEPIXcAysYUEV3uBXZh E3hg== 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=PVavlMvyMd64Xp7pg69LkDUlV3ao7rCW+YbfGdGmSAU=; fh=mNbeIYxRDc8iR0pql7lHwR29wDnQIqTXxTQLW9RDTWw=; b=01xN1vWAzFkm4G3l0lA9mp40Poxhh516kePvbAY/wOeeoYd0xXtE+CnqssDcRiOr0h cawffeXzAu8elhQve+gB7At/IxsJisFJna7QmlgWvrPCEKfDV9OUwhHfJd4mkJGhCZiJ h+bGsddRgZN7oNQ5NJoGQBBQFP/6pu+W7YweytmddBP2klvSkXPQ8NtcQyjzHdIP5dGz js2Nl13+s37YIddC9y3+BqJR1npS9t84EqwfBCcbV70GGERnUSjvLjyuXY6nTNyAGn0i 5Br0MaYYjEn3h2dMUDZWJtFYBnhiv+AlKNlDC/Rw+tSRAPS1KBYKlFYqKIZeJgHkWtmD eMLA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Hx6IKDNp; 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-195356-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-195356-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id d75a77b69052e-43ff0186c98si1691651cf.375.2024.05.30.05.24.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 May 2024 05:24:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-195356-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Hx6IKDNp; 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-195356-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-195356-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 644FD1C212E3 for ; Thu, 30 May 2024 12:24:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B63401C9EB7; Thu, 30 May 2024 12:24:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Hx6IKDNp" 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 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-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: 8bit 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 = smp_processor_id(); /* Make sure that timer wheel updates are propagated */ - if ((sched_core_idle_cpu(cpu) && !need_resched()) || tick_nohz_full_cpu(cpu)) { + if ((is_idle_task(current) && !need_resched()) || tick_nohz_full_cpu(cpu)) { if (!in_hardirq()) tick_nohz_irq_exit(); } -- 2.41.0