Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp108205rdh; Wed, 25 Oct 2023 18:13:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGD4+/uWhVONw14fW3CN+Efaz6q5v0EJE5hA5h4bMAk8k1Tabyqmxq0hYzAIGXEEgaLS1tM X-Received: by 2002:a25:7656:0:b0:d9a:3f66:1b16 with SMTP id r83-20020a257656000000b00d9a3f661b16mr2503264ybc.27.1698282832045; Wed, 25 Oct 2023 18:13:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698282832; cv=none; d=google.com; s=arc-20160816; b=lp4AFh6aFFLVbXMvKe+n10Xzz7zSFu/EbodyZ8dN1IP93+1h7ZKz/1TAp8LdSrIsAU 0x0OBQXxrx/UN6jWPvsMOD8QK15KtPa9UrgBQ90AVC49yde/MgOQvK3LHsJVEAT871ro pNU5iSdOqt2nVWiIxD+W+9V9SuDc/2HqUxRt0DxZLeWpBsQ6ac973xexluqN7roaxphZ pZkGc/iHrXcIeEDImt22NvDUqX/tH+Ih+WYqCUVoKxcdj7T0fNg+vo9Bdhk1TuW9bMQj zBHd4jpxIGsNSQ7pzH/jCOhpTMOdcWILexMfpUqIpF3dg/KiIotnhf2RiJyQLGxB04ZR uizA== 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=mGVzyThCeMsq1Ql/qWp3Hv0sRwMs5TH21XawzUNxYmY=; fh=52ExxW9obACgYvMbnqLF2MtAlILsePU20osSqdrhemQ=; b=LTs+2HDGMuOEytonN2fxJegq0bwei4g5P/ApnKwY16rfxzhvo9oOATM5KqTlqu4cDO lmOARMguNy+C32NGje5Mfc6n6ZsjoSsMhwUhn+xPxCYo1aCwQjwuLwZ/98eMPGWipA4S sKcaCRU7j8Tpp84/dQRjn5cir8U3Mu60s4Fa0dLPtSM2iVYGOcBu4XMup4EdRNPptKTq sNK2BE2BERrEKJw0fCFvvitNUL12SVUjHPyAdF6k5YuZKm8KBy3BCgFoI2pM5RLxaYSI iSKeXvDIRuGG7VIdeso7jXtb9QrsSYXs9sr4aKNFgc/hkYDKjGsapvA+jN+bl+3WJnN4 +gdg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id w20-20020a25ac14000000b00d9caba4deb1si12153909ybi.23.2023.10.25.18.13.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 18:13:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id C30BE803FC1E; Wed, 25 Oct 2023 18:13:45 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229554AbjJZBNf (ORCPT + 99 others); Wed, 25 Oct 2023 21:13:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229638AbjJZBNe (ORCPT ); Wed, 25 Oct 2023 21:13:34 -0400 Received: from wxsgout04.xfusion.com (wxsgout03.xfusion.com [36.139.52.80]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 94A2AA4; Wed, 25 Oct 2023 18:13:31 -0700 (PDT) Received: from wuxshcsitd00600.xfusion.com (unknown [10.32.133.213]) by wxsgout04.xfusion.com (SkyGuard) with ESMTPS id 4SG75F2FpWz9xn2W; Thu, 26 Oct 2023 09:10:25 +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:12:54 +0800 Date: Thu, 26 Oct 2023 09:12:54 +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 agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Wed, 25 Oct 2023 18:13:45 -0700 (PDT) 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.