Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp1182490ybf; Thu, 27 Feb 2020 06:27:06 -0800 (PST) X-Google-Smtp-Source: APXvYqwTy77iR+QpRae19yylMjKMJiTiTHo3eq12e7Ppe5/R/MDaDsw/6ExJ2hstAMTTxUc33uRE X-Received: by 2002:aca:b1d5:: with SMTP id a204mr3467102oif.82.1582813626524; Thu, 27 Feb 2020 06:27:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582813626; cv=none; d=google.com; s=arc-20160816; b=ENSKC9ytTVeu3MiAUpCspg/cT20/Nf+YSIE0IlSd3aBmXI06aigxTwMZkWmtXncKwy 5pF0zKQAPRLRBhkThfoivIYx14EysqXKlIN05xfzubofzmmA/SVP82OAfb7UDK9MFwgK 2WhYa8jXNTfq0UZnBCM1k6j0KSJMMx3MaujFOo1OS8riQO9LHs/Bi9WGCq/eVGKryD4K jZjz7/eyUPv3+xXsRfFz09bRWLcwimXMibTrNdoN8RyU03bZ6tAHjOvFeAHKE68K0CmI fV/JmzTR0+0dyVlNb4aWOl3lWaV5FDdeF01HWxz9FH89Ub1uy2OlZqiuEiF1aJ8DNtDC ee/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=6EV7PHXD7mnsbz0vUaf6w9+02kn5hCeksewiZktXz0o=; b=TBtfshKa0qhntk9GhBogbkDOr4Q2s6TQ+eW8GaJLC0uSnLMu6EhciGQjA05NI8AxwF 8PdJ1+pymjEKta3o5O8Bshovce8uL/rJclws6KHbbD8CH5CTeswYxe0hn6VVtWVwfzlb 5EiOu+6y7AlTSItAU0HXJ0mu7/s0Oxf9K5qLK5upGxZ9yg+iZ1jN2Wbqmd7N+WGTcUyt RxQtjVoDWkAja5O2q6xfx5I1i2WWoSI77YvAefEtaOH1sOmS5lIELyaKeMs78bM73/mW +TpjrDfR2k8DdNeXEwEbNdW8+8dfsD9gFk3FgddkapTXBaV3TumB2ZK8B7lRL+WWfTcj WmQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="OdeK/dTW"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h9si1589981oti.155.2020.02.27.06.26.54; Thu, 27 Feb 2020 06:27:06 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="OdeK/dTW"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388448AbgB0OKA (ORCPT + 99 others); Thu, 27 Feb 2020 09:10:00 -0500 Received: from mail.kernel.org ([198.145.29.99]:48090 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730257AbgB0OJ7 (ORCPT ); Thu, 27 Feb 2020 09:09:59 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6B5E720578; Thu, 27 Feb 2020 14:09:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582812598; bh=mcWs5hysCJ0vA6NTA/QZOnkdCPZ7v6LU7HoQobOuHYU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OdeK/dTW5YZFcn4oA+tnT8G+MoDDOOwJaQV5zNUbvtfuJ+AnKMpi3syliHIAeF81y +CGPJK7agK28rBJXik8DBvsqoMNuQcK0dg4YKg4W6oJfJ1ZY94QkIfTqnBtS49XP8c MDZhv5wisFEXt7PUOEKoM8tnpnCc3WoCjN+dI4KI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Shijie Luo , Theodore Tso , Jan Kara , stable@kernel.org Subject: [PATCH 5.4 080/135] ext4: add cond_resched() to __ext4_find_entry() Date: Thu, 27 Feb 2020 14:37:00 +0100 Message-Id: <20200227132241.411971542@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200227132228.710492098@linuxfoundation.org> References: <20200227132228.710492098@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Shijie Luo commit 9424ef56e13a1f14c57ea161eed3ecfdc7b2770e upstream. We tested a soft lockup problem in linux 4.19 which could also be found in linux 5.x. When dir inode takes up a large number of blocks, and if the directory is growing when we are searching, it's possible the restart branch could be called many times, and the do while loop could hold cpu a long time. Here is the call trace in linux 4.19. [ 473.756186] Call trace: [ 473.756196] dump_backtrace+0x0/0x198 [ 473.756199] show_stack+0x24/0x30 [ 473.756205] dump_stack+0xa4/0xcc [ 473.756210] watchdog_timer_fn+0x300/0x3e8 [ 473.756215] __hrtimer_run_queues+0x114/0x358 [ 473.756217] hrtimer_interrupt+0x104/0x2d8 [ 473.756222] arch_timer_handler_virt+0x38/0x58 [ 473.756226] handle_percpu_devid_irq+0x90/0x248 [ 473.756231] generic_handle_irq+0x34/0x50 [ 473.756234] __handle_domain_irq+0x68/0xc0 [ 473.756236] gic_handle_irq+0x6c/0x150 [ 473.756238] el1_irq+0xb8/0x140 [ 473.756286] ext4_es_lookup_extent+0xdc/0x258 [ext4] [ 473.756310] ext4_map_blocks+0x64/0x5c0 [ext4] [ 473.756333] ext4_getblk+0x6c/0x1d0 [ext4] [ 473.756356] ext4_bread_batch+0x7c/0x1f8 [ext4] [ 473.756379] ext4_find_entry+0x124/0x3f8 [ext4] [ 473.756402] ext4_lookup+0x8c/0x258 [ext4] [ 473.756407] __lookup_hash+0x8c/0xe8 [ 473.756411] filename_create+0xa0/0x170 [ 473.756413] do_mkdirat+0x6c/0x140 [ 473.756415] __arm64_sys_mkdirat+0x28/0x38 [ 473.756419] el0_svc_common+0x78/0x130 [ 473.756421] el0_svc_handler+0x38/0x78 [ 473.756423] el0_svc+0x8/0xc [ 485.755156] watchdog: BUG: soft lockup - CPU#2 stuck for 22s! [tmp:5149] Add cond_resched() to avoid soft lockup and to provide a better system responding. Link: https://lore.kernel.org/r/20200215080206.13293-1-luoshijie1@huawei.com Signed-off-by: Shijie Luo Signed-off-by: Theodore Ts'o Reviewed-by: Jan Kara Cc: stable@kernel.org Signed-off-by: Greg Kroah-Hartman --- fs/ext4/namei.c | 1 + 1 file changed, 1 insertion(+) --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c @@ -1507,6 +1507,7 @@ restart: /* * We deal with the read-ahead logic here. */ + cond_resched(); if (ra_ptr >= ra_max) { /* Refill the readahead buffer */ ra_ptr = 0;