Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp512153ybf; Fri, 28 Feb 2020 02:23:46 -0800 (PST) X-Google-Smtp-Source: APXvYqxZZcDBTBcGjGZzP9aAbicmcKTv978laTG8RnpXPItR/5EWUw3dQanyS08QvHxAnqxzNseG X-Received: by 2002:aca:2118:: with SMTP id 24mr2648942oiz.28.1582885426609; Fri, 28 Feb 2020 02:23:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582885426; cv=none; d=google.com; s=arc-20160816; b=qOdUDXCAqOWkcaDUup6ukdizC7LY/m6SwjqDr+7fVBZXwdTIC+cK5Kyp1dAPcC875Q N3pydJ2aoG71IgMXbVFdGiMrAaHQrbHAT71JqkLvHpysX0O1jdKk4OrfGiNsu1Hxg/+g w9DsfAXWW1rQYBtmALAdcB3DDXWP8Mlult3g+rSSqW6AguIYTDjrrXFfUhRDWjA3pdUI HWi6Kt438b50Mbxn+SIzWJYLdp2ULep0dnrUaaz8Vr29nTsLgfwkKh3V7qrhfa/HKRbS TgYvNx8AB4GbXwN0XToGcMeJ6b5e8M9vLBXTrobOzIgp0w79G1fNV0TtEgml0/chAicT mFaw== 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=UxuggNNzearR180tpKOC+gN2nR4ttuW45PhgH1v5/2w=; b=oMULT5seQBkFHRExbcZO/F6xZCY05WGyRVzPr4+8oOFXZJHY3qE1yfxrS1Aqj8hlJ9 u2n96wQfZQm57mTH0gwGUo/l/Pa9tTi+JlhcZdevZydZkFTVhxBezvEhilVdKWQiJ+sB 6OB1x70Xw7FuAm90nXYv0DdrizBCpPKt8thrvrWwJKEyWsfO6Po/DtblhnOubKpxO5DD DlDZ0x5P6zK/WtA3CF8255jt8OZpA7D3aktHZ984HAx1P2FgqLeWEt7nZD1iODeDghsb 9uSpBoTb4iCnZOR+OowvMhN2clKwfuzCGLEWJ8xdtZdfbrccP8cLCTyVbV2ekrsTD1/E 2eAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=QLwIe1zG; 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 i6si1298665otp.5.2020.02.28.02.23.34; Fri, 28 Feb 2020 02:23:46 -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=QLwIe1zG; 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 S1726538AbgB1KXJ (ORCPT + 99 others); Fri, 28 Feb 2020 05:23:09 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:49749 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726005AbgB1KXI (ORCPT ); Fri, 28 Feb 2020 05:23:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582885387; 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=UxuggNNzearR180tpKOC+gN2nR4ttuW45PhgH1v5/2w=; b=QLwIe1zGBi+ywmi8LVF2UeJbMRcT8ZwtgPdoSunqruyli7aJy0JkP0MnngYQIosdbukDLX ncKfs3TcOwVX8D9UZkRRkT0zxWnK22H+dPrT50pInYmMKL++QL8kuWAJxx5bUMhm9wvJu8 hQzQPmuEtL1VxcMbqgvqLpEQPUgT45I= 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-276-ttNN7RDmOGKWZpNVOC-gPw-1; Fri, 28 Feb 2020 05:23:02 -0500 X-MC-Unique: ttNN7RDmOGKWZpNVOC-gPw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 00B7D107ACC9; Fri, 28 Feb 2020 10:23:01 +0000 (UTC) Received: from localhost (ovpn-12-49.pek2.redhat.com [10.72.12.49]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2E60C101D48A; Fri, 28 Feb 2020 10:22:57 +0000 (UTC) Date: Fri, 28 Feb 2020 18:22:54 +0800 From: Baoquan He To: David Hildenbrand Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Segher Boessenkool , Andrew Morton , Oscar Salvador , Michal Hocko , Dan Williams , Wei Yang Subject: Re: [PATCH v2 1/2] mm/memory_hotplug: simplify calculation of number of pages in __remove_pages() Message-ID: <20200228102254.GL4937@MiWiFi-R3L-srv> References: <20200228095819.10750-1-david@redhat.com> <20200228095819.10750-2-david@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200228095819.10750-2-david@redhat.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/28/20 at 10:58am, David Hildenbrand wrote: > In commit 52fb87c81f11 ("mm/memory_hotplug: cleanup __remove_pages()"), > we cleaned up __remove_pages(), and introduced a shorter variant to > calculate the number of pages to the next section boundary. > > Turns out we can make this calculation easier to read. We always want to > have the number of pages (> 0) to the next section boundary, starting from > the current pfn. > > We'll clean up __remove_pages() in a follow-up patch and directly make > use of this computation. > > Suggested-by: Segher Boessenkool > Cc: Andrew Morton > Cc: Oscar Salvador > Cc: Michal Hocko > Cc: Baoquan He > Cc: Dan Williams > Cc: Wei Yang > Signed-off-by: David Hildenbrand > --- > mm/memory_hotplug.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c > index 4a9b3f6c6b37..8fe7e32dad48 100644 > --- a/mm/memory_hotplug.c > +++ b/mm/memory_hotplug.c > @@ -534,7 +534,8 @@ void __remove_pages(unsigned long pfn, unsigned long nr_pages, > for (; pfn < end_pfn; pfn += cur_nr_pages) { > cond_resched(); > /* Select all remaining pages up to the next section boundary */ > - cur_nr_pages = min(end_pfn - pfn, -(pfn | PAGE_SECTION_MASK)); > + cur_nr_pages = min(end_pfn - pfn, > + SECTION_ALIGN_UP(pfn + 1) - pfn); Reviewed-by: Baoquan He