Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp2718947rdb; Mon, 5 Feb 2024 15:58:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IHrnWVwLrJFDwk614yroaGVz6ZWFhAPDUzsH7yc8xT9Ly6ACZnyf24YHVZ2h0pXqabhCqIY X-Received: by 2002:a17:906:608a:b0:a37:2ed2:cba1 with SMTP id t10-20020a170906608a00b00a372ed2cba1mr281784ejj.22.1707177525263; Mon, 05 Feb 2024 15:58:45 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707177525; cv=pass; d=google.com; s=arc-20160816; b=v8cMg91sXPJqSPiA87xmMJXoBmfnDrEPpjnJ/DCV56BJzojXhkNeldaP4F5BzzmzRf rcWsc8OFzCS2uE4HKw9TdsimyMxAyqKXC36iKucJjFax18vBq1fhuS3/z68wcwpaiAZd d8vQu24o63xSxYKNVFPtl9mSXVRMVov3hjpeS03wxsZz+xMm8XXdFYXvTGhQqjsom2i7 bYTMgjLr0hKBkKEHpFUW3NaFCNgyl1NhjYQlvQT1Wpw/a7qraBSL1zw/AIKfpc2mVJxW PmC8YVv8/5HR5oe4XIqHI5H63ylR2XkBRxIBJx2FGhyGIYklU1qetlHze3PMSV5DkPPz zbow== 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=LtaKsqfpcyHuWJPjZvPw/ChfmsDTwQtI/UDfAaWKaM8=; fh=WoOZwTVE3x3N7nIsBPnVmSfBYb4jspVxMLk9LvG+jIk=; b=CndaZyZnPekmbDZ7J68+81Xi5zZsPkUEILEkKHPVxdSTMbPNLedMceQhyZ4cwxPM9t KK6bwd/Iq9jyZKyYFTRRf1YrMFMdr+WmiUn/g93/oJJBISQUMt1mg4amll9qTG+DoqN5 fJahK6fhWfy6FRuurYqPz3LjWXy/G2MQLMbUyfCM9nyUfssmuyeEPODqQvnFzb62eBLp Ok+/00JfVgoCSSgXcI0Hr+xLEcv7EgTxEfx0sstVig1efyjS3Pmgy/aOSA96pfPaHUUd sYcAXrdrnaWf3NaScklGu0UWRy5Ij0RciZsXklRwWYqs+YtEWvlEChWSnTwAGwQiYskB riww==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=deCfnlkG; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-54109-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-54109-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCXqpltP08OmKHkExlJSWpkpvJT2d/qdmm5YvcIO/7rT2S1YabVWJDCuiFAzhi9uHX+26uo9hX1SoML89e18Pg23JJWzdEBklMsylqfM+Q== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id ca23-20020a170906a3d700b00a381acb7289si137355ejb.318.2024.02.05.15.58.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 15:58:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-54109-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=deCfnlkG; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-54109-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-54109-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 04AD01F267F1 for ; Mon, 5 Feb 2024 23:58:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C6CAB4C602; Mon, 5 Feb 2024 23:58:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="deCfnlkG" Received: from mail-oa1-f50.google.com (mail-oa1-f50.google.com [209.85.160.50]) (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 5925948CF2; Mon, 5 Feb 2024 23:58:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707177514; cv=none; b=meDH2kb/3E3OGYy9HvFFJhWrmjG+MXgE0cY9d2+fTp3Ps8/3nivrX0uEkJvRDm2z4rGTR3ra/GBlft50vopFQ97Jl6BvLFMjBnYF433xsOHHV6Z7wQvDXWXaD+mlaXQzcIP/4e9JqRUqjXwgYRy3Zw4SP+fruxkO2k61DNJ3z9g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707177514; c=relaxed/simple; bh=93QXxafaVw5XvGO/nunfJv/0a5KfZBxmrHdx1Ptzq+M=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=jWA44upCpvLWN8B0VGGdLZRla6Y0cZfljYu1LIZ/nKOT6ZShNHVssDQCJymCFnagBzAcsu9A6aW0xe7etAmxlOHU1UBAP5KwV5nWwynGA/WR2nbwPlNP7jc+XAce9JJIoNm+bjQVrwmGEhSBsFY+/YGCxEwbYJlt4G6KXYBiAT0= 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=deCfnlkG; arc=none smtp.client-ip=209.85.160.50 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-oa1-f50.google.com with SMTP id 586e51a60fabf-20503dc09adso3388107fac.2; Mon, 05 Feb 2024 15:58:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707177511; x=1707782311; 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=LtaKsqfpcyHuWJPjZvPw/ChfmsDTwQtI/UDfAaWKaM8=; b=deCfnlkGvThZXSSrL/+2e4zxvV0ZNfCMEGIRpUSktFvbHNrzUdEkq35lORhND5LRQr LS2fP63cddgZoUxIaUSvh2fQ5YiSV2skMoyEaesDCnmaSomClXH21yFuMAoZvNSI5iCt 6bRz5nO8KtL1duQniFQfhbEEY6oPz6mSrceV4uBR+5HqUgppMYvxv3mWs6PT/tWaEbXf Khe6kyaMnwf3yloCnsfsuGEBVVLeZv/uLyeV1c0h7CEDk2HEtvly6CmnnhmxKW+AwDFb /zaXGVyce4tJs2r2aDzsNlcGxqTcmWtD85C4MXBA5txczBmkricOj/xMR7YBx+xCZUVT qpDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707177511; x=1707782311; 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=LtaKsqfpcyHuWJPjZvPw/ChfmsDTwQtI/UDfAaWKaM8=; b=gbWG1OMS9AJVP0e0RKFBMBR6FXB7/SjugZaOvqAvMid3iC0NArraruZoiICIi2MfR7 miQmt7b8lAVQ7x82tx/sixNGZE66YjmFHtC7KasJ77uJbiF7V8N9IuQIIZLkOGEILzXX 5C8Sl1uZku1QEOlJLGJ0/LH1blJdkG5VUDzVBvt/Vyx7dwKdzmiwZp2eBr8vt3JJfKnt 9m01SD9tVc99LFknYvjGFdOPFsdEoO+i9sLPpyV7rGb5YTh2Ws8NavMZx1VSgq8Z4rCo 9MyBBsfDi3uUJWK1gQshsNQmH3NKWrABHhruvsXkxmkV97WL9o23y4c4PgMGcfTgPGG7 M+lw== X-Gm-Message-State: AOJu0Yzzb7TzAZrNIFtkk3U3x1SMkSy+Q3qGQjZdb6aJwsqKza3snjkZ oNTcHz9+Flcw0zHiyw7ZADFVXkPqidYjyccP8/vEn9AmYKM10/QZ X-Received: by 2002:a05:6870:bac7:b0:218:3c0a:7d75 with SMTP id js7-20020a056870bac700b002183c0a7d75mr823025oab.9.1707177511257; Mon, 05 Feb 2024 15:58:31 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCUPExShyc/bRXaRWNwyV382EpjROWLSZRHV+E1tHFlJX4UAhwzw/ml5wc9Zo77/jpdsVTeXv20H4AxQjFvom/yinEOhZBvnsB6r/v0bV9zuri73ASy5SavqSn5P4U1scnqV+K7ETfrwcqeIipUaWvDKZss= Received: from localhost (dhcp-141-239-144-21.hawaiiantel.net. [141.239.144.21]) by smtp.gmail.com with ESMTPSA id g20-20020a635214000000b005d8b89bbf20sm637409pgb.63.2024.02.05.15.58.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 15:58:30 -0800 (PST) Sender: Tejun Heo Date: Mon, 5 Feb 2024 13:58:29 -1000 From: Tejun Heo To: Kent Overstreet , Brian Foster Cc: linux-bcachefs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] bcachefs: Use alloc_ordered_workqueue() to create ordered workqueues Message-ID: 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 BACKGROUND ========== When multiple work items are queued to a workqueue, their execution order doesn't match the queueing order. They may get executed in any order and simultaneously. When fully serialized execution - one by one in the queueing order - is needed, an ordered workqueue should be used which can be created with alloc_ordered_workqueue(). However, alloc_ordered_workqueue() was a later addition. Before it, an ordered workqueue could be obtained by creating an UNBOUND workqueue with @max_active==1. This originally was an implementation side-effect which was broken by 4c16bd327c74 ("workqueue: restore WQ_UNBOUND/max_active==1 to be ordered"). Because there were users that depended on the ordered execution, 5c0338c68706 ("workqueue: restore WQ_UNBOUND/max_active==1 to be ordered") made workqueue allocation path to implicitly promote UNBOUND workqueues w/ @max_active==1 to ordered workqueues. While this has worked okay, overloading the UNBOUND allocation interface this way creates other issues. It's difficult to tell whether a given workqueue actually needs to be ordered and users that legitimately want a min concurrency level wq unexpectedly gets an ordered one instead. With planned UNBOUND workqueue updates to improve execution locality and more prevalence of chiplet designs which can benefit from such improvements, this isn't a state we wanna be in forever. This patch series audits all callsites that create an UNBOUND workqueue w/ @max_active==1 and converts them to alloc_ordered_workqueue() as necessary. WHAT TO LOOK FOR ================ The conversions are from alloc_workqueue(WQ_UNBOUND | flags, 1, args..) to alloc_ordered_workqueue(flags, args...) which don't cause any functional changes. If you know that fully ordered execution is not ncessary, please let me know. I'll drop the conversion and instead add a comment noting the fact to reduce confusion while conversion is in progress. If you aren't fully sure, it's completely fine to let the conversion through. The behavior will stay exactly the same and we can always reconsider later. As there are follow-up workqueue core changes, I'd really appreciate if the patch can be routed through the workqueue tree w/ your acks. Thanks. Signed-off-by: Tejun Heo Cc: Kent Overstreet Cc: Brian Foster --- fs/bcachefs/btree_update_interior.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/fs/bcachefs/btree_update_interior.c +++ b/fs/bcachefs/btree_update_interior.c @@ -2484,7 +2484,7 @@ void bch2_fs_btree_interior_update_init_ int bch2_fs_btree_interior_update_init(struct bch_fs *c) { c->btree_interior_update_worker = - alloc_workqueue("btree_update", WQ_UNBOUND|WQ_MEM_RECLAIM, 1); + alloc_ordered_workqueue("btree_update", WQ_MEM_RECLAIM); if (!c->btree_interior_update_worker) return -BCH_ERR_ENOMEM_btree_interior_update_worker_init;