From patchwork Tue Jan 16 16:19:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juri Lelli X-Patchwork-Id: 188563 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:42cf:b0:101:a8e8:374 with SMTP id q15csp372561dye; Tue, 16 Jan 2024 08:32:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IES1xXkjR5ub9+KLVosb8KM2Nm2qpa28/pU/JWaP28PSjZ7qhf7zdvk6SOdBAFlsucN6NST X-Received: by 2002:a05:6a21:2790:b0:19a:5293:6e60 with SMTP id rn16-20020a056a21279000b0019a52936e60mr3537443pzb.39.1705422723965; Tue, 16 Jan 2024 08:32:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705422723; cv=none; d=google.com; s=arc-20160816; b=xpUnk8kwfl8TxodaLo/7rDCanIFhQnj9ZteNUf7qzcrX46UB3QAm8rIPeF47Rp70uD EOTVDTQM7p1c7yRauIXjdIFFFciDz4gmAuQoJ0W8Gv4x/n1mgS8LBsf3tnxKTOnN+yon guDfcuvIYnufwmsZwoBQZzKxDePeHwRDASaqpFzF4XWUz0Ljbn8fcZTU436f/PtshSTn QG149bN4+CS5veBT7hGw6RxPuV1P0NCNRRzjDN1q+4xdCBAFoe85NBIrpUEFAVBHdZ+S S7uavXg+ckd2Zv6fS5pYRzE9FmvEu+QlHe8h3M7wAVvzjAoQGsGKzIE24iUey7CHoXT6 MHoA== ARC-Message-Signature: i=1; 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:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=O3OclCH75wBgs4Z0eklBI2HCm5hzhoXh5DbDkEBHEUI=; fh=Nsf1u1rbcJryyiFo9sS/VsYZC3vmqvYt/oMU7uIxbeo=; b=Qei76YQC0jYUAk1d4e5sdFgwqG2f8zgllclaFSJSQvzmAuAIG8bWwpGYgOc3fBxLCC Jgt5eBWZTLi+pXTOuVG4UQEWDubk3Z+wfZbbpq0/7gGEycnWcSxbAj+8OfkvTsICQXbs vtT8mklRW3i4xsEhYdUZL/G0EfHe6fsjRmRyTxske7UmKe2b9fZ7dJ8kUiqJuqx7HLtp 02l1Jh6qaieeULtsGIuSGphJgtGjbIZ5eSXU3ax19g5kt1ZMr8WhIB2hyAVt6YpI+402 nCye0CitGViCJiKI/sZFBBsp9wm/AkZPqI4HDu5Tn3qDc1Dy0oXJLV5a5FoejM8Dt+/0 ysMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=eKfwZdun; spf=pass (google.com: domain of linux-kernel+bounces-27568-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-27568-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id bn16-20020a056a02031000b005cdfb08b91asi12860800pgb.796.2024.01.16.08.32.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jan 2024 08:32:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-27568-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=eKfwZdun; spf=pass (google.com: domain of linux-kernel+bounces-27568-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-27568-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 60F6C287278 for ; Tue, 16 Jan 2024 16:21:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 30E101CD3C; Tue, 16 Jan 2024 16:20:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="eKfwZdun" 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 32FF71CA80 for ; Tue, 16 Jan 2024 16:20:04 +0000 (UTC) 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=1705422004; 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=O3OclCH75wBgs4Z0eklBI2HCm5hzhoXh5DbDkEBHEUI=; b=eKfwZdunjp2UEWBqVtYha196XToso2VFxyVuB1K9aj/4bOGUpZWWLDR/NQxrwzxQez368X 2AiSRKHcXcCU399qEao2OTYa0RH5O4hVe0y7T8tOzbbF8gVOgKjrhxDQQAvigYWtQd22Ij EsbMyIqYFJj9r6cSdB0CEaaSV8GNXHU= Received: from mail-oi1-f197.google.com (mail-oi1-f197.google.com [209.85.167.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-313-TsjjLbXOPBy1GrlyOYlZMQ-1; Tue, 16 Jan 2024 11:19:58 -0500 X-MC-Unique: TsjjLbXOPBy1GrlyOYlZMQ-1 Received: by mail-oi1-f197.google.com with SMTP id 5614622812f47-3bd3b54e5c6so12445923b6e.1 for ; Tue, 16 Jan 2024 08:19:55 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705421994; x=1706026794; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=O3OclCH75wBgs4Z0eklBI2HCm5hzhoXh5DbDkEBHEUI=; b=OunUfUUc596HfqEz9VZ148bjXWhq7QP4sFOZQ7xE/ydxFs8BGc8R7zFlKJVAi+3lDz bkgcdJ2u+Bozpjn/724Qb/Gs5RjDiiQuefBxxhsxl+UfbsbFN8mGVD8DmsYTcpXmw3C3 jmy4uxQgoZRBf5wywqTSQvhWzPOWOKHIGqZBFG4O4v2EFsdPm3m8ytolClMMG2lLSXPo 12FVkQhPZQuoIQBO4pUOCDtAMlYKXiRPeicdhEPc2Zklk9QzkiZvRCMMA6cQgoVYPhqF +BQtvks+9IwwwYgyC5ipYbozzFCnoihf6opRJI6pUsmX+YnTbyhuvzBOUger5EWOUB1O furQ== X-Gm-Message-State: AOJu0YzbeJ+WZweYUaaiVYwV3WgMsl1mX1ZD5W6lEY92SgrVPuLXvPMc /UQhblGFmucwhWPb9rIbYVy0E51+vJHONiP7ErTJjsGo27gv5ULZzRWwoEJ2yiu8SNK36Wl7egu JuyXhHB8BoW3eLBTWPONwvkWIkRizVMxS X-Received: by 2002:a05:6808:1a27:b0:3bc:3c49:19fd with SMTP id bk39-20020a0568081a2700b003bc3c4919fdmr9036112oib.66.1705421994698; Tue, 16 Jan 2024 08:19:54 -0800 (PST) X-Received: by 2002:a05:6808:1a27:b0:3bc:3c49:19fd with SMTP id bk39-20020a0568081a2700b003bc3c4919fdmr9036103oib.66.1705421994466; Tue, 16 Jan 2024 08:19:54 -0800 (PST) Received: from localhost.localdomain ([151.29.130.8]) by smtp.gmail.com with ESMTPSA id fd10-20020a05622a4d0a00b00429d3257dd6sm3809166qtb.45.2024.01.16.08.19.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jan 2024 08:19:54 -0800 (PST) From: Juri Lelli To: Tejun Heo Cc: Lai Jiangshan , Aaron Tomlin , Valentin Schneider , Waiman Long , Juri Lelli , linux-kernel@vger.kernel.org Subject: [RFC PATCH 1/4] tools/workqueue: Add rescuers printing to wq_dump.py Date: Tue, 16 Jan 2024 17:19:26 +0100 Message-ID: <20240116161929.232885-2-juri.lelli@redhat.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240116161929.232885-1-juri.lelli@redhat.com> References: <20240116161929.232885-1-juri.lelli@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788265338338810348 X-GMAIL-MSGID: 1788265338338810348 Retrieving rescuers information (e.g., affinity and name) is quite useful when debugging workqueues configurations. Add printing of such information to the existing wq_dump.py script. Signed-off-by: Juri Lelli --- tools/workqueue/wq_dump.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tools/workqueue/wq_dump.py b/tools/workqueue/wq_dump.py index d0df5833f2c18..6da621989e210 100644 --- a/tools/workqueue/wq_dump.py +++ b/tools/workqueue/wq_dump.py @@ -175,3 +175,32 @@ for wq in list_for_each_entry('struct workqueue_struct', workqueues.address_of_( if wq.flags & WQ_UNBOUND: print(f' {wq.dfl_pwq.pool.id.value_():{max_pool_id_len}}', end='') print('') + +print('') +print('Workqueue -> rescuer') +print('=====================') +print(f'wq_unbound_cpumask={cpumask_str(wq_unbound_cpumask)}') +print('') +print('[ workqueue \ type unbound_cpumask rescuer pid cpumask]') + +for wq in list_for_each_entry('struct workqueue_struct', workqueues.address_of_(), 'list'): + print(f'{wq.name.string_().decode()[-24:]:24}', end='') + if wq.flags & WQ_UNBOUND: + if wq.flags & WQ_ORDERED: + print(' ordered ', end='') + else: + print(' unbound', end='') + if wq.unbound_attrs.affn_strict: + print(',S ', end='') + else: + print(' ', end='') + print(f' {cpumask_str(wq.unbound_attrs.cpumask):24}', end='') + else: + print(' percpu ', end='') + print(' ', end='') + + if wq.flags & WQ_MEM_RECLAIM: + print(f' {wq.rescuer.task.comm.string_().decode()[-24:]:24}', end='') + print(f' {wq.rescuer.task.pid.value_():5}', end='') + print(f' {cpumask_str(wq.rescuer.task.cpus_ptr)}', end='') + print('') From patchwork Tue Jan 16 16:19:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juri Lelli X-Patchwork-Id: 188558 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:42cf:b0:101:a8e8:374 with SMTP id q15csp365836dye; Tue, 16 Jan 2024 08:20:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IE1sgXktc7/G723pXPtPNgfspmb1nyvdG/vmLTxkw8Vr0eU8pDaxcNVK1mQvd3uDWf+XaWc X-Received: by 2002:a05:620a:102a:b0:783:350c:e10d with SMTP id a10-20020a05620a102a00b00783350ce10dmr7810275qkk.111.1705422028191; Tue, 16 Jan 2024 08:20:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705422028; cv=none; d=google.com; s=arc-20160816; b=H4Kx6Y2jOWR/ihZmVccfccvLqn3uqRnSPmxcv004FMxyYO3ZVFnvhWwcT3RqGB5sDs 5WUIus3ONPOkp+0B8d79K/bep45pHlSIezpvokd4IjZqjA3by9aUVGCp5qlYF7LLnCgW sTCMGvdLR8yqn4mkfN2uhSD493v2GCmCrCX9IZvhMKvlK7rywuqIJG0TDpEIwRaB0wpL MCZUpH8W3xUtuJ74CfvYXtJqYZmCbOfJg0/hMia+V3nf8fgnJIWv+SFpFTmx30enYH8I aR2CF+TL5fpZJ9uQ/zoMMVZ2d9lzM7WsMNFI7vvKPuzEggAFOo2ddvyZSItJSbNZPP/u s9Tg== ARC-Message-Signature: i=1; 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:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=QGenYj0c7lCcQP9RiIc1lnECi134uIaPUzH+TIc7bto=; fh=Nsf1u1rbcJryyiFo9sS/VsYZC3vmqvYt/oMU7uIxbeo=; b=fbkLNHGSUtoG8e55zUwkYnyn4XHEo0yyCrnRGi7qFowyqPjM1DE3ixI/I5Xaljb32g s9orib0Fmld1zG0yHEBqiwlJCG+wqZMzxn2artevl+6KT5UrMiB+JbYaDZSmJsNH5uOW FQtPgUyz8Xw+W4Oub6BMLOELypGcKCo1UyzmqDHARw6oLtvGtx+vXvu7YAxz6P1gmZ2l 1+4nHjzgv6wm6Y4HFE+ZGiqzSA0EMbggGK9al3nvM7kgRGyzu+BseEl6DM7MPHIXaIxi mQ0U3zBcYkozKfKcXzNQYT1BQcjzKwUibQym8a+RV5YcaQki4QPHtTEWCOp+pWtOdiuV 93Ow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YBgXbVQI; spf=pass (google.com: domain of linux-kernel+bounces-27566-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-27566-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. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id c5-20020ac87d85000000b00429f6bc97dfsi3031553qtd.272.2024.01.16.08.20.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jan 2024 08:20:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-27566-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YBgXbVQI; spf=pass (google.com: domain of linux-kernel+bounces-27566-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-27566-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 EE7271C2347C for ; Tue, 16 Jan 2024 16:20:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 281EF1CAB6; Tue, 16 Jan 2024 16:20:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="YBgXbVQI" 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 3C4F91CA8C for ; Tue, 16 Jan 2024 16:19:58 +0000 (UTC) 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=1705421998; 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=QGenYj0c7lCcQP9RiIc1lnECi134uIaPUzH+TIc7bto=; b=YBgXbVQIHGN40zrb4fS+EZkFMqQHSigSSK2l1P3eP9/mWvXucyKT4QeoE4HPzYPJVNWAI+ uaLuO7oDftVToqOK20FeHbAec7T+NA4Ut+RrnsorNBjT2knTMKAlsHF+r6vbsfnRxmSIwg D1bHtztkTB49/c9JfhDsJhdeZuAB8h4= Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-588-k752fPfFOJ2HbSqLvYfSng-1; Tue, 16 Jan 2024 11:19:56 -0500 X-MC-Unique: k752fPfFOJ2HbSqLvYfSng-1 Received: by mail-qt1-f200.google.com with SMTP id d75a77b69052e-429d02a63baso67020381cf.0 for ; Tue, 16 Jan 2024 08:19:56 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705421996; x=1706026796; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QGenYj0c7lCcQP9RiIc1lnECi134uIaPUzH+TIc7bto=; b=SX/7tlWK+y8cZncZSwXDQMfN17KzY8d1viCEAhaTv2PnN+Qp98E0xqy1cwnSaBx1vA BIJPa5LeUcSu//9EzTnyrsYKn1e0PALZOhJ8pb6xGJXXQvvdZbYvW29MZd49JD0MmEDy Ya53FL+9wTv6n/3scFJHeUJQp5QvxlSl/BMV+MKt3Bzpf8WQ4WAeWkhUxHUokxpqK1wh fCPum+CFHMa2K7y2X6CSEceFRIaeG0H4zQqj3u+ILA4e9fb7/oKnGIU4j6++tgoJXZOQ YGzQAv8nv7vRh6+9FwEH1LhsWe/LeIYi5q/qls1nM71dFeKyxE26kZVtL7kY5oMnI9lo zSaw== X-Gm-Message-State: AOJu0YyyQ5MMjTc6rXmgMa9+xqdkglYcqL7r47Xvr/OaMWXAe6USs17n tyDNATO1s7Czqgd5FOjxG5Z+U7WCYynU6LPRoN6TK43trbWLRPhEO3jlLcHey8n6bxJ22ncxGYl 9BfWos1KqdqgvMWUHfyqPWuAi0GrlYPWv X-Received: by 2002:ac8:5f4d:0:b0:429:c7ce:46a1 with SMTP id y13-20020ac85f4d000000b00429c7ce46a1mr10150572qta.119.1705421996379; Tue, 16 Jan 2024 08:19:56 -0800 (PST) X-Received: by 2002:ac8:5f4d:0:b0:429:c7ce:46a1 with SMTP id y13-20020ac85f4d000000b00429c7ce46a1mr10150561qta.119.1705421996127; Tue, 16 Jan 2024 08:19:56 -0800 (PST) Received: from localhost.localdomain ([151.29.130.8]) by smtp.gmail.com with ESMTPSA id fd10-20020a05622a4d0a00b00429d3257dd6sm3809166qtb.45.2024.01.16.08.19.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jan 2024 08:19:55 -0800 (PST) From: Juri Lelli To: Tejun Heo Cc: Lai Jiangshan , Aaron Tomlin , Valentin Schneider , Waiman Long , Juri Lelli , linux-kernel@vger.kernel.org Subject: [RFC PATCH 2/4] kernel/workqueue: Bind rescuer to unbound cpumask for WQ_UNBOUND Date: Tue, 16 Jan 2024 17:19:27 +0100 Message-ID: <20240116161929.232885-3-juri.lelli@redhat.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240116161929.232885-1-juri.lelli@redhat.com> References: <20240116161929.232885-1-juri.lelli@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788264608198969459 X-GMAIL-MSGID: 1788264608198969459 At the time they are created unbound workqueues rescuers currently use cpu_possible_mask as their affinity, but this can be too wide in case a workqueue unbound mask has been set as a subset of cpu_possible_mask. Make new rescuers use their associated workqueue unbound cpumask from the start. Signed-off-by: Juri Lelli --- kernel/workqueue.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 76e60faed8923..3a1d5a67bd66a 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -4652,7 +4652,10 @@ static int init_rescuer(struct workqueue_struct *wq) } wq->rescuer = rescuer; - kthread_bind_mask(rescuer->task, cpu_possible_mask); + if (wq->flags & WQ_UNBOUND) + kthread_bind_mask(rescuer->task, wq->unbound_attrs->cpumask); + else + kthread_bind_mask(rescuer->task, cpu_possible_mask); wake_up_process(rescuer->task); return 0; From patchwork Tue Jan 16 16:19:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juri Lelli X-Patchwork-Id: 188562 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:42cf:b0:101:a8e8:374 with SMTP id q15csp372560dye; Tue, 16 Jan 2024 08:32:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IEaDu0qNLSsENAFhyJfk0dHLswFKxjsYAjQoulErpnantY60Y9AZekj2tKg7KhYqVSV9aHD X-Received: by 2002:a05:6358:5157:b0:175:64c5:ca6a with SMTP id 23-20020a056358515700b0017564c5ca6amr5842074rwj.40.1705422723938; Tue, 16 Jan 2024 08:32:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705422723; cv=none; d=google.com; s=arc-20160816; b=Yy9FjBXm3x7aeAUiZfO8xxKJgDiEf4CP8iEWaPCA2qqKjolZ8OZeQMicHJr2ix3TfY dxav0FRaCNY2+J9uS5CgPhJByyjcbFJ0wZ+K3Bk/dpbBzt+j3gtQwDQtBmh73pu5eaW/ YY1ojMDAm/KvGnFLFnKvAS1i47emrIducdQPwnA2otB5SNNHDxSd3JZgxjQOa1EfugeG H6+ubjfKaWXZyPsdPTNXDjLeUvUc/PiZ5aFa5Rk+Q+gTsCvw5NtZ645ZxQ2isdMN1or/ ArTqPuNuUYbpC07iB0Em2GdFiWgGqQbHTkjw8n6apM670z8RvHBaZlW5Ux3qBD3yvm66 R6ww== ARC-Message-Signature: i=1; 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:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=s4fKpZjH++WRt1yV+Gjohw4fqgWgBKev/a1YdUdJYkI=; fh=Nsf1u1rbcJryyiFo9sS/VsYZC3vmqvYt/oMU7uIxbeo=; b=Ouy5mv+0Bv2sjtzF20ANJ5lA0jKpYiJyhfGhvElFXl1svzxjcJfI8R3CKxHlZTefpZ Qz0Jrg4GB67+AMpZBYrlIOtVhLr8tM1qF3k8eiO35n/XG4vUbnkEiUo+q4hmjRkAK8wi g4ZzSh5ID4b3h1czknoujbGDpz9pb65v6VlEhBr+NEPeconJNW9QX1PBCUJvZZSrXoND 9lKD7efZBV/EJjuN7QwVpsVvw59RElwgNt2g5CEnRXMKPPxkBM5CjA76MAemZhFCIBSf +z94GDLsUIykzjwOtcTl6tDJujgB5E31wYaJJg8zWmWaPWSi2JI7vNhjdxXvxjqLeNZu IJsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=jBFXv5r8; spf=pass (google.com: domain of linux-kernel+bounces-27567-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-27567-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id y5-20020a17090aa40500b0028dafc233e6si11298686pjp.131.2024.01.16.08.32.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jan 2024 08:32:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-27567-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=jBFXv5r8; spf=pass (google.com: domain of linux-kernel+bounces-27567-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-27567-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 629F6286EE5 for ; Tue, 16 Jan 2024 16:20:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0FA281CD22; Tue, 16 Jan 2024 16:20:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="jBFXv5r8" 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 1F41C1CABA for ; Tue, 16 Jan 2024 16:20:03 +0000 (UTC) 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=1705422003; 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=s4fKpZjH++WRt1yV+Gjohw4fqgWgBKev/a1YdUdJYkI=; b=jBFXv5r8MedtjrQPeaqHWEe9Vb/TkhenEG7x+7BodPLIPXvZQ/2MoPljCAn9rRueCrnaaM NNVcFc/qDJ6haExEC2tH8sJZNoQ7dzCKnrQYirMpFU/5OSTKi+gzXAcv/vLDLW3UXcYGzH gvCQps7e6RFTyBaBu/ukzuHEHiBfNxk= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-553-LmG8ySuHOSyhu9_A6-SC9Q-1; Tue, 16 Jan 2024 11:19:58 -0500 X-MC-Unique: LmG8ySuHOSyhu9_A6-SC9Q-1 Received: by mail-qk1-f199.google.com with SMTP id af79cd13be357-7831bc14ae3so1385270485a.2 for ; Tue, 16 Jan 2024 08:19:58 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705421998; x=1706026798; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=s4fKpZjH++WRt1yV+Gjohw4fqgWgBKev/a1YdUdJYkI=; b=Ntlcsmxq6fK2ImFMM9kNTlb9YicO0gG9746E0qftEaVDdsKUjYs3pAvSdAThtvJ0Lw OsXgSb9//0mpIgsfVumtHFT3Z6ZpwjtfNXhTBtJEx6jCktBJxuuDgu7Sf9SAP5OM1SLD peKeI5FJIOF8rtA2BoCG9yh18SGh6izz0kxZbgth2CrhjuVDTvERjVwO2aHgEzpCTKOi t2mx6fo7l6hTYdT0Gg4HzWSqpjSZ25GIbneISEwD9gS5mPKhfh0+n2BmyT9QP9JaVoOZ Oo28uHFtldJucmBkePc4a/3JYXuMX+1DToxdNM4c98AN52JUQpBhLLSPuARWi7GblSb7 zvBw== X-Gm-Message-State: AOJu0YzoZlLoVaUFaQlYXa/iTYiJhmDTFzu4yStDxQbQ0yUy16LuVhpR YDvKGX8HsZuMgmBQENivOU4Hz7a7otOc4CbAUnSHp1Eh66LuouKuCJ00UGhNbillYCYMC499Zz9 FtJP+bCoZ6vzBj2dHnTnMLH5GXcifPns2 X-Received: by 2002:a05:620a:4799:b0:783:6831:70e3 with SMTP id dt25-20020a05620a479900b00783683170e3mr1526837qkb.142.1705421998034; Tue, 16 Jan 2024 08:19:58 -0800 (PST) X-Received: by 2002:a05:620a:4799:b0:783:6831:70e3 with SMTP id dt25-20020a05620a479900b00783683170e3mr1526825qkb.142.1705421997769; Tue, 16 Jan 2024 08:19:57 -0800 (PST) Received: from localhost.localdomain ([151.29.130.8]) by smtp.gmail.com with ESMTPSA id fd10-20020a05622a4d0a00b00429d3257dd6sm3809166qtb.45.2024.01.16.08.19.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jan 2024 08:19:57 -0800 (PST) From: Juri Lelli To: Tejun Heo Cc: Lai Jiangshan , Aaron Tomlin , Valentin Schneider , Waiman Long , Juri Lelli , linux-kernel@vger.kernel.org Subject: [RFC PATCH 3/4] kernel/workqueue: Distinguish between general unbound and WQ_SYSFS cpumask changes Date: Tue, 16 Jan 2024 17:19:28 +0100 Message-ID: <20240116161929.232885-4-juri.lelli@redhat.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240116161929.232885-1-juri.lelli@redhat.com> References: <20240116161929.232885-1-juri.lelli@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788265337817340155 X-GMAIL-MSGID: 1788265337817340155 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); 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; - ctx->wq = wq; return ctx; From patchwork Tue Jan 16 16:19:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juri Lelli X-Patchwork-Id: 188561 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:42cf:b0:101:a8e8:374 with SMTP id q15csp372003dye; Tue, 16 Jan 2024 08:31:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IGlvNyDpP5xJh3oszv+s7QOzaLhDtJT1aqy2WQDhq6zYeeGx48WkDjjRX0dtN6R3kWv5yqg X-Received: by 2002:a17:902:ec86:b0:1d5:36e8:9ac0 with SMTP id x6-20020a170902ec8600b001d536e89ac0mr9030679plg.50.1705422674938; Tue, 16 Jan 2024 08:31:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705422674; cv=none; d=google.com; s=arc-20160816; b=FuE5GJk5IbQ1QPDn16oAtI8pdWfunq42KLqSaZ1em/0Vhc9lLix7d66TOcIRpXAgSv uvXnLGwz9GR6rt/4zpZqN+5fN9he1+dG/Ak1V5pv16BcEX3BD78cJvNya7DQnTKt6TAM kvpzdTwNwDVamdcsDbeemNL0rMr+ve3+d1YVIkFoCEaWi0gi2XyI9aQrcrAdrxtvFPoT /fXvzkfjVEeN+qn29szdAz88n8pNj5WNKbdqGOoNrHWrCppdB8QzXX9Oex75bFmDg4+B 5mRPaFevmxvk2ic98fFSBkcQ0/Kcx7vlbkglxkhYz7hEyUy4DC+3PcH5L1KmGoMLLZ91 TrCg== ARC-Message-Signature: i=1; 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:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=MbtUeDj38iJv40DVhrJMpGto1LA7FQWBcqkGB+BZKUs=; fh=Nsf1u1rbcJryyiFo9sS/VsYZC3vmqvYt/oMU7uIxbeo=; b=ij09HVMi7H1o9bxO8WHGZ1MyTfLqQs14GgBLTRQ40dPtJZVkevOxiGx/i/HnOdyoh9 z1ZaHgcnvm0o/NscRxMQJ21Vb6wK/mtGahABBMi+YBjzHplWXGWDYofUWVMu8DPDhM7F IxE4pUuuohIggorPL5fLZvXMSGmQFzoDj3iQzX9bMFQqgmpWDaO86lK0Q3Zjq8HThj1a xD92QKwmnxc9KA5fnm3bs84DH7n2ej9RCFCu4lTsGi37tDkO3eCxAJi26O31TaH7xr6x L77TU+1Mk0V19mlEpnoS5M+3evWM0rlEPm33iXmNG955XIhPod115/kyutkgaEwDvwuc 906w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=AOYT6YOv; spf=pass (google.com: domain of linux-kernel+bounces-27569-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-27569-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id jj18-20020a170903049200b001d4c4bdc0e0si11430493plb.537.2024.01.16.08.31.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jan 2024 08:31:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-27569-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=AOYT6YOv; spf=pass (google.com: domain of linux-kernel+bounces-27569-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-27569-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id BC50828751F for ; Tue, 16 Jan 2024 16:21:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 393751CF91; Tue, 16 Jan 2024 16:20:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="AOYT6YOv" 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 4E1A51CA84 for ; Tue, 16 Jan 2024 16:20:06 +0000 (UTC) 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=1705422005; 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=MbtUeDj38iJv40DVhrJMpGto1LA7FQWBcqkGB+BZKUs=; b=AOYT6YOviBP7jy2mIIfB8ea/NYN4hKFi3nm14vrSBPgEROGbnJ0diDl17TLo7XsKbWxtaC 3pt1wNq83asZsNgjEOIsM0pYysgWeUrCXWe+tG097ECmKlVVHMw3HlJTDrJi/1qdo6e09Z 51OKKtkZmmat0VWgrr6bBPWLqR9+7Ys= Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-662-5PMRCyo6M4SSjR1tL74EVg-1; Tue, 16 Jan 2024 11:20:03 -0500 X-MC-Unique: 5PMRCyo6M4SSjR1tL74EVg-1 Received: by mail-qt1-f200.google.com with SMTP id d75a77b69052e-429a7149210so81107851cf.3 for ; Tue, 16 Jan 2024 08:20:02 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705422002; x=1706026802; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MbtUeDj38iJv40DVhrJMpGto1LA7FQWBcqkGB+BZKUs=; b=FinF9XLiZDykhiViPj6zHY9xdJdUmYZd8TNOM6O04I1JiaYmyg+IVQjWXC1ptryDS5 2+ipEnHTxPQutfx7/IF3R7iHXa+S73nXIyubKSLvDPJc0ugctVN7TtXI2rde2E+iv+Ix OXB8g/mF82SZxuPczpjhFoZ2I6VLIA+ihpMnWU3bsWxI6nOHdnVQQba2/s0C47LWZ4gL uH3i0A9s4qJSwnPpDtvua3EgtVrsaTd77naywYkEJtkuZKYP0bzfs8Sk2WuOWqPiNQt2 djbm0TLRcf2iOba8pEY49lBaP+XZzcvGxXzwUJGarM/urRxK1RednGQA03DdFOKjXh6K 6T9g== X-Gm-Message-State: AOJu0YzWFj3JoFdXEbu8S1hCzsq+q60Rkcg1H8pi+USOAnpNJbMew3ta BO5fMnFOIjyjxyDvTuvXl1WNw3IO2NPSRAl0C3onG5PL8lC0eYnvN66AB76T8Ld2L8cL18wivWN LnJ0JaKK0zHnNMUzur094ysoSitCGWit8 X-Received: by 2002:a05:622a:120e:b0:429:ca1c:7fd3 with SMTP id y14-20020a05622a120e00b00429ca1c7fd3mr9264966qtx.68.1705422001906; Tue, 16 Jan 2024 08:20:01 -0800 (PST) X-Received: by 2002:a05:622a:120e:b0:429:ca1c:7fd3 with SMTP id y14-20020a05622a120e00b00429ca1c7fd3mr9264959qtx.68.1705422001616; Tue, 16 Jan 2024 08:20:01 -0800 (PST) Received: from localhost.localdomain ([151.29.130.8]) by smtp.gmail.com with ESMTPSA id fd10-20020a05622a4d0a00b00429d3257dd6sm3809166qtb.45.2024.01.16.08.19.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jan 2024 08:19:59 -0800 (PST) From: Juri Lelli To: Tejun Heo Cc: Lai Jiangshan , Aaron Tomlin , Valentin Schneider , Waiman Long , Juri Lelli , linux-kernel@vger.kernel.org Subject: [RFC PATCH 4/4] kernel/workqueue: Let rescuers follow unbound wq cpumask changes Date: Tue, 16 Jan 2024 17:19:29 +0100 Message-ID: <20240116161929.232885-5-juri.lelli@redhat.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240116161929.232885-1-juri.lelli@redhat.com> References: <20240116161929.232885-1-juri.lelli@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788265286421081174 X-GMAIL-MSGID: 1788265286421081174 When workqueue cpumask changes are committed the associated rescuer (if one exists) affinity is not touched and this might be a problem down the line for isolated setups. Make sure rescuers affinity is updated every time a workqueue cpumask changes, so that rescuers can't break isolation. Signed-off-by: Juri Lelli Reviewed-by: Lai Jiangshan --- kernel/workqueue.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 2ef6573909070..df7f2f2bfd0c8 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -4416,6 +4416,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) { + set_cpus_allowed_ptr(ctx->wq->rescuer->task, ctx->attrs->cpumask); + wake_up_process(ctx->wq->rescuer->task); + } + mutex_unlock(&ctx->wq->mutex); }