Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp4567705pxa; Mon, 10 Aug 2020 12:17:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyjAr9+gr9t7hMSPxQS0KHkSowlqc3dtIqFHLC44FWuT4x+GzN3Y9udoD4E8/KNYl2h8yWy X-Received: by 2002:aa7:cdd0:: with SMTP id h16mr22568066edw.116.1597087058621; Mon, 10 Aug 2020 12:17:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597087058; cv=none; d=google.com; s=arc-20160816; b=p6lYzLrYoQbd2bJIqRzENYOC67D3Ujwl3jrLQZIJ9LaRxchlBi9trbN5Nh9bm01Uby 1WfULXfnZJ06DBz400XhxuMsQb9x0MbFiuxM5Ok9TSqmTxql4cvteJW6DckZJDhZLg6R uNiFJN8c8zlqQ4Wrkn8qrV6YN/XBZu/HZCndJr5xB6gPndxfhagUOCGfJuRUGKwTv/fQ o3X/ns40nIREYx9IaYWyY3TZwXT6cL3bMAGN+1jebRkTvSzwpvaSqq4uJhpSjhMS5jO4 TuRjDqoSRCEJ9zFs+NqEJmy1aGVg6zX2q66ntJdpO0pevcxzu+iy4/2fTRZhCsOpUZl0 3ddA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=50vTvnAxIEikmxKFYj/7Ob9LZDggQUQXOBu/i9jBTpQ=; b=CFayQaQhDUeHJNh/SmkNwnssPij7dJfhdH22g1/z2dV1bCwBxTiv9raEWzT3IuOCK4 S5DCf6ODgjlqpmfdqTpA5W5VaqcBC2RmZRiTV+YxEgcj//fXQ0hJe17fGQwaSug9GYkT j3cj3DowEO6HkYawpXcWoYMj53heMWE5UTDXGeboJlhBUC/xEI23OedTjcwtevsXNn+Y /S2Invbu8/Zcksnxw6RTmII9vv0F4zAqzP2XUJ/cmH2YEBB1rYYU8aVVrWFoE4SFSmpx nF31BEx4aUcsRzPUoVikvYfizhya2f8Gu3wKfBoLJfS7P1E67ZzON7B01yT1z8A5RvX4 PYhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ReJM0dCD; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e10si11804025ejk.32.2020.08.10.12.17.15; Mon, 10 Aug 2020 12:17:38 -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=@kernel.org header.s=default header.b=ReJM0dCD; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729649AbgHJTQS (ORCPT + 99 others); Mon, 10 Aug 2020 15:16:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:47352 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730092AbgHJTOt (ORCPT ); Mon, 10 Aug 2020 15:14:49 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0A56222BEB; Mon, 10 Aug 2020 19:14:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597086888; bh=rkIkLFMimB7x9/DIDpwBmJitV76NacxY2sxEGNkNxco=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ReJM0dCDh3ScUBEc1PJ21OmHM8rFsNyTl6zAwYSuc06miZMFcTo9SuDmFU71VbNBQ VwZZ8clKzUcl85g6zIEO9qNYyOQp+/ZrJmhR0DnvkSOTI32i8tSXcONGemy8qK3a6B MVTsGOIQ0kxyL8qTqjZcFRPXTfAuebChh6+MHXF8= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: "Paul E. McKenney" , Sasha Levin , linux-btrfs@vger.kernel.org Subject: [PATCH AUTOSEL 4.4 03/16] fs/btrfs: Add cond_resched() for try_release_extent_mapping() stalls Date: Mon, 10 Aug 2020 15:14:30 -0400 Message-Id: <20200810191443.3795581-3-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200810191443.3795581-1-sashal@kernel.org> References: <20200810191443.3795581-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Paul E. McKenney" [ Upstream commit 9f47eb5461aaeb6cb8696f9d11503ae90e4d5cb0 ] Very large I/Os can cause the following RCU CPU stall warning: RIP: 0010:rb_prev+0x8/0x50 Code: 49 89 c0 49 89 d1 48 89 c2 48 89 f8 e9 e5 fd ff ff 4c 89 48 10 c3 4c = 89 06 c3 4c 89 40 10 c3 0f 1f 00 48 8b 0f 48 39 cf 74 38 <48> 8b 47 10 48 85 c0 74 22 48 8b 50 08 48 85 d2 74 0c 48 89 d0 48 RSP: 0018:ffffc9002212bab0 EFLAGS: 00000287 ORIG_RAX: ffffffffffffff13 RAX: ffff888821f93630 RBX: ffff888821f93630 RCX: ffff888821f937e0 RDX: 0000000000000000 RSI: 0000000000102000 RDI: ffff888821f93630 RBP: 0000000000103000 R08: 000000000006c000 R09: 0000000000000238 R10: 0000000000102fff R11: ffffc9002212bac8 R12: 0000000000000001 R13: ffffffffffffffff R14: 0000000000102000 R15: ffff888821f937e0 __lookup_extent_mapping+0xa0/0x110 try_release_extent_mapping+0xdc/0x220 btrfs_releasepage+0x45/0x70 shrink_page_list+0xa39/0xb30 shrink_inactive_list+0x18f/0x3b0 shrink_lruvec+0x38e/0x6b0 shrink_node+0x14d/0x690 do_try_to_free_pages+0xc6/0x3e0 try_to_free_mem_cgroup_pages+0xe6/0x1e0 reclaim_high.constprop.73+0x87/0xc0 mem_cgroup_handle_over_high+0x66/0x150 exit_to_usermode_loop+0x82/0xd0 do_syscall_64+0xd4/0x100 entry_SYSCALL_64_after_hwframe+0x44/0xa9 On a PREEMPT=n kernel, the try_release_extent_mapping() function's "while" loop might run for a very long time on a large I/O. This commit therefore adds a cond_resched() to this loop, providing RCU any needed quiescent states. Signed-off-by: Paul E. McKenney Signed-off-by: Sasha Levin --- fs/btrfs/extent_io.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 42b7409d4cc55..2f9f738ecf84a 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -4437,6 +4437,8 @@ int try_release_extent_mapping(struct extent_map_tree *map, /* once for us */ free_extent_map(em); + + cond_resched(); /* Allow large-extent preemption. */ } } return try_release_extent_state(map, tree, page, mask); -- 2.25.1