Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1658375iog; Sat, 25 Jun 2022 15:55:37 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vncXFMe5XvwX6fXl7Yyo3xvV8Oj3awIky0TOMXNQtCx29MZFc0x8cxN8QVRaSsSsQePoDD X-Received: by 2002:a17:902:a9c9:b0:161:5b73:5ac9 with SMTP id b9-20020a170902a9c900b001615b735ac9mr6367752plr.14.1656197737172; Sat, 25 Jun 2022 15:55:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656197737; cv=none; d=google.com; s=arc-20160816; b=gDLHVFNA2awAZdfrwcbHY8RQaeyEdiXKq7eB91VGBiW+7qAzmUXA9w0qZ+i5vgMfXH hmx8+h2TO6kHNXec9mGbBpDlvekv7zoE4/yRwXXuXesD8im/4v/Do2KWAMrpLKoMjYi5 wp+BlZaeODgAYBVMTQQ+nnxM97TXBwD+FoTANluAcoaHnfXSCJcXCkB4rgtEn9/B8ner v65gqWF/YSrIwcixQwK3uOQYWkAmeY2c2fn3YDHfCsO/kM5b/YtgcLSY1XeSIfMs+Mjw aCFUt1C9dDdihsLhiucEdOW9HttFQnJHmb/4dmfkg/42WP+KkVQBBRsbz1pA8PGOSTDg TVRQ== 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 :message-id:date:subject:cc:to:from; bh=/CwAT29jZT+04p78Y6Fhzc2wdRdIzPRIIF4Z4J3hpTU=; b=QQdrNQlNqV50q9WheUHfiALzkCJrUW8+bP9HeOK2RmMaBFRq1axKZCR3ZV9wxJUMlN AVa2FIk447rURIHF3vTLcANPwmrS7L9Zie50sRnOT+jHIuh2CEp8vLDB4B7FwxCCqlUL kU8TmWcM2SeGaMahaML2SU71gbU6ZHf3a62TscSuuEQt+cFCzmfsgmY66QULIYY7Po9n KbPYKiuQO3PLFrVATPqJ9z4pakdd0g6BBzINiDhpBU4UwAfkXrOWvg4QTUKQplFv89dJ d7onD4d+V4tiSOOCI5hkiiGa+VeWwuOH0slS1OzNjfD44icYweten5qX7qTqqp4J5LLj WSIw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-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 be5-20020a170902aa0500b00153b2d164fbsi8177633plb.259.2022.06.25.15.55.18; Sat, 25 Jun 2022 15:55:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233555AbiFYWuL (ORCPT + 99 others); Sat, 25 Jun 2022 18:50:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233530AbiFYWuK (ORCPT ); Sat, 25 Jun 2022 18:50:10 -0400 Received: from mail.meizu.com (edge05.meizu.com [157.122.146.251]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8215313DF4 for ; Sat, 25 Jun 2022 15:50:08 -0700 (PDT) Received: from IT-EXMB-1-125.meizu.com (172.16.1.125) by mz-mail12.meizu.com (172.16.1.108) with Microsoft SMTP Server (TLS) id 14.3.487.0; Sun, 26 Jun 2022 06:50:08 +0800 Received: from localhost.localdomain (172.16.255.36) by IT-EXMB-1-125.meizu.com (172.16.1.125) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.14; Sun, 26 Jun 2022 06:50:05 +0800 From: Yuwen Chen To: CC: , , , Yuwen Chen Subject: [PATCH] erofs: Wake up all waiters after z_erofs_lzma_head ready. Date: Sat, 25 Jun 2022 22:50:00 +0800 Message-ID: <20220625145000.2720-1-chenyuwen1@meizu.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [172.16.255.36] X-ClientProxiedBy: IT-EXMB-1-126.meizu.com (172.16.1.126) To IT-EXMB-1-125.meizu.com (172.16.1.125) X-Spam-Status: No, score=0.3 required=5.0 tests=BAYES_00,DATE_IN_PAST_06_12, KHOP_HELO_FCRDNS,SPF_HELO_NONE,SPF_SOFTFAIL,T_SCC_BODY_TEXT_LINE autolearn=no 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-kernel@vger.kernel.org When the user mounts the erofs second times, the decompression thread may hung. The problem happens due to a sequence of steps like the following: 1) Task A called z_erofs_load_lzma_config which obtain all of the node from the z_erofs_lzma_head. 2) At this time, task B called the z_erofs_lzma_decompress and wanted to get a node. But the z_erofs_lzma_head was empty, the Task B had to sleep. 3) Task A release nodes and push nodes into the z_erofs_lzma_head. But task B was still sleeping. One example report when the hung happens: task:kworker/u3:1 state:D stack:14384 pid: 86 ppid: 2 flags:0x00004000 Workqueue: erofs_unzipd z_erofs_decompressqueue_work Call Trace: __schedule+0x281/0x760 schedule+0x49/0xb0 z_erofs_lzma_decompress+0x4bc/0x580 ? cpu_core_flags+0x10/0x10 z_erofs_decompress_pcluster+0x49b/0xba0 ? __update_load_avg_se+0x2b0/0x330 ? __update_load_avg_se+0x2b0/0x330 ? update_load_avg+0x5f/0x690 ? update_load_avg+0x5f/0x690 ? set_next_entity+0xbd/0x110 ? _raw_spin_unlock+0xd/0x20 z_erofs_decompress_queue.isra.0+0x2e/0x50 z_erofs_decompressqueue_work+0x30/0x60 process_one_work+0x1d3/0x3a0 worker_thread+0x45/0x3a0 ? process_one_work+0x3a0/0x3a0 kthread+0xe2/0x110 ? kthread_complete_and_exit+0x20/0x20 ret_from_fork+0x22/0x30 Signed-off-by: Yuwen Chen --- fs/erofs/decompressor_lzma.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/erofs/decompressor_lzma.c b/fs/erofs/decompressor_lzma.c index 05a3063cf2bc..5e59b3f523eb 100644 --- a/fs/erofs/decompressor_lzma.c +++ b/fs/erofs/decompressor_lzma.c @@ -143,6 +143,7 @@ int z_erofs_load_lzma_config(struct super_block *sb, DBG_BUGON(z_erofs_lzma_head); z_erofs_lzma_head = head; spin_unlock(&z_erofs_lzma_lock); + wake_up_all(&z_erofs_lzma_wq); z_erofs_lzma_max_dictsize = dict_size; mutex_unlock(&lzma_resize_mutex); -- 2.25.1