Received: by 10.223.176.5 with SMTP id f5csp1060584wra; Fri, 2 Feb 2018 10:29:33 -0800 (PST) X-Google-Smtp-Source: AH8x22518FlLWdoqGvalJiGXQIcyZkGR0mlUMDTDw5RUKlpuSfDomy/JycR/t9HJdk89PwwH+2Zz X-Received: by 2002:a17:902:b104:: with SMTP id q4-v6mr5827501plr.143.1517596173524; Fri, 02 Feb 2018 10:29:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517596173; cv=none; d=google.com; s=arc-20160816; b=f/6luXWmr0T1VCT2RAoAWU01K2UMifeQ0VsL6bKvkPVRmhv9fIbNY65WeoaqXlu0Iz Mf5DdwDVzOFziSfHY0YpXp+1k/z+lQBvcEv+6/Z+LZeKj0r0AS1xbHPAqsrLqht1F28V MUVrKL8U6m9V1sAaVXPivvEWusulmDiGPs9XYI/rUOm42evTmYEGd8jKGpPwRl1Iaq4a D4bBc+/aOL/SKKEczUDbqfdL+6pOfag6b3q/TYA4f877G4ohDWu7T/xetl1O9KykGRZm RquOxFsNGi/xMRwKYBGr99OUtIH1G6FV2EIjO7p7CkyOdXNGpHVywRCAk3bIACESG8Cb 3EIQ== 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=Ad5aY8JiyQZLr3H/PrHdHozNY9L1tOg34j/rcqN9ocA=; b=e45LwGw9UFBJGT6KiT1snLPR/xk561JlmgqZW3OtaRVVfh94mOyV1oKj1PVnx9YH9E IZVUdN4o8YNV4AGszX4N3ZYUOBoKKyxSL3l8gMyGIduO+fF1NPpfF9PqshtNi/rgfQvW leZGvw/GRfK27XEFwg0ZL9FYdqifd+mykCd3ZestvSt2lce6K7za6f42wiq1vYRz2Pr+ B+vLL85cnIYFu0LAHQFyonYdoNtuu+JPNQY6CjshHTWkG7dO3iin2TsczTeYCcpFjM6+ jBCBeUKv9G/bjavIwhs4QqegyX1herPBv8DEM/zpaupHeRAxiTbyuGN5MbkBbCP3mr/N J7Jw== 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 a67si473556pgc.151.2018.02.02.10.29.18; Fri, 02 Feb 2018 10:29:33 -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 S1754905AbeBBS2g (ORCPT + 99 others); Fri, 2 Feb 2018 13:28:36 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:35114 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752100AbeBBRB0 (ORCPT ); Fri, 2 Feb 2018 12:01:26 -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 C2FDCDF6; Fri, 2 Feb 2018 17:01:25 +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.4 47/67] kmemleak: add scheduling point to kmemleak_scan() Date: Fri, 2 Feb 2018 17:58:16 +0100 Message-Id: <20180202140820.602701736@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180202140815.091718203@linuxfoundation.org> References: <20180202140815.091718203@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.4-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 @@ -1394,6 +1394,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();