From patchwork Mon Jan 20 02:33:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pingfan Liu X-Patchwork-Id: 11340877 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C1FC2139A for ; Mon, 20 Jan 2020 02:35:48 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7C631206D7 for ; Mon, 20 Jan 2020 02:35:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mxy3bJRI" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7C631206D7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id A5F856B0598; Sun, 19 Jan 2020 21:35:47 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A10CD6B0599; Sun, 19 Jan 2020 21:35:47 -0500 (EST) 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 9262E6B059A; Sun, 19 Jan 2020 21:35:47 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0136.hostedemail.com [216.40.44.136]) by kanga.kvack.org (Postfix) with ESMTP id 7CCB16B0598 for ; Sun, 19 Jan 2020 21:35:47 -0500 (EST) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with SMTP id 1513A249D for ; Mon, 20 Jan 2020 02:35:47 +0000 (UTC) X-FDA: 76396447134.06.quilt39_6ca52cf575433 X-Spam-Summary: 2,0,0,0ddceb283042e537,d41d8cd98f00b204,kernelfans@gmail.com,::kernelfans@gmail.com:akpm@linux-foundation.org:david@redhat.com:dan.j.williams@intel.com:osalvador@suse.de:mhocko@kernel.org:bhe@redhat.com:cai@lca.pw:kexec@lists.infradead.org:k-hagio@ab.jp.nec.com,RULES_HIT:41:355:379:541:800:960:966:968:973:981:988:989:1260:1345:1431:1437:1534:1541:1711:1730:1747:1777:1792:2196:2199:2393:2559:2562:2693:2895:2907:3138:3139:3140:3141:3142:3353:3865:3866:3867:3868:3870:3871:3872:3874:4250:4321:4385:5007:6261:6653:7514:7903:9413:10004:10241:11026:11473:11658:11914:12043:12296:12297:12438:12517:12519:12555:12895:12986:13069:13161:13229:13311:13357:13846:14093:14096:14181:14384:14394:14687:14721:21080:21433:21444:21451:21627:21666:21795:30051:30054:30064:30070,0,RBL:209.85.214.194:@gmail.com:.lbl8.mailshell.net-62.50.0.100 66.100.201.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:24,LUA _SUMMARY X-HE-Tag: quilt39_6ca52cf575433 X-Filterd-Recvd-Size: 4742 Received: from mail-pl1-f194.google.com (mail-pl1-f194.google.com [209.85.214.194]) by imf49.hostedemail.com (Postfix) with ESMTP for ; Mon, 20 Jan 2020 02:35:46 +0000 (UTC) Received: by mail-pl1-f194.google.com with SMTP id a6so12527024plm.3 for ; Sun, 19 Jan 2020 18:35:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=wlt7J6YX/+zJd9kW5sXYOIVVIkX0dlrdrokN/uFDoZw=; b=mxy3bJRI2vIq2veTmVnwjT5q8VSFqnGz8AQlKMCTnT+JDDgo4mDeyrA+fYWdpiW36E j7JvxAOn+JBAO1e2b8sm4l0YSmOWithMnU+S6BLQwnwn2dqYJP3D+ezuNqhYKK88Bjw2 HY4WwdBgdzaQU+76LW42EbhIUp/2+OCz3AMIf8INDkhzROxB6dtMAggCOMkFHdpJuHcD qIV7L1DMP48LfwMsD8FyYycDMJwxVNpEJ/R0MsaLSacRRHgLl32XXUJuKsAVIZkRevOL dM+mafA29AQQ9VkKFMv+ZQym+JItHEY7vV5YhAjh4r0Tya7ceXvVzIgQuZ+nH1PMwh8p mshg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=wlt7J6YX/+zJd9kW5sXYOIVVIkX0dlrdrokN/uFDoZw=; b=hEEine4iP+w/a22vipJo2eB9zt0NwnFF9JWr2UtUxzT1151MoLFypzLQyDuAxe9tXV mF2EOtHRbyVUfj7hOXZOe0T48ALfn2xyKw7/ZQFMx6RO3jAaoY1Tq8r3VZnDCfF+fIGw K+Rfp8iX9a4lSwcIptuiN47DXs8cIIgQzse0uNkJ9PKnwKCBR5k7762+vnMD9tVhtKkX 69+asQttz5b7pUaInTAENei1Gg3ty33babUVAW5CKa89mGScH2SC9N8LXWOUE3AdaNww qPkbsNr17Txjz5n9StMCtg8lhgiu/O6n8tljyc4r3MZsh0QSM0QEIKqZyWwMnO1fgg9P RZ1A== X-Gm-Message-State: APjAAAXz/lft4IX44xvOeXTbsBGMtHtn56nVZ2si19JulFfGmFNFFmmW fNdtBzt7TShYNJtYrrtqM65IRtFnHA== X-Google-Smtp-Source: APXvYqwKdppuo78Bmv4mW597zkYEkcjDo1L3fm2u4vw1ikPyVxK1zADeKN4O/RbMBCnabUd0f7C1Tg== X-Received: by 2002:a17:90b:8c6:: with SMTP id ds6mr20172885pjb.111.1579487745338; Sun, 19 Jan 2020 18:35:45 -0800 (PST) Received: from mylaptop.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id y197sm37574075pfc.79.2020.01.19.18.35.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 Jan 2020 18:35:44 -0800 (PST) From: Pingfan Liu To: linux-mm@kvack.org Cc: Pingfan Liu , Andrew Morton , David Hildenbrand , Dan Williams , Oscar Salvador , Michal Hocko , Baoquan He , Qian Cai , kexec@lists.infradead.org, Kazuhito Hagio Subject: [PATCHv2] mm/sparse: reset section's mem_map when fully deactivated Date: Mon, 20 Jan 2020 10:33:14 +0800 Message-Id: <1579487594-28889-1-git-send-email-kernelfans@gmail.com> X-Mailer: git-send-email 2.7.5 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000005, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: After commit ba72b4c8cf60 ("mm/sparsemem: support sub-section hotplug"), when a mem section is fully deactivated, section_mem_map still records the section's start pfn, which is not used any more and will be reassigned during re-added. In analogy with alloc/free pattern, it is better to clear all fields of section_mem_map. Beside this, it breaks the user space tool "makedumpfile" [1], which makes assumption that a hot-removed section has mem_map as NULL, instead of checking directly against SECTION_MARKED_PRESENT bit. (makedumpfile will be better to change the assumption, and need a patch) The bug can be reproduced on IBM POWERVM by "drmgr -c mem -r -q 5" , trigger a crash, and save vmcore by makedumpfile [1]: makedumpfile, commit e73016540293 ("[v1.6.7] Update version") Signed-off-by: Pingfan Liu To: linux-mm@kvack.org Cc: Andrew Morton Cc: David Hildenbrand Cc: Dan Williams Cc: Oscar Salvador Cc: Michal Hocko Cc: Baoquan He Cc: Qian Cai Cc: kexec@lists.infradead.org Cc: Kazuhito Hagio Acked-by: Michal Hocko Acked-by: David Hildenbrand --- v1 -> v2: make an explicit convertion from NULL to ulong improve commit log mm/sparse.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/sparse.c b/mm/sparse.c index 3822ecb..3918fc3 100644 --- a/mm/sparse.c +++ b/mm/sparse.c @@ -789,7 +789,7 @@ static void section_deactivate(unsigned long pfn, unsigned long nr_pages, ms->usage = NULL; } memmap = sparse_decode_mem_map(ms->section_mem_map, section_nr); - ms->section_mem_map = sparse_encode_mem_map(NULL, section_nr); + ms->section_mem_map = (unsigned long)NULL; } if (section_is_early && memmap)