Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1465060ybv; Thu, 6 Feb 2020 04:39:21 -0800 (PST) X-Google-Smtp-Source: APXvYqwZWMV1p+OmQMhnhmRD2RarGl79svzCyBC0M5PxADU83L3uaMg+5eXVAGtowJgnT3Co1W1O X-Received: by 2002:a9d:65da:: with SMTP id z26mr30341987oth.197.1580992761264; Thu, 06 Feb 2020 04:39:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580992761; cv=none; d=google.com; s=arc-20160816; b=FPZfI6sHL+Bj2h5cFn807me4GwPUA/2B+/PQ0fJnOA/WPS4vVWjAvvaKA0GI06erhI e6hns2v/Y/bS8PPPXZAvN1ezxw/dEptysuxRoYeGavtszJN4sMal7Q8d0GGwsUjdjV+Z fWHTG8Uv9o3MYxTkiamCrvdUd6hbO1hx9EyOnyQfECrgAvBN0tmRD/Idd465OQ3cUGsj wNatAe+aJGXc2ApZbPqWfCjslCYMXcCkj5ZV5cF6PuSEwSBn2fZIFt0dJZV4XVmWK9wM LNqmWdFbiPRYtG/7RutC/ewQV90AbZF+cxH1hVUYPS3Z/iajY4VLnVzQNFdV4TeGoZBA 9kwQ== 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; bh=Pvb5Lq5mLvkgI32T4Web6EEelbvMY8wXBU/Tf1xcERM=; b=r1pBJPDUVOnP3b8EFRkjoc3CvnxXUG/NbNbBckJh9cIpaRXJf3EDcQ4RTWqZY9BB8K fcyIQNWEz9k/fSZD6ad1NC4WjjwViWl2jhw1OLxHZgoR1tUXks6S18PGKbvv40O+L5e0 ti/otLyGxpa9B/3TNrQYwg630yoMMJf8nGXHdHIuIFtjW4hUDq1v1/DF3ulcrO8wLYhY Ee/rsiH4Vmb5k498BmwBsp0M7/yHQhJ8ioQ73AfECV+LEWi9MrOPX3Uyuj4KCQ1vsaQk SFoeYSJ1dYXY8PBmXT/gmjRZVOktyvpQb0+27aKMc0pXxjI/fCbRN+EGphhnDuFmBysC XKLQ== ARC-Authentication-Results: i=1; mx.google.com; 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 l139si1879606oih.233.2020.02.06.04.39.07; Thu, 06 Feb 2020 04:39:21 -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; 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 S1727390AbgBFLh7 (ORCPT + 99 others); Thu, 6 Feb 2020 06:37:59 -0500 Received: from mga18.intel.com ([134.134.136.126]:49547 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726687AbgBFLh6 (ORCPT ); Thu, 6 Feb 2020 06:37:58 -0500 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Feb 2020 03:37:58 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,409,1574150400"; d="scan'208";a="264572935" Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.54]) by fmsmga002.fm.intel.com with ESMTP; 06 Feb 2020 03:37:56 -0800 Date: Thu, 6 Feb 2020 19:38:12 +0800 From: Wei Yang To: David Hildenbrand Cc: Baoquan He , Wei Yang , Wei Yang , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Segher Boessenkool , Andrew Morton , Michal Hocko , Oscar Salvador Subject: Re: [PATCH v1] mm/memory_hotplug: Easier calculation to get pages to next section boundary Message-ID: <20200206113812.GA7092@richard> Reply-To: Wei Yang References: <20200205135251.37488-1-david@redhat.com> <20200205231945.GB28446@richard> <20200205235007.GA28870@richard> <20200206001317.GH8965@MiWiFi-R3L-srv> <20200206003736.GI8965@MiWiFi-R3L-srv> <20200206022644.6u7pxf7by2w5trmi@master> <20200206024816.GK8965@MiWiFi-R3L-srv> <20200206043401.22i2cucwqctsrtps@master> <20200206043924.GM8965@MiWiFi-R3L-srv> <14cca79e-2e76-28ef-1a17-81f044548c33@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <14cca79e-2e76-28ef-1a17-81f044548c33@redhat.com> User-Agent: Mutt/1.9.4 (2018-02-28) 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 10:01:21AM +0100, David Hildenbrand wrote: >On 06.02.20 05:39, Baoquan He wrote: >> On 02/06/20 at 04:34am, Wei Yang wrote: >>> On Thu, Feb 06, 2020 at 10:48:16AM +0800, Baoquan He wrote: >>>> On 02/06/20 at 02:26am, Wei Yang wrote: >>>>> On Thu, Feb 06, 2020 at 08:37:36AM +0800, Baoquan He wrote: >>>>>> On 02/06/20 at 08:13am, Baoquan He wrote: >>>>>>> On 02/06/20 at 07:50am, Wei Yang wrote: >>>>>>>> On Thu, Feb 06, 2020 at 07:19:45AM +0800, Wei Yang wrote: >>>>>>>>> On Wed, Feb 05, 2020 at 02:52:51PM +0100, David Hildenbrand wrote: >>>>>>>>>> Let's use a calculation that's easier to understand and calculates the >>>>>>>>>> same result. Reusing existing macros makes this look nicer. >>>>>>>>>> >>>>>>>>>> We always want to have the number of pages (> 0) to the next section >>>>>>>>>> boundary, starting from the current pfn. >>>>>>>>>> >>>>>>>>>> Suggested-by: Segher Boessenkool >>>>>>>>>> Cc: Andrew Morton >>>>>>>>>> Cc: Michal Hocko >>>>>>>>>> Cc: Oscar Salvador >>>>>>>>>> Cc: Baoquan He >>>>>>>>>> Cc: Wei Yang >>>>>>>>>> Signed-off-by: David Hildenbrand >>>>>>>>> >>>>>>>>> Reviewed-by: Wei Yang >>>>>>>>> >>>>>>>>> BTW, I got one question about hotplug size requirement. >>>>>>>>> >>>>>>>>> I thought the hotplug range should be section size aligned, while taking a >>>>>>>>> look into current code function check_hotplug_memory_range() guard the range. >>>>>>> >>>>>>> A good question. The current code should be block size aligned. I >>>>>>> remember in some places we assume each block comprise all the sections. >>>>>>> Can't imagine one or some of them are half section filled. >>>>>> >>>>>> I could be wrong, half filled block may not cause problem. >>>>>> >>>>> >>>>> David must be angry about our flooding the mail list :-) >>>> >>>> Believe he won't, :-) If you like, we can talk off line. >>>> >>>>> >>>>> Check the code again, there are two memory range check: >>>>> >>>>> * check_hotplug_memory_range(), block/section aligned >>>>> * check_pfn_span(), subsection aligned >>>>> >>>>> The second check, check_pfn_span() in __add_pages(), enable the capability to >>>>> add a memory range with subsection size. >>>>> >>>>> This means hotplug still keeps section alignment. >>>> >>>> memremap_pages() also call add_pages(), it doesn't have the >>>> check_hotplug_memory_range() invocation. check_pfn_span() is made for >>>> it specifically. >>>> >>> >>> If my understanding is correct, memremap_pages() is used to add some dev >>> memory to system. This is the use case which Dan want to enable for >>> sub-section. Since memremap_pages() is not called in mem-hotplug path, this >>> doesn't affect the hotplug range alignment. >> >> Yeah, we are on the same page. > >We allow sub-section hoy-add only for device memory/hmm. BIOS often >align PMEM devices to sub-sections, and not supporting this makes life >difficult to support these devices. (You cannot simply cut off something >of a disk :) ) > >System memory can only be hotplugged in memory block granularity, the >same granularity onlining/offlining from user space will happen. Boot >memory, however, can be sub-section aligned, but can never be offlined >(as it contains holes) and therefore never be removed. > This makes life easier. Thanks for your explanation. -- Wei Yang Help you, Help me