Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1485835ybv; Thu, 6 Feb 2020 05:02:53 -0800 (PST) X-Google-Smtp-Source: APXvYqwKNesJTq+0RITcfdHpXatWSTbyarVtMmt2Wqe453B0d/tWeSn+V+nOoDJ4CAj5H9Bget9J X-Received: by 2002:a9d:5888:: with SMTP id x8mr28720278otg.361.1580994172861; Thu, 06 Feb 2020 05:02:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580994172; cv=none; d=google.com; s=arc-20160816; b=SNYuGK5onIg1D2OBG7kxkNI3mgj6pVDDxJnnycfniqGO7abGq35r/p0bU6wLPZRx0p VJsf3zWnvpGp0wmiJfcOp0hAmpYDaUtE8YrO9skpX/Cv52/UMR05uuliv0GbdvT8cyBu OvFl9IupG1ZWc+Z1oEyeFniBQeSTfd3EmgEWmqeI7xig4npZdM1r+t8mAElzHi6MSCe9 0xmNNg0Sggqjqd8Jcj53kQssKoXj9azE7CnLbv6x0yrY4U6Cy7k/bCa0Bju9uliLini+ 9p6Z6zY2KCrXXTdd79kzQdFKHF4AGAGV0rCzbF8UsquBjFWtZ/cvpJHvoFq2GnGZxe+o DLmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=EMuoJjaGTajVNUavy/C0eXTlrcta24le80Vo4e2Bym4=; b=TafE1IRblcnANc4R7TAmd8auBDzJsHECIC2F9GQE9IvB9v1cGn6PvvQlgYs8b+JeHw 1umyonl4ixfawtNzWwSNtjnjK5uoGSV921ZcC5DBNJ/+Y+sCvBCHH6SXQHKvk5nGhoD8 ImMnvVPU3yrrjwTgSNnCqJnBWwDA7g96qLmURmy50a8Gv4SIA3g+EJm/nR1dDuxQJnLd /hMuxK7sm2SND5KgNtlefZFTCZcuEXW0A9YG+5UMFjzXDGspuqtV7MHSimRDyA/CI7lk AIqjFbq7Ac6+TYWShNbIYZbah6JBnhzwjKFmaSogwLjR7PLLICnKGf3Irq5DMKi9WZxs kOdQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s9si1912445oij.78.2020.02.06.05.02.37; Thu, 06 Feb 2020 05:02:52 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727784AbgBFMxa (ORCPT + 99 others); Thu, 6 Feb 2020 07:53:30 -0500 Received: from mga02.intel.com ([134.134.136.20]:53131 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727613AbgBFMxa (ORCPT ); Thu, 6 Feb 2020 07:53:30 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Feb 2020 04:53:30 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,409,1574150400"; d="scan'208";a="255079976" Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.54]) by fmsmga004.fm.intel.com with ESMTP; 06 Feb 2020 04:53:28 -0800 From: Wei Yang To: akpm@linux-foundation.org, osalvador@suse.de, dan.j.williams@intel.com Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, david@redhat.com, bhe@redhat.com, Wei Yang Subject: [PATCH] mm/sparsemem: pfn_to_page is not valid yet on SPARSEMEM Date: Thu, 6 Feb 2020 20:53:43 +0800 Message-Id: <20200206125343.9070-1-richardw.yang@linux.intel.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When we use SPARSEMEM instead of SPARSEMEM_VMEMMAP, pfn_to_page() doesn't work before sparse_init_one_section() is called. This leads to a crash when hotplug memory. We should use memmap as it did. Fixes: ba72b4c8cf60 ("mm/sparsemem: support sub-section hotplug") Signed-off-by: Wei Yang CC: Dan Williams --- mm/sparse.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/sparse.c b/mm/sparse.c index 5a8599041a2a..2efb24ff8f96 100644 --- a/mm/sparse.c +++ b/mm/sparse.c @@ -882,7 +882,7 @@ int __meminit sparse_add_section(int nid, unsigned long start_pfn, * Poison uninitialized struct pages in order to catch invalid flags * combinations. */ - page_init_poison(pfn_to_page(start_pfn), sizeof(struct page) * nr_pages); + page_init_poison(memmap, sizeof(struct page) * nr_pages); ms = __nr_to_section(section_nr); set_section_nid(section_nr, nid); -- 2.17.1