From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dl2-f42.google.com (mail-dl2-f42.google.com [74.125.229.170]) (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 BB1DC49DB9B for ; Fri, 2 Oct 2026 13:11:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.229.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790946716; cv=none; b=CV5EkmNdVr9lNnrcyzfjJHxVzVy6AB2bmskLyjTfYqe97b5ZXZmkVOapi+XSZn20bpGf0SioQCCCGkY+UpduOrkaIbstlBhgaqj9pZBfZUhCta8JCtEJkYMbtt0ZC/mAZ4OSQd9FyC5fTjw2EQ3koAOwuS/Ipu75qpZ46boSZ84= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790946716; c=relaxed/simple; bh=ioHFspw6dBzml20bQjh5wqXld+9sMKkrChXphGvT8j8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=rynPhQvbblo8xqOxNpyuttKpcp5Uv4VC8GSqZSVUmG8Ih2v6wqch/QYRbDlxVNiL25nEwC3qA5usKW7ftUl0vyNtDf1Atm80hiF+tWjOGV+sVZ/nW+dwvTAU4lY2aIEzsgr1WZPVQ9UymXIA2zIP1+2mEVXiYUuzh/1+AVHFxLo= 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=K6xo5Vcf; arc=none smtp.client-ip=74.125.229.170 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="K6xo5Vcf" Received: by mail-dl2-f42.google.com with SMTP id a92af1059eb24-1438cb9b3a3so6539336c88.2 for ; Fri, 02 Oct 2026 06:11:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1790946707; x=1791551507; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=LZG5fAQ0FiH64NGyRXubKr6Xz8RTMEKx2x1RgTKTW7s=; b=K6xo5VcfNZoeivzQxs3LR+sbDQwKIxZogzBCOgqHkneIVAXVAV3rmxD342nWtdlsdy BOEKtlhyLi8zGMfxv3kk1abWaQUm9NOcWoCFvbiWauYxDliCYbFoY3g3FSblTbd+THc0 P722ylgCWkf76DWE8OrT8FFOjYnDT+Jmnh7/qz0cTCPbDuCnXT8eYl2yQ6ChVSqOYZRY KFOCgGz4oQYzEMelUPBcZDyyBO1X93jUNbfs8KDblK+8wEFTJwxmaZPI0ube+zuGOg2z /bt+y4LBahF3jrKVfQ8XBTBJfp33mbGjzOeOUnYjyVw+E+lhRIC616yhU6MoZP0240eO 1uFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790946707; x=1791551507; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=LZG5fAQ0FiH64NGyRXubKr6Xz8RTMEKx2x1RgTKTW7s=; b=BSX7GbOTi/iAmGvRg2+JieTgnk+TPEZHUBfNKEDjJ77VCD3MxD9JBwsthbhgXaBCOb mpsEU5aPyuvjERkUiTto3JNovC0em2yMXWhGNFKjyvmXFyAoRa1y7xNZWp0kpx9fgHUT mLJ2ifP35RjT3g7lbjiAfWyeqh+lsi2IDsO3MqJ5k6lchH4VHuVU+UAFK0qtYC0TPQeu 6msOvAtM/dUCquhEicaukEKVvEysySk2CkYayGYYTltXFiUhKFdeC0VXajKroXqqHlUf kisPsc/2tK5zXSF6JqQKuYDpQvwbXVWqAIPTKkFBLcq1JAg7e/orEJ/q9ADmSzuw9wNx qK7w== X-Forwarded-Encrypted: i=1; AKwUvBwC2oB94XTlj4HNTIa4pJJbYrDiBJR/F2JF0WhIjGbJweXr8gMk6Ql6+JhU+5fuBOIWfDLZtOFWY017ziM=@vger.kernel.org X-Gm-Message-State: AFuF++nJCN6kGxqN2nULheDKMcbIT8ntuFI2Swi4nnuiPnWhy7RX5s9C dx9W7MKksqEVkxO43H0/MUlaIi9/T0znGBULmuhdqb9jxiT2uBNRHPQb X-Gm-Gg: AYBFou0eXQA+wWLG6VRJ1EWPr1yU0e+mcwU/VQ99AIRzEPKruVCAKuK/VLvX6uQOzJI fHf5Netjd7AIjeHK82hlByHQ9Qrpd9hdxNLf9TAmQRQzodhpBqLNuQIK5WOMNM/Zhubz4oaCgC7 aOuyqaNQgIrZPKE6obgmBLAdWga+AbkC9EiFN7ConqAUEq5c4dxOnc9hX6G6ZdVTGiJNLkKNT4P 6Xb/2gLzo2hf5TimVGKDw+sMKEmLWZCQRE3Ki0b1vi+uu9GLU1T/9V0CoDOStY+osvBVxJ0r/Mb zdKPYUhTRHdukLCS3gmEkDb9Jp+sT9kVCdSVntiyH2HXrYfGexTzYL58ng/f0c8eymcNkWgFPcL cJHVDSXgEQFeUqRJEd2eCicMmcyyjeD/4YftKk++R0yeNsgXrxQYZ9sjrD8uzCvCsmwY1jF67Ym he7YfJn8EyPwJ8qixYhuSY2wWubfk2hwYM3fQfaq3b1GrpPkpnsLfivctqqa7HQoD6lQ== X-Received: by 2002:a05:701b:2512:b0:13d:974:a2c6 with SMTP id a92af1059eb24-14f5b9fbb86mr2985232c88.7.1790946706628; Fri, 02 Oct 2026 06:11:46 -0700 (PDT) Received: from [127.0.1.1] ([23.254.208.9]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-34f0672c739sm7309347eec.3.2026.10.02.06.11.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Oct 2026 06:11:46 -0700 (PDT) From: Qiliang Yuan Date: Fri, 02 Oct 2026 21:10:29 +0800 Subject: [PATCH v5 09/12] cpuset: Add dhm_cycling_cpus mask to suppress transient invalidation Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20261002-wujing-dhm-v5-9-78a6996d87ad@gmail.com> References: <20261002-wujing-dhm-v5-0-78a6996d87ad@gmail.com> In-Reply-To: <20261002-wujing-dhm-v5-0-78a6996d87ad@gmail.com> To: Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , "Paul E. McKenney" , Frederic Weisbecker , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Uladzislau Rezki , Mathieu Desnoyers , Lai Jiangshan , Zqiang , Anna-Maria Behnsen , Tejun Heo , Jonathan Corbet , Shuah Khan , Shuah Khan , Thomas Gleixner Cc: Waiman Long , linux-kernel@vger.kernel.org, rcu@vger.kernel.org, cgroups@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, Qiliang Yuan X-Mailer: b4 0.13.0 When the cpuset code cycles a CPU through hotplug to apply kernel-noise isolation (remove_cpu followed by add_cpu), the CPU disappears from cpu_active_mask temporarily. cpuset_hotplug_update_tasks() sees an empty effective CPU set on the isolated partition and issues partcmd_invalidate, tearing down the partition. The subsequent add_cpu brings the CPU back online, but the partition has already been marked invalid and requires manual user intervention to restore. Add a global dhm_cycling_cpus cpumask protected by dhm_cycling_lock. The isolation cycling path sets the bits for CPUs being cycled before calling remove_cpu(), clears them after add_cpu() completes. cpuset_hotplug_update_tasks() checks whether any of the cpuset's effective exclusive CPUs are in dhm_cycling_cpus and skips the invalidation command when they are, treating the transient empty-CPU state as expected rather than an error. A global cpumask avoids the need to walk the cpuset tree to find the owning cpuset during the cycling loop which runs without cpuset locks. Signed-off-by: Qiliang Yuan --- kernel/cgroup/cpuset.c | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index 8b3bb034adf62..6213e63cf348d 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -157,6 +157,14 @@ static bool update_housekeeping; /* RWCS */ */ static cpumask_var_t isolated_hk_cpus; /* T */ +/* + * CPUs currently being cycled through hotplug for kernel-noise isolation. + * Protected by dhm_cycling_lock; read in cpuset_hotplug_update_tasks() to + * suppress transient partition invalidation during the offline step. + */ +static DEFINE_SPINLOCK(dhm_cycling_lock); +static cpumask_var_t dhm_cycling_cpus; + /* * A flag to force sched domain rebuild at the end of an operation. * It can be set in @@ -3906,6 +3914,7 @@ int __init cpuset_init(void) BUG_ON(!zalloc_cpumask_var(&subpartitions_cpus, GFP_KERNEL)); BUG_ON(!zalloc_cpumask_var(&isolated_cpus, GFP_KERNEL)); BUG_ON(!zalloc_cpumask_var(&isolated_hk_cpus, GFP_KERNEL)); + BUG_ON(!zalloc_cpumask_var(&dhm_cycling_cpus, GFP_KERNEL)); cpumask_setall(top_cpuset.cpus_allowed); nodes_setall(top_cpuset.mems_allowed); @@ -3991,6 +4000,20 @@ static void cpuset_hotplug_update_tasks(struct cpuset *cs, struct tmpmasks *tmp) if (remote && (cpumask_empty(subpartitions_cpus) || (cpumask_empty(&new_cpus) && partition_is_populated(cs, NULL)))) { + bool cycling; + + /* + * Suppress transient invalidation when the offline is part + * of a hotplug cycling step for kernel-noise isolation. + */ + spin_lock(&dhm_cycling_lock); + cycling = cpumask_available(dhm_cycling_cpus) && + cpumask_intersects(cs->effective_xcpus, + dhm_cycling_cpus); + spin_unlock(&dhm_cycling_lock); + if (cycling) + goto unlock; + WRITE_ONCE(cs->prs_err, PERR_HOTPLUG); remote_partition_disable(cs, tmp); compute_effective_cpumask(&new_cpus, cs, parent); @@ -4008,8 +4031,21 @@ static void cpuset_hotplug_update_tasks(struct cpuset *cs, struct tmpmasks *tmp) if (is_local_partition(cs) && (!is_partition_valid(parent) || tasks_nocpu_error(parent, cs, &new_cpus) || - cpumask_empty(subpartitions_cpus))) - partcmd = partcmd_invalidate; + cpumask_empty(subpartitions_cpus))) { + bool cycling; + + /* + * Suppress transient invalidation when the offline is part + * of a hotplug cycling step for kernel-noise isolation. + */ + spin_lock(&dhm_cycling_lock); + cycling = cpumask_available(dhm_cycling_cpus) && + cpumask_intersects(cs->effective_xcpus, + dhm_cycling_cpus); + spin_unlock(&dhm_cycling_lock); + if (!cycling) + partcmd = partcmd_invalidate; + } /* * On the other hand, an invalid partition root may be transitioned * back to a regular one with a non-empty effective xcpus. -- 2.43.0