Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3546431pxj; Mon, 24 May 2021 09:05:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxQskQjcQiLfWShvKi5wKrFcTb8kAQKpbwTdPgm7LHV3ExVDWU3DYZUxmJkpeSClrJJZGU+ X-Received: by 2002:a05:6638:344e:: with SMTP id q14mr27057037jav.47.1621872351831; Mon, 24 May 2021 09:05:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621872351; cv=none; d=google.com; s=arc-20160816; b=KlJx5O63UTroIG0onAa7HWtF24CEfaEiCYL+4yT36k9pcDPf5Mvvfkr6Sq/Z6tVz78 inh37a6lu4Pe5P9C19TP7s7qbVVIo8KNVrVs5MbtGhD/9jAwM/xX+6Rx5yM3vKY5qhtw cvna6gy6l595KKmYQ3ts1ntuOEKhK+K/58f5XROYgS3maCLJyFOupfItQsmQVsv0cyIL gM9n2U0K9VLj1gCiEG5F74ZpPvQXTGDTiqviKM5hlXnVa0tBXoSMlWvK6z+9JJKolsyp oAWhHD/LtW1t6ileBmXu+6kMHzgzWuig9UUIeraNly9sT0WSn9eiHiGAK96ccvlsPa1s k3/Q== 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=kgsT5wfsOqoyAdOgaJ5HhneV9AU/QavfjE2CnRCsa/s=; b=jlz9+eU1tWFZPFjQRugOa7f84KIVHc6qjs+oKigC/ySMnpyI0GYlNf92/8fzOOkWQZ 6ttczxnx4Tt6LGOLRaQtppUJWXBUGY09SnjjAaoktEN6Po0+MJNScLV73cOU1at4KElq OtK0EcN5lRD/3t2QBx0p8uq9roXpz5ez7X8/8HMHGVaDawX58WPByRpeXsAeyNFH2TnC Fs+nDwNA8mX+Gm3Wcgvfpj3N/oVmqi01DtXdCO1wq2ZvIECPGD/qLStieBMkGj1Gc+FN +z2bBzQm3Q1vgUs+cV+wdgCmeNKl2kB2rUqyfrCmIF3Gcc++wdMprSao6Srn4ZCPpSC8 i2aQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="PmKWSab/"; 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 n9si14197392jaj.15.2021.05.24.09.05.33; Mon, 24 May 2021 09:05:51 -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="PmKWSab/"; 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 S236415AbhEXQET (ORCPT + 99 others); Mon, 24 May 2021 12:04:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:39954 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235047AbhEXP5e (ORCPT ); Mon, 24 May 2021 11:57:34 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 17EE961954; Mon, 24 May 2021 15:43:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621871020; bh=ef2Jue2QD5V+1y3aD/PrGDsVDrMUNIS1SIQLhYS5L5c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PmKWSab/G/SdH8us7t6ZrSzIaW9r6qSzyplo+n+lNCQ8OicqeTFvSDz2r3Rs++ojO +uIf/dawWl2pAFQYi80ldNnt36FkqWHqcimCI0ywOvaoaJhSzgjf5tzdZbk9yiPIJr Q26pPkOJK8bOC+mbDA2lC2b6IAgWT/Jcwmcajg9A= 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.12 035/127] btrfs: avoid RCU stalls while running delayed iputs Date: Mon, 24 May 2021 17:25:52 +0200 Message-Id: <20210524152336.037395420@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210524152334.857620285@linuxfoundation.org> References: <20210524152334.857620285@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 @@ -3253,6 +3253,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); }