From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 92954C3F2D1 for ; Fri, 28 Feb 2020 09:58:39 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5345E246AA for ; Fri, 28 Feb 2020 09:58:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="UaeFpwFW" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5345E246AA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id CD8856B0005; Fri, 28 Feb 2020 04:58:38 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C88636B0006; Fri, 28 Feb 2020 04:58:38 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B9D826B0007; Fri, 28 Feb 2020 04:58:38 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0042.hostedemail.com [216.40.44.42]) by kanga.kvack.org (Postfix) with ESMTP id A04D56B0005 for ; Fri, 28 Feb 2020 04:58:38 -0500 (EST) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 60525180AD807 for ; Fri, 28 Feb 2020 09:58:38 +0000 (UTC) X-FDA: 76539086316.04.heat56_8597b7dc38b58 X-HE-Tag: heat56_8597b7dc38b58 X-Filterd-Recvd-Size: 3901 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by imf25.hostedemail.com (Postfix) with ESMTP for ; Fri, 28 Feb 2020 09:58:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582883917; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MNW9HVPqI0kTe9A0LBBiSsbv8ETEfJ83EjG1Wn7sou0=; b=UaeFpwFWyiH6w9h3cWQ9Ic4/u9PYEZJ7daPPksNGlJnU6XAiNenoODe/nK/jX2a4XzsxKh dinTss+oSyPVfChXViKWDTO3t0vS0fK1OW0QE4qo/CXmdqfIKp7AAhJNMGxigtmkshLC0o 14tTc0DhfYG0f1ksh6260ooWccxrmFs= 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-389-wBE7xIANOIGU3sQYTsMG0A-1; Fri, 28 Feb 2020 04:58:34 -0500 X-MC-Unique: wBE7xIANOIGU3sQYTsMG0A-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CFD30800D5B; Fri, 28 Feb 2020 09:58:32 +0000 (UTC) Received: from t480s.redhat.com (ovpn-117-180.ams2.redhat.com [10.36.117.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id A40C76E3EE; Fri, 28 Feb 2020 09:58:30 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Segher Boessenkool , Andrew Morton , Oscar Salvador , Michal Hocko , Baoquan He , Dan Williams , Wei Yang Subject: [PATCH v2 1/2] mm/memory_hotplug: simplify calculation of number of pages in __remove_pages() Date: Fri, 28 Feb 2020 10:58:18 +0100 Message-Id: <20200228095819.10750-2-david@redhat.com> In-Reply-To: <20200228095819.10750-1-david@redhat.com> References: <20200228095819.10750-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 fro= m 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 +=3D cur_nr_pages) { cond_resched(); /* Select all remaining pages up to the next section boundary */ - cur_nr_pages =3D min(end_pfn - pfn, -(pfn | PAGE_SECTION_MASK)); + cur_nr_pages =3D min(end_pfn - pfn, + SECTION_ALIGN_UP(pfn + 1) - pfn); __remove_section(pfn, cur_nr_pages, map_offset, altmap); map_offset =3D 0; } --=20 2.24.1