Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp2770993lqz; Wed, 3 Apr 2024 08:10:53 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXAUAJ+A6gZpvu/l6/lBPLZR7UCe9lBK7vIb3WpXPMInV2wNYLQlaKV9QhZmY3JpITjD77CWTnq/7DHN+DVSxO7IhPRCsoDd6iI4CMzMg== X-Google-Smtp-Source: AGHT+IFkdOXXHsP1CODDZ+WboJqpvDXdvmEYp3WEb8h/VqYeEJ+x/AqYG2YUJ/dOxxHNoZ8snmZi X-Received: by 2002:a17:90a:7d02:b0:2a0:4495:1f3d with SMTP id g2-20020a17090a7d0200b002a044951f3dmr16624673pjl.0.1712157053455; Wed, 03 Apr 2024 08:10:53 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712157053; cv=pass; d=google.com; s=arc-20160816; b=fErQ9uYYP3Rsv1vPgb2n7mVIrTO5NnVrZi93okxN3hGRVIEKhzzQjMZkLKGTeaT+Pz sRWcEGKtO1V36gOOZ6VBUMHyFPUuI64sxpAYda73wsFhnj8h7A3S7JL0sJ7OZLvxDKKU mrSr6DWG61TWUzKF0gSfkdsCoAHeYHkACCed0IEymP9e+egOJ/E7zg31xVVjsy1oJxnd tH9hXCbg5McpBo08oH0uOjBijjqVSMROytVWqlfAxhMp8fEeO4uPs9rXoMb2kxC30j+i AxZarEb8mMXQFsEU8w+tmoChMauEjLjmwrQjf+CfuAVK+6uv5VwTJ2+NdoFXwGjAIMj6 nRaw== 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=PISQxklyVv7qospZXeCASI8F2F5T3kOJQSdEIwZ5TOs=; fh=wavJH6ZmcZntBwO/7K1dqACMXWn5JjxJE+X7EEu4idw=; b=zvA067d7ehoxPUNU2ZionArlVTGlVxCcE+RzTKyCHwlv/mALyWNpWJJXR5fuR4SksO 15VCsdhjDQ7c5R01NfA6fCLVYWZ0ePP4UEK04d2O8UukxZUDkT/XVLCGDRqqCyyT8Ep9 8Ks6Lvny8dM++GHQl5Suni1nY0WNBUNzeOBjTe8VvdmD2r3c38djEDvcbbtLgXi+68AI Q81h2eLbRsSSpV4yyHo2JRaC29GYaJxVxpsZTl8McxQNFYOInd5OvkAcmAuKpuyHQcXm 5l7FJGnLqJkLjTenaeAqSd7uS6jtl0eCYyw5IR6Mby1Q7IceNUY3wPHLKg/brpCoGYOD vWIA==; 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-130040-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-130040-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id h19-20020a17090acf1300b002a2950bb99csi1487420pju.84.2024.04.03.08.10.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 08:10:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-130040-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; 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-130040-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-130040-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 6D7D0283A59 for ; Wed, 3 Apr 2024 15:08:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E9CDC14A4EB; Wed, 3 Apr 2024 15:07:10 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F1C4B149E0A for ; Wed, 3 Apr 2024 15:07:08 +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=1712156830; cv=none; b=CXR+3PhdlcY904SSaygKOrhTCAoBj3Rli4KBNvuGfowZYoKvhqrche0S/aNJWE3Uzx72FEvmJtIHtmSI0FGQJGLM//GDi6ixkKTDNBMYZ8Y3hlRAOGbimsHkgmTClpgXufYoF6S46NngErqL0DdUNAOdEbZLeJfYOT+u4RS2s5I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712156830; c=relaxed/simple; bh=W3JT2si9ImtOXLQWk2Xzg1pUyMSMDml9LjW4wwC97aw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=nTuC6jyOIJGZpP8M5Wz/FMYBMkdP6qOYBp4Dm3YCfXdQ5BpPazQk/WvuEpL9fb0WETRSJsIfQ+0EF3JS5OI5oP/DTPmReVXJQUFeJGiMI9sFeFC2F8O2X4K3qi6ubv2Q4zFH/GQxcnHX1kygtJMPJHszU//Uply/DpvryLfwPUc= 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 AF09F1691; Wed, 3 Apr 2024 08:07:39 -0700 (PDT) Received: from e126645.arm.com (unknown [10.57.74.15]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 4DFCF3F7B4; Wed, 3 Apr 2024 08:07:04 -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 , Waiman Long , Tejun Heo Subject: [PATCH 7/7] sched/fair: Clear idle_cpus_mask for CPUs with NULL sd Date: Wed, 3 Apr 2024 17:05:39 +0200 Message-Id: <20240403150543.2793354-8-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 As reported in [1], an isolated CPU keeps the values of: - rq->nohz_tick_stopped - nohz.idle_cpus_mask - nohz.nr_cpus when a NULL sd is attached to the CPU. Clear the values. [1] https://lore.kernel.org/all/20230804090858.7605-1-rui.zhang@intel.com/ Signed-off-by: Pierre Gondois --- include/linux/sched/nohz.h | 2 ++ kernel/sched/fair.c | 11 +++++++++++ kernel/sched/topology.c | 6 ++++-- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/include/linux/sched/nohz.h b/include/linux/sched/nohz.h index 6d67e9a5af6b..18e620715c9d 100644 --- a/include/linux/sched/nohz.h +++ b/include/linux/sched/nohz.h @@ -9,8 +9,10 @@ #if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON) extern void nohz_balance_enter_idle(int cpu); extern int get_nohz_timer_target(void); +extern void nohz_clear_state(int cpu); #else static inline void nohz_balance_enter_idle(int cpu) { } +static void nohz_clear_state(int cpu) { } #endif #ifdef CONFIG_NO_HZ_COMMON diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 9657c8f2176b..6786d4d78e41 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -12014,6 +12014,17 @@ static void nohz_balancer_kick(struct rq *rq) kick_ilb(flags); } +void nohz_clear_state(int cpu) +{ + struct rq *rq = cpu_rq(cpu); + + if (rq->nohz_tick_stopped) { + rq->nohz_tick_stopped = 0; + cpumask_clear_cpu(cpu, nohz.idle_cpus_mask); + atomic_dec(&nohz.nr_cpus); + } +} + static void set_cpu_sd_state_busy(int cpu) { struct sched_domain *sd; diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c index b4fc212ccfb0..e8e40b7d964b 100644 --- a/kernel/sched/topology.c +++ b/kernel/sched/topology.c @@ -775,10 +775,12 @@ cpu_attach_domain(struct sched_domain *sd, struct root_domain *rd, int cpu) sched_domain_debug(sd, cpu); - if (sd) + if (sd) { housekeeping_runtime_set_cpu(cpu, HKR_TYPE_SCHED); - else + } else { housekeeping_runtime_clear_cpu(cpu, HKR_TYPE_SCHED); + nohz_clear_state(cpu); + } rq_attach_root(rq, rd); tmp = rq->sd; -- 2.25.1