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.133.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 3D5613876AF for ; Thu, 14 May 2026 17:03:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778778202; cv=none; b=OFKlsIXKtLIV5KvBlpjUpOWptQlHTYPRWxHOEEdU1UDgKCs8WilV8x2EFcEiQh3qx9M/a6pbQ49HQ7zCGp9xvUY1uv4nKLMOvjASqTpXghqn2AO1VOIDdvhIOMTqqSuU09nNUsbw3iKaNIlZQv+3IkjreZWVVedSb/3XUGUmHig= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778778202; c=relaxed/simple; bh=iKoFddTMDlVHV4CXsvi7sFe225ba9qRiv/Yem/1K3g0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XjlExI1w2MOInNPNLSCTAOytDc+1uFb3FXwBVUF+W9z8PzcGrwpvXCchTKOzMdu0N+UWC5JaRD4bF3K0eIZxqhV9V9CNhdAUFCApw9GJgFNqmmSYRDq5j34u4oAt2N/GCoZpojVQCQy4nl9SIuVtBfoQmeNM5i2Y+a2AsBwQbFI= 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=d5Or0pxw; arc=none smtp.client-ip=170.10.133.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="d5Or0pxw" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778778200; 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=X5qv11FgV5fy/6EX+8T25xoRvDD1FKxp0C5IFRIAwRw=; b=d5Or0pxwhHbjjJAJWamY1L4nV90SpYEUziyKpbL1EmEHX30WUv1VHHkGV5l7OQBO4EeAqD Sb/fw9UsFnug+dm6qgeWCcgLAW0iZ4l3VAVa7HQ9FfoVhwkUQXeku/swlmcp4nY1vM5FZD ZI9XF5/x1iwysTYR4Q4deMeBJBkffkw= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-610-3OmNstXvN1m3sRrU8EZYlQ-1; Thu, 14 May 2026 13:03:16 -0400 X-MC-Unique: 3OmNstXvN1m3sRrU8EZYlQ-1 X-Mimecast-MFC-AGG-ID: 3OmNstXvN1m3sRrU8EZYlQ_1778778194 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 0F2DA1800626; Thu, 14 May 2026 17:03:14 +0000 (UTC) Received: from llong-thinkpadp16vgen1.westford.csb (unknown [10.2.16.73]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 47AD530002DA; Thu, 14 May 2026 17:03:10 +0000 (UTC) From: Waiman Long To: Chen Ridong , Tejun Heo , Johannes Weiner , =?UTF-8?q?Michal=20Koutn=C3=BD?= Cc: cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, Dietmar Eggemann , Aaron Tomlin , Juri Lelli , Waiman Long Subject: [PATCH cgroup/for-next 1/4] cgroup/cpuset: Add an alloc_dl_bw() helper Date: Thu, 14 May 2026 13:02:37 -0400 Message-ID: <20260514170240.575156-2-longman@redhat.com> In-Reply-To: <20260514170240.575156-1-longman@redhat.com> References: <20260514170240.575156-1-longman@redhat.com> Precedence: bulk X-Mailing-List: cgroups@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Extract the DL bandwidth allocation code in cpuset_attach() to a new alloc_dl_bw() helper to simplify code. No functional change is expected. Signed-off-by: Waiman Long --- kernel/cgroup/cpuset.c | 50 +++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index bcefc9f50ac5..9de3c907436f 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -2980,6 +2980,25 @@ static int cpuset_can_attach_check(struct cpuset *cs) return 0; } +static int alloc_dl_bw(struct cpuset *cs) +{ + int cpu, ret; + + if (!cs->sum_migrate_dl_bw) + return 0; + + cpu = cpumask_any_and(cpu_active_mask, cs->effective_cpus); + if (unlikely(cpu >= nr_cpu_ids)) + return -EINVAL; + + ret = dl_bw_alloc(cpu, cs->sum_migrate_dl_bw); + if (ret) + return ret; + + cs->dl_bw_cpu = cpu; + return 0; +} + static void reset_migrate_dl_data(struct cpuset *cs) { cs->nr_migrate_dl_tasks = 0; @@ -2994,7 +3013,7 @@ static int cpuset_can_attach(struct cgroup_taskset *tset) struct cpuset *cs, *oldcs; struct task_struct *task; bool setsched_check; - int cpu, ret; + int ret; /* used later by cpuset_attach() */ cpuset_attach_old_cs = task_cs(cgroup_taskset_first(tset, &css)); @@ -3050,31 +3069,18 @@ static int cpuset_can_attach(struct cgroup_taskset *tset) } } - if (!cs->sum_migrate_dl_bw) - goto out_success; - - cpu = cpumask_any_and(cpu_active_mask, cs->effective_cpus); - if (unlikely(cpu >= nr_cpu_ids)) { - ret = -EINVAL; - goto out_unlock; - } - - ret = dl_bw_alloc(cpu, cs->sum_migrate_dl_bw); - if (ret) - goto out_unlock; - - cs->dl_bw_cpu = cpu; - -out_success: - /* - * Mark attach is in progress. This makes validate_change() fail - * changes which zero cpus/mems_allowed. - */ - cs->attach_in_progress++; + ret = alloc_dl_bw(cs); out_unlock: if (ret) reset_migrate_dl_data(cs); + else + /* + * Mark attach is in progress. This makes validate_change() fail + * changes which zero cpus/mems_allowed. + */ + cs->attach_in_progress++; + mutex_unlock(&cpuset_mutex); return ret; } -- 2.54.0