Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp66608ybv; Thu, 6 Feb 2020 18:09:27 -0800 (PST) X-Google-Smtp-Source: APXvYqwZssm23KxYeQGwnlnAfLirEzGN2JX7XqiAKMb2qY5ua68h9Tl3hLffJHqWDM1X27zgcBGE X-Received: by 2002:a9d:7e8c:: with SMTP id m12mr918170otp.346.1581041367580; Thu, 06 Feb 2020 18:09:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581041367; cv=none; d=google.com; s=arc-20160816; b=KdzvAlhRCJRunFad2MZ5KJOgaAjkZ1iYDo2r6aLW05vYVEbs0tRWWWruMc3F+SWxNl eXgtBt7eVAo9Jf0JtRuwjdtgdA0s65/BU5LuTeNcgM7TavkF7KUIEvTd55BXuKZnUJ0k Z1qUnyCe9/GDZ1PJDhlAG0O7W5taF1gzkPnLyHzbFDrXjEHnEyysNq5wJwJ+nMolDPuo BQsx+gRm3BwRDSZ7XRvI6mfLROH3aL8YOy10Bkbq8gz+IJ4um3gsDL23So02/U+QmcZP +dVRwxQBfnzgszQgdzlWhwCd9U3U/FR81MVuB0QH5HUWO1uJKUMjWCxtzpxIutZCkdAP 2qig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=uvCOMTEZ/7iStxJtrD6tPP6xJ8Vye04ExaeRhOxsh7Y=; b=0Cmq2pC8ZLQalbAofnk206bFm0Bsn/lCfhZwkM4PSWAGx4Bf050JOww5xqNCvaYTYc nnwgqmVaQRKSmaO3Hs5yXG09EC+QWpwdclpIEvdNg19x9INA4BdixS14qgKEgMK2RJHD bE7V+O8FqiECxvM4Gek3M882biZaJ6By+4bXiGLLKoN/zQ1dmE5/gdoOD7WXWdTkERKK et+QekiTZejnN7YESx1HZMWQuWO7dIGT68TrPkfrFh8T9TS72+3WG5eSS1dzpqfaaufc XHIZyEN0IKyKu33KfP4oMuUhXQ2AYFST3IJJTcu0FmLWg4zX7mUlEQJbLcBs4n2HWLKb 7UzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=BeX6rgmG; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m26si889895otk.305.2020.02.06.18.09.12; Thu, 06 Feb 2020 18:09:27 -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=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=BeX6rgmG; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727303AbgBGCHG (ORCPT + 99 others); Thu, 6 Feb 2020 21:07:06 -0500 Received: from mail-ot1-f68.google.com ([209.85.210.68]:44887 "EHLO mail-ot1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726956AbgBGCHG (ORCPT ); Thu, 6 Feb 2020 21:07:06 -0500 Received: by mail-ot1-f68.google.com with SMTP id h9so653563otj.11 for ; Thu, 06 Feb 2020 18:07:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=uvCOMTEZ/7iStxJtrD6tPP6xJ8Vye04ExaeRhOxsh7Y=; b=BeX6rgmG81vvCZ0nexPUUfbwEJgSXrjahRwqQ+nN+qyiSOiRp9PDYDBdOJb8AetnzE bD0CCpw+fG7Xyke43KqqqAUCqTq4ajrAqN6FBIRq7RY3ae2cY2WSmsOMcEsWVt8TsHWe 7zFyxe/67QIsyrBHmyVAwZkTv7JxynLvwiVZGlMBatb7h6CwaUfYwW548/FUpcqU7yOm H+PB93h8nLAKHUke67jROUqxWc9vU+RZAogHknDerNbgometmHC89V/E8S6oCOJuX5bT 5nLJW8q0UZi2+MzOBMPg15ZMZ5bkVL6d6QbQqf25YgztL5H1yRclFDw0CLacHe/ElT/j Av7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=uvCOMTEZ/7iStxJtrD6tPP6xJ8Vye04ExaeRhOxsh7Y=; b=sFJTqdr7QYprJzkYcGDoCjHnMX9cHw4glVFEV+KOGYA1/vQf0RBKz7Yzu1V1ldeitS MfAlUfsalQPEb7Y0jxP2VUH56yrcqBogMGTteOjJS0hWQGNaR3lDGhqU53iD7vC1Ywc9 o232UAzqPugPMRzshJcnSZsFpCiHuJOUtPZ0ohLheqisufN5tAaI0xST7NIfM8Bfk6KJ Xoy9lypvp5isz1Uk4I3X/FSI5+y8uRozddAZgiS9Z0iFoQ36olFhwM32HiiMdEjb0B1y 1DpbZXZYGZKlzQ2rokugknBVq6518VbJCsc7vxXWcPGIIQZP9wJRolhdJ3HWpxljShnh inFA== X-Gm-Message-State: APjAAAXljMofQeoMOsaxxolPT7y4zaHUVyW3CiRvcSboqZdTy30suS+Z Kyj8Vr98r+I6CpuA4lQniyUexKKpnws1b7hTAj1hKg== X-Received: by 2002:a9d:64d8:: with SMTP id n24mr838353otl.71.1581041225376; Thu, 06 Feb 2020 18:07:05 -0800 (PST) MIME-Version: 1.0 References: <20200206231629.14151-1-richardw.yang@linux.intel.com> <20200206231629.14151-4-richardw.yang@linux.intel.com> In-Reply-To: <20200206231629.14151-4-richardw.yang@linux.intel.com> From: Dan Williams Date: Thu, 6 Feb 2020 18:06:54 -0800 Message-ID: Subject: Re: [PATCH 3/3] mm/sparsemem: avoid memmap overwrite for non-SPARSEMEM_VMEMMAP To: Wei Yang Cc: Andrew Morton , Oscar Salvador , Linux MM , Linux Kernel Mailing List , Baoquan He , David Hildenbrand Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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?