From patchwork Fri Feb 9 00:11:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejun Heo X-Patchwork-Id: 198710 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp546145dyd; Thu, 8 Feb 2024 16:41:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IHYe9VBwFF90GaH0oWWBZfvMQIHxpLp09N97LQWd1ZRVLsoFgK7Ns2qVCwugojOil34s1xt X-Received: by 2002:a05:6870:164f:b0:219:f5f1:d60 with SMTP id c15-20020a056870164f00b00219f5f10d60mr43095oae.56.1707439316211; Thu, 08 Feb 2024 16:41:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707439316; cv=pass; d=google.com; s=arc-20160816; b=kIiBRUllJPzCmVLduIrcEFfWzJix4z5MmYVKPME03phPoPuuN3gAkeccqszV+8sElO ZdfLxmJcYN/kIAkP0n2CrM5/r7QO+vJEjWj8AqiLuelYSmISkjmkyRyiNJa70xzeWmaC JW5Ld0Cz+FkOwhG9ApcfI+i/5Ezh49wjlNvFQm42akXYgh8cYJuUmVGvs+P9EqWZ8TTQ fMh3PNOlKjLP2THE7d59Crahsqpx3/mdW/vRb5TBSYfQuSSh/Q3fzRfoF0OnkOMh4Qvu dU5aaJ/azEpNEGObu9Po0ByvzyNkZ65TZ9vg76/6c6salmWSYYg9pyTGwAeuFKGw6X/V /ztg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-disposition:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:message-id:subject:cc:to:from:date:sender :dkim-signature; bh=XQZvJgedD8LlLuZzJKiEJoT/ySdzdPZ0zmmi9A45YQg=; fh=dFfGewdC3NCfOqXM3zMXb2x/+EGGLCX8DS8V2ea8ik4=; b=Trz3XnKIofznOuKQD/dvHmbb7GyyJQ2cHmRnRENqpMLx+N0jwW6gPGOFO778G53txU zb55INGrjr3PVWq3VPtWkvPWAxwKQuXnM4BjAcW2qOuXbEnUWiKfwZtIVnkF2bGPJndx qVMg8OVJhXc2jzX+5FPXXj98WTWBjxkdUEhuWNPlcVooRXtGYzJCyE7UOU41IZ21LNpC AiGEdXl1cVqmE2pFziArK2O9qiHDAlNZpSaiaDBnD7GhT77bBfwHwiyalqEE8eWPas+8 B5w6CqK5lPlkXmhTZwz8JggWpc3sS5l05v3xJ9xScevXuArrZwTfNmmWgs1px87kEnKy U1cg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=FtVG1Hk1; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-58893-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58893-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCWuAkFEkq4aHK5yCtkL1vszQIsQ8lCPgTMRDLAPrU5+7WbJkW+mP9Oijttlc4etzOZ72Iovd10jQlwO3VDKiVny1y3vZQ== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id k63-20020a638442000000b005d92a3f1196si651315pgd.592.2024.02.08.16.41.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 16:41:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-58893-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=FtVG1Hk1; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-58893-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58893-ouuuleilei=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 78A92B242EE for ; Fri, 9 Feb 2024 00:12:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id ED323EBB; Fri, 9 Feb 2024 00:12:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FtVG1Hk1" Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) (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 9E362364 for ; Fri, 9 Feb 2024 00:11:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707437521; cv=none; b=X0INzOEn7H1V8MBLOmbWR7YEKLqOOWcuZloC0fRCqSBX3qtXLbQXJ1mcQvcbsHgh4Yun2wOzOVrIIK/z+g0H5y75WkuRYjOzif0EWE3FLrHC/TX/+WgBpYNj3XHp1MuhjJc1PBd6XUGk/IHmkS70ECmYbkYlPqgEsWlxdDR2lhk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707437521; c=relaxed/simple; bh=MrtQG68CQj3jGguwb2kDauw/NcdRMELRTxmQJt6Xpy8=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=HwzSgHzdUX/0p32Jl2vg3mdERE8XffGKkNGtHk5Gc/Iv8C/e7lmShv98ADbJ0DKVPIZFzvREzbl9zb49lNaJlSVdjZDHHsxwBvBvlKt4n1+YzZVTjj2vC8koLt6bEzX/kNZ19mvbBvCBK70wl98y6appTDsltr5eBKruZvALxwY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=FtVG1Hk1; arc=none smtp.client-ip=209.85.210.170 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 Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-6e062fa6e00so266145b3a.1 for ; Thu, 08 Feb 2024 16:11:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707437519; x=1708042319; darn=vger.kernel.org; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :sender:from:to:cc:subject:date:message-id:reply-to; bh=XQZvJgedD8LlLuZzJKiEJoT/ySdzdPZ0zmmi9A45YQg=; b=FtVG1Hk17IBgMwfvOLZCIEQCeuf8J/qEoJ6rAVoUH+vkR5Heac1N5TRHk9Thwe3W0p gKBErW/pV153rUDZ7HYqBjUoZjMTzwxcHz+aEUngqmz/9v9VF/quI/H8eQBfsojUtP/K wiwA5urRNjrpcWZtxayr8Obk79EVpJoB91+fqlGgY84sZuHzAfIN1nq1rpkCefAyEZCe QTNVRNAs7BS3iUt8vXpBeyASLHl+TlWn56gwmxJkyLmbfMP0vzPXUryT3TVdxZX6H74P 15MSTqIxBdSHX6L2nk/Exx4xCBdN0kc85QGyDjD+hHH0BM2Hgm4X7SG4P8gzAPWSrp6e exuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707437519; x=1708042319; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=XQZvJgedD8LlLuZzJKiEJoT/ySdzdPZ0zmmi9A45YQg=; b=fC2EVhRWJt4tGpus1dHPuQ7IGhv9krs7tISVsWIhOJGOPSWM7JnnmKkwkLAJxevsp1 IYqUoTgYE/l/LW0c4yJRBmcn+mVk8rIZnUprck0M9ehD9U8Bse7M1oqXPVMMUt2Q6Mai iLRgInaQHmbtLNnRCAAOywXbeF6Bb8M6UPIRfP4bdAZN5V8YxJpJjN6FUliqau87DGrO lPgal8UmYIpcc0iAntenP12OejqAEvRTsev/Qo0hFvPbqtfrzNuL90TOV5yDwVjHTi8/ rambh2Lj6XZ4Izkjo5L9YeQh7uMeobH1uwwFiVJCl6v9I+5H8lwb3F7G1AzOtXuVgncT ZO0w== X-Gm-Message-State: AOJu0YyXPuCA9iEU3BFFhfNsQZIdCKOORd/gZ42Mu1TdkJy7GpRpffn8 YfluTgwE0zzQG1VG/MWFk4a4RN8MS2Lgy5SBgqC/o3oBcKRgoZrb4pYB0cbshT0= X-Received: by 2002:a05:6a00:1393:b0:6e0:4b09:a9c4 with SMTP id t19-20020a056a00139300b006e04b09a9c4mr136174pfg.2.1707437518757; Thu, 08 Feb 2024 16:11:58 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWk7lyW/tEgtaQBxQGucpaotDVXiVjuNQymjGei6+VSK0+3ar7g8KPGJ7xfOmttyRTSguFKepmdvOmSs+jSiBPkBgbXjpNG6eFpvHKJy4+hYbSFgJQWCCYCoWGGnYbsb3u7OCCFkb3CJ+5Csw7oe2FjC2+YDxJL Received: from localhost ([2620:10d:c090:400::4:3c45]) by smtp.gmail.com with ESMTPSA id fn6-20020a056a002fc600b006e03c2f96fbsm367245pfb.148.2024.02.08.16.11.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 16:11:58 -0800 (PST) Sender: Tejun Heo Date: Thu, 8 Feb 2024 14:11:56 -1000 From: Tejun Heo To: Marek Szyprowski Cc: "Rafael J. Wysocki" , linux-kernel@vger.kernel.org, Lai Jiangshan Subject: [PATCH 1/2 wq/for-6.9] workqueue: Implement workqueue_set_min_active() Message-ID: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790379888240773769 X-GMAIL-MSGID: 1790379888240773769 Since 5797b1c18919 ("workqueue: Implement system-wide nr_active enforcement for unbound workqueues"), unbound workqueues have separate min_active which sets the number of interdependent work items that can be handled. This value is currently initialized to WQ_DFL_MIN_ACTIVE which is 8. This isn't high enough for some users, let's add an interface to adjust the setting. Signed-off-by: Tejun Heo --- include/linux/workqueue.h | 2 ++ kernel/workqueue.c | 27 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) --- a/include/linux/workqueue.h +++ b/include/linux/workqueue.h @@ -553,6 +553,8 @@ extern bool flush_rcu_work(struct rcu_wo extern void workqueue_set_max_active(struct workqueue_struct *wq, int max_active); +extern void workqueue_set_min_active(struct workqueue_struct *wq, + int min_active); extern struct work_struct *current_work(void); extern bool current_is_workqueue_rescuer(void); extern bool workqueue_congested(int cpu, struct workqueue_struct *wq); --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -5627,6 +5627,33 @@ void workqueue_set_max_active(struct wor EXPORT_SYMBOL_GPL(workqueue_set_max_active); /** + * workqueue_set_min_active - adjust min_active of an unbound workqueue + * @wq: target unbound workqueue + * @min_active: new min_active value + * + * Set min_active of an unbound workqueue. Unlike other types of workqueues, an + * unbound workqueue is not guaranteed to be able to process max_active + * interdependent work items. Instead, an unbound workqueue is guaranteed to be + * able to process min_active number of interdependent work items which is + * %WQ_DFL_MIN_ACTIVE by default. + * + * Use this function to adjust the min_active value between 0 and the current + * max_active. + */ +void workqueue_set_min_active(struct workqueue_struct *wq, int min_active) +{ + /* min_active is only meaningful for non-ordered unbound workqueues */ + if (WARN_ON((wq->flags & (WQ_BH | WQ_UNBOUND | __WQ_ORDERED)) != + WQ_UNBOUND)) + return; + + mutex_lock(&wq->mutex); + wq->saved_min_active = clamp(min_active, 0, wq->saved_max_active); + wq_adjust_max_active(wq); + mutex_unlock(&wq->mutex); +} + +/** * current_work - retrieve %current task's work struct * * Determine if %current task is a workqueue worker and what it's working on. From patchwork Fri Feb 9 00:14:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejun Heo X-Patchwork-Id: 198708 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp535188dyd; Thu, 8 Feb 2024 16:14:38 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXYQyTMpjILUBxLYfv99oIh2PJdi3btzT6hhvGZJ9cdrmGc1q87PRt69jLGpXOE0KuonGF0g02jgcA/GmwkChH+FhbhCQ== X-Google-Smtp-Source: AGHT+IHAlDlAUoDkA3nFAwxSYW73s2c8AVDrwDDxnGn3/2pOwocDuizfjCJL2Og24j4Bmxpcv3NT X-Received: by 2002:a0c:9a41:0:b0:68c:cd57:6b81 with SMTP id q1-20020a0c9a41000000b0068ccd576b81mr6252qvd.31.1707437678664; Thu, 08 Feb 2024 16:14:38 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707437678; cv=pass; d=google.com; s=arc-20160816; b=eFTkqCrkfO6OOAtgb1sAX9e7X5QfmkfY8bkqXg7WWLie/UfCVhBJS+o/E0Pkw5+IsZ CuP/4JpNP3+3F3G5zSiHvbaCBlzn5eL8j8Ep+KtHp4JIoiZ2DiP3foJLBQHtCPOqdaW1 bPFoeWRJkk+NMg2Bvo1DC3nVIciOmoc8Nj+M47nqD/k39TRxAFQwno5CkI5qGu6k2wqU uq0SwGY0/L4Qpzpiz8K66ZPWMe5VjK/Ivs3dXBmJN73jeM5LDYN+jIkGSnoWzZH5a8gm XfYnfk+DSojegGm2Eb/RbYm8oSAPUVrD3KGGD7owG+LX0i2gAIUC3Z+7ojh8xmFMRIXO KXCQ== 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=EnfYxv6e7qTli+BXi1Z+qdjTd9GL+skcxMsHzG17xFo=; fh=/VQO8SpXQUXNARhezQKTCbslLe44E4ablz0ElMbvA/Q=; b=P+/KJ+e1DIEssPcbaaekDO7j5Lucm0EBOwLP/Ub/rM/EnfuJa8jPOo22LMYeIf0YFU rtKE943gJt1Q+wJv0KvGRV36AiGK8Vk0tvKUToCSjLDm47bFydaQ4z6VPiD9D18z0rTR hZ7LC1UejvxqNLZJdNv3Uyl28UV4EftI8sgTf2Lsj2RcfjE2/xY3uF6H1ZWG97FbuGfl kHKERx5DMeLaL+nNdfJTIqJ29xurTpn3Q17mOuJydwYytHo5zcTo5zQBp2di5LF2LXaF Q2D8ZT3XpmRClGb+tbuoBWCzOcBwUvdZGWQmNDUeT5tb5atVVU2D4AndBH8mEqSKGMBm VEkA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=SdUYUC0E; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-58895-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58895-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCUndwY/jsfvV5mVxUUtBByYzREwVsxo22wAyOh7qNBdBoXPJ5x2GIa1Cld+RP9nuzSDk1gU8ZudAHsc6z72NEjKkWUhSg== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id l5-20020a05620a28c500b007839a42c28dsi941338qkp.320.2024.02.08.16.14.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 16:14:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-58895-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=@gmail.com header.s=20230601 header.b=SdUYUC0E; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-58895-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58895-ouuuleilei=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 737E51C2433B for ; Fri, 9 Feb 2024 00:14:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 64C156AD7; Fri, 9 Feb 2024 00:14:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="SdUYUC0E" Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) (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 EF4745673 for ; Fri, 9 Feb 2024 00:14:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707437660; cv=none; b=O7LIJLfs+Y6CKlN9BnM2JqgmPKTntuVvi78sD2ZwptxPUK2YgumIszK7V9FPjuYaDjPMpPVsakJjH3414DLl1X8HYDZuWg0lL04PGdcC4eASlYPjZSe4TtDtjDZCBRIg3qFRQ6q18JnXErg8EgW3aWnhvjKQWQcl/minW9DOJI0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707437660; c=relaxed/simple; bh=2MO5ems9wmxxF4Q2y59hV3zfphUYzla6prAAb/Rg5js=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=nZ7fwf7aO+xjeYR+7EmvhAOR0UuF90OC94t3m7piPTpFQ2eeR3sfejcPnjg1YqpZLx9MzQpjWEOjUVeSSiXJIEKDrSt2mUcOVmuzSEA86AQvQMYmdpwqZfSl4t/WZgNTi3ELqigIREfRGXCkukOiDdQXM2S1mGpBt+vRK+S8nbM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=SdUYUC0E; arc=none smtp.client-ip=209.85.214.169 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 Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-1d99c5f6bfeso10679185ad.1 for ; Thu, 08 Feb 2024 16:14:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707437658; x=1708042458; 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=EnfYxv6e7qTli+BXi1Z+qdjTd9GL+skcxMsHzG17xFo=; b=SdUYUC0EYE9eCVx2tx8YRuHzMy9b1XR11aLlhMnCV/OwY8zoBcFPj/6ejNqQUvik7v yDRkhRjuHiata8sGtsbxaPURgvh0N0tPwLSKxuwPZbzo1sKCtZBHgVo/r2wUZCC5dbGM WqLwbeo9OL6KBWLel8LBvb27HbFjsUeHugIy+LzmVv+KtBRA4wGan6YXGCQ6SLsIzU0n CD7JuaKNrLxM7DU77bvygoP8DgfAK/uA7tzqneIP/c3g9y0Q5IZNMPCR/ut2GB1qTkoX IbVUFdLtEkdYYcn7H5+4PHEUlwSMVkcCOV/zaK+q601XeEFgW74ZxLRbUBUzX+DLKuKY RpAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707437658; x=1708042458; 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=EnfYxv6e7qTli+BXi1Z+qdjTd9GL+skcxMsHzG17xFo=; b=M6Zy8ttgvoj8sIQEJgBJr3JpzwtqvB3ydjTBxQUEYgvcJCZMZIHhwAbZdAORNkVUwl 4qKh1TISwK/XFsNEwHa8H7VkN+diFG3GCmWGKwHsXo2op3wTLF/dkH51NJXAf4qeVA8r Xx4DlS4vRuKn2QN3YoLMEuGWxvxlTOENpOOy1W45/1uyYp/S3StAjf5Zt0nuUtwBw6sT oM+4zhEaFyg5PCnYKgNPWNGviq6yo35qtAcRzzYvOxHq5MmB2htgQJd4hS3X+mUPk1Az 27SXvYMFbW2nfBZFzw/Hc2iZ2X7PyuWp+icjo3Cqu5sSd+iaDjhccqLFt+pEtfDBXjzM cLxQ== X-Forwarded-Encrypted: i=1; AJvYcCWg/r1OST5U26aAlGRW+/34aNzaZW4De84b2tE8Tf6Zb873r3S+2t7sHpvC7M/raesmYLIOhJtXM6VhxX8qDcbd7aSnbYtIPshipMti X-Gm-Message-State: AOJu0YzzFfbAkBIlMyUZzgvmNTGTCNPEBaPYoO9BXAIbAozVdgip1WTg PR3iu3jiSseKMFeSPSTBh243XzIIxPAnxLtUIqchUmYIC+m04pDb X-Received: by 2002:a17:902:e5c3:b0:1d9:aa5d:a54 with SMTP id u3-20020a170902e5c300b001d9aa5d0a54mr1810769plf.32.1707437658135; Thu, 08 Feb 2024 16:14:18 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUm/tl70d+wNfM0y2qWN9wYaDXrucVK6WJwWQ7kjztJnir4PaLrk3j8VZ0SU9WEPSwcSAVkutgHc7GM25WV2CLJsCWZnXfJ29t2Nn/4to58NehB28ujjAjB+Hn8t0NwDFBnwYWFVrEGtZ9GXZdlO3cxs9x2bPd5 Received: from localhost ([2620:10d:c090:400::4:3c45]) by smtp.gmail.com with ESMTPSA id mp6-20020a170902fd0600b001d5f1005096sm351403plb.55.2024.02.08.16.14.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 16:14:17 -0800 (PST) Sender: Tejun Heo Date: Thu, 8 Feb 2024 14:14:16 -1000 From: Tejun Heo To: Marek Szyprowski Cc: "Rafael J. Wysocki" , linux-kernel@vger.kernel.org, Lai Jiangshan Subject: [PATCH 2/2 wq/for-6.9] async: Use a dedicated unbound workqueue with raised min_active Message-ID: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790378171765745693 X-GMAIL-MSGID: 1790378171765745693 Async can schedule a number of interdependent work items. However, since 5797b1c18919 ("workqueue: Implement system-wide nr_active enforcement for unbound workqueues"), unbound workqueues have separate min_active which sets the number of interdependent work items that can be handled. This default value is 8 which isn't sufficient for async and can lead to stalls during resume from suspend in some cases. Let's use a dedicated unbound workqueue with raised min_active. Signed-off-by: Tejun Heo Link: http://lkml.kernel.org/r/708a65cc-79ec-44a6-8454-a93d0f3114c3@samsung.com Reported-by: Marek Szyprowski Cc: Rafael J. Wysocki Tested-by: Marek Szyprowski --- Hello, Marek, can you please see whether this solves the hang while resuming? If it does and Rafael is okay with it, I'll route this patch through wq/for-6.9. Thanks. include/linux/async.h | 1 + init/main.c | 1 + kernel/async.c | 17 ++++++++++++++++- 3 files changed, 18 insertions(+), 1 deletion(-) --- a/include/linux/async.h +++ b/include/linux/async.h @@ -120,4 +120,5 @@ extern void async_synchronize_cookie(asy extern void async_synchronize_cookie_domain(async_cookie_t cookie, struct async_domain *domain); extern bool current_is_async(void); +extern void async_init(void); #endif --- a/init/main.c +++ b/init/main.c @@ -1545,6 +1545,7 @@ static noinline void __init kernel_init_ sched_init_smp(); workqueue_init_topology(); + async_init(); padata_init(); page_alloc_init_late(); --- a/kernel/async.c +++ b/kernel/async.c @@ -64,6 +64,7 @@ static async_cookie_t next_cookie = 1; static LIST_HEAD(async_global_pending); /* pending from all registered doms */ static ASYNC_DOMAIN(async_dfl_domain); static DEFINE_SPINLOCK(async_lock); +static struct workqueue_struct *async_wq; struct async_entry { struct list_head domain_list; @@ -174,7 +175,7 @@ static async_cookie_t __async_schedule_n spin_unlock_irqrestore(&async_lock, flags); /* schedule for execution */ - queue_work_node(node, system_unbound_wq, &entry->work); + queue_work_node(node, async_wq, &entry->work); return newcookie; } @@ -345,3 +346,17 @@ bool current_is_async(void) return worker && worker->current_func == async_run_entry_fn; } EXPORT_SYMBOL_GPL(current_is_async); + +void __init async_init(void) +{ + /* + * Async can schedule a number of interdependent work items. However, + * unbound workqueues can handle only upto min_active interdependent + * work items. The default min_active of 8 isn't sufficient for async + * and can lead to stalls. Let's use a dedicated workqueue with raised + * min_active. + */ + async_wq = alloc_workqueue("async", WQ_UNBOUND, 0); + BUG_ON(!async_wq); + workqueue_set_min_active(async_wq, WQ_DFL_ACTIVE); +}