Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1543858ybv; Thu, 6 Feb 2020 05:59:06 -0800 (PST) X-Google-Smtp-Source: APXvYqwo4f2RHOVe8NAq+ToPIHPSuE2/DzMaTl1XMm4dUeejjh3KAe7J8aBZwOcH0UFYZlxEqnh5 X-Received: by 2002:aca:ea43:: with SMTP id i64mr7062919oih.30.1580997546090; Thu, 06 Feb 2020 05:59:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580997546; cv=none; d=google.com; s=arc-20160816; b=JfOajuhybeJ6dn5DxCFmKB8Jo2mFdsn1VFMHm5fiRrukBv70GVQpniyghtil/+Piql 1x4j0Wcv7+oJGg3OqlT/K1ZUtWonWuFDXC0hx4Eg97gbbsvRKX+PL5EH/cYLfv5NPB2K dJhmUYU6Hm9IAcSXKwlHU6lwpRWFjKPx8Uz5iT3vMcDb5k3v4iRUP3b5qtLEcITRJGhg ODUai8CKzLJPl6l+3ge/M7yz1bOS132oVgVNukamcRTqU73ildiucHPzkUzgkQh/SYx0 MfagLeq5Dj+m66Uy3NE2Qhd92ioPNRDgvj0OcfSkNudjMe++mhiroaZGoWsUwXNvToSw N/EQ== 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=37rkqrVeTaF+mZnTFwvQ9NfsdsUskom+KVb6+jBTRMY=; b=UqGIZfeiG0fbBOd1lY5reNjunLQMSvNzKRo0MEkgP1qQ7Dwkbfzwa2sqTFIJRb8RTd cHaBX8XPC8CnyUezG2D5CpwyJm0dSXsBxXCKauosNXWb6w3s3n5jbVH8h2CdJJYSEj5U FCU7EOk2155yDwDoTmDFPjhxXwdFL1zjF09YWFd9ykIBUBmbPacK85wZFoc9fZebXpTd /EmBeqrG1oPYkntWCxXjo8A+cEMuh6L7TTvs5mBQ43dIVrVcsvX3JyJlL+xl0DEIKX4v eiubv4PVbYsUiMa55TlMY9dUzMONIk83D2qJybol7pMR3bRfrl68kjGH2BRs1X7jYQHn NTPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=WyQ5OENC; 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 d199si2242509oib.135.2020.02.06.05.58.54; Thu, 06 Feb 2020 05:59:06 -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=WyQ5OENC; 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 S1727861AbgBFN5q (ORCPT + 99 others); Thu, 6 Feb 2020 08:57:46 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:35712 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727549AbgBFN5q (ORCPT ); Thu, 6 Feb 2020 08:57:46 -0500 Received: by mail-wr1-f65.google.com with SMTP id w12so7347313wrt.2 for ; Thu, 06 Feb 2020 05:57:43 -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=37rkqrVeTaF+mZnTFwvQ9NfsdsUskom+KVb6+jBTRMY=; b=WyQ5OENCxNDcGZer2tSh2fFvA+ujWZQVW0Sq1drxk3NvK4WXYuCVzMS4Smv+KqAv2q jQDLMZtpsPg4NhYE8M9W68qbyhtUrvTIQTC+BuqKz8imR2fZpnUZMFXJSEb7PcjYTvy5 EV9dzmxQGtj0j4kQgFL2pZONUoLumxjg7CQCL83LqUqDx2rzo7sPtslyido2PJil4Jc4 TZzxkwvMFwFdFdbyY58gZA0m+HGsuuBdeBGaix4P/8dNTpp7ZeqRx/4vbBeRCmEaxp0P 5ghXItAykEskc0tJ8bP4JkEd33Lb71kzA5KqkMGRl3GRncQOf4Di0xJFtKT7aBsrR9M4 776A== 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=37rkqrVeTaF+mZnTFwvQ9NfsdsUskom+KVb6+jBTRMY=; b=UFIGvQYZtjPca73uoDGvFDXMaTv7Ks3+eSm3dWsr+9fBS1Uese+AK4MXGwCCTT+2PJ GsKHZwubaeY6CXMXoDxRIr+MO84R59ubVws+LNwtRVAmn4KdwZsPhI9RAQUvt8EuFS6x T9SZRc48yaxVFnYmxF6Eq0+YFvSO8fcDdZy73gFfzxaS+QvFAeb/7hER5f5Tc8nA8b6Y gsHxstBmy2Kt2dcWAeCiArZg7GN2XR1qJOp4OYhwIb8d61jpKeuwPOcds2Y7WWaZjY0f tnJXMH3+/Swutcq9KaNw3dA3gG2R/3QqgiItZYxgW44A89GFeb6G52T/L0Q++LN7rlpN S09A== X-Gm-Message-State: APjAAAVy0gINs27bNM6MQFztxb0LNNXk7Qi1/V/91w/6OJXI77nakwdC Le5TreZgsgQoN9+pDXQl8rQ= X-Received: by 2002:adf:f787:: with SMTP id q7mr3922226wrp.297.1580997463195; Thu, 06 Feb 2020 05:57:43 -0800 (PST) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id 124sm4030148wmc.29.2020.02.06.05.57.42 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Feb 2020 05:57:42 -0800 (PST) Date: Thu, 6 Feb 2020 13:57:42 +0000 From: Wei Yang To: David Hildenbrand Cc: Wei Yang , akpm@linux-foundation.org, osalvador@suse.de, dan.j.williams@intel.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, bhe@redhat.com Subject: Re: [PATCH] mm/sparsemem: pfn_to_page is not valid yet on SPARSEMEM Message-ID: <20200206135742.454wgna4ta76yv5w@master> Reply-To: Wei Yang References: <20200206125343.9070-1-richardw.yang@linux.intel.com> <6d9e36cb-ee4a-00c8-447b-9b75a0262c3a@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6d9e36cb-ee4a-00c8-447b-9b75a0262c3a@redhat.com> 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 02:28:53PM +0100, 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. > >Instead of memmap, there would have to be something like > >memmap + (start_pfn - SECTION_ALIGN_DOWN(start_pfn)) > >If I am not wrong :) Hi, David, Thanks for your comment. To be hones, I am not familiar with SPARSEMEM_VMEMMAP. Here is my understanding about section_activate() when SPARSEMEM_VMEMMAP is set. section_activate(nid, start_pfn, nr_pages, altmap) populate_section_mmemap(start_pfn, nr_pages, nid, altmap) __populate_section_mmemap(start_pfn, nr_pages, nid, altmap) return pfn_to_page(start_pfn) So the memmap is the page struct for start_pfn when SPARSEMEM_VMEMMAP is set. Maybe I missed some critical part? > >-- >Thanks, > >David / dhildenb -- Wei Yang Help you, Help me