Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp2724962rdb; Mon, 5 Feb 2024 16:10:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IENd3BORmQpvIqW8QjCWHufJTFRm9KpqJfqP1GaT291/zWwMvDltctZyUmh3/C4WRrXrnuD X-Received: by 2002:ac8:619a:0:b0:42c:2147:b525 with SMTP id kq26-20020ac8619a000000b0042c2147b525mr1838441qtb.18.1707178241386; Mon, 05 Feb 2024 16:10:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707178241; cv=pass; d=google.com; s=arc-20160816; b=RxBgEDMdUQipOHV7dlWDNFIw9SnXtOMn25cFL/bP84YfNZHBi3SUWqnr88UHb2dU3j stmn1j5igiAyIrphEXO2VkCU4N2s75FpjPv1ubQ5N27Q3z8ArzMqR/hKXU155aMvgvKi stMlXbLfPZt3YoQ8lY/SKfOvd7mBd702tqEAr3G4QFMY3isubA4JyO/1eRlz4gOHXwGA k9ZLtTTynvxNM308FVE3HmId2QkfLqlg/CWctIbKaCwiSXGCxEubn4b4Cn4jbX/F6LSP VTnpaIB5U/iPI+uP2wu6/BzV9aFnY/cwv0j8c3bnPvl/R4NY9fpiO8cwOk7XuRdHPord Qftg== 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:dkim-signature:date; bh=DGtsKhqTTNpaIDjq1vKDcZl0fR89t64g8nFeZ7iH1Uo=; fh=g6I9RMks140b9f8jCUzXy9MHTIA9dv5GguO7GweVc54=; b=tYsNnDtYAsyBoCJqK+L0Q/ZpXtuLAbqc4Y0k4u6ojYeU9z4ErhhAMyjaOnLXqlzJuG rBNezraXD66AqVhKMkeW8CdE7FGp3FjFAoDq8c85jb+z8A7Nw7xsiKrTlQoPXQD9f1yl AyOA0ftF7U/YMAIbxbCZtYOyx04cDjTtnbPKyCUml+FERx2piqitbs5Gdiy9lYqr/RdK u5S5WkWjl2Wqgcjt50UwA/F8eDoQYSk8zV1qGMnXJwZ7Lx/GRx3a+o9mJiCMMy8pbE8x GtRRTCllgfCLx4EnM49/4a8GVeyjVpKHRRRr+kq2vaj3ss1mxu+D5/eu8KRDi88oaiqI h+nQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=qOsAQHWA; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-54112-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-54112-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev X-Forwarded-Encrypted: i=1; AJvYcCXCikbI5WRgqet/GvSju/0wPKGN+jRP99P3whoZES+3GIsWes0CSxBWPtmx1G9gaO10yl8G7XnFPNdIw+ZAz/vP9eD/uivCsCUHYnNDsw== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id f9-20020a05622a1a0900b0042c0b76723dsi1153817qtb.588.2024.02.05.16.10.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 16:10:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-54112-linux.lists.archive=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=@linux.dev header.s=key1 header.b=qOsAQHWA; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-54112-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-54112-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev 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 198B11C234DB for ; Tue, 6 Feb 2024 00:10:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 11C8015C0; Tue, 6 Feb 2024 00:10:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="qOsAQHWA" Received: from out-171.mta0.migadu.com (out-171.mta0.migadu.com [91.218.175.171]) (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 54B8D1362 for ; Tue, 6 Feb 2024 00:10:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707178235; cv=none; b=QQ908hflrd6/arLqJJNuY98BHT9nUBR/+j3QpAsBpAMartku8FWGHayAXImZDQYOSbs+cHyHS3BqMv0x3iecbJW+NidbldvxL0N0tsDAOMrAJub1TX4ECdIsh8r5YUcwrBI+vWOF7rG+/sglgrWIivip2IrwDKIX0+ukVAKKWPc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707178235; c=relaxed/simple; bh=mY3kM4wkEcCfDb8VcAjk8TVVa8cwcy1QsEtwBHhbYzg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=uUZdI4tSnv5RGEbUn9C1yQ03uYqOUsbG2+svvVrQGvMml3Ca77GDzjlzFcGU/vLqxKAC/5m+QHIQaK2xPkINM8lTSoINTLFc43AD/j3eZnctU/jd/uDCF0XAkA+1pW1pYxObrWDNaEdvM7vwNHJO/a17b1cgWf21nDhHRWG92OE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=qOsAQHWA; arc=none smtp.client-ip=91.218.175.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Date: Mon, 5 Feb 2024 19:10:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1707178230; 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=DGtsKhqTTNpaIDjq1vKDcZl0fR89t64g8nFeZ7iH1Uo=; b=qOsAQHWA4L0Bjk0srxhctSJinauhHQq3yXq31wFyts011eQd0XotTcMs9/2pJAELDGFVlO +gvRWbGsZu901GPSYhTcIDa5qwfyhacsCN/Zd3tpbmvAsrYykcild9nfaX16ERyxHORLbI U4OWXlFzMf1Kl6MpbbiZnik839L+nKw= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Kent Overstreet To: Tejun Heo Cc: Brian Foster , linux-bcachefs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] bcachefs: Use alloc_ordered_workqueue() to create ordered workqueues Message-ID: References: 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: X-Migadu-Flow: FLOW_OUT On Mon, Feb 05, 2024 at 01:58:29PM -1000, Tejun Heo wrote: > 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; > This one doesn't actually need to be ordered - if anything, we might want to bump up max_active. Tejun, can you drop this patch? If you're trying to get rid of all WQ_UNBOUND with max_active=1 workqueues for your own auditing, either you or I could change that to 8.