Received: by 2002:a05:7412:1492:b0:e2:908c:2ebd with SMTP id s18csp445774rdh; Wed, 23 Aug 2023 05:07:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGg/4WRDol41mrb+swPIJAjtc0yZRgl8LFW3SXVb4jhmS2ubiM1ykR670jCnUBxelQR9Mg6 X-Received: by 2002:a17:902:e9c2:b0:1bd:fa80:103d with SMTP id 2-20020a170902e9c200b001bdfa80103dmr9666746plk.25.1692792427214; Wed, 23 Aug 2023 05:07:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692792427; cv=none; d=google.com; s=arc-20160816; b=lxAFWea/2BakZOFPM7vBGdwCmLDx2woOw+lbEX29ct3qImoLl0XIsMjLYF1Fva5wkk C04n4k4eIuyHEXw/r1hWmSXmtxJ8Lm3fLx5XAJw6CdwLvTq6S8wUgz4Lv4PDG25hZyh2 3dfz+plOSe0ceeHTdnE3BLEC6pIMunRg3CXK7vYFyCXHsW5rld1R4pvJ/aTgKXUwubhP xb5WsMVdTQGH95N0YXNClj/hzXuDYoUqvukUUxKLMiwXUPy2ink3RSTc1X9uVW0URo4J gCR8vf56vX3acBimx2DBveUwuU76pkcT51LOH6FLhBFZO30Tg1JD29B5M+pvquB8WjiY 58ZA== 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=cMs5NBckVAS7SrR6vz+yKzN58PkGR8aNibZyI79Aljs=; fh=iHyqMrvcwx6u0/zjCP29HQFOWd+aXWd9XbkGG2+7EBs=; b=1HeY0Gh9uI4lyqTzUlJJjN0cy4uf4Z0yTbA7aSlU0ZFlg8zJqG4sepcGXQi7R4ExbJ 8EOwVsrxmnwTZTXkrBkCe1z3heoC1TBtZ0Jcvi0KwM4MAzvgpbpJK+aKnQfY1jcHTQdp gXlz3c7H6mpAYrn5SUZJV3BA+uWjzdVNq/jwQ/wyIz5Er+1O29MVPXMgvHLMv/KfNOh0 vvxbDaA0Tp78/tdpmZUPDQ6KNNCYCz8jtbWuKGAg4r0QnDTdLDVmf2WyMqDv7qfXhiIm sLrPsk55EOe9/Q7T0UaK11N9kC+GO5vG3nKJJJd/wrxY2x7DsFQrTQJTrrKx1cU1ok15 R85Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e12-20020a170902e0cc00b001bc7d717ac4si10402307pla.104.2023.08.23.05.06.48; Wed, 23 Aug 2023 05:07:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236057AbjHWJvT (ORCPT + 99 others); Wed, 23 Aug 2023 05:51:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235980AbjHWJs7 (ORCPT ); Wed, 23 Aug 2023 05:48:59 -0400 Received: from 167-179-156-38.a7b39c.syd.nbn.aussiebb.net (167-179-156-38.a7b39c.syd.nbn.aussiebb.net [167.179.156.38]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B063B210A for ; Wed, 23 Aug 2023 02:28:41 -0700 (PDT) Received: from loth.rohan.me.apana.org.au ([192.168.167.2]) by formenos.hmeau.com with smtp (Exim 4.94.2 #2 (Debian)) id 1qYkA1-006tnc-VF; Wed, 23 Aug 2023 17:28:23 +0800 Received: by loth.rohan.me.apana.org.au (sSMTP sendmail emulation); Wed, 23 Aug 2023 17:28:22 +0800 Date: Wed, 23 Aug 2023 17:28:22 +0800 From: Herbert Xu To: Lu Jialin Cc: Steffen Klassert , Daniel Jordan , "David S . Miller" , Guo Zihua , linux-crypto@vger.kernel.org Subject: Re: [PATCH v2] crypto: Fix hungtask for PADATA_RESET Message-ID: References: <20230823073047.1515137-1-lujialin4@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230823073047.1515137-1-lujialin4@huawei.com> X-Spam-Status: No, score=2.7 required=5.0 tests=BAYES_00,HELO_DYNAMIC_IPADDR2, PDS_RDNS_DYNAMIC_FP,RCVD_IN_DNSWL_BLOCKED,RDNS_DYNAMIC,SPF_HELO_NONE, SPF_PASS,TVD_RCVD_IP,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Wed, Aug 23, 2023 at 07:30:47AM +0000, Lu Jialin wrote: > We found a hungtask bug in test_aead_vec_cfg as follows: > > INFO: task cryptomgr_test:391009 blocked for more than 120 seconds. > "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. > Call trace: > __switch_to+0x98/0xe0 > __schedule+0x6c4/0xf40 > schedule+0xd8/0x1b4 > schedule_timeout+0x474/0x560 > wait_for_common+0x368/0x4e0 > wait_for_completion+0x20/0x30 > test_aead_vec_cfg+0xab4/0xd50 > test_aead+0x144/0x1f0 > alg_test_aead+0xd8/0x1e0 > alg_test+0x634/0x890 > cryptomgr_test+0x40/0x70 > kthread+0x1e0/0x220 > ret_from_fork+0x10/0x18 > Kernel panic - not syncing: hung_task: blocked tasks > > For padata_do_parallel, when the return err is 0 or -EBUSY, it will call > wait_for_completion(&wait->completion) in test_aead_vec_cfg. In normal > case, aead_request_complete() will be called in pcrypt_aead_serial and the > return err is 0 for padata_do_parallel. But, when pinst->flags is > PADATA_RESET, the return err is -EBUSY for padata_do_parallel, and it > won't call aead_request_complete(). Therefore, test_aead_vec_cfg will > hung at wait_for_completion(&wait->completion), which will cause > hungtask. > > The problem comes as following: > (padata_do_parallel) | > rcu_read_lock_bh(); | > err = -EINVAL; | (padata_replace) > | pinst->flags |= PADATA_RESET; > err = -EBUSY | > if (pinst->flags & PADATA_RESET) | > rcu_read_unlock_bh() | > return err > > In order to resolve the problem, we retry at most 5 times when > padata_do_parallel return -EBUSY. For more than 5 times, we replace the > return err -EBUSY with -EAGAIN, which means parallel_data is changing, and > the caller should call it again. Steffen, should we retry this at all? Or should it just fail as it did before? Thanks, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt