Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp302283ybv; Wed, 5 Feb 2020 05:55:50 -0800 (PST) X-Google-Smtp-Source: APXvYqxZWP/ofIPnV+IrF/WW02a1+AtvAIPVK6AjXr84VYbeElcRK9qlgHy2989l8FjoF5fvBHr7 X-Received: by 2002:a05:6830:14c3:: with SMTP id t3mr25191835otq.213.1580910949993; Wed, 05 Feb 2020 05:55:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580910949; cv=none; d=google.com; s=arc-20160816; b=LQNyfFOAk8bRQAvKrtRzfRxr259E+Y1De5BZ8o7B4du2Kp9aEqkeBRyMYCo/M9jV1l Xuc/WZyMfiKSH/RuHspkBv2dVeAodFibCY7oKB1gfWAF9hrDwW4Cmp6EqHDYL4HQWCWR VFdHY87EhAYVSY5BWLjidxhiKpd1GvHJZL9ErMYOqdtqeKFvBP8ICrcxJjEwR91zkZ6d xPKuMRmZd75ZPduYVNctJqIUdG3yuhJKbikMH4OBZCqXrDo/Uj9iqDzZ0JHzzmzUvacm +T1xdLGHqyjqVMVpxsqsgOq819HEua+cVS5V4f70qh/quAaHbPE3L5pTBkf9SFv1+Cim EMzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=kMQltNsA1uUOUOr4lm3GKwUv0TAsDgw6Dk2mWcNnf7A=; b=axxqcnPPdWLgapEDIIUWnEJzf57f5G43IVqjvvVfNwBAYP4/L7cNpwSh4MteJaBV5g A/TI5p7RGK+0GUl6yWkFxp1NX8FmRZwDu2nnshJCz443T9r1u0qL7w4c+iwN04oHcqh/ IQ+FBis9IDhv35HjEMhZLl9STSIK0VRyUamUrNECv7SeuIatNrSQWDVwKkJGRjHA7Gmr u89U6WWTHWP1wCeA4YMjelFCH33HJ/n2nU+k4KqZtXb9znk06ehLaZu0fH5XUqct5G9w 6GOo8xlVZfd9fWaItq0s1tDme5oTo/oavDoF4Rmr1Ara0lq7UziQvh7TmvzSCLNOCDMq S00g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Y1HdVowG; 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 n2si7515078otq.315.2020.02.05.05.55.36; Wed, 05 Feb 2020 05:55:49 -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=Y1HdVowG; 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 S1728188AbgBENxE (ORCPT + 99 others); Wed, 5 Feb 2020 08:53:04 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:50415 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726308AbgBENxE (ORCPT ); Wed, 5 Feb 2020 08:53:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580910783; 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; bh=kMQltNsA1uUOUOr4lm3GKwUv0TAsDgw6Dk2mWcNnf7A=; b=Y1HdVowGUjC6b3vviRrkgYXVzPyVN5/JxMdg48J4MMi5YYhxaiUEVOq0IU+CxYKw1ANjvi aNDFbps1s+l7ZUpeRv7VIb1TWMU27F38u74PQpriXjc2oX5NnTXHgre3Wqkgfns/eLywzj bc08n0ySg3WatHA8e/W4ASa4flTDw2I= 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-291-N-9C93N-NWmPXdEIF_RnUg-1; Wed, 05 Feb 2020 08:52:59 -0500 X-MC-Unique: N-9C93N-NWmPXdEIF_RnUg-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 840CA184AEA4; Wed, 5 Feb 2020 13:52:57 +0000 (UTC) Received: from t480s.redhat.com (ovpn-116-217.ams2.redhat.com [10.36.116.217]) by smtp.corp.redhat.com (Postfix) with ESMTP id D139187B15; Wed, 5 Feb 2020 13:52:52 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Segher Boessenkool , Andrew Morton , Michal Hocko , Oscar Salvador , Baoquan He , Wei Yang Subject: [PATCH v1] mm/memory_hotplug: Easier calculation to get pages to next section boundary Date: Wed, 5 Feb 2020 14:52:51 +0100 Message-Id: <20200205135251.37488-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 +=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