Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1078470ybv; Wed, 5 Feb 2020 20:42:21 -0800 (PST) X-Google-Smtp-Source: APXvYqyRu+KSqLPAqjcrpExfm6S14mP++lpX4nZfMW3QVY+cE0wAscrbMmg5LzXtbIqBlbUyfnu3 X-Received: by 2002:aca:1c01:: with SMTP id c1mr5739441oic.18.1580964141384; Wed, 05 Feb 2020 20:42:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580964141; cv=none; d=google.com; s=arc-20160816; b=K/GoYWgVC4HvqXg/7aJ2TjMvPyCpmLONlHCqBgQ6bgtYSA1bhfupA8GhBfgOSx+P7y NalYcquflfix3eQcq3xT7M8+CPqExUMGBLfO18Pp50vJwSbeAQMWkI3SK7v9E6/XAD/Q qNwZkmdZjvxNwRSWNdKMVHr9WGj3a1ed0ut51b8sEVwSF95UPZNT5/tuReaQYqVqmzxq kwZwad2vWo21UAe1ZLTGN3BFdhAp5kjjrTa4SZ1T4G4NnNIsltSMUhDuUTVEu3uZXJqt QDjrKJk9bo7WXsYZjvPNwqNKTQHbHPPk4y+YS3UVRoroGK556bJsIhulRmeTZ+2+Qi03 Zr6Q== 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=jD9/2mW1BpIu0uZXPhLN5/Mns7AsVR8pLNm1mJ7Pg7M=; b=BmWzsAbX1uRXg5Io1OW0mmTSN+KoQ4XIKYsgDazbkL8Ayugj/PsIjzPfDl+lJwcOnb 6+HFK/lIJCy+SGXI5YTtRKsp0kh/u6mkMs+042GfFTfLgUB8uPcZU755bhxU+FF3VyDX udx2s+WWTz2y8+hgaSLTmv1rX7hbpE5CvDnit2Sbx9WBKK2VfDITCsmdLxGcWQLL7HqF Mh1aPIRKG4XgHilSp6yYdwpXLwbz0Efa+UySWV9Wbv9NdfKRORggHjZDcqymH0Sc/oax S9zQRHrDn0Nk732T4r5NvZmbsZIPAm2IGdvg/ufcZtxuIoukZn4CsQ4qS+K8W5PfGZTG M3ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="iaC/j0Sn"; 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 l11si1359949otn.189.2020.02.05.20.42.08; Wed, 05 Feb 2020 20:42: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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="iaC/j0Sn"; 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 S1727762AbgBFEji (ORCPT + 99 others); Wed, 5 Feb 2020 23:39:38 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:28672 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726687AbgBFEji (ORCPT ); Wed, 5 Feb 2020 23:39:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580963976; 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=jD9/2mW1BpIu0uZXPhLN5/Mns7AsVR8pLNm1mJ7Pg7M=; b=iaC/j0SnGlhmfEBhxjZXdgxdccIf6l45Nl3zpt0dJWlAnALVEVr7As1dm2cx5I4R/XvTRA YkbGEeUsOX4NR/9ZShpv6Cnq8Y6To8Da+K1uzv5CYzGE8Suw6BXN5Mezbwa3l4gkdAfXK9 8xfswkkbrhiPG7bxCnYkCCt5f3oPrVk= 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-273-7niV5Q4BMNmUGktlzn4pLg-1; Wed, 05 Feb 2020 23:39:31 -0500 X-MC-Unique: 7niV5Q4BMNmUGktlzn4pLg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1F829800D5F; Thu, 6 Feb 2020 04:39:30 +0000 (UTC) Received: from localhost (ovpn-12-19.pek2.redhat.com [10.72.12.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 03A411C94F; Thu, 6 Feb 2020 04:39:26 +0000 (UTC) Date: Thu, 6 Feb 2020 12:39:24 +0800 From: Baoquan He To: Wei Yang Cc: Wei Yang , David Hildenbrand , 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: <20200206043924.GM8965@MiWiFi-R3L-srv> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200206043401.22i2cucwqctsrtps@master> User-Agent: Mutt/1.10.1 (2018-07-13) X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. > > >> > >> BTW, __add_pages() share the same logic as __remove_pages(). Why not change it > >> too? Do I miss something or I don't have the latest source code? > > > >Good question, and I think it need. Just David is refactoring/cleaning > >up the remove_pages() code path, this is found out by Segher from patch > >reviewing. > > Ah, we may need a following cleanup :-) Agree. See what David will say. Fold it into this patch, or anyone post a new one.