Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5507958rdb; Wed, 13 Dec 2023 10:32:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IF6I/1HjRgqFGY18hzwXi/6uZZxChWgXFkPu5UbSxJ2ikQ7Ezhglu7IP6lkeRBnB4TXfioX X-Received: by 2002:a17:90b:2308:b0:28b:3d2:27fb with SMTP id mt8-20020a17090b230800b0028b03d227fbmr102965pjb.44.1702492348354; Wed, 13 Dec 2023 10:32:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702492348; cv=none; d=google.com; s=arc-20160816; b=vbyBl0SuZzBdWkewXqpF9ZgGgtPzUQ+ZB+AUOfwbhm4QajSNwJbOaqrPZBJ7hZN/Lf CottXzbK2ZTAsCSq7mYjjdLJLrXeb1H6ft/H4uSzVST+8OMaGhLimqK47Z73rRx2wpNU FKsP9g/0mtdZ0wsWMz6Dhfq1VlXLj3f6MoNuK2V1t0ZTiyAMiOOSEwkL5VkwOWR29oka sf1vdobkp2zknUI7z0u5VKqbhdF4bUpcrEFEyqK1lnbRWrSF4uYWp4ifNYRWadz2Szo7 HKc2aiRMFfQNIQTWHnY7LnNPi2PJ+y9AULewgP5Z97f3dwajDCCu3Gcm0NfKx/fWOIZX ZHXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=dJhCQPbtOQfgKm8z4OfKiUr7HEqaHFUnnxRgNKGT468=; fh=1CqPlySqPiCaeSrZ0glMCByHtsyOrAfvOKmHKyPOlJU=; b=xGH5xlRBN6jAWtiN/p2H8dVuJY/ALTORuAtFo3DvXjLNWiooqd8nxKiHsiP7+fcX6j 1X7lISDZk6clpk6R3Smjt0O0S+n1D/8eiuM8NKCsv0XDJChaq9tkqzs/WalOXG0NACvH winK0wwYFOrbYUEmtxSXLNGc3FJtfmmhvfb0xcGeOcKIPJibwhbd8zwwlteLyJjOt4t7 jNKvQFB2wgZf40H02o6eJd3naHnjBUoQSE2AwSa33VHZtl++GsGebTEdOQ+Q2AqR3ivu Lt/WW5D9CPNiEeL3EKVQ6im4EOcJh0mJI0rUpnqX5iZFRr3sjuQPWCk+eHgywkcaYENo TRZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Vy+jNB5Z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id u6-20020a17090a3fc600b0028ae125eacbsi1582232pjm.184.2023.12.13.10.32.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 10:32:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Vy+jNB5Z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id DF374807410B; Wed, 13 Dec 2023 10:32:25 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229872AbjLMScM (ORCPT + 99 others); Wed, 13 Dec 2023 13:32:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229744AbjLMScL (ORCPT ); Wed, 13 Dec 2023 13:32:11 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D458CB9 for ; Wed, 13 Dec 2023 10:32:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1702492337; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=dJhCQPbtOQfgKm8z4OfKiUr7HEqaHFUnnxRgNKGT468=; b=Vy+jNB5Zn6rN8xcAVmNnRtVMHmDQKyDjAI28+bl7GyDirpZWKOufjR3iq1bvWD9wpwK6PX b/c3icbcXYQ3CQb/Ct/HcpesspOQzbbOAEONfxLKVcuvfMQm3TzgzWAgeRjmBLJiFIVG+D yk8QDQIsy3NOfSRg/pRghBeidvrv35M= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-421-3jyEvenuOSeCZRjXHIITDA-1; Wed, 13 Dec 2023 13:32:15 -0500 X-MC-Unique: 3jyEvenuOSeCZRjXHIITDA-1 Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-77f515c2a5fso742314485a.1 for ; Wed, 13 Dec 2023 10:32:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702492335; x=1703097135; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=dJhCQPbtOQfgKm8z4OfKiUr7HEqaHFUnnxRgNKGT468=; b=PTk29oXlfgp1/sXf4vu8lE503ILHDOmnpx2V0m5wGztB5Er1ZEvyxC4vv3YgvjWMsC VLFn2kiYdmG0ZaEtuTROvCbSv+vCPfGNkguGF7QaK2pMMLdu4FwNi4Pgt7yG9LVQ3nFc +qNtuP3WUCnTpKmXNRz778jpNXbwo7IIQo5ReJU6rA7TV5dH02fVXakksPNZu1TmYeA5 txXxaIrR2dF927pFEIitalO91QnRV331/0TVHwbxjQEfV1Gi+YxZrwiGJNcefRV+4BT8 kEfFV1w0qgxWlxd8tOCHG5pJVN7WpLHsEKAE5ARRdwR46xBpkrHevN2llF/H2Sxu/48O dzUw== X-Gm-Message-State: AOJu0Yz4JttO3EiJeganOtW2oLYRWKpPFjQZoWQfZvMbWtTY0mFdO5Ma nhS1y1A581OT4jwi5vR6w+PQGz49yZ+nrlMk+zcPtbxqKW4oLuwwr0Mdf7iAy7Wjt5dWvPEQbSR lp5REEhODB5tiVIEkq0la+IfI X-Received: by 2002:a05:620a:839b:b0:77f:3bc0:4be0 with SMTP id pb27-20020a05620a839b00b0077f3bc04be0mr10510564qkn.63.1702492334899; Wed, 13 Dec 2023 10:32:14 -0800 (PST) X-Received: by 2002:a05:620a:839b:b0:77f:3bc0:4be0 with SMTP id pb27-20020a05620a839b00b0077f3bc04be0mr10510555qkn.63.1702492334583; Wed, 13 Dec 2023 10:32:14 -0800 (PST) Received: from localhost.localdomain ([151.29.78.8]) by smtp.gmail.com with ESMTPSA id g3-20020a05620a278300b0077f435ed844sm4674999qkp.112.2023.12.13.10.32.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 10:32:14 -0800 (PST) Date: Wed, 13 Dec 2023 19:32:10 +0100 From: Juri Lelli To: Tejun Heo Cc: Aaron Tomlin , linux-kernel@vger.kernel.org, jiangshanlai@gmail.com, peterz@infradead.org Subject: Re: [RFC PATCH 0/2] workqueue: Introduce PF_WQ_RESCUE_WORKER Message-ID: References: <20230729135334.566138-1-atomlin@atomlin.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Wed, 13 Dec 2023 10:32:26 -0800 (PST) On 13/12/23 05:35, Tejun Heo wrote: > Hello, > > On Wed, Dec 13, 2023 at 09:59:42AM +0100, Juri Lelli wrote: > > Something like the following then maybe? > > > > --- > > kernel/workqueue.c | 6 ++++++ > > 1 file changed, 6 insertions(+) > > > > diff --git a/kernel/workqueue.c b/kernel/workqueue.c > > index 2989b57e154a7..ed73f7f80d57d 100644 > > --- a/kernel/workqueue.c > > +++ b/kernel/workqueue.c > > @@ -4405,6 +4405,12 @@ static void apply_wqattrs_commit(struct apply_wqattrs_ctx *ctx) > > link_pwq(ctx->dfl_pwq); > > swap(ctx->wq->dfl_pwq, ctx->dfl_pwq); > > > > + /* rescuer needs to respect wq cpumask changes */ > > + if (ctx->wq->rescuer) { > > + kthread_bind_mask(ctx->wq->rescuer->task, ctx->attrs->cpumask); > > + wake_up_process(ctx->wq->rescuer->task); > > + } > > + > > mutex_unlock(&ctx->wq->mutex); > > } > > I'm not sure kthread_bind_mask() would be safe here. The rescuer might be > running a work item. wait_task_inactive() might fail and we don't want to > change cpumask while the rescuer is active anyway. > > Maybe the easiest way to do this is making rescuer_thread() restore the wq's > cpumask right before going to sleep, and making apply_wqattrs_commit() just > wake up the rescuer. Hummm, don't think we can call that either while the rescuer is actually running. Maybe we can simply s/kthread_bind_mask/set_cpus_allowed_ptr/ in the above? Thanks, Juri