Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1605448ybv; Thu, 6 Feb 2020 06:51:17 -0800 (PST) X-Google-Smtp-Source: APXvYqyv3rbbTr1JSIkeUapEkmny4JzroDvysxo0PTwh1rzIJUetdRAa130wFtt5ZM+RwOSy4YYP X-Received: by 2002:aca:3f43:: with SMTP id m64mr6926306oia.165.1581000677725; Thu, 06 Feb 2020 06:51:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581000677; cv=none; d=google.com; s=arc-20160816; b=G2NIeLakpjdP1UG9WK3qWyy+VomZ03leQDZlZy7HEIJZVY4qIV/U3TqkTm68us9Mxw p2mQYJyynbijvNjprznHjPyS1AUA49pyStZmMmAS2dOd2aLBPPmHtap6q2T+IsYPTNLt 5Tpx9TFPD6ScMZzdly4UtyapAp2nlaHnsxFbbi8iA60pfuOExeME/E45brfKKmzV3lET RBW3Ycwv6lvVjZNawpI74aFLaVujJ0hQbp8p+BEveDRR4/up7p5IcGGQ1J3TBWdY57Qo dLWqVs3wlb1zsYpAL7OaYK1nhW6jMnpRU8Z7a3I4C2iQ47tTwPGuVQ/qOVUgHYBx0JUC SfCQ== 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:reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=0mIHdzeqpLLVAXoLxv/ivBAsxFJuMaQ5HhkNdYNHfr4=; b=dAPKOPY30RHWrbqnTGZeQyD3JcMTqDkDzsxn2XMN9OWUOin+pCoNM0v323AidD0xJJ lKX8dnKmIlDY27KR2Uh9AkoRE2X6LrdbyNwbJNg/LK1O60WPGm4iNQQmAfPIpZPKBa3l TjnTk/fVyIQVEkVnb9qZVG9O6vj4tlKCvNnutMprzviDBzVkvxfvoZyEoNCvS3R+4V0y U4k7CnosFm7HWvBv4fDXg5ctnF7GBHlQeUMLbKwhsjsuUdbSqwDG8Gx9V9fBnRQormPE HBTTEo4XNfg1cHdQDt44njJAsJCpbq/22K4RL5yv4CK6EKkeQo1svHLDOPkSWAGj45X1 tszQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=GKRXcfBg; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a8si1953193otp.258.2020.02.06.06.51.04; Thu, 06 Feb 2020 06:51:17 -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=@gmail.com header.s=20161025 header.b=GKRXcfBg; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727913AbgBFOPi (ORCPT + 99 others); Thu, 6 Feb 2020 09:15:38 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:37312 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727511AbgBFOPi (ORCPT ); Thu, 6 Feb 2020 09:15:38 -0500 Received: by mail-wr1-f65.google.com with SMTP id w15so7396834wru.4 for ; Thu, 06 Feb 2020 06:15:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:reply-to:references:mime-version :content-disposition:in-reply-to:user-agent; bh=0mIHdzeqpLLVAXoLxv/ivBAsxFJuMaQ5HhkNdYNHfr4=; b=GKRXcfBgyN60W5V2e8tDnm6xwx6oVQO5KxN0UZzvrxv8sWQ57CAfKlafMjX9J77pUg zJu6NKvaZOR+P7+bwPSMDXQiM6sB0KtlEPGvnWYe0nkKRhR0Xw5UjvC8arnDzPUtLQip o/T4OSqrLxCwfsOTGgIt6q64XfdMAd+kqZbBcrzFSJq63QLeqvBl5kh2YETlpx3T4J3Z Ve0Zc6F36TFZnoWaXAlm13wTdRjOR3ZkDtpef65HGZWhjH/LZwn0tLBdcBBeKWB35NkR oSFpJiJ+XrVRSnQWw6UP5tszeYWMujYxbExGIhcQEAWdlLGWdJVN75X1ypUxpBsKHyCy z9fA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:reply-to :references:mime-version:content-disposition:in-reply-to:user-agent; bh=0mIHdzeqpLLVAXoLxv/ivBAsxFJuMaQ5HhkNdYNHfr4=; b=JYCtS8Nt+EevH8udgs2ZxT+vsWIEPS5+k2sEjpRV+hUpLbyQ0TGYh1c+9yIGtYJiZ7 8NrhcB1C7DqB/uulwIWPLP1qmmzWeuP4aiQ+ZJIcMPVysfFb1+RozzaRgXQzaiaFYdSp HGiCHczb1d+HSDtB5ebcb7bjbBgNbX+PPuc7db08IMPD5mgJa2I0MSLkmQlrFO0YFIuV 25Z28DvxPPmPRR4ZjAY4FQqtz4vy2dKDTIiB8V/KVYJD2bK1UflwONisf/sjnmQmYXoQ Tvi+S26jaY7mWZ1G/gllxfmwfgFQyh3k08yyvCeXy76hshO8tCWiu8jspYAo6TvO4omj dBxA== X-Gm-Message-State: APjAAAVaDdoUSmdjiyzXTpUh+KdD5JeVxlIkyrEsbZSj/gzo1WfOru2a rYB9FphvLNAHA4NkKEXCHRJgVLR+ X-Received: by 2002:a5d:4a06:: with SMTP id m6mr4051750wrq.155.1580998536235; Thu, 06 Feb 2020 06:15:36 -0800 (PST) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id t9sm3667009wmj.28.2020.02.06.06.15.35 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Feb 2020 06:15:35 -0800 (PST) Date: Thu, 6 Feb 2020 14:15:35 +0000 From: Wei Yang To: Baoquan He Cc: David Hildenbrand , Wei Yang , akpm@linux-foundation.org, osalvador@suse.de, dan.j.williams@intel.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm/sparsemem: pfn_to_page is not valid yet on SPARSEMEM Message-ID: <20200206141535.4w4h5wnuzxmi37wu@master> Reply-To: Wei Yang References: <20200206125343.9070-1-richardw.yang@linux.intel.com> <6d9e36cb-ee4a-00c8-447b-9b75a0262c3a@redhat.com> <20200206135016.GA25537@MiWiFi-R3L-srv> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200206135016.GA25537@MiWiFi-R3L-srv> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 06, 2020 at 09:50:16PM +0800, Baoquan He wrote: >On 02/06/20 at 02:28pm, David Hildenbrand wrote: >> On 06.02.20 13:53, 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. >> > >> > 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); >> >> If you add sub-sections that don't fall onto the start of the section, >> >> pfn_to_page(start_pfn) != memmap >> >> and your patch would break that under SPARSEMEM_VMEMMAP if I am not wrong. > >It returns the pfn_to_page(pfn) from __populate_section_memmap() and >assign to memmap in vmemmap case, how come it breaks anything. Correct >me if I was wrong. > Just see your reply. Thanks for your explanation. :-) >> David / dhildenb -- Wei Yang Help you, Help me