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=-8.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 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 710F3C2D0B1 for ; Thu, 6 Feb 2020 14:14:37 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 32E4F2082E for ; Thu, 6 Feb 2020 14:14:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Pnmv1SuS" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 32E4F2082E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id D09C06B0003; Thu, 6 Feb 2020 09:14:36 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CBB496B0006; Thu, 6 Feb 2020 09:14:36 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BCF9C6B0007; Thu, 6 Feb 2020 09:14:36 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0004.hostedemail.com [216.40.44.4]) by kanga.kvack.org (Postfix) with ESMTP id A32BA6B0003 for ; Thu, 6 Feb 2020 09:14:36 -0500 (EST) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 5918B3A9B for ; Thu, 6 Feb 2020 14:14:36 +0000 (UTC) X-FDA: 76459897752.04.shame31_453a5d4e2670e X-HE-Tag: shame31_453a5d4e2670e X-Filterd-Recvd-Size: 5837 Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) by imf46.hostedemail.com (Postfix) with ESMTP for ; Thu, 6 Feb 2020 14:14:35 +0000 (UTC) Received: by mail-wm1-f66.google.com with SMTP id q9so120337wmj.5 for ; Thu, 06 Feb 2020 06:14:35 -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=L4wzPANWYgERy1cMwQMGoaERgyMcBgGsGEw8L2NAiws=; b=Pnmv1SuSGpo08+31yoUVLBO9aAPsOeeVIP8x10+b/qESSGN6MXZBXMwoEFH7wsK1RF ANxyhhZl+x0TDBBToxCfaVO+ryfneBJLcSSV8Ksb53u8X8r2XTTecLzYwCVmSnKo3PZ+ 3ZB/q6nzkFlokp3Vf9lQyDpOvlnu4iYJ2BZ6oiGXugU4bPTI79ddB3l2bL7bDBqwoTok MS3rtYTLZLTkpZIDEpye8GdvNcU2UHD99Qm0C2bU52Afr5UN/5XObojYPEyb8uVVx5k8 9Yuz/CYrIT84XQ83RDMxrWdV9fZV+fCWuVmeSc4jAloQwL02lZ8caLEUL4//AHtqNbMr nseA== 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=L4wzPANWYgERy1cMwQMGoaERgyMcBgGsGEw8L2NAiws=; b=OJpI6iZwSb57/SO7XeA1bnhYBEB8eBQSEOAy1FAbndzs9fYBL+5TjquhmdYPfzgovC Ioc0WjBBbfiawAav71280/axKw4NVZtvueMt0A6kGbsZnnFlXkFmrzmucPkvIlQzfmcb J6jvzuThr6VaxDFHwOlKEVumTK9cGidcEod1vt02CV75tD0nZQFMfuiaKM+pva/lcE66 uufGXj5NzXZ92IwrVapsdRBhnF90BKL/nd7mqV/avxTeILFDcTW0f2Wkf0mvGNPj1FUq ZuH8y1OWu+G0ZbonrWQgbZEGenwOD/5vRbIa3/16fkSAXVr48yZgz5cAgPitVXYIaK56 OuxQ== X-Gm-Message-State: APjAAAXovMRr3eMbB2gILv7ZCmTJHvE/m050DSclihD1R+pwNMNVdmNH vuoqg4p+74QhisQIGQBh91g= X-Google-Smtp-Source: APXvYqxghAN5gjnjGAKwUOP9mL/xlFo3XoZhE8qAtbakKGvgyXc0jIjYm7P29ZowE4GrMji/ce7Zzg== X-Received: by 2002:a7b:ce8b:: with SMTP id q11mr4948042wmj.100.1580998474529; Thu, 06 Feb 2020 06:14:34 -0800 (PST) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id g21sm3731908wmh.17.2020.02.06.06.14.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Feb 2020 06:14:33 -0800 (PST) Date: Thu, 6 Feb 2020 14:14:33 +0000 From: Wei Yang To: David Hildenbrand Cc: Wei Yang , 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: <20200206141433.dqtqcuhb4g4wzyxd@master> Reply-To: Wei Yang References: <20200206125343.9070-1-richardw.yang@linux.intel.com> <6d9e36cb-ee4a-00c8-447b-9b75a0262c3a@redhat.com> <20200206135742.454wgna4ta76yv5w@master> <185d502e-d5a8-9149-18fc-1ef9b251843e@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <185d502e-d5a8-9149-18fc-1ef9b251843e@redhat.com> User-Agent: NeoMutt/20170113 (1.7.2) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, Feb 06, 2020 at 02:59:50PM +0100, David Hildenbrand wrote: >On 06.02.20 14:57, Wei Yang wrote: >> 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? > >I was assuming that memmap is the memmap of the section, not of the >sub-section. (judging from the change in the original patch) > >If the right memmap pointer to the sub-section is returned, then we are >fine. Will double check :) > Thanks, your comments are valuable :-) >-- >Thanks, > >David / dhildenb -- Wei Yang Help you, Help me