From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-f182.google.com (mail-qk1-f182.google.com [209.85.222.182]) (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 756AA3B8BC8 for ; Fri, 6 Mar 2026 20:52:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772830377; cv=none; b=p/3PEL8tZ+N6wxklCv/yz19fRrVHU8bZlemxv5RgxAU4u6c0aoBg5i+V8fVpsZqyBYPe0GrRCm/7WEtrM98iZlQh+yecsz6nRuSWwnAuIYCam9qJ4GW+fME+7KU5hwPI9qBBMPH0cKNqqMPVRqhFRYQEbjoBFwYzbKFlhy5ApkA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772830377; c=relaxed/simple; bh=pBSrh7n9zfC4yRqe4M5RKyuj1n4ovuQev213YWPb1p0=; h=Mime-Version:Content-Type:Date:Message-Id:Cc:Subject:From:To: References:In-Reply-To; b=NDJMl127WSUVPCpkNAkC6jrPCTy/GBofmoOVre2RSGusIkhYqVVge7oO+2+EOrZ4BPG9o/KwoWei4QWOf22PCL6cHXo8UNMJA4z3KMvOsi542Vr1R1yC2bGdu62/NJoia2WDZwHf+kmJZ9UZe3XsdUDcfW+w2S+p/K4aDv+JKLk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=etsalapatis.com; spf=pass smtp.mailfrom=etsalapatis.com; dkim=pass (2048-bit key) header.d=etsalapatis-com.20230601.gappssmtp.com header.i=@etsalapatis-com.20230601.gappssmtp.com header.b=K+HuIei/; arc=none smtp.client-ip=209.85.222.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=etsalapatis.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=etsalapatis.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=etsalapatis-com.20230601.gappssmtp.com header.i=@etsalapatis-com.20230601.gappssmtp.com header.b="K+HuIei/" Received: by mail-qk1-f182.google.com with SMTP id af79cd13be357-8cd759f502dso31964285a.3 for ; Fri, 06 Mar 2026 12:52:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=etsalapatis-com.20230601.gappssmtp.com; s=20230601; t=1772830375; x=1773435175; darn=vger.kernel.org; h=in-reply-to:references:to:from:subject:cc:message-id:date :content-transfer-encoding:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=2VDCfgcHJ+D4cblCuaPqSDuGNSSw2HHIqymIwPMAZ3s=; b=K+HuIei/cOpbmv/SPcjUGPOY6O+6O6K0th0vYowiSDKw6OGB5YEFXNwjN3fkKzw5QA pcuIbnRVRirzcJ6FWflAqBLf1oAwBZC2eED8gBsTnzRyImCyhycr2pQ8XdH/wMldfMVM Lfohp4X9DAOET8nlLcwmghBMo/A//Gl0JwWtDAEceaWivUG5jURkqBXJDAZfemYSIuuH PS5Xi+WoBy1PF2DIaP1vLZbddIqh+ZXuTDzbxtDSerVNmLc/HurIJ9Yn3t1tWVFsvJF6 qAFVduPG+Eg7ZOMjcjrSEvPrswCwT4oETkYWBYzYRlByMt2pTPNA7hInufQMzD7bxSPo URTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772830375; x=1773435175; h=in-reply-to:references:to:from:subject:cc:message-id:date :content-transfer-encoding:mime-version:x-gm-gg:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=2VDCfgcHJ+D4cblCuaPqSDuGNSSw2HHIqymIwPMAZ3s=; b=W/lWoi/KGO+JeQikN8/vNuRTTKtO1EWxllZKb0TapIDn5oFrE7+VetbrDDI15pc3Rz rDEP9uR6gXZr1D+mx0e1ccXW76OzgbsUh4/zEs96HaLLNiHMpJL/flL/M2svEURW3lzQ hUcelaoW+0Npl/j6/WpXIstL7ywDiSe8VwI/gvJnEeQmd+UxpvmInuioq93au4Nxrhnr OoUiWs1t9Er/m37JyLCp0I+dXXDB8+dgUjwbunxkcqpQncTK9lK3MNXPYYrjfXaJdLbG zKPu4w9tF3YW8IOsuU12O+tZINidRBpbiUkbza1M5IQXifEGEkiroLpRRXlPOUcvLUaW mMOg== X-Forwarded-Encrypted: i=1; AJvYcCVOnXRYO70i6eZSOGB6aGqLWXgN9n/DYK+J8vKYkPkSC5DZYhCe6iTsTgsTTVl+C3nz6/t1YiLik/FwiFY=@vger.kernel.org X-Gm-Message-State: AOJu0YyQ2pB46voM5F5kBico8eO4w5skiACQvtg3uewULd3ZbYQ/uf1J F+TqBTh04bEjflvbEeC/LLXfZBK1TCNkXevpjGEIiAputzrSSRwuWdkOswLR+KxAWWx8qACnM5P oIaLo X-Gm-Gg: ATEYQzx7OBSGkf2rj5dN903VYO3ADhz2Uv28k4u55zc4KY4aNOoH236kWJuqlBQ1zjM stwAPllXQGPVB92pGIan5CeIiV/zyi8+eRmV3hIv/TX1/Zq0gcAP9Lb8KQecldAugsFsq+JNsgP b/Y49wD4Wvt0fgH0zEjaJ2bapJOddxpgdRe8m97Fhy0p1S6RNc+M++dPHtoNE+rOcJagtVX37+j H7nZfSCsx+zWDbbX8GbKEcrVkneEKEWAmklrTEsOcSZchVhYrpcDm+uxV2587wGKVRYGaETFFE2 aipkOddf3qoji8I23orcoOfug4vnuYiutCDV0jW1iVBdJjqRBXu+UPIWeydepQ4BDqAnOZFWa9g u0vR+50kMzPpKR51rEsFujUo8DUwf1qM4PWJ8ZMr2NWdaiqLQYfjKmLZhcAPempubUU0N4CSp6z tLYqNcQuSHYTz+e2dH887ukNY= X-Received: by 2002:a05:620a:3f85:b0:8ca:3175:cc72 with SMTP id af79cd13be357-8cd6d3d99c0mr452069985a.15.1772830375332; Fri, 06 Mar 2026 12:52:55 -0800 (PST) Received: from localhost ([140.174.219.137]) by smtp.gmail.com with ESMTPSA id af79cd13be357-8cd6f484288sm183999885a.7.2026.03.06.12.52.54 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 06 Mar 2026 12:52:55 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Fri, 06 Mar 2026 15:52:53 -0500 Message-Id: Cc: , , Subject: Re: [PATCH 02/15] sched_ext: Wrap global DSQs in per-node structure From: "Emil Tsalapatis" To: "Tejun Heo" , , X-Mailer: aerc 0.20.1 References: <20260306190623.1076074-1-tj@kernel.org> <20260306190623.1076074-3-tj@kernel.org> In-Reply-To: <20260306190623.1076074-3-tj@kernel.org> On Fri Mar 6, 2026 at 2:06 PM EST, Tejun Heo wrote: > Global DSQs are currently stored as an array of scx_dispatch_q pointers, > one per NUMA node. To allow adding more per-node data structures, wrap th= e > global DSQ in scx_sched_pnode and replace global_dsqs with pnode array. > > NUMA-aware allocation is maintained. No functional changes. > > Signed-off-by: Tejun Heo Reviewed-by: Emil Tsalapatis > --- > kernel/sched/ext.c | 32 ++++++++++++++++---------------- > kernel/sched/ext_internal.h | 6 +++++- > 2 files changed, 21 insertions(+), 17 deletions(-) > > diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c > index fe222df1d494..9232abea4f22 100644 > --- a/kernel/sched/ext.c > +++ b/kernel/sched/ext.c > @@ -344,7 +344,7 @@ static bool scx_is_descendant(struct scx_sched *sch, = struct scx_sched *ancestor) > static struct scx_dispatch_q *find_global_dsq(struct scx_sched *sch, > struct task_struct *p) > { > - return sch->global_dsqs[cpu_to_node(task_cpu(p))]; > + return &sch->pnode[cpu_to_node(task_cpu(p))]->global_dsq; > } > =20 > static struct scx_dispatch_q *find_user_dsq(struct scx_sched *sch, u64 d= sq_id) > @@ -2229,7 +2229,7 @@ static bool consume_global_dsq(struct scx_sched *sc= h, struct rq *rq) > { > int node =3D cpu_to_node(cpu_of(rq)); > =20 > - return consume_dispatch_q(sch, rq, sch->global_dsqs[node]); > + return consume_dispatch_q(sch, rq, &sch->pnode[node]->global_dsq); > } > =20 > /** > @@ -4148,8 +4148,8 @@ static void scx_sched_free_rcu_work(struct work_str= uct *work) > free_percpu(sch->pcpu); > =20 > for_each_node_state(node, N_POSSIBLE) > - kfree(sch->global_dsqs[node]); > - kfree(sch->global_dsqs); > + kfree(sch->pnode[node]); > + kfree(sch->pnode); > =20 > rhashtable_walk_enter(&sch->dsq_hash, &rht_iter); > do { > @@ -5707,23 +5707,23 @@ static struct scx_sched *scx_alloc_and_add_sched(= struct sched_ext_ops *ops, > if (ret < 0) > goto err_free_ei; > =20 > - sch->global_dsqs =3D kzalloc_objs(sch->global_dsqs[0], nr_node_ids); > - if (!sch->global_dsqs) { > + sch->pnode =3D kzalloc_objs(sch->pnode[0], nr_node_ids); > + if (!sch->pnode) { > ret =3D -ENOMEM; > goto err_free_hash; > } > =20 > for_each_node_state(node, N_POSSIBLE) { > - struct scx_dispatch_q *dsq; > + struct scx_sched_pnode *pnode; > =20 > - dsq =3D kzalloc_node(sizeof(*dsq), GFP_KERNEL, node); > - if (!dsq) { > + pnode =3D kzalloc_node(sizeof(*pnode), GFP_KERNEL, node); > + if (!pnode) { > ret =3D -ENOMEM; > - goto err_free_gdsqs; > + goto err_free_pnode; > } > =20 > - init_dsq(dsq, SCX_DSQ_GLOBAL, sch); > - sch->global_dsqs[node] =3D dsq; > + init_dsq(&pnode->global_dsq, SCX_DSQ_GLOBAL, sch); > + sch->pnode[node] =3D pnode; > } > =20 > sch->dsp_max_batch =3D ops->dispatch_max_batch ?: SCX_DSP_DFL_MAX_BATCH= ; > @@ -5732,7 +5732,7 @@ static struct scx_sched *scx_alloc_and_add_sched(st= ruct sched_ext_ops *ops, > __alignof__(struct scx_sched_pcpu)); > if (!sch->pcpu) { > ret =3D -ENOMEM; > - goto err_free_gdsqs; > + goto err_free_pnode; > } > =20 > for_each_possible_cpu(cpu) > @@ -5819,10 +5819,10 @@ static struct scx_sched *scx_alloc_and_add_sched(= struct sched_ext_ops *ops, > kthread_destroy_worker(sch->helper); > err_free_pcpu: > free_percpu(sch->pcpu); > -err_free_gdsqs: > +err_free_pnode: > for_each_node_state(node, N_POSSIBLE) > - kfree(sch->global_dsqs[node]); > - kfree(sch->global_dsqs); > + kfree(sch->pnode[node]); > + kfree(sch->pnode); > err_free_hash: > rhashtable_free_and_destroy(&sch->dsq_hash, NULL, NULL); > err_free_ei: > diff --git a/kernel/sched/ext_internal.h b/kernel/sched/ext_internal.h > index 4cb97093b872..9e5ebd00ea0c 100644 > --- a/kernel/sched/ext_internal.h > +++ b/kernel/sched/ext_internal.h > @@ -975,6 +975,10 @@ struct scx_sched_pcpu { > struct scx_dsp_ctx dsp_ctx; > }; > =20 > +struct scx_sched_pnode { > + struct scx_dispatch_q global_dsq; > +}; > + > struct scx_sched { > struct sched_ext_ops ops; > DECLARE_BITMAP(has_op, SCX_OPI_END); > @@ -988,7 +992,7 @@ struct scx_sched { > * per-node split isn't sufficient, it can be further split. > */ > struct rhashtable dsq_hash; > - struct scx_dispatch_q **global_dsqs; > + struct scx_sched_pnode **pnode; > struct scx_sched_pcpu __percpu *pcpu; > =20 > u64 slice_dfl;