From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 81D8DC352A3 for ; Mon, 10 Feb 2020 13:25:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5858B208C4 for ; Mon, 10 Feb 2020 13:25:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581341107; bh=x7mbJwPnoYiCrby8z4so/XhuqJLNCKJT4HctfRopyZE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=H+eJtvLQDuNDokEAJExJxXOPig/7nrLXX7vPdNsUerubV0ctlb6pui/k3Fg/QRGBM LOA1GuTnxBbmcfducCUx6tjsY9SESDqS8GGzC51oXoaOCF/8BAdFDxw09jFK03zxf9 CQ0n5EbAbpYpFwF0TAQbSmIbHX7UPeFxI9Jdjits= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729787AbgBJNZG (ORCPT ); Mon, 10 Feb 2020 08:25:06 -0500 Received: from mail.kernel.org ([198.145.29.99]:57542 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728576AbgBJMg5 (ORCPT ); Mon, 10 Feb 2020 07:36:57 -0500 Received: from localhost (unknown [209.37.97.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 687862080C; Mon, 10 Feb 2020 12:36:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581338217; bh=x7mbJwPnoYiCrby8z4so/XhuqJLNCKJT4HctfRopyZE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sS+MNX9DSmjJ7koXqRYShfMLx3vtIFFIfQIHa/RpejMoQ8VFrHcAi1Y6zRoX0p+mM XMMexID842BwPM0HjZyCkRi2yDDGF96Z+w78jx3TzMyc58vWnVE6yvGZZo8ZpaGegj zi7ehwC4+YEcXTh4jH05nT9xbyO/0XNv/cW6aZJU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pingfan Liu , Michal Hocko , David Hildenbrand , Dan Williams , Oscar Salvador , Baoquan He , Qian Cai , Kazuhito Hagio , Andrew Morton , Linus Torvalds Subject: [PATCH 5.4 049/309] mm/sparse.c: reset sections mem_map when fully deactivated Date: Mon, 10 Feb 2020 04:30:05 -0800 Message-Id: <20200210122410.721455186@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200210122406.106356946@linuxfoundation.org> References: <20200210122406.106356946@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pingfan Liu commit 1f503443e7df8dc8366608b4d810ce2d6669827c upstream. 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-addition. 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") Link: http://lkml.kernel.org/r/1579487594-28889-1-git-send-email-kernelfans@gmail.com Signed-off-by: Pingfan Liu Acked-by: Michal Hocko Acked-by: David Hildenbrand Cc: Dan Williams Cc: Oscar Salvador Cc: Baoquan He Cc: Qian Cai Cc: Kazuhito Hagio Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- mm/sparse.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/mm/sparse.c +++ b/mm/sparse.c @@ -787,7 +787,7 @@ static void section_deactivate(unsigned 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)