Received: by 10.223.176.5 with SMTP id f5csp993243wra; Fri, 2 Feb 2018 09:22:57 -0800 (PST) X-Google-Smtp-Source: AH8x224ECZHP0G8carO2B31sUYivMlirifVngpzJeHSv0vMseVfhYzeb6v1kl0QEr2e/scjswZqz X-Received: by 10.99.114.24 with SMTP id n24mr5273450pgc.376.1517592177642; Fri, 02 Feb 2018 09:22:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517592177; cv=none; d=google.com; s=arc-20160816; b=Ma4YpvJeecdCPIQ+JaAOIpwaYe+OPRiZgmMfAU/Ky0O86dTipAr1Oh7016Gb2YSCq6 TvO8a5c94+DntsIcAWzPiNIs35wlDD19yIMyQ0raFIqCxaNz1i7v/MWiTVizP+9K5h9f pYCr5T9QfEo/p/7uXu97S6rpCEoaMR6+UDdaMUGHiDPz0+s8E0WqVP4pzJZWdURR97cX 0s5BvCjjZwyMiXLajspwbXwSvBSTW8TQ0UbmOEKqgtXhsXwcLEIlUVwn7FVSNBCbfyrZ 4YnX6CRve6rwiPHXbIqwhDEf2YrtgAK/Jxu2jWRWhZTSBCCGA6tkmNNP8VmqFl8Kx1Ct qNrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=UfyKHaUmyEab3o7p9g0O38fRcEk9BkJw5uxoorW75FA=; b=mjQw7HESHFlO4IZMf1SvEDttMTBrpevO6VQsOmIjb757CfkJDdnSJZYazdbtl5zmA7 +6hZl+bclPkrtvgJn0D/xggK19BF6020fVyEN8K5ZeITE435ewoDMjVPpcJsl2Fd71Oi nM+LMaICn9ZK/RuhpmQdbtiW4gZwE59KcYzki/YkG46fVfub9MgN/U4z8uaohXmWxNnD emqGNvL7ccKJk9nECIctifgUcbZvDjT7CcXuhn1JJIOXAGFq++PBhWdKNSeTHtYfSup7 aCuoVdA9kCmRpI+WdZ0YhqI6VYx8+tbELsscSGPlV6PnOiHZb6lP5sl58ovCFt1Oefk5 7Z3Q== ARC-Authentication-Results: i=1; mx.google.com; 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 p19-v6si2120443plo.199.2018.02.02.09.22.43; Fri, 02 Feb 2018 09:22:57 -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; 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 S1753928AbeBBRVe (ORCPT + 99 others); Fri, 2 Feb 2018 12:21:34 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:39256 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753508AbeBBRNO (ORCPT ); Fri, 2 Feb 2018 12:13:14 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 58545EF7; Fri, 2 Feb 2018 17:13:13 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yisheng Xie , Catalin Marinas , Michal Hocko , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH 4.14 104/156] kmemleak: add scheduling point to kmemleak_scan() Date: Fri, 2 Feb 2018 17:58:05 +0100 Message-Id: <20180202140844.899537645@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180202140840.242829545@linuxfoundation.org> References: <20180202140840.242829545@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Yisheng Xie [ Upstream commit bde5f6bc68db51128f875a756e9082a6c6ff7b4c ] kmemleak_scan() will scan struct page for each node and it can be really large and resulting in a soft lockup. We have seen a soft lockup when do scan while compile kernel: watchdog: BUG: soft lockup - CPU#53 stuck for 22s! [bash:10287] [...] Call Trace: kmemleak_scan+0x21a/0x4c0 kmemleak_write+0x312/0x350 full_proxy_write+0x5a/0xa0 __vfs_write+0x33/0x150 vfs_write+0xad/0x1a0 SyS_write+0x52/0xc0 do_syscall_64+0x61/0x1a0 entry_SYSCALL64_slow_path+0x25/0x25 Fix this by adding cond_resched every MAX_SCAN_SIZE. Link: http://lkml.kernel.org/r/1511439788-20099-1-git-send-email-xieyisheng1@huawei.com Signed-off-by: Yisheng Xie Suggested-by: Catalin Marinas Acked-by: Catalin Marinas Cc: Michal Hocko Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- mm/kmemleak.c | 2 ++ 1 file changed, 2 insertions(+) --- a/mm/kmemleak.c +++ b/mm/kmemleak.c @@ -1532,6 +1532,8 @@ static void kmemleak_scan(void) if (page_count(page) == 0) continue; scan_block(page, page + 1, NULL); + if (!(pfn % (MAX_SCAN_SIZE / sizeof(*page)))) + cond_resched(); } } put_online_mems();