Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp2582563ybv; Sun, 9 Feb 2020 02:37:23 -0800 (PST) X-Google-Smtp-Source: APXvYqwp8gcqeGTkZxd2UzR8y+g626oe19UVAI8R2OiCb2u21qPxCl2tGgiL+wesgMtRz0/T+8RZ X-Received: by 2002:a54:488d:: with SMTP id r13mr7324807oic.115.1581244643284; Sun, 09 Feb 2020 02:37:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581244643; cv=none; d=google.com; s=arc-20160816; b=qKzm7iAP1XLf/LGzAjjmvM7gZ6fW4MsAZZ7O2nzH2XzXaWi4IyjBeqZekBhgIzC25i sjbEfndSH1pIJXYgViurlH8S6c9nj4LPhTzM98GwmO9BbJ5THw9Q2z8eabl/diaZd9ZQ VLGmmT/M28N7Zg3ga8hkTw37OHSjshONHFDwp0sP199ZxARTx7nXz54SHteJQFlZq0CK oef1SDo69wN8q1cm50mHoPixPWK+1u9JvfFYGCrzwuCAh66FGS5D2MfVpAqV/Clc5/jj farMv0F3m4TG3vGG/rH55awJamtCka3FHBPlP17HPMs7FkAq/ucMkl7HCCFyh+CrTGZe MNUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=SWKMsAmoROZC3QCkAyrOWBtkkYi/wXfg2JPbAKg922E=; b=PxpUtnWtz+pwWCMxMRRVmNWgmlPRERsfcKPmb635bAiYgeBYI7h1UNPSHBZQWCa5jM xzB4LyBHWTMr6peSgFxTqXP2e56u9Hg7mZe+SXBfAs4g1caAxGoOFKISjjEKfl1pXYam 00J4itCRUfi1Wz3zQkM9QrWNjiHaCAbug+4B7bv3WPG+8IJqHPCBH2J+7qyty+4zvEKN xcxR+C8trbFtPwcNGzEjBy8VPluyBw7fESh1/JAdlINQb1Mvey8k62tnNie9tkUwNlAG z/Z1SiZMbcv+Z16uOmf8SPcoFooWBkiFvv0J1NF2bMLrHepF1ID6dETx4CoYZG4tcBly L3AQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="D+aJI4T/"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p26si2906872oto.240.2020.02.09.02.37.11; Sun, 09 Feb 2020 02:37:23 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="D+aJI4T/"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727650AbgBIKhC (ORCPT + 99 others); Sun, 9 Feb 2020 05:37:02 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:57496 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726312AbgBIKhC (ORCPT ); Sun, 9 Feb 2020 05:37:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581244620; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=SWKMsAmoROZC3QCkAyrOWBtkkYi/wXfg2JPbAKg922E=; b=D+aJI4T/1Lde4ZTIvmbTLsbBB/rB+Ie931OEwArdTuHrsDKhT6iQNwRZ/U/tvt6U/dk4J+ OPpsZIB0/9Sb6wM/5xcfXAsgLVT+juWBKvY6h1Eyp3Gsicd6a3xgsW70RH+3e97p2ZLQS4 yHS5f2TOs9YAWtFAKc/kdXS5eIX9X78= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-440-a_SbAk6FME6VvC-3ifZFBg-1; Sun, 09 Feb 2020 05:36:57 -0500 X-MC-Unique: a_SbAk6FME6VvC-3ifZFBg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B0A288017CC; Sun, 9 Feb 2020 10:36:55 +0000 (UTC) Received: from localhost (ovpn-12-31.pek2.redhat.com [10.72.12.31]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7ED9619C58; Sun, 9 Feb 2020 10:36:52 +0000 (UTC) Date: Sun, 9 Feb 2020 18:36:49 +0800 From: Baoquan He To: Wei Yang Cc: akpm@linux-foundation.org, osalvador@suse.de, dan.j.williams@intel.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, david@redhat.com Subject: Re: [PATCH] mm/sparsemem: pfn_to_page is not valid yet on SPARSEMEM Message-ID: <20200209103649.GW8965@MiWiFi-R3L-srv> References: <20200206125343.9070-1-richardw.yang@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200206125343.9070-1-richardw.yang@linux.intel.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/06/20 at 08:53pm, Wei Yang wrote: > 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. A good fix, thanks. Reviewed-by: Baoquan He By the way, the failure trace should be added to log so that people can know better what happened. And this happened in hot adding side in SPARSEMEM|!VMEMMAP case, the hot removing failed too in this case, I will psot patch to fix it right away. > > 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 >