Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0356DC6FD1D for ; Thu, 23 Mar 2023 08:07:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230281AbjCWIHu (ORCPT ); Thu, 23 Mar 2023 04:07:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229500AbjCWIHt (ORCPT ); Thu, 23 Mar 2023 04:07:49 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E86B19F22 for ; Thu, 23 Mar 2023 01:07:44 -0700 (PDT) Received: from [0.0.0.0] ([149.28.201.231]) by mail.gmx.net (mrgmx105 [212.227.17.174]) with ESMTPSA (Nemesis) id 1MlNp7-1qKOhV3snF-00lp48; Thu, 23 Mar 2023 09:07:33 +0100 Message-ID: Date: Thu, 23 Mar 2023 16:07:28 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: Re: [PATCH 03/10] btrfs: offload all write I/O completions to a workqueue Content-Language: en-US To: Christoph Hellwig Cc: Chris Mason , Josef Bacik , David Sterba , Johannes Thumshirn , linux-btrfs@vger.kernel.org References: <20230314165910.373347-1-hch@lst.de> <20230314165910.373347-4-hch@lst.de> <2aa047a7-984e-8f6f-163e-8fe6d12a41d8@gmx.com> <20230320123059.GB9008@lst.de> <20230321125550.GB10470@lst.de> <5eebb0fc-0be3-c313-27cd-4e11a7b04405@gmx.com> <20230322083258.GA23315@lst.de> From: Qu Wenruo In-Reply-To: <20230322083258.GA23315@lst.de> Content-Type: text/plain; charset=UTF-8; format=flowed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/PxQGLu05ZymdpMU5NQiLmSg6t6liOusEuvhzXZ5OSCCfWW+F tC7owhoTNj5pku0J/+OxmN1XbNbTFDT2e3qVLnJV0aw3r0ZwqJk32ROX0StRkyohvjzVweou2 2i1b1JUlIgtMrNkWEM0q5zls36GoAFpsRth7mNN5fmHtcvWyNXZlSUAx0WIvL+AbkT1FesCbZ TEnrHY1NcpdqWUHHWGTX9DpYZEM= Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org On 2023/3/22 16:32, Christoph Hellwig wrote: > On Wed, Mar 22, 2023 at 07:37:07AM +0800, Qu Wenruo wrote: >>> If you limit max_active to a certain value, you clearly tell the >>> workqueue code not not use more workers that that. That is what the >>> argument is for. >> >> And if a work load can only be deadlock free using the default max_active, >> but not any value smaller, then I'd say the work load itself is buggy. > > Anything that has an interaction between two instances of a work_struct > can deadlock. Only a single execution context is guaranteed (and even > that only with WQ_MEM_RECLAIM), and we've seen plenty of deadlocks due > to e.g. only using a global workqueue in file systems or block devices > that can stack. Shouldn't we avoid such cross workqueue workload at all cost? IIRC at least we don't have such usage in btrfs. And I hope we will never have. > > Fortunately these days lockdep is generally able to catch these > dependencies as well. > >> The usecase is still there. >> To limit the amount of CPU time spent by btrfs workloads, from csum >> verification to compression. > > So this is the first time I see an actual explanation, thanks for that > first. If this is the reason we should apply the max_active to all > workqueus that do csum an compression work, but not to other random > workqueues. If we're limiting the max_active for certain workqueues, then I'd say why not to all workqueues? If we have some usage relying on the amount of workers, at least we should be able to expose it and fix it. (IIRC we should have a better way with less cross-workqueue dependency) Thanks, Qu > > Dave, Josef, Chis: do you agree to this interpretation?