Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp2768545lqz; Wed, 3 Apr 2024 08:07:34 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU+vDzMs9OI19x2ZrCl4NU/9lahD8rbWVforGUxgJCg1KASmKWiZiBUUgrFX7CMtdgKxtZVa0uuLgJhECVkagMQQ72vz0b14Ed32haXsg== X-Google-Smtp-Source: AGHT+IFXlcBS/4Vy2uxpniW+tWR2+ntIIgk8OobX9S8pDkFFqCfcdt6YDPBjgp1qqukD7EPdAqHL X-Received: by 2002:a05:6402:5111:b0:56e:418:5559 with SMTP id m17-20020a056402511100b0056e04185559mr2014705edd.3.1712156854803; Wed, 03 Apr 2024 08:07:34 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712156854; cv=pass; d=google.com; s=arc-20160816; b=E4MKgSpxrtaXjvczlz44Pakf8wuXIXCIyPkEyTtp7eLKX1Xizgel2bYH5rOnWwFrIF ypiCuPJ3s55vDxuJGRxsjjykzRNhQPny2I6A02G9vZvaubXZQ9iWEPLjWMXdblLDakcR yHih9fgMbJ+xvsq4MZFZGPtzQZGy5rP5gTbjTfJe1ZpgglPT6aABoevdeG82LP+n0xa4 oWIwNJCJFx111rg06JkNqI7Xc/M9A6BsUCwxKS1zHD0wqxJegjYx9Dh8sb96MhgYekrd XacUowrXI/NmmRDDEBpfcLqTKaumxpHZZNfM7YjpeHsn11WiZWdhZtsKsDrkzdLHnFZS r7Og== 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; bh=geWh0ck7OguQB95gM23kbTkvLdlTXYUSEkeeN1Tq8NE=; fh=QXFAoy63r9JFArJAdiiFLh0KpNbDG0CoInGdQZSM+E4=; b=u/7xIfubZQNL07pkKdBqHwNbUtFogXUW5tFgNn1IS6l+W8mzBwlAiW25fxou39u+il sYaR/bGLjP2SnvGGtID0KuKvoUS/TQBgA4s3blTV91Yyclt4KUtRlSia+F6zBk4dM4AF 0U9fg3bWUrJsuOcC/CLtwg/OctzCxRIUYVGtBAyGEHZl/kY2REaZf5DR5IEl/pEZTLX4 sqbql9XdNRfme1uufP95GVkCMWoiATUhXV/mtwWC/aaFgFKAgdwVtCUPJdm8SyJdvCwC TpHcHUtaegUCez7yP0tXrpRl9G34CwDJmT9EyX+FYcsQMi8cDQQB7faoGgky780o73N0 PLNg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-130035-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-130035-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id t5-20020a508d45000000b0056c1cc96ba0si6839836edt.642.2024.04.03.08.07.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 08:07:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-130035-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-130035-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-130035-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.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 am.mirrors.kernel.org (Postfix) with ESMTPS id A49FC1F21B5C for ; Wed, 3 Apr 2024 15:07:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B993314A0A4; Wed, 3 Apr 2024 15:06:43 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9D64A14A0A6 for ; Wed, 3 Apr 2024 15:06:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712156803; cv=none; b=Y0js+CFdbQzhJQbEMaBEGxO3DiTWUSDQ5xtTdMGNS0gPz14M6dPRiEGrwTkrWVWkVpqBOyKgNb7AG7Sez1FEjuDkKQW/KGMH7zYPDqLslgZ66A3OPrCn+CV6muOJyl50+/WXz6pM0aZNFgE17RDz+JBCv/hrCg/B8pLbl5KLKx8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712156803; c=relaxed/simple; bh=pimyCXvc7YX8asor/As9BfBUS8PADGX9CEj0YFa8W2Y=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=RvDbhsV1C/cdlKIxWB4Gm/bKwdNFIUn0oNNbYd1LefIjgv6SUjp5DJcCtX5vV7Jq+Ug1E24Z5GXDMLkRTsnQOlgj6uAJPRo0OhK08L/+HOD1QWbcCN4Fj9bCTSaKHTcnQsZKrGZSdbzbJexqswLeTqdp7a5JklXxqlFexMYfyac= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id EDA771688; Wed, 3 Apr 2024 08:07:11 -0700 (PDT) Received: from e126645.arm.com (unknown [10.57.74.15]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 338893F7B4; Wed, 3 Apr 2024 08:06:36 -0700 (PDT) From: Pierre Gondois To: linux-kernel@vger.kernel.org Cc: Aaron Lu , Rui Zhang , Pierre Gondois , Anna-Maria Behnsen , Frederic Weisbecker , Ingo Molnar , Thomas Gleixner , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider , Andrew Morton , Michal Hocko , Tejun Heo , Waiman Long Subject: [PATCH 4/7] sched/fair: Move/add on_null_domain()/housekeeping_cpu() checks Date: Wed, 3 Apr 2024 17:05:36 +0200 Message-Id: <20240403150543.2793354-5-pierre.gondois@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240403150543.2793354-1-pierre.gondois@arm.com> References: <20240403150543.2793354-1-pierre.gondois@arm.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 Prepare a following patch by moving/adding on_null_domain() and housekeeping_runtime_cpu() checks. In nohz_balance_enter_idle(): - The housekeeping_runtime_cpu(cpu, HKR_TYPE_SCHED) call is currently a no-op as HKR_TYPE_SCHED is never configured. The call can thus be moved down. - In the current code, an isolated CPU sets nohz.has_blocked, but isn't set in nohz.idle_cpus_mask. However, _nohz_idle_balance::for_each_cpu_wrap() iterates over nohz.idle_cpus_mask cpus. Move the check up to avoid this. In nohz_balance_exit_idle(): - The check against a NULL sd in: nohz_balance_enter_idle() \-if (on_null_domain()) \-[returning here] \-rq->nohz_tick_stopped = 1 prevents from setting the rq's nohz_tick_stopped, and sched_balance_trigger() \-if (on_null_domain()) \-[returning here] \-nohz_balancer_kick() \-nohz_balance_exit_idle() prevents from resetting the nohz.[nr_cpus|idle_cpus_mask] variables. So the newly added on_null_domain() check doesn't change current behaviour. It however prepares: - the use of the HKR_TYPE_SCHED isolation mask - the removal of on_null_domain() in a later patch. Signed-off-by: Pierre Gondois --- kernel/sched/fair.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 0665f5eb4703..3e0f2a0f153f 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -12039,6 +12039,10 @@ void nohz_balance_exit_idle(struct rq *rq) { SCHED_WARN_ON(rq != this_rq()); + /* If we're a completely isolated CPU, we don't play: */ + if (on_null_domain(rq)) + return; + if (likely(!rq->nohz_tick_stopped)) return; @@ -12079,10 +12083,6 @@ void nohz_balance_enter_idle(int cpu) if (!cpu_active(cpu)) return; - /* Spare idle load balancing on CPUs that don't want to be disturbed: */ - if (!housekeeping_runtime_test_cpu(cpu, HKR_TYPE_SCHED)) - return; - /* * Can be set safely without rq->lock held * If a clear happens, it will have evaluated last additions because @@ -12090,6 +12090,14 @@ void nohz_balance_enter_idle(int cpu) */ rq->has_blocked_load = 1; + /* Spare idle load balancing on CPUs that don't want to be disturbed: */ + if (!housekeeping_runtime_test_cpu(cpu, HKR_TYPE_SCHED)) + return; + + /* If we're a completely isolated CPU, we don't play: */ + if (on_null_domain(rq)) + return; + /* * The tick is still stopped but load could have been added in the * meantime. We set the nohz.has_blocked flag to trig a check of the @@ -12099,10 +12107,6 @@ void nohz_balance_enter_idle(int cpu) if (rq->nohz_tick_stopped) goto out; - /* If we're a completely isolated CPU, we don't play: */ - if (on_null_domain(rq)) - return; - rq->nohz_tick_stopped = 1; cpumask_set_cpu(cpu, nohz.idle_cpus_mask); -- 2.25.1