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.3 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 339F8C352A2 for ; Thu, 6 Feb 2020 13:50:29 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id EB615217BA for ; Thu, 6 Feb 2020 13:50:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="EBSnrko3" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EB615217BA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 972836B0003; Thu, 6 Feb 2020 08:50:28 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 949CB6B0006; Thu, 6 Feb 2020 08:50:28 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8127A6B0007; Thu, 6 Feb 2020 08:50:28 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0238.hostedemail.com [216.40.44.238]) by kanga.kvack.org (Postfix) with ESMTP id 693A86B0003 for ; Thu, 6 Feb 2020 08:50:28 -0500 (EST) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 20C77180AD804 for ; Thu, 6 Feb 2020 13:50:28 +0000 (UTC) X-FDA: 76459836936.14.woman96_40b6c3c6261b X-HE-Tag: woman96_40b6c3c6261b X-Filterd-Recvd-Size: 3868 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by imf13.hostedemail.com (Postfix) with ESMTP for ; Thu, 6 Feb 2020 13:50:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580997027; 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=W5cANr4eZW1Ze25yG7ClVn5wTKGraXdr9//7Uu9WkcI=; b=EBSnrko3/QIMsqyTo04Xwt16qF0s80bfzoRuP5c1jcJv8dcB5IqXsZnXkDgfUiWyB6WnHQ 07HiIBIQJguOX8eur154PUbvGKD6BU/dZo/O+fYYUhLj9ShT2YXCFlN0neqB+axbqpQXNj dx8zXVRB4/l/DNj+iomIsFd8tuO/lpM= 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-367-y_daEZWhN9CaDR13pcBrDw-1; Thu, 06 Feb 2020 08:50:23 -0500 X-MC-Unique: y_daEZWhN9CaDR13pcBrDw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DE93D18AB2E9; Thu, 6 Feb 2020 13:50:21 +0000 (UTC) Received: from localhost (ovpn-12-19.pek2.redhat.com [10.72.12.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2BF0F5DA7D; Thu, 6 Feb 2020 13:50:18 +0000 (UTC) Date: Thu, 6 Feb 2020 21:50:16 +0800 From: Baoquan He 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 Subject: Re: [PATCH] mm/sparsemem: pfn_to_page is not valid yet on SPARSEMEM Message-ID: <20200206135016.GA25537@MiWiFi-R3L-srv> 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: Mutt/1.10.1 (2018-07-13) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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 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. > > Instead of memmap, there would have to be something like > > memmap + (start_pfn - SECTION_ALIGN_DOWN(start_pfn)) > > If I am not wrong :) > > -- > Thanks, > > David / dhildenb