Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp119121rdh; Wed, 25 Oct 2023 18:46:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEQUU/+XF6RKMz3staKwF9RQ1HHE7dw+B3bCgCJeMwDghwKqmT9rXVDJ472Cv3fzbtGeO+9 X-Received: by 2002:a05:620a:471e:b0:76c:da86:3169 with SMTP id bs30-20020a05620a471e00b0076cda863169mr20363158qkb.40.1698284781000; Wed, 25 Oct 2023 18:46:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698284780; cv=none; d=google.com; s=arc-20160816; b=qK4by8CZfo6uVcqexpeKRhzE/X/QQeXU1pF+jpip3JOTUipDS1DHyt3ovSeSaFU3kN 7CuJBSNzWoN3f4rPNJ3thFZmqFS0MbN4bvKllv0/PKaA9o5hJigy+ZLy4HqI9UPySEO/ c91nA6tZKnF2MCeInxIOv6ReYXtH9lKWoWz0gdIB4iRjqnyEkDszzEx53anJkPm2HLjv zX1tuN1hReNVD6EEu3zBYGM4qQ8oT1xj3NB0SwfVF/oUdJbJRTB1rnRYXGt7KSxJDhtu Z7NMijotl64KBzJoV23w2SEF/AqGOAcrfcf5RQA3Xz1BFzbqo6ZBSm0VVONsl2MjtaIj Mdzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=gt9ViGS7ZcdgLORd86Jptb0EPMtsTQOxDdQLwpP71z8=; fh=52ExxW9obACgYvMbnqLF2MtAlILsePU20osSqdrhemQ=; b=QwDwHcI+gorMm05jv1xphheRqEqVTbcBrsxbbHpMl23ycuHXypFvakYhIT0cvU++7u CFo5cUqgITy/j3vGpefzkc64V+UzHwvaOxvNcy7+CHKl0RGrvBMgdVbnfwKhJ2627c7X ragcsEl67j0L1G+R+ERK1011cDBKbo3k1+I9ScxwcjsLOd9IfgQ1ZJvVv7xqnIpthY5v BtcrnzLq0A8VQJARZJSdY0CuhdTuG0JGLUlneQzy/1QQExLiDlJbuS3ECYFao2Ar7dlU l4NRz3smCX72RsdX88YlT/yph+7/pXEi5PPYgM9bQZP4M3WiYGm6WjKGnBHeYHmmz5/9 ON1A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id l76-20020a0de24f000000b005a7a8e90d3esi12617534ywe.152.2023.10.25.18.46.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 18:46:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id EBF22807293E; Wed, 25 Oct 2023 18:45:35 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230028AbjJZBpZ (ORCPT + 99 others); Wed, 25 Oct 2023 21:45:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229638AbjJZBpZ (ORCPT ); Wed, 25 Oct 2023 21:45:25 -0400 Received: from wxsgout04.xfusion.com (wxsgout04.xfusion.com [36.139.87.180]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B571BD; Wed, 25 Oct 2023 18:45:22 -0700 (PDT) Received: from wuxshcsitd00600.xfusion.com (unknown [10.32.133.213]) by wxsgout04.xfusion.com (SkyGuard) with ESMTPS id 4SG7pW2zRkz9yNtn; Thu, 26 Oct 2023 09:42:43 +0800 (CST) Received: from localhost (10.82.147.3) by wuxshcsitd00600.xfusion.com (10.32.133.213) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Thu, 26 Oct 2023 09:45:18 +0800 Date: Thu, 26 Oct 2023 09:45:18 +0800 From: Wang Jinchao To: Daniel Jordan CC: Steffen Klassert , , , Subject: Re: [RFC/REFACT] Refactoring and significantly reducing code complexity Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: X-Originating-IP: [10.82.147.3] X-ClientProxiedBy: wuxshcsitd00602.xfusion.com (10.32.132.250) To wuxshcsitd00600.xfusion.com (10.32.133.213) X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Wed, 25 Oct 2023 18:45:36 -0700 (PDT) On Thu, Oct 26, 2023 at 09:12:54AM +0800, Wang Jinchao wrote: > On Wed, Oct 25, 2023 at 02:12:31PM -0400, Daniel Jordan wrote: > > On Thu, Sep 28, 2023 at 04:53:38PM +0800, Wang Jinchao wrote: > > > -/** > > > - * struct parallel_data - Internal control structure, covers everything > > > - * that depends on the cpumask in use. > > > - * > > > - * @ps: padata_shell object. > > > - * @reorder_list: percpu reorder lists > > > - * @squeue: percpu padata queues used for serialuzation. > > > - * @refcnt: Number of objects holding a reference on this parallel_data. > > > - * @seq_nr: Sequence number of the parallelized data object. > > > - * @processed: Number of already processed objects. > > > - * @cpu: Next CPU to be processed. > > > - * @cpumask: The cpumasks in use for parallel and serial workers. > > > - * @reorder_work: work struct for reordering. > > > - * @lock: Reorder lock. > > > - */ > > > -struct parallel_data { > > > - struct padata_shell *ps; > > > - struct padata_list __percpu *reorder_list; > > > - struct padata_serial_queue __percpu *squeue; > > > - refcount_t refcnt; > > > - unsigned int seq_nr; > > > - unsigned int processed; > > > - int cpu; > > > - struct padata_cpumask cpumask; > > > - struct work_struct reorder_work; > > > - spinlock_t ____cacheline_aligned lock; > > > -}; > > > > reorder_list used to serialize one sequence of objects per padata_shell, > > but now serial_wq serializes all sequences of objects in one list of > > work_structs. That works in theory, since a total order can maintain > > each sequence's order, but it's possible (not sure yet, need to think > > more) that this could lead to deadlocks or other issues in odd cases > > such as the one that padata_shell was introduced for in bbefa1dd6a6d > > ("crypto: pcrypt - Avoid deadlock by using per-instance padata queues"). > > > Yes, you are correct. This version is not only ordered at the padata_shell > level but at the instance level, which indeed doesn't align with the design. > Apart from potential deadlocks, it may also cause a padata_shell_B that > should have completed earlier to be blocked by an unrelated padata_shell_B. > I will address this issue in subsequent patches. Apart from potential deadlocks, it may also cause a padata_shell_B that should have completed earlier to be blocked by an unrelated padata_shell_A. I will address this issue in subsequent patches.