From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 34DA83ACA4E for ; Thu, 2 Jul 2026 21:48:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783028932; cv=none; b=mxQew7ISV/qrsaqY6kb5ZSiiejb6loBOX+EbMHHNtMCxBd+zxF9XIa/qbfiknRRJtvtxT2ELU5AulK0i4Cx4075lcr/NjFXxB9oKEIKUjtlkji4ma0tXTMnIJ/KMMBJX1YFmNFHgpda4SpwBnXP5PXQtLXDm5XSvzfwRduWKNuU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783028932; c=relaxed/simple; bh=1zYP7AWMSe2LQisOmozCIZ1pT9vYhHKFeXF2hVezRR0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mIfbFlITOM5a1puvJynH52K7rhV2pZq2VRz8GTLjsh35VeXQUX07FR2Wd5EFwe/3p0q5PySV979jp+y6tCO3KaJPdv18pOuDLIPeMsk2nsFD1zeV98ChYImHitB/KiIMaa/iv+ksIy10YH6eeFeOL/5luHPALp3AVBrSec8bOPY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=CV/vFvJV; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="CV/vFvJV" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1783028930; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gzCGdoJz9K05gSMHoIBcKzVJ6IPdjGcSgO5/nHPKeq4=; b=CV/vFvJVJSKHnfabZEs7JD1hAP6k/bD5thrmiFYcn/VdHuro6EsVilWqEGCNkwRgS0IysN HYlFpIOxXna+Ybzn6eAxsOci8yzd+i/Cig1AwgoscyHM18maWpvXVeBDiVS5IEwGNc3XTL vzYQNKYrKgZl+moQKonGIj/UYa5VG44= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-507-M9HyPyM0Nt6fm8ElfDtaRg-1; Thu, 02 Jul 2026 17:48:47 -0400 X-MC-Unique: M9HyPyM0Nt6fm8ElfDtaRg-1 X-Mimecast-MFC-AGG-ID: M9HyPyM0Nt6fm8ElfDtaRg_1783028925 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 672B81944AA9; Thu, 2 Jul 2026 21:48:45 +0000 (UTC) Received: from llong-thinkpadp16vgen1.westford.csb (unknown [10.2.16.58]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 81B3B3189; Thu, 2 Jul 2026 21:48:42 +0000 (UTC) From: Waiman Long To: Ridong Chen , Tejun Heo , Johannes Weiner , =?UTF-8?q?Michal=20Koutn=C3=BD?= , Shuah Khan , Juri Lelli Cc: cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Aaron Tomlin , Guopeng Zhang , Waiman Long Subject: [PATCH-next v10 04/11] cgroup/cpuset: Put all task attach related variables into attach_ctx Date: Thu, 2 Jul 2026 17:47:50 -0400 Message-ID: <20260702214757.579012-5-longman@redhat.com> In-Reply-To: <20260702214757.579012-1-longman@redhat.com> References: <20260702214757.579012-1-longman@redhat.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 Put the task attach related cpuset_attach_old_cs and cpuset_attach_nodemask_to static variables into the new attach_ctx structure to improve readability and ease maintanence. No functional change is expected. Suggested-by: Ridong Chen Signed-off-by: Waiman Long Reviewed-by: Ridong Chen --- kernel/cgroup/cpuset.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index 1a78d0590737..47aa8f2fdfdc 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -362,6 +362,8 @@ static DECLARE_WAIT_QUEUE_HEAD(cpuset_attach_wq); */ static struct { int in_progress; + struct cpuset *old_cs; /* Source cpuset */ + nodemask_t nodemask_to; } attach_ctx; /* @@ -3015,8 +3017,6 @@ static int update_prstate(struct cpuset *cs, int new_prs) return 0; } -static struct cpuset *cpuset_attach_old_cs; - /* * Check to see if a cpuset can accept a new task * For v1, cpus_allowed and mems_allowed can't be empty. @@ -3048,8 +3048,8 @@ static int cpuset_can_attach(struct cgroup_taskset *tset) int cpu, ret; /* used later by cpuset_attach() */ - cpuset_attach_old_cs = task_cs(cgroup_taskset_first(tset, &css)); - oldcs = cpuset_attach_old_cs; + attach_ctx.old_cs = task_cs(cgroup_taskset_first(tset, &css)); + oldcs = attach_ctx.old_cs; cs = css_cs(css); mutex_lock(&cpuset_mutex); @@ -3152,7 +3152,6 @@ static void cpuset_cancel_attach(struct cgroup_taskset *tset) * allocate from cpuset_init(). */ static cpumask_var_t cpus_attach; -static nodemask_t cpuset_attach_nodemask_to; static void cpuset_attach_task(struct cpuset *cs, struct task_struct *task) { @@ -3169,7 +3168,7 @@ static void cpuset_attach_task(struct cpuset *cs, struct task_struct *task) */ WARN_ON_ONCE(set_cpus_allowed_ptr(task, cpus_attach)); - cpuset_change_task_nodemask(task, &cpuset_attach_nodemask_to); + cpuset_change_task_nodemask(task, &attach_ctx.nodemask_to); cpuset1_update_task_spread_flags(cs, task); } @@ -3179,7 +3178,7 @@ static void cpuset_attach(struct cgroup_taskset *tset) struct task_struct *leader; struct cgroup_subsys_state *css; struct cpuset *cs; - struct cpuset *oldcs = cpuset_attach_old_cs; + struct cpuset *oldcs = attach_ctx.old_cs; bool cpus_updated, mems_updated; bool queue_task_work = false; @@ -3191,7 +3190,7 @@ static void cpuset_attach(struct cgroup_taskset *tset) cpus_updated = !cpumask_equal(cs->effective_cpus, oldcs->effective_cpus); mems_updated = !nodes_equal(cs->effective_mems, oldcs->effective_mems); - guarantee_online_mems(cs, &cpuset_attach_nodemask_to); + guarantee_online_mems(cs, &attach_ctx.nodemask_to); /* * In the default hierarchy, enabling cpuset in the child cgroups @@ -3230,7 +3229,7 @@ static void cpuset_attach(struct cgroup_taskset *tset) */ if (is_memory_migrate(cs)) { cpuset_migrate_mm(mm, &oldcs->old_mems_allowed, - &cpuset_attach_nodemask_to); + &attach_ctx.nodemask_to); queue_task_work = true; } else mmput(mm); @@ -3240,7 +3239,7 @@ static void cpuset_attach(struct cgroup_taskset *tset) out: if (queue_task_work) schedule_flush_migrate_mm(); - cs->old_mems_allowed = cpuset_attach_nodemask_to; + cs->old_mems_allowed = attach_ctx.nodemask_to; if (cs->nr_migrate_dl_tasks) { atomic_add(cs->nr_migrate_dl_tasks, &cs->nr_deadline_tasks); @@ -3693,7 +3692,7 @@ static void cpuset_fork(struct task_struct *task) /* CLONE_INTO_CGROUP */ mutex_lock(&cpuset_mutex); - guarantee_online_mems(cs, &cpuset_attach_nodemask_to); + guarantee_online_mems(cs, &attach_ctx.nodemask_to); cpuset_attach_task(cs, task); dec_attach_in_progress_locked(); -- 2.54.0