Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp143569ybv; Thu, 6 Feb 2020 19:52:23 -0800 (PST) X-Google-Smtp-Source: APXvYqw9XbRgTfomyjBsYtOxPBJynAoLMC5r1+h3ShwSyL9IriTWJXnwnh2Eq4IAw2kgigpwBkCM X-Received: by 2002:a9d:1c9c:: with SMTP id l28mr1137030ota.210.1581047543479; Thu, 06 Feb 2020 19:52:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581047543; cv=none; d=google.com; s=arc-20160816; b=FPLEmGP9Z+2zKDQyNOqpi0nAYgIIFvsdXvxVSuP7JQurOx+dUAc6cVj4EEMcM4Hw/y YtIO3YSGijQPXmCSq5RBLDjyJhkXX9CkTriacrkq2vwEmtaJtAknxP7Sd1ERb/ZTC64i 7pvzcUv+x2/gGNmoRm9oHfIPkdPDwiktFkcyLCg/vjx9vW1NWfW6H3ilYxqh/bqVwLwj sHyDsd30wXLGgM5Cc6pGg9lOXDFKqrr+wX9lBsAkrPzOJjMQyzAVtzvcIL7GLe9Qq1P+ m5KWTvskL0fsSKGJ52C1HeE1ZvTM4zpDD50ecnufqI+zhQ8L1Tp9RJK46hKTwUElblji GCCQ== 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=cx8e2wfAv9dePW9BR8XJjN0ewzvUtV9OKTioZ+Wm6BA=; b=ZwAlK1LG9U6a1JS5khwEbMCMW6aZuVIVMUdeNWzUiDMExKQ6YWg/OFlD/aDei5OFoO lAKaRK7kTMnr9ArfWMoq7fT3uSohey1TFRAX+5cdI2ZgXtr5pHUGrokXx4cOkrQRjuFC j3G2cggoFUCz5Zr5NG96KX7UEPqvofpzxCiPTibnXrZJKygONJefnMK2d8fMk/gDan/0 nosiQrUFv0lf2IITLzvk6hYWTHXLuF/S7o/gnHuhkVBR0+0FQ3XMnQz/wfa6CtHRW/9H i5p/voFJrL2OwcBdvEE7FLVcagFQmO6rbxsl5k8t0Gaf1mJoNEsU9xxs/rGFH8PxQ9hF PILw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="cuUu2WL/"; 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 m25si1058111otn.208.2020.02.06.19.52.11; Thu, 06 Feb 2020 19:52: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="cuUu2WL/"; 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 S1727490AbgBGDuf (ORCPT + 99 others); Thu, 6 Feb 2020 22:50:35 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:57416 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727131AbgBGDuf (ORCPT ); Thu, 6 Feb 2020 22:50:35 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581047434; 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=cx8e2wfAv9dePW9BR8XJjN0ewzvUtV9OKTioZ+Wm6BA=; b=cuUu2WL/twcExMymMpnvqibLKGnAxStHWoYcz+H+v+4e3wVoC3w+Az1Ehbrc3e6XxBQ1Kf tXCmW/FiU3z22goY84qhxzekO97u3/x8/mNSO6OChX7G2exlD5QM0LUvYIRteDL9QWugnW T3agiJ/WVkTRdtPmadBFJnluAw+sahs= 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-271-6GQjwyIGP5GxR10_2uQUXQ-1; Thu, 06 Feb 2020 22:50:30 -0500 X-MC-Unique: 6GQjwyIGP5GxR10_2uQUXQ-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 F24C9802CAC; Fri, 7 Feb 2020 03:50:28 +0000 (UTC) Received: from localhost (ovpn-12-30.pek2.redhat.com [10.72.12.30]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 08EF55DA7D; Fri, 7 Feb 2020 03:50:25 +0000 (UTC) Date: Fri, 7 Feb 2020 11:50:23 +0800 From: Baoquan He To: Dan Williams Cc: Wei Yang , Andrew Morton , Oscar Salvador , Linux MM , Linux Kernel Mailing List , David Hildenbrand Subject: Re: [PATCH 3/3] mm/sparsemem: avoid memmap overwrite for non-SPARSEMEM_VMEMMAP Message-ID: <20200207035023.GT8965@MiWiFi-R3L-srv> References: <20200206231629.14151-1-richardw.yang@linux.intel.com> <20200206231629.14151-4-richardw.yang@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/06/20 at 06:06pm, Dan Williams wrote: > On Thu, Feb 6, 2020 at 3:17 PM Wei Yang wrote: > > > > In case of SPARSEMEM, populate_section_memmap() would allocate memmap > > for the whole section, even we just want a sub-section. This would lead > > to memmap overwrite if we a sub-section to an already populated section. > > > > Just return the populated memmap for non-SPARSEMEM_VMEMMAP case. > > > > Fixes: ba72b4c8cf60 ("mm/sparsemem: support sub-section hotplug") > > Signed-off-by: Wei Yang > > CC: Dan Williams > > --- > > mm/sparse.c | 10 ++++++++++ > > 1 file changed, 10 insertions(+) > > > > diff --git a/mm/sparse.c b/mm/sparse.c > > index 56816f653588..c75ca40db513 100644 > > --- a/mm/sparse.c > > +++ b/mm/sparse.c > > @@ -836,6 +836,16 @@ static struct page * __meminit section_activate(int nid, unsigned long pfn, > > if (nr_pages < PAGES_PER_SECTION && early_section(ms)) > > return pfn_to_page(pfn); > > > > + /* > > + * If it is not SPARSEMEM_VMEMMAP, we always populate memmap for the > > + * whole section, even for a sub-section. > > + * > > + * Return its memmap if already populated to avoid memmap overwrite. > > + */ > > + if (!IS_ENABLED(CONFIG_SPARSEMEM_VMEMMAP) && > > + valid_section(ms)) > > + return __section_mem_map_addr(ms); > > Again, is check_pfn_span() failing to prevent this path? The answer should be yes, this patch is not needed. >