Message ID | 20240130183336.511948-1-longman@redhat.com |
---|---|
Headers |
Return-Path: <linux-kernel+bounces-45113-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1419762dyb; Tue, 30 Jan 2024 10:34:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IE/Kh3rdjq0rsFY+QDLE25Ob5MH3x0m3cQ8MjsEE3Z9Oh4UU5PCYUap+96tf5Imz2dEGD0D X-Received: by 2002:a05:622a:90:b0:42a:5fae:fe75 with SMTP id o16-20020a05622a009000b0042a5faefe75mr10029261qtw.40.1706639681713; Tue, 30 Jan 2024 10:34:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706639681; cv=pass; d=google.com; s=arc-20160816; b=xncYTdTnWz2CCX8JzaUZCEn31Xi7XWl6k1pu+SY9l+0Kk6COZEpLH1noLjKvoY2Owo XsnytI4NYg2yD0zM5YHWXuaiQOz5cgv3N1dHjx0hhSt2C6fstX5svbW0u/P9R4POlbui 4wsu8PclqSAgQOfwXfFlt4OlPQSd8bKqxtyu5+a8MC2UEAVibwca4CmcZ1V98HN9D3uc T7IzpKVYmOJBknJ9lECvtGjZxYZ2ubIe+51p9SzAwQht73Vwgy5xCDmkjc5VipAZJchW DDeN9fM051298bEufg9h8pcxW1SIrthsaIKORtjxdUBsFTHzYdEtCdClt8w2jcjqhKBQ C0QQ== 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:message-id:date:subject:cc:to :from:dkim-signature; bh=0Ij0fUh99sNPGQIuhuaIyYnTfjT0QFXCH+1kvsJ6p4E=; fh=lt2js4+oSVfpbDjw8gm9/JJoU0YKcT6Mty9go3Ytfy0=; b=arrlnqVicRyd0n3f87TaRkdytMuCHoSRvAoOEXLBu+cjqfkAnB4EruyqF32hKFFRV4 c1LlZbU10Ft1/BBYA1kqj2xeipKcVapJbqaCANgh1NOIbWvZNzQV7YFDk2nTpn0ugB05 sPRXp67492ledXYtyP12fbElBQ/fGyA+Dc0QWjH6BQ95nkV9YT0/hYgAx9Oa4/Ub2HvK M8dr9XCcW3QjaP1mHSA+4OKYxS8K1gU3oWvluglkREG5oPy+moychnT3S4bEywSe4wdy 1O3hTAJE0C/834Tab5qrqZNWm8tH9J70tL3bVaIhQSRGNGAGGJz45fGqvnYfj94dClgh WFnQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=btSLtLni; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-45113-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45113-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id t10-20020a05622a148a00b0042aa94859a0si4202261qtx.738.2024.01.30.10.34.41 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 10:34:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-45113-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=btSLtLni; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-45113-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45113-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 815321C23D40 for <ouuuleilei@gmail.com>; Tue, 30 Jan 2024 18:34:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6AF6378B44; Tue, 30 Jan 2024 18:34:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="btSLtLni" 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 1FE97762C7 for <linux-kernel@vger.kernel.org>; Tue, 30 Jan 2024 18:34:00 +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=1706639642; cv=none; b=fkyBKsGt918SjjkpBMlBk4JD1v9I13oLYmQbRjUZZpsR8o5EL5ePMx6LuNwr3KRF7rV0N/4bR4FE5tFE3KNfoUexFUlxgN4XA7Ng+EaD8jpr3oS6FTtq91Yeil7b46BUwCz2CDdRXXt7Dp/g7YRbLgJ0SPBLRfhQtGtDMF3Q+NE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706639642; c=relaxed/simple; bh=eC7+OI6/+9wto86uJj8ssIpbqkS2aO7JFeCrcZQgCgw=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=N8MVIr/xMyHg/MIXmmmSqQC/XeFHdlHstFfV4161UULKz3Gu9oeOTS+NAraQuwD9oKsqKXNCZxf1cYIU3RoA3K1PPTXuwti9UBCBAeZHnbMoaUnn0vvr1NTKuKfR9Zu9X+UAUXaMl+gkkQYUdMWgskiP1+d0SLuzdSF3UEiEvIA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none 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=btSLtLni; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706639640; 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; bh=0Ij0fUh99sNPGQIuhuaIyYnTfjT0QFXCH+1kvsJ6p4E=; b=btSLtLninwegMg6AIWGJtY+TAqaHX9qI1ZgNuSNyFvEu1peg1u2cZ+cx4pfw1ixCUBpauR qtwZOkxeH0bjUWFR1Ouj31HUcOQCBN8C/JJtA1dn3JIRg3/3w3DAoQS/0XLrkn06h4Gtql rFBGa7zm9/BNRy0/JWBVnRGEbEn8/OE= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-653-e8NJ87b1OLq84HdCPEafQw-1; Tue, 30 Jan 2024 13:33:56 -0500 X-MC-Unique: e8NJ87b1OLq84HdCPEafQw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1B768881EA5; Tue, 30 Jan 2024 18:33:56 +0000 (UTC) Received: from llong.com (unknown [10.22.8.207]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9E83E40C122E; Tue, 30 Jan 2024 18:33:55 +0000 (UTC) From: Waiman Long <longman@redhat.com> To: Tejun Heo <tj@kernel.org>, Lai Jiangshan <jiangshanlai@gmail.com> Cc: linux-kernel@vger.kernel.org, Juri Lelli <juri.lelli@redhat.com>, Cestmir Kalina <ckalina@redhat.com>, Alex Gladkov <agladkov@redhat.com>, Waiman Long <longman@redhat.com> Subject: [RFC PATCH 0/3] workqueue: Enable unbound cpumask update on ordered workqueues Date: Tue, 30 Jan 2024 13:33:33 -0500 Message-Id: <20240130183336.511948-1-longman@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789541411024418352 X-GMAIL-MSGID: 1789541411024418352 |
Series |
workqueue: Enable unbound cpumask update on ordered workqueues
|
|
Message
Waiman Long
Jan. 30, 2024, 6:33 p.m. UTC
Ordered workqueues does not currently follow changes made to the global unbound cpumask because per-pool workqueue changes may break the ordering guarantee. IOW, a work function in an ordered workqueue may run on a cpuset isolated CPU. This series enables ordered workqueues to follow changes made to the global unbound cpumask by temporaily saving the work items in an internal queue until the old pwq has been properly flushed and to be freed. At that point, those work items, if present, are queued back to the new pwq to be executed. Waiman Long (3): workqueue: Skip __WQ_DESTROYING workqueues when updating global unbound cpumask workqueue: Break out __queue_work_rcu_locked() from __queue_work() workqueue: Enable unbound cpumask update on ordered workqueues kernel/workqueue.c | 217 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 183 insertions(+), 34 deletions(-)
Comments
Hi Waiman, Thanks for working on this! On 30/01/24 13:33, Waiman Long wrote: > Ordered workqueues does not currently follow changes made to the > global unbound cpumask because per-pool workqueue changes may break > the ordering guarantee. IOW, a work function in an ordered workqueue > may run on a cpuset isolated CPU. > > This series enables ordered workqueues to follow changes made to the > global unbound cpumask by temporaily saving the work items in an > internal queue until the old pwq has been properly flushed and to be > freed. At that point, those work items, if present, are queued back to > the new pwq to be executed. I took it for a quick first spin (on top of wq/for-6.9) and this is what I'm seeing. Let's take edac-poller ordered wq, as the behavior seems to be the same for the rest. Initially we have (using wq_dump.py) wq_unbound_cpumask=0xffffffff 000000ff .. pool[80] ref= 44 nice= 0 idle/workers= 2/ 2 cpus=0xffffffff 000000ff pod_cpus=0xffffffff 000000ff .. edac-poller ordered 80 80 80 80 80 80 80 80 ... .. edac-poller 0xffffffff 000000ff 345 0xffffffff 000000ff after I # echo 3 >/sys/devices/virtual/workqueue/cpumask I get wq_unbound_cpumask=00000003 .. pool[86] ref= 44 nice= 0 idle/workers= 2/ 2 cpus=00000003 pod_cpus=00000003 .. edac-poller ordered 86 86 86 86 86 86 86 86 86 86 ... .. edac-poller 0xffffffff 000000ff 345 0xffffffff 000000ff So, IIUC, the pool and wq -> pool settings are updated correctly, but the wq.unbound_cpus (and its associated rescure affinity) are left untouched. Is this expected or are we maybe still missing an additional step? Best, Juri
On 1/31/24 08:01, Juri Lelli wrote: > Hi Waiman, > > Thanks for working on this! > > On 30/01/24 13:33, Waiman Long wrote: >> Ordered workqueues does not currently follow changes made to the >> global unbound cpumask because per-pool workqueue changes may break >> the ordering guarantee. IOW, a work function in an ordered workqueue >> may run on a cpuset isolated CPU. >> >> This series enables ordered workqueues to follow changes made to the >> global unbound cpumask by temporaily saving the work items in an >> internal queue until the old pwq has been properly flushed and to be >> freed. At that point, those work items, if present, are queued back to >> the new pwq to be executed. > I took it for a quick first spin (on top of wq/for-6.9) and this is what > I'm seeing. > > Let's take edac-poller ordered wq, as the behavior seems to be the same > for the rest. > > Initially we have (using wq_dump.py) > > wq_unbound_cpumask=0xffffffff 000000ff > ... > pool[80] ref= 44 nice= 0 idle/workers= 2/ 2 cpus=0xffffffff 000000ff pod_cpus=0xffffffff 000000ff > ... > edac-poller ordered 80 80 80 80 80 80 80 80 ... > ... > edac-poller 0xffffffff 000000ff 345 0xffffffff 000000ff > > after I > > # echo 3 >/sys/devices/virtual/workqueue/cpumask > > I get > > wq_unbound_cpumask=00000003 > ... > pool[86] ref= 44 nice= 0 idle/workers= 2/ 2 cpus=00000003 pod_cpus=00000003 > ... > edac-poller ordered 86 86 86 86 86 86 86 86 86 86 ... > ... > edac-poller 0xffffffff 000000ff 345 0xffffffff 000000ff > > So, IIUC, the pool and wq -> pool settings are updated correctly, but > the wq.unbound_cpus (and its associated rescure affinity) are left > untouched. Is this expected or are we maybe still missing an additional > step? Isn't this what the 4th patch of your RFC workqueue patch series does? https://lore.kernel.org/lkml/20240116161929.232885-5-juri.lelli@redhat.com/ The focus of this series is to make sure that we can update the pool cpumask of ordered workqueue to follow changes in global unbound workqueue cpumask. So I haven't touched anything related to rescuer at all. I will include your 4th patch in the next version of this series. Cheers, Longman
On 31/01/24 10:31, Waiman Long wrote: > > On 1/31/24 08:01, Juri Lelli wrote: > > Hi Waiman, > > > > Thanks for working on this! > > > > On 30/01/24 13:33, Waiman Long wrote: > > > Ordered workqueues does not currently follow changes made to the > > > global unbound cpumask because per-pool workqueue changes may break > > > the ordering guarantee. IOW, a work function in an ordered workqueue > > > may run on a cpuset isolated CPU. > > > > > > This series enables ordered workqueues to follow changes made to the > > > global unbound cpumask by temporaily saving the work items in an > > > internal queue until the old pwq has been properly flushed and to be > > > freed. At that point, those work items, if present, are queued back to > > > the new pwq to be executed. > > I took it for a quick first spin (on top of wq/for-6.9) and this is what > > I'm seeing. > > > > Let's take edac-poller ordered wq, as the behavior seems to be the same > > for the rest. > > > > Initially we have (using wq_dump.py) > > > > wq_unbound_cpumask=0xffffffff 000000ff > > ... > > pool[80] ref= 44 nice= 0 idle/workers= 2/ 2 cpus=0xffffffff 000000ff pod_cpus=0xffffffff 000000ff > > ... > > edac-poller ordered 80 80 80 80 80 80 80 80 ... > > ... > > edac-poller 0xffffffff 000000ff 345 0xffffffff 000000ff > > > > after I > > > > # echo 3 >/sys/devices/virtual/workqueue/cpumask > > > > I get > > > > wq_unbound_cpumask=00000003 > > ... > > pool[86] ref= 44 nice= 0 idle/workers= 2/ 2 cpus=00000003 pod_cpus=00000003 > > ... > > edac-poller ordered 86 86 86 86 86 86 86 86 86 86 ... > > ... > > edac-poller 0xffffffff 000000ff 345 0xffffffff 000000ff > > > > So, IIUC, the pool and wq -> pool settings are updated correctly, but > > the wq.unbound_cpus (and its associated rescure affinity) are left > > untouched. Is this expected or are we maybe still missing an additional > > step? > > Isn't this what the 4th patch of your RFC workqueue patch series does? > > https://lore.kernel.org/lkml/20240116161929.232885-5-juri.lelli@redhat.com/ > > The focus of this series is to make sure that we can update the pool cpumask > of ordered workqueue to follow changes in global unbound workqueue cpumask. > So I haven't touched anything related to rescuer at all. My patch only uses the wq->unbound_attrs->cpumask to change the associated rescuer cpumask, but I don't think your series modifies the former? Thanks, Juri
On 2/1/24 05:18, Juri Lelli wrote: > On 31/01/24 10:31, Waiman Long wrote: >> On 1/31/24 08:01, Juri Lelli wrote: >>> Hi Waiman, >>> >>> Thanks for working on this! >>> >>> On 30/01/24 13:33, Waiman Long wrote: >>>> Ordered workqueues does not currently follow changes made to the >>>> global unbound cpumask because per-pool workqueue changes may break >>>> the ordering guarantee. IOW, a work function in an ordered workqueue >>>> may run on a cpuset isolated CPU. >>>> >>>> This series enables ordered workqueues to follow changes made to the >>>> global unbound cpumask by temporaily saving the work items in an >>>> internal queue until the old pwq has been properly flushed and to be >>>> freed. At that point, those work items, if present, are queued back to >>>> the new pwq to be executed. >>> I took it for a quick first spin (on top of wq/for-6.9) and this is what >>> I'm seeing. >>> >>> Let's take edac-poller ordered wq, as the behavior seems to be the same >>> for the rest. >>> >>> Initially we have (using wq_dump.py) >>> >>> wq_unbound_cpumask=0xffffffff 000000ff >>> ... >>> pool[80] ref= 44 nice= 0 idle/workers= 2/ 2 cpus=0xffffffff 000000ff pod_cpus=0xffffffff 000000ff >>> ... >>> edac-poller ordered 80 80 80 80 80 80 80 80 ... >>> ... >>> edac-poller 0xffffffff 000000ff 345 0xffffffff 000000ff >>> >>> after I >>> >>> # echo 3 >/sys/devices/virtual/workqueue/cpumask >>> >>> I get >>> >>> wq_unbound_cpumask=00000003 >>> ... >>> pool[86] ref= 44 nice= 0 idle/workers= 2/ 2 cpus=00000003 pod_cpus=00000003 >>> ... >>> edac-poller ordered 86 86 86 86 86 86 86 86 86 86 ... >>> ... >>> edac-poller 0xffffffff 000000ff 345 0xffffffff 000000ff >>> >>> So, IIUC, the pool and wq -> pool settings are updated correctly, but >>> the wq.unbound_cpus (and its associated rescure affinity) are left >>> untouched. Is this expected or are we maybe still missing an additional >>> step? >> Isn't this what the 4th patch of your RFC workqueue patch series does? >> >> https://lore.kernel.org/lkml/20240116161929.232885-5-juri.lelli@redhat.com/ >> >> The focus of this series is to make sure that we can update the pool cpumask >> of ordered workqueue to follow changes in global unbound workqueue cpumask. >> So I haven't touched anything related to rescuer at all. > My patch only uses the wq->unbound_attrs->cpumask to change the > associated rescuer cpumask, but I don't think your series modifies the > former? I don't think so. The calling sequence of apply_wqattrs_prepare() and apply_wqattrs_commit() will copy unbound_cpumask into ctx->attrs which is copied into unbound_attrs. So unbound_attrs->cpumask should reflect the new global unbound cpumask. This code is there all along. The only difference is that ordered workqueues were skipped for unbound cpumask update before. This patch series now includes those ordered workqueues when the unbound cpumask is updated. Cheers, Longman
On 01/02/24 09:28, Waiman Long wrote: > On 2/1/24 05:18, Juri Lelli wrote: > > On 31/01/24 10:31, Waiman Long wrote: .. > > My patch only uses the wq->unbound_attrs->cpumask to change the > > associated rescuer cpumask, but I don't think your series modifies the > > former? > > I don't think so. The calling sequence of apply_wqattrs_prepare() and > apply_wqattrs_commit() will copy unbound_cpumask into ctx->attrs which is > copied into unbound_attrs. So unbound_attrs->cpumask should reflect the new > global unbound cpumask. This code is there all along. Indeed. I believe this is what my 3/4 [1] was trying to cure, though. I still think that with current code the new_attr->cpumask gets first correctly initialized considering unbound_cpumask apply_wqattrs_prepare -> copy_workqueue_attrs(new_attrs, attrs); wqattrs_actualize_cpumask(new_attrs, unbound_cpumask); but then overwritten further below using cpu_possible_mask apply_wqattrs_prepare -> copy_workqueue_attrs(new_attrs, attrs); cpumask_and(new_attrs->cpumask, new_attrs->cpumask, cpu_possible_mask); operation that I honestly seem to still fail to grasp why we need to do. :) In the end we commit that last (overwritten) cpumask apply_wqattrs_commit -> copy_workqueue_attrs(ctx->wq->unbound_attrs, ctx->attrs); Now, my patch was wrong, as you pointed out, as it wasn't taking into consideration the ordering guarantee. I thought maybe your changes (plus and additional change to the above?) might fix the problem correctly. Best, Juri 1 - https://lore.kernel.org/lkml/20240116161929.232885-4-juri.lelli@redhat.com/
Hello, On Fri, Feb 02, 2024 at 03:55:15PM +0100, Juri Lelli wrote: > Indeed. I believe this is what my 3/4 [1] was trying to cure, though. I > still think that with current code the new_attr->cpumask gets first > correctly initialized considering unbound_cpumask > > apply_wqattrs_prepare -> > copy_workqueue_attrs(new_attrs, attrs); > wqattrs_actualize_cpumask(new_attrs, unbound_cpumask); > > but then overwritten further below using cpu_possible_mask > > apply_wqattrs_prepare -> > copy_workqueue_attrs(new_attrs, attrs); > cpumask_and(new_attrs->cpumask, new_attrs->cpumask, cpu_possible_mask); > > operation that I honestly seem to still fail to grasp why we need to do. > :) So, imagine the following scenario on a system with four CPUs: 1. Initially both wq_unbound_cpumask and wq A's cpumask are 0xf. 2. wq_unbound_cpumask is set to 0x3. A's effective is 0x3. 3. A's cpumask is set to 0xe, A's effective is 0x3. 4. wq_unbound_cpumask is restore to 0xf. A's effective should become 0xe. The reason why we're saving what user requested rather than effective is to be able to do #4 so that the effective is always what's currently allowed from what the user specified for the workqueue. Now, if you want the current effective cpumask, that always coincides with the workqueue's dfl_pwq's __pod_cpumask and if you look at the current wq/for-6.9 branch, that's accessible through unbound_effective_cpumask() helper. Thanks.
On 2/2/24 12:07, Tejun Heo wrote: > Hello, > > On Fri, Feb 02, 2024 at 03:55:15PM +0100, Juri Lelli wrote: >> Indeed. I believe this is what my 3/4 [1] was trying to cure, though. I >> still think that with current code the new_attr->cpumask gets first >> correctly initialized considering unbound_cpumask >> >> apply_wqattrs_prepare -> >> copy_workqueue_attrs(new_attrs, attrs); >> wqattrs_actualize_cpumask(new_attrs, unbound_cpumask); >> >> but then overwritten further below using cpu_possible_mask >> >> apply_wqattrs_prepare -> >> copy_workqueue_attrs(new_attrs, attrs); >> cpumask_and(new_attrs->cpumask, new_attrs->cpumask, cpu_possible_mask); >> >> operation that I honestly seem to still fail to grasp why we need to do. >> :) > So, imagine the following scenario on a system with four CPUs: > > 1. Initially both wq_unbound_cpumask and wq A's cpumask are 0xf. > > 2. wq_unbound_cpumask is set to 0x3. A's effective is 0x3. > > 3. A's cpumask is set to 0xe, A's effective is 0x3. > > 4. wq_unbound_cpumask is restore to 0xf. A's effective should become 0xe. > > The reason why we're saving what user requested rather than effective is to > be able to do #4 so that the effective is always what's currently allowed > from what the user specified for the workqueue. > > Now, if you want the current effective cpumask, that always coincides with > the workqueue's dfl_pwq's __pod_cpumask and if you look at the current > wq/for-6.9 branch, that's accessible through unbound_effective_cpumask() > helper. Thank for the explanation, we will use the new unbound_effective_cpumask() helper. It does look like there is a major restructuring of the workqueue code in 6.9. I will adapt my patch series to be based on the for-6.9 branch. Cheers, Longman
On 02/02/24 14:03, Waiman Long wrote: > On 2/2/24 12:07, Tejun Heo wrote: > > Hello, > > > > On Fri, Feb 02, 2024 at 03:55:15PM +0100, Juri Lelli wrote: > > > Indeed. I believe this is what my 3/4 [1] was trying to cure, though. I > > > still think that with current code the new_attr->cpumask gets first > > > correctly initialized considering unbound_cpumask > > > > > > apply_wqattrs_prepare -> > > > copy_workqueue_attrs(new_attrs, attrs); > > > wqattrs_actualize_cpumask(new_attrs, unbound_cpumask); > > > > > > but then overwritten further below using cpu_possible_mask > > > > > > apply_wqattrs_prepare -> > > > copy_workqueue_attrs(new_attrs, attrs); > > > cpumask_and(new_attrs->cpumask, new_attrs->cpumask, cpu_possible_mask); > > > > > > operation that I honestly seem to still fail to grasp why we need to do. > > > :) > > So, imagine the following scenario on a system with four CPUs: > > > > 1. Initially both wq_unbound_cpumask and wq A's cpumask are 0xf. > > > > 2. wq_unbound_cpumask is set to 0x3. A's effective is 0x3. > > > > 3. A's cpumask is set to 0xe, A's effective is 0x3. > > > > 4. wq_unbound_cpumask is restore to 0xf. A's effective should become 0xe. > > > > The reason why we're saving what user requested rather than effective is to > > be able to do #4 so that the effective is always what's currently allowed > > from what the user specified for the workqueue. Thanks for the explanation! > > Now, if you want the current effective cpumask, that always coincides with > > the workqueue's dfl_pwq's __pod_cpumask and if you look at the current > > wq/for-6.9 branch, that's accessible through unbound_effective_cpumask() > > helper. > > Thank for the explanation, we will use the new unbound_effective_cpumask() > helper. Right, that should indeed work. Best, Juri