From patchwork Wed Oct 31 12:58:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Hocko X-Patchwork-Id: 10662615 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3B20114BD for ; Wed, 31 Oct 2018 12:59:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2907E2ACEB for ; Wed, 31 Oct 2018 12:59:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1CEC72ACF2; Wed, 31 Oct 2018 12:59:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9B49E2ACEB for ; Wed, 31 Oct 2018 12:59:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 225356B0006; Wed, 31 Oct 2018 08:59:18 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 1D3276B026E; Wed, 31 Oct 2018 08:59:18 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0C3106B0270; Wed, 31 Oct 2018 08:59:18 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by kanga.kvack.org (Postfix) with ESMTP id A802C6B0006 for ; Wed, 31 Oct 2018 08:59:17 -0400 (EDT) Received: by mail-ed1-f71.google.com with SMTP id c2-v6so8702344edi.6 for ; Wed, 31 Oct 2018 05:59:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:mime-version:content-transfer-encoding; bh=F0Kz97Mz2sEmViRrO4SLpsnIpXFB+vaEvmsFGBYKUaI=; b=H/aJOtyNEM6pGCfTxW+CtX2luuy5TLfGIXlfQ1USoUzBc+mWgzfCvzjcPp4gfbNnKP 0wYlkd0sOiETZtWt9ip2Wxu9YOqavDZ0BoWbln/Gb1V86NgJ75gMcCBBGEMCDh2HZA9Z 595pjPk+cxNYnAxxJdip3KwgSNELNallqnuJ/CZcRzXfQVNrr3m/VEsdi0o1ATlD2pvq BY/Wp7AxoD2srfqGbuwPc9XtJp2YXlPObLrxaDddP0tzzq3uXqE3J+/PAg8w+p6yzB51 OvCHDhcTbdFELbYpa/snr48BSkqDOTO3lspij9Pc0uiJyeRqY0lnbGl5vrJ7osh3fudX 7+xA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of mstsxfx@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=mstsxfx@gmail.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Gm-Message-State: AGRZ1gKv7gfAIq/lI3Swqk0753jVh9KWlc0flY5INWCwaJehW9hB7PdA oM6P96KDWiu7wNXPJJVsEGuKDkPP4alNEvIHunuvhmCzxLk7ibvvUkW8/3pE18uHNUe5yXZTgaD 9MYgO1xQN3H77m8B3pYH4pLJ2tIMuHEMYKG1JsVRLzKDxsTVSocGdxBqUmnpI/DY8z/kN90cJJK kOVjtFA6LZLZlqsdsR9z4TKZsYq4Daa4d2R/Tt13gCv5XxBt4y/ZdfGM4ArPlhiJX0ipdCl4nSg PnH/FveRm2DTSK+R3D02oaqNCp4ha5P1w03f7tDtLzFl2qN1DfzpCjs09FVy6pRM8+k08OLGZ5/ 6UQEOT3Xisl9AbcwoEMh1K1KNVv967yCFbaETqGEUcYkdyBxxGF75KmQyK5Wa7uDxyD0O+qbyg= = X-Received: by 2002:a17:906:5a0a:: with SMTP id p10-v6mr1519926ejq.43.1540990757000; Wed, 31 Oct 2018 05:59:17 -0700 (PDT) X-Received: by 2002:a17:906:5a0a:: with SMTP id p10-v6mr1519872ejq.43.1540990755723; Wed, 31 Oct 2018 05:59:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540990755; cv=none; d=google.com; s=arc-20160816; b=E41R0m5SyBGA5t1SgEhyGDMmG2seRLoSNKrd3d3Ikmip6NDDzYR/zisG8XkJqVombh dXrnBE+EozMacSWkXVNq1f0KbMat8tIt9JmAV1JCITqg/WguV6ThQeGszyn8DcDMvZjr Rx1/1JrKzfqSfPlIbN2cKGXu/g4exBCPn8BrbPweEFvvR/3QodScOeR/MB+9XQ9fdjbB PURN4/ZNYF7a/XqIu7DOk1lqIYxAuK9uyXTeD6hliFcmiVQImyR8vpXaAzukQL9ShmZp 1x+1DF7ULqKhUjwA746917mMSPnjk3uT9EX5xmJTcikyFhf1qnvXeCk+SECkf5xnX0l4 wlTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from; bh=F0Kz97Mz2sEmViRrO4SLpsnIpXFB+vaEvmsFGBYKUaI=; b=pmuqcBkMIWmIFKp8sYzU7JMno8t2qg79ChIVQxMPgtTtkw3jN9VUgBJK9Gu87XIaRc I6yB6aztFm3C8BzPaKL4D4N4M3Hc4myEWwkKwXa007YMVXtStGkoCP2iY8Qfq4joFlM8 Q/pQHB/w6YUvFrsrhcSWmWk674TqjiAC5WBPkDR5CnHq8b2lTOXApezDjFiefaOiH3zV rfH1KE084dghvJbEXFDsP1MDSbMyM7nRHXhoDh+/CIugTWX9Gy6CcMZrKcXa9dL9GDgN oQaudFq7o9xQd+zqdWiMEY1SPc0ch4OCPwRATYkRKgS20xO4W6oCnqZn7CeXtMGjmOPS /vZg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of mstsxfx@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=mstsxfx@gmail.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id m17-v6sor7255992eje.24.2018.10.31.05.59.15 for (Google Transport Security); Wed, 31 Oct 2018 05:59:15 -0700 (PDT) Received-SPF: pass (google.com: domain of mstsxfx@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; spf=pass (google.com: domain of mstsxfx@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=mstsxfx@gmail.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Google-Smtp-Source: AJdET5edQ/BfT9xyMnM7Hy1SH594rplvXtvRVQmxwTHvPW9Yh/5fY5Pt3r7ig4osWYN1yskEeQ9AXg== X-Received: by 2002:a17:906:90d9:: with SMTP id v25-v6mr1490567ejw.214.1540990754933; Wed, 31 Oct 2018 05:59:14 -0700 (PDT) Received: from tiehlicka.microfocus.com (prg-ext-pat.suse.com. [213.151.95.130]) by smtp.gmail.com with ESMTPSA id r19-v6sm4212562edp.17.2018.10.31.05.59.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 31 Oct 2018 05:59:13 -0700 (PDT) From: Michal Hocko To: Andrew Morton Cc: Dan Williams , Johannes Thumshirn , , LKML , Michal Hocko Subject: [PATCH] memory_hotplug: cond_resched in __remove_pages Date: Wed, 31 Oct 2018 13:58:40 +0100 Message-Id: <20181031125840.23982-1-mhocko@kernel.org> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Michal Hocko We have received a bug report that unbinding a large pmem (>1TB) can result in a soft lockup: [ 380.339203] NMI watchdog: BUG: soft lockup - CPU#9 stuck for 23s! [ndctl:4365] [...] [ 380.339316] Supported: Yes [ 380.339318] CPU: 9 PID: 4365 Comm: ndctl Not tainted 4.12.14-94.40-default #1 SLE12-SP4 [ 380.339318] Hardware name: Intel Corporation S2600WFD/S2600WFD, BIOS SE5C620.86B.01.00.0833.051120182255 05/11/2018 [ 380.339319] task: ffff9cce7d4410c0 task.stack: ffffbe9eb1bc4000 [ 380.339325] RIP: 0010:__put_page+0x62/0x80 [ 380.339326] RSP: 0018:ffffbe9eb1bc7d30 EFLAGS: 00000282 ORIG_RAX: ffffffffffffff10 [ 380.339327] RAX: 000040540081c0d3 RBX: ffffeb8f03557200 RCX: 000063af40000000 [ 380.339328] RDX: 0000000000000002 RSI: ffff9cce75bff498 RDI: ffff9e4a76072ff8 [ 380.339329] RBP: 0000000a43557200 R08: 0000000000000000 R09: ffffbe9eb1bc7bb0 [ 380.339329] R10: ffffbe9eb1bc7d08 R11: 0000000000000000 R12: ffff9e194a22a0e0 [ 380.339330] R13: ffff9cce7062fc10 R14: ffff9e194a22a0a0 R15: ffff9cce6559c0e0 [ 380.339331] FS: 00007fd132368880(0000) GS:ffff9cce7ea40000(0000) knlGS:0000000000000000 [ 380.339332] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 380.339332] CR2: 00000000020820a0 CR3: 000000017ef7a003 CR4: 00000000007606e0 [ 380.339333] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 380.339334] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [ 380.339334] PKRU: 55555554 [ 380.339334] Call Trace: [ 380.339338] devm_memremap_pages_release+0x152/0x260 [ 380.339342] release_nodes+0x18d/0x1d0 [ 380.339347] device_release_driver_internal+0x160/0x210 [ 380.339350] unbind_store+0xb3/0xe0 [ 380.339355] kernfs_fop_write+0x102/0x180 [ 380.339358] __vfs_write+0x26/0x150 [ 380.339363] ? security_file_permission+0x3c/0xc0 [ 380.339364] vfs_write+0xad/0x1a0 [ 380.339366] SyS_write+0x42/0x90 [ 380.339370] do_syscall_64+0x74/0x150 [ 380.339375] entry_SYSCALL_64_after_hwframe+0x3d/0xa2 [ 380.339377] RIP: 0033:0x7fd13166b3d0 It has been reported on an older (4.12) kernel but the current upstream code doesn't cond_resched in the hot remove code at all and the given range to remove might be really large. Fix the issue by calling cond_resched once per memory section. Signed-off-by: Michal Hocko Acked-by: Johannes Thumshirn Signed-off-by: Balbir Singh Acked-by: Balbir Singh --- mm/memory_hotplug.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 7e6509a53d79..1d87724fa558 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -587,6 +587,7 @@ int __remove_pages(struct zone *zone, unsigned long phys_start_pfn, for (i = 0; i < sections_to_remove; i++) { unsigned long pfn = phys_start_pfn + i*PAGES_PER_SECTION; + cond_resched(); ret = __remove_section(zone, __pfn_to_section(pfn), map_offset, altmap); map_offset = 0;