Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp482258ybv; Fri, 7 Feb 2020 03:04:58 -0800 (PST) X-Google-Smtp-Source: APXvYqxXCndIaoyfMWu+bdG8tdqCkzA0hHnXN1uW+vR/I27k1sHOiej+lStZnZc1ldaPQ/eyEuC1 X-Received: by 2002:a9d:6283:: with SMTP id x3mr2136290otk.367.1581073498159; Fri, 07 Feb 2020 03:04:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581073498; cv=none; d=google.com; s=arc-20160816; b=i42Jq2Mflq4j2L+DHqycf4edsciMFBujxpAI/m1c7dM1XiCNnh2yoxzrLIlUvpu7ky J2MI/HTwYCQxgip/8runil4UxWi+HwBpTKXYCAvR86WGVUXOIrAf+eQEFvngtZNEOzzy s5k1aIWNy8f6fpmhmGu92Sn+JidCvHnkxk3OhLX8OVY23ZSOEzweTbFi3X696D+kafv0 WqtYns/mLcs01FJJ4w7G83ZWL85QGlK3G6xlmwsMEVeYrokgGTjUL7mdOzK136DNqQZ0 PlUGbrjLVgYTNrvsnTkB0aqfT1cpQoJf2StYBPkVE4chJay5jRG+PyPK79MdT2GDbCWm FW9w== 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=Pr/AFFZh+9W+/zvI3rplARVHDi+LtGtzWNQb6hfXDww=; b=yu2x/XkTXbXBDyjdrunn+Hv1aW1WvJfhpI898H4oatZZdzdBJm6kED94v1H3gR7muF BBwOkaxjINk+qTBKXY1cFDTfAqbONuuk/PIUGFRicby7pLwarFdKynfjKjkwZgLjtVm7 8FZ3RDYQWcNDyZucztgdJR5UD/i4nYVfHn4PaZPjK7UDSALbvMi+JIflWK+TD12GhWaq zb56H2QjRA9IeAHYcEhXI0+1K67tib0SN+2oQU2lA/NpF3nw7j4InkYJ9cFuE8SNJtcn w5ic9ncYalJmphcMQ9x0gceGjPfVAPyC+yHaIdbfvAvKAXep4FGZynd4uWXb5iZ5nksE xW6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=URmXcpaA; 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 t3si3778811oig.25.2020.02.07.03.04.36; Fri, 07 Feb 2020 03:04:58 -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=URmXcpaA; 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 S1727026AbgBGLCF (ORCPT + 99 others); Fri, 7 Feb 2020 06:02:05 -0500 Received: from mail-wm1-f67.google.com ([209.85.128.67]:54928 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726674AbgBGLCE (ORCPT ); Fri, 7 Feb 2020 06:02:04 -0500 Received: by mail-wm1-f67.google.com with SMTP id g1so2083102wmh.4 for ; Fri, 07 Feb 2020 03:02:02 -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=Pr/AFFZh+9W+/zvI3rplARVHDi+LtGtzWNQb6hfXDww=; b=URmXcpaAWOrS3/SMZE4NVbt7qQF6+RTfC3TNmZdDu58fLYTCJph2tT3pLVM+DgUI3T mldH4MppB/34vOusWxFfmwFGuJsad1OtmCsOeaNCEd4UC2GIe9BSOpfM31IXPr6hyA59 bi0onuaTVyGGBKCxDGxTUnLQy8UNN7EAFaeLN1V5gE5S3zNi8r6yAT3IANbs/qDls0qQ HkJi8k+BsSXXgQvTlBfyASCwwJUbUvs4vI97w1YTofc9bX3kCd6wQDBUBYc72d+JnQn4 MKl1m6Bvs/amulmzzmBNBFmeE8JDI+WUrxNJhdfSQJMovI1e6nN57L7c+UAp/jMrsZKa 8fXQ== 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=Pr/AFFZh+9W+/zvI3rplARVHDi+LtGtzWNQb6hfXDww=; b=uIPC0lIsUHzfYQA18KBsNZ29sjCAZQ1hA3dmDCBPrOUr3+RctKrwFeY4yu7NNtFj7h omZBCyBaK/PbtMQvLrY4zq+PAtWNtyjPcx7jCoJYOiC23emBXh/u4oiEz0/Zn+/xrctg ePg8Ku1/MHHN6yR5IJuJFYp2q11D3xsKCaLa6ON7lGpKauWEDUaBr86PV/LhrqzR+ENZ yzcQezFEcUs5b3CoPtDRL9maU8zh98cBQF082VXQCHVW/KbK7GdlRevj5JJdJoS7X4LH 0PcNP6I6/+KMzr0VCnxfrNNB2/NWAdpM9Qo2skAMflWPnLHLwKfefQWmhHC4e1C8rouC vPiw== X-Gm-Message-State: APjAAAV5uN5fPUZw9AWv0pq5wfuhqq4vRap/co8xvs5kQ40RWKsedsmS Yr242aN9Jy9pEPhSAshvihY= X-Received: by 2002:a1c:770e:: with SMTP id t14mr3791122wmi.101.1581073321737; Fri, 07 Feb 2020 03:02:01 -0800 (PST) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id e17sm2735445wrn.62.2020.02.07.03.02.01 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 07 Feb 2020 03:02:01 -0800 (PST) Date: Fri, 7 Feb 2020 11:02:00 +0000 From: Wei Yang To: Dan Williams Cc: Wei Yang , Andrew Morton , Oscar Salvador , Linux MM , Linux Kernel Mailing List , Baoquan He , David Hildenbrand Subject: Re: [PATCH 3/3] mm/sparsemem: avoid memmap overwrite for non-SPARSEMEM_VMEMMAP Message-ID: <20200207110200.leb2uutwdp5sxmpu@master> Reply-To: Wei Yang 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: 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 06:06:54PM -0800, 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? Oh, you are right. Thanks -- Wei Yang Help you, Help me