Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp948828ybv; Wed, 5 Feb 2020 17:48:57 -0800 (PST) X-Google-Smtp-Source: APXvYqwhaCGLeVdCre7eQnyWYpF+m37TMfh2dzpDYxTE3g5NDNeQowUlc6CCCxifo4iw2Qk09hp6 X-Received: by 2002:aca:2803:: with SMTP id 3mr5183304oix.162.1580953736878; Wed, 05 Feb 2020 17:48:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580953736; cv=none; d=google.com; s=arc-20160816; b=J8r3la616tj8nEda/kvkBvQKmRNBl6pu07oV/gj/1WGkt0LgNmw3tWek2ufEroGxze 0UYj6nhQC6M/011DYJlyojB0/WTTW20a2BPhZh66jI1bqI6U6cC/5OSSNb3+QEO3cm4k R/nN6D3GffK3NVdCefqYHDX8rUPS1f13u3u7fKeq0bt2dMaw8alPXp3IpwyoDRxusF8f HSVA2RY/hq1RjgbtsGjtVKZxyjtcxLKdVtl0EjZsx0XmFLYqabIEmH3uSHa8RSrKH3mk 3HwPOAf0Hs1G1nsVvoxfQhGy7suHbKWGVkI89r70Qf6ODrNr85mySWrl4bWjdrwRVZkO H8kw== 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=QFMZVwYTnIpL7fCFcXZb1GizaNxHu6MTVpIRsyiA0gQ=; b=QRhOysoXcbBr7NXOQT4uYTcB+tSMfwTXl51yKjKYCgWiBanwfW07yK00M0duTgaFE/ f5cwaOX1DIa3puockRLOVaFPOpqZo2muVPeieeV6dv3JCtdg0uWhhJM59nhKxxfyc4AB Kq6mEdh4iiyCNMVuAYIP1XkWKqaJgkaK/zjO5+h3nZcKHyQYc+a2pMeygLb9EoIuCg08 yTX+n3TEDoJVqzyO2XvW6fp7TlaboCZJ+qHbFcak3Z5qiw07jGCnhcxaACGbK9xZwzLa i6l5nghzD1eL012mw95Zt0bMipseCFPrwm2b4uFJwGnZR/Mlqg/gByS+2BNcdl47HQ2c Qx8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=RlzdZLPU; 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 p1si1133139otk.42.2020.02.05.17.48.44; Wed, 05 Feb 2020 17:48:56 -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=RlzdZLPU; 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 S1727561AbgBFBq4 (ORCPT + 99 others); Wed, 5 Feb 2020 20:46:56 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:54116 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727170AbgBFBqz (ORCPT ); Wed, 5 Feb 2020 20:46:55 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580953614; 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=QFMZVwYTnIpL7fCFcXZb1GizaNxHu6MTVpIRsyiA0gQ=; b=RlzdZLPUl5L2d8CZkKUhvMdXjAGtEhk29SH/M0EZcTTNWSaopmSUMZxb4RR8EgsQY7hnzz o3az559rtRnNWG64hEpWZUavLF7q2UEEr/Y87EA/XvnJjFndVJoledf0kUvi7XzpBOi7Fj CAO0KPIe7dHRdxRgt2K15w7XtybFdiw= 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-213-FQ5uAGHWOuGLBy3AOFBdww-1; Wed, 05 Feb 2020 20:46:50 -0500 X-MC-Unique: FQ5uAGHWOuGLBy3AOFBdww-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 B9A4F10753F3; Thu, 6 Feb 2020 01:46:48 +0000 (UTC) Received: from localhost (ovpn-12-19.pek2.redhat.com [10.72.12.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F0B271A7E3; Thu, 6 Feb 2020 01:46:45 +0000 (UTC) Date: Thu, 6 Feb 2020 09:46:42 +0800 From: Baoquan He To: David Hildenbrand Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Segher Boessenkool , Andrew Morton , Michal Hocko , Oscar Salvador , Wei Yang Subject: Re: [PATCH v1] mm/memory_hotplug: Easier calculation to get pages to next section boundary Message-ID: <20200206014642.GJ8965@MiWiFi-R3L-srv> References: <20200205135251.37488-1-david@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200205135251.37488-1-david@redhat.com> 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/05/20 at 02:52pm, 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 LGTM. Reviewed-by: Baoquan He > --- > 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 0a54ffac8c68..c30191183c04 100644 > --- a/mm/memory_hotplug.c > +++ b/mm/memory_hotplug.c > @@ -528,7 +528,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); > __remove_section(pfn, cur_nr_pages, map_offset, altmap); > map_offset = 0; > } > -- > 2.24.1 >