Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3541665pxj; Mon, 24 May 2021 09:01:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzcdmGkExvDP7JY2IbHqHCMby4pN4S28B5vHQaRWunECJ1zM14nV6W2iJvruAqCHubuKckf X-Received: by 2002:a05:6e02:1b06:: with SMTP id i6mr14017425ilv.139.1621872065863; Mon, 24 May 2021 09:01:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621872065; cv=none; d=google.com; s=arc-20160816; b=VEcBYQ+diEQ6KFAX9SYy6CdlYtfC2YFa0ylX9UyIrQoO85g6avZCRsFShfIPr4hTNv wtgq4azjf9G3Is6CEEs6CvUv/Z0eafZzPcN87OP9P4zXeMg+CfVAUGMi/REJRFEy4A12 1NhnbfYooutJstpi6N65DmC6fA2JxS8LbvIriFtPXTWOUjpBpZMFaGftuWOgueIzQBC/ JTL4z2879uPXHsTwRA9ctc7vLzATaTHlq5iDXO180C2BvOSdI3Otap2Yy1xTiKcoLnQI 9kxkNH3g4PWt+B2Ae9PyPWctHAOmtUq/tTsu7jzVTreF1vRdgr7CkLox1Oc27b5S9oIy EXcw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=nrDE2z9HYbGQCH/6DyhFhs+l+4zxniANZwG0ZMqCX4I=; b=czHWWuA7AYf9o1/pM1s2TtarQEaBH2OijtxhsVsX5AoFXW4xPyEGGtDdhbK8TH9f6c yD7wVEXWyICrya4YUNQTeAN4d1lr0230wu0p7xAgSpnkO1aB5rf9T1Cyp0gSnQh9u2gQ SYK4id2nqxj1gMpkPVdTcI20FvnnuipuAMJ3z1UuROaTtfEv1RadW9gwrNOYAQ3Wtzh+ DHKkfXrSjxCNYRfkE3MXOrV2BoxGHdxBe72koVCpf7PTujkB/fe9JRy+yP1WZFQHh2VO H+sB4SO1x07+pvnFc7GdtRujvb/ur2V8aAXxN2sMgNG2Pv9WEyxd3XUaE+3i7Js8fNgp amEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=E6vn1Bu6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k7si14482380jaq.89.2021.05.24.09.00.52; Mon, 24 May 2021 09:01:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=E6vn1Bu6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235614AbhEXQAk (ORCPT + 99 others); Mon, 24 May 2021 12:00:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:38696 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234194AbhEXPyM (ORCPT ); Mon, 24 May 2021 11:54:12 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6025461400; Mon, 24 May 2021 15:39:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621870779; bh=PUcFZFfMlxrF6KIC44lRkzF2bo/Fg2nBQPLL+pmSMp4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E6vn1Bu6Fs4QRqofPhPzcVHvU3GG2pyJ0O7m7YiMwUDimXIWqbfXbofPkMZccm3rn 0dEv9Np26fBEOjGciWp7uirNuf4xb1lNPeQNSVQT5kewC2uPbvpTH9V+nua3XPW1pn Yd5bTyLNsuZxJyIs/7zhpw93LBqLVkKeGm/z78Io= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Rik van Riel , Josef Bacik , David Sterba Subject: [PATCH 5.10 031/104] btrfs: avoid RCU stalls while running delayed iputs Date: Mon, 24 May 2021 17:25:26 +0200 Message-Id: <20210524152333.849600830@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210524152332.844251980@linuxfoundation.org> References: <20210524152332.844251980@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Josef Bacik commit 71795ee590111e3636cc3c148289dfa9fa0a5fc3 upstream. Generally a delayed iput is added when we might do the final iput, so usually we'll end up sleeping while processing the delayed iputs naturally. However there's no guarantee of this, especially for small files. In production we noticed 5 instances of RCU stalls while testing a kernel release overnight across 1000 machines, so this is relatively common: host count: 5 rcu: INFO: rcu_sched self-detected stall on CPU rcu: ....: (20998 ticks this GP) idle=59e/1/0x4000000000000002 softirq=12333372/12333372 fqs=3208 (t=21031 jiffies g=27810193 q=41075) NMI backtrace for cpu 1 CPU: 1 PID: 1713 Comm: btrfs-cleaner Kdump: loaded Not tainted 5.6.13-0_fbk12_rc1_5520_gec92bffc1ec9 #1 Call Trace: dump_stack+0x50/0x70 nmi_cpu_backtrace.cold.6+0x30/0x65 ? lapic_can_unplug_cpu.cold.30+0x40/0x40 nmi_trigger_cpumask_backtrace+0xba/0xca rcu_dump_cpu_stacks+0x99/0xc7 rcu_sched_clock_irq.cold.90+0x1b2/0x3a3 ? trigger_load_balance+0x5c/0x200 ? tick_sched_do_timer+0x60/0x60 ? tick_sched_do_timer+0x60/0x60 update_process_times+0x24/0x50 tick_sched_timer+0x37/0x70 __hrtimer_run_queues+0xfe/0x270 hrtimer_interrupt+0xf4/0x210 smp_apic_timer_interrupt+0x5e/0x120 apic_timer_interrupt+0xf/0x20 RIP: 0010:queued_spin_lock_slowpath+0x17d/0x1b0 RSP: 0018:ffffc9000da5fe48 EFLAGS: 00000246 ORIG_RAX: ffffffffffffff13 RAX: 0000000000000000 RBX: ffff889fa81d0cd8 RCX: 0000000000000029 RDX: ffff889fff86c0c0 RSI: 0000000000080000 RDI: ffff88bfc2da7200 RBP: ffff888f2dcdd768 R08: 0000000001040000 R09: 0000000000000000 R10: 0000000000000001 R11: ffffffff82a55560 R12: ffff88bfc2da7200 R13: 0000000000000000 R14: ffff88bff6c2a360 R15: ffffffff814bd870 ? kzalloc.constprop.57+0x30/0x30 list_lru_add+0x5a/0x100 inode_lru_list_add+0x20/0x40 iput+0x1c1/0x1f0 run_delayed_iput_locked+0x46/0x90 btrfs_run_delayed_iputs+0x3f/0x60 cleaner_kthread+0xf2/0x120 kthread+0x10b/0x130 Fix this by adding a cond_resched_lock() to the loop processing delayed iputs so we can avoid these sort of stalls. CC: stable@vger.kernel.org # 4.9+ Reviewed-by: Rik van Riel Signed-off-by: Josef Bacik Reviewed-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/inode.c | 1 + 1 file changed, 1 insertion(+) --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -2967,6 +2967,7 @@ void btrfs_run_delayed_iputs(struct btrf inode = list_first_entry(&fs_info->delayed_iputs, struct btrfs_inode, delayed_iput); run_delayed_iput_locked(fs_info, inode); + cond_resched_lock(&fs_info->delayed_iput_lock); } spin_unlock(&fs_info->delayed_iput_lock); }