Received: by 2002:a05:7412:8d09:b0:fa:4c10:6cad with SMTP id bj9csp636822rdb; Tue, 16 Jan 2024 10:57:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IElRmWNQ3Cc/FScCrF8d6aUuwbsszmMh4WgyuYfMPjfuVRi34ROnWPOo3ODQfwGHYqz2sgc X-Received: by 2002:a17:90b:2c87:b0:28d:2410:9501 with SMTP id sw7-20020a17090b2c8700b0028d24109501mr4420342pjb.95.1705431461958; Tue, 16 Jan 2024 10:57:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705431461; cv=pass; d=google.com; s=arc-20160816; b=NVW9DePNSpNlxNpRpNVBNbJALZbyKMJebxe2HTql+5KPyY6vI8vEc61hMmsQIqPLcv t68xTubX9JLyRDhVn3OXMYhXFHnGlSxhajy0QV/W/QeUSrNXRMMc35j4IDEKUExF6CED 9P1GF3gBPkg0pY2AQivLTb8kuU3eAM2orc5g62K8e7n62iNv+FrivbRnTWE0Aus6D+mn D0FsErM10/7JOE7AgCzzpgr9XnWvyXA9Y19zT6G3TsANja936MbwzrP9YBgnlPj3nATv lvy8IL0LMXVGOOi6kNhs8c8Q1rHrYY97s6GTfgkckzF1gdWjn7fG7zQP2wBF62dE9i0Y W3ZA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:sender:dkim-signature; bh=2Ggt3qdMUg1GC8c+54SNnJmlwZL/CKF8hO+X890U6Qk=; fh=7q2Pms2rUdoF9t+ncWv6VqychpXXKiXJyn4xbMKRSuA=; b=Jwk4V9oG9UFSgcuDGjyaQMk+d9MAxzQ6Y9I57ZpbdkJAmCUq/t2ffDgYbHi2aXOKNZ 0+6FE8/f2sgxxQB1nfXSIW3gvnGzgxng3hEwNexzYRG5rr4fLeSeXiM8hUzw4omkc/Dw YuDdsjWCs8GlDunDMk5S3zTLcqknmzvh06cUU7+CLBHKjqrfqLqMicg1P4kCN6B5fNdR 5Rh/97aKMR63eN5KiDXeAgJZj2ioPsA5hjfL0a2FtFMOHtIcCyI8X0CWevqMlhAvpmkT e+fN+K2cORuVNL99w35cHvI+MLOD7ABp+1VxyhVE2KnoDVWU/fM6Aw0AfpmP1dYXwWWJ JqIw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=DIoKsz9n; arc=pass (i=1 dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-27718-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-27718-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id l4-20020a17090a72c400b0028e7ff90e5fsi1459821pjk.66.2024.01.16.10.57.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jan 2024 10:57:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-27718-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=DIoKsz9n; arc=pass (i=1 dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-27718-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-27718-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id BB942B22A15 for ; Tue, 16 Jan 2024 18:57:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C6E181CF99; Tue, 16 Jan 2024 18:57:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DIoKsz9n" Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) (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 956111CAA2 for ; Tue, 16 Jan 2024 18:57:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705431447; cv=none; b=M1mT+Z7qxwjNqWIq6q2KgK/KyXFDcaFV+ZNldGwvPldK1AevbAAE9BwJNrI+iEHuGmSrDic5dz5ltLDh82B1Lioc81qZFSuBqJGmx3SS+aVmfqFNll5QyWEIsF+5Ku68g0iCPVgOq76UUn0k62ze7lKDxFtuMfGRlIaY07rGAWw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705431447; c=relaxed/simple; bh=T8kXfy8I6R29x/com7Ybs10y68lo/wxDKPQ38ALGylk=; h=Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Google-Smtp-Source:X-Received:Received:Sender: Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=b9SbkHMA0exHztZPtDSTywDyfkq4N6kAUkKHvX3/GM1tz7Edx+FcOH9np+vkkgww73vaGtaArLXyykVgErKU+J3qRhShFqWqFN3CTNtqOJbPXMwSwwPDRmNlDunxd/AHIrEio3CYvNCWAoW177WBBZYc5+DPZcY/snROR3vs6/c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=DIoKsz9n; arc=none smtp.client-ip=209.85.216.49 Received: by mail-pj1-f49.google.com with SMTP id 98e67ed59e1d1-28be8ebcdc1so6789644a91.0 for ; Tue, 16 Jan 2024 10:57:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705431446; x=1706036246; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:from:to:cc:subject:date:message-id :reply-to; bh=2Ggt3qdMUg1GC8c+54SNnJmlwZL/CKF8hO+X890U6Qk=; b=DIoKsz9nyFSPV9Jgs/0YDEiLlM4y0bqjPJq5irVCbIrRLp9qBvMbi3OvkTpk0oYOzt XYXcUjYRawVAYfha2mwJMV9YbpD549COp1mpw8+l1OlnCXzKqi3eXxLKtInyZRnQ+WQb k31sj9flBwVsUJYwJdVzgypraDqMuSCg+4K4LZ9ISzd1ieTwphtW/aXx5DCNizQUPTR0 GUvuanWbwWHx2Cl2KrHTfuZnBptDmhSlaAiEtx0O2sRY8gunUPO5LZaf0LY+y56zvOuf U40xY1jiEJFtMO1i2B08OGqlYJ2ekM4RMeD0ky3jH91gpnPHCgIiUphPfHBu4gVbUpnM e9Ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705431446; x=1706036246; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2Ggt3qdMUg1GC8c+54SNnJmlwZL/CKF8hO+X890U6Qk=; b=lFafvicS8LlyBfaGpI33jgQiI1kz3TmZKjACycpqHUPvWWh723hNB0zrYBBc5QK41t rR2ILyfoW698GxLBivmn/LiO1JrlmLAefoUYsb+41bHEbjVCQ9OamwUQ7ubyog5iAxjG 1EK21ThpivW2aIJPtdxRes/fgFH3RB4uLxtl9ZbU4UMYqK441I0Ig2Koe2Kt3m7YxHfv 9eeJ/fldU96ME2yTudnM+uaxSYes68zLDsgn3AZLxIuOzKny/TvYLyAv6NZJwFTNArlQ Y1Jkg/yifsBYTcc0b6hcm3bSMsJqbgSlBH7Z8YQkCsYzeuCimQ0th0DQlRKoVqDdnuaj AWug== X-Gm-Message-State: AOJu0Yw1378NvJGmfMyiv0SEgNIMn+c+ZzBmsK+XCNgBxHbmY9NZLTMA xeuZ0R2SxxkSaOza5YRDPqk= X-Received: by 2002:a17:90b:408e:b0:28d:29ea:25f8 with SMTP id jb14-20020a17090b408e00b0028d29ea25f8mr4237296pjb.72.1705431445732; Tue, 16 Jan 2024 10:57:25 -0800 (PST) Received: from localhost (dhcp-72-235-13-140.hawaiiantel.net. [72.235.13.140]) by smtp.gmail.com with ESMTPSA id j5-20020a170902c3c500b001d5e7afe97csm1567559plj.152.2024.01.16.10.57.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jan 2024 10:57:25 -0800 (PST) Sender: Tejun Heo Date: Tue, 16 Jan 2024 08:57:24 -1000 From: Tejun Heo To: Juri Lelli Cc: Lai Jiangshan , Aaron Tomlin , Valentin Schneider , Waiman Long , linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH 3/4] kernel/workqueue: Distinguish between general unbound and WQ_SYSFS cpumask changes Message-ID: References: <20240116161929.232885-1-juri.lelli@redhat.com> <20240116161929.232885-4-juri.lelli@redhat.com> 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=us-ascii Content-Disposition: inline In-Reply-To: <20240116161929.232885-4-juri.lelli@redhat.com> Hello, Juri. On Tue, Jan 16, 2024 at 05:19:28PM +0100, Juri Lelli wrote: > Both general unbound cpumask and per-wq (WQ_SYSFS) cpumask changes end > up calling apply_wqattrs_prepare for preparing for the change, but this > doesn't work well for general unbound cpumask changes as current > implementation won't be looking at the new unbound_cpumask. > > Fix the prepare phase for general unbound cpumask changes by checking > which type of attributes (general vs. WQ_SYSFS) are actually changing. > > Signed-off-by: Juri Lelli > --- > kernel/workqueue.c | 17 +++++++++++------ > 1 file changed, 11 insertions(+), 6 deletions(-) > > diff --git a/kernel/workqueue.c b/kernel/workqueue.c > index 3a1d5a67bd66a..2ef6573909070 100644 > --- a/kernel/workqueue.c > +++ b/kernel/workqueue.c > @@ -4359,7 +4359,17 @@ apply_wqattrs_prepare(struct workqueue_struct *wq, > * it even if we don't use it immediately. > */ > copy_workqueue_attrs(new_attrs, attrs); > - wqattrs_actualize_cpumask(new_attrs, unbound_cpumask); > + > + /* > + * Is the user changing the general unbound_cpumask or is this a > + * WQ_SYSFS cpumask change? > + */ > + if (attrs == wq->unbound_attrs) > + cpumask_copy(new_attrs->cpumask, unbound_cpumask); > + else > + wqattrs_actualize_cpumask(new_attrs, unbound_cpumask); > + > + cpumask_and(new_attrs->cpumask, new_attrs->cpumask, cpu_possible_mask); This looks rather hacky. Can you elaborate how the current code misbehaves with an example? For the unbound_cpumask update path, the intention is supplying the current ->attrs (wq user's request) and the new unbound_cpumask expecting wqattrs_actualize_cpumask() to do the right thing. Is the problem that you want to have access to the effective cpumask for the entire workqueue? If so, we don't want to do that with ctx->attrs as that's supposed to carry the user's requested configuration rather than the currently effective. We can just add a new field. > cpumask_copy(new_attrs->__pod_cpumask, new_attrs->cpumask); > ctx->dfl_pwq = alloc_unbound_pwq(wq, new_attrs); > if (!ctx->dfl_pwq) > @@ -4377,12 +4387,7 @@ apply_wqattrs_prepare(struct workqueue_struct *wq, > } > } > > - /* save the user configured attrs and sanitize it. */ > - copy_workqueue_attrs(new_attrs, attrs); > - cpumask_and(new_attrs->cpumask, new_attrs->cpumask, cpu_possible_mask); > - cpumask_copy(new_attrs->__pod_cpumask, new_attrs->cpumask); > ctx->attrs = new_attrs; This part exists to store the user requested configuration rather than the applied effective configuration, so that e.g. later if the unbound_cpumask changes, we can apply the effective mask according to the user's latest requested configuration. I'm not sure why this is being dropped. Thanks. -- tejun