Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp1020000rdg; Fri, 11 Aug 2023 07:23:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFJGjpJH4P+lTStbOEPlisHDZ1/SiSMbZj3+yWHtFm5igYIVNbE6xXmGHkOd2G/dQKpk81g X-Received: by 2002:a05:6512:344e:b0:4f8:66e1:14e8 with SMTP id j14-20020a056512344e00b004f866e114e8mr1301447lfr.69.1691763830789; Fri, 11 Aug 2023 07:23:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691763830; cv=none; d=google.com; s=arc-20160816; b=fb4IkPSQl22uOzagAh1nOtn75spu1Ff0aFQw39FF1nmgt2HYl9IuFw1MhEEBikJG+T 1GkBqSP8O15/QMyNZTt1EwniWxSv17wyhEv3qAmqnKBsZ7y6GCOHo0TldDCR2C7ojXFi aS+EJVFOJnNphQzOmeKrHUMVAFgEM9gRkOIDzINjLHtrpWWcpU3EeQXoZzQVMT+NOpDG SHWDOnkrZCOlGwg9UtYegA3KgfTbiHG2w1fK1Hpc/qqqeeyd7q8eKGEBRgjhHwwzGU3Z sNYbpDwdAV/AOBvkLcZYU0TLazDHkV4G0DQ4InmDyEb0/AufBqakTeHmI/eVHG83WAhO neWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=JKMe7QOfDZfok/upygmjGwOjr892lvPjR2yP8zs7qj4=; fh=fXxcka4ttcRjf8y/QNeUVBVR3n8KtaOL7ehuC2YQY+g=; b=K/P5bPNpGlzVzjKhNTOUq52QoSj7KndfdKsde4Mdw4onPzCCoZSs6iuPaGYBbqwc+4 tloa4S3RMynGFO3fgExzTZN/rajgmrgh7MDGCg/BmBPWq96k8nphK+RGqXZJk7HSz81m iqla1wBJ01745npodKG4BFxyR/efzk6UeoyjZoHcQfM2vNoOfFUhvvWacvnb9cIqU/zc WjPm7kDvz+B5XpeUttuSPi6jsstLQKEBBLVULyTUDWmJ8sL4Cr4R8ML0viCGuegDF086 YZBYsgH3aIrINpidBBpNW2gCAIo2PVl5qeSA66ec1GUxQ16RgrX2J16DjjbpHNr8O1G8 W0bA== 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; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n12-20020a05640206cc00b0052322c96a40si3393602edy.472.2023.08.11.07.23.26; Fri, 11 Aug 2023 07:23:50 -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; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234470AbjHKOKx (ORCPT + 99 others); Fri, 11 Aug 2023 10:10:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234620AbjHKOKu (ORCPT ); Fri, 11 Aug 2023 10:10:50 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5383C2696 for ; Fri, 11 Aug 2023 07:10:50 -0700 (PDT) Received: from kwepemm600009.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4RMlzK587XzrSQY for ; Fri, 11 Aug 2023 22:09:33 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by kwepemm600009.china.huawei.com (7.193.23.164) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Fri, 11 Aug 2023 22:10:47 +0800 From: Weili Qian To: CC: , , , Weili Qian Subject: [PATCH v2 5/7] crypto: hisilicon/qm - prevent soft lockup in qm_poll_req_cb()'s loop Date: Fri, 11 Aug 2023 22:07:47 +0800 Message-ID: <20230811140749.5202-6-qianweili@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230811140749.5202-1-qianweili@huawei.com> References: <20230811140749.5202-1-qianweili@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.69.192.56] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemm600009.china.huawei.com (7.193.23.164) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 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 The function qm_poll_req_cb() may take a while due to complex req_cb, so soft lockup may occur in kernel with preemption disabled. The error logs: watchdog: BUG: soft lockup - CPU#23 stuck for 23s! [kworker/u262:1:1407] [ 1461.978428][ C23] Call trace: [ 1461.981890][ C23] complete+0x8c/0xf0 [ 1461.986031][ C23] kcryptd_async_done+0x154/0x1f4 [dm_crypt] [ 1461.992154][ C23] sec_skcipher_callback+0x7c/0xf4 [hisi_sec2] [ 1461.998446][ C23] sec_req_cb+0x104/0x1f4 [hisi_sec2] [ 1462.003950][ C23] qm_poll_req_cb+0xcc/0x150 [hisi_qm] [ 1462.009531][ C23] qm_work_process+0x60/0xc0 [hisi_qm] [ 1462.015101][ C23] process_one_work+0x1c4/0x470 [ 1462.020052][ C23] worker_thread+0x150/0x3c4 [ 1462.024735][ C23] kthread+0x108/0x13c [ 1462.028889][ C23] ret_from_fork+0x10/0x18 Add a cond_resched() to prevent that. Signed-off-by: Weili Qian --- drivers/crypto/hisilicon/qm.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/crypto/hisilicon/qm.c b/drivers/crypto/hisilicon/qm.c index 376f6a3c5c7f..c9ed30b181bb 100755 --- a/drivers/crypto/hisilicon/qm.c +++ b/drivers/crypto/hisilicon/qm.c @@ -958,6 +958,8 @@ static void qm_poll_req_cb(struct hisi_qp *qp) qm_db(qm, qp->qp_id, QM_DOORBELL_CMD_CQ, qp->qp_status.cq_head, 0); atomic_dec(&qp->qp_status.used); + + cond_resched(); } /* set c_flag */ -- 2.33.0