linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: linux-mm@kvack.org, David Hildenbrand <david@redhat.com>,
	Segher Boessenkool <segher@kernel.crashing.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Oscar Salvador <osalvador@suse.de>,
	Michal Hocko <mhocko@kernel.org>, Baoquan He <bhe@redhat.com>,
	Dan Williams <dan.j.williams@intel.com>,
	Wei Yang <richardw.yang@linux.intel.com>
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	[thread overview]
Message-ID: <20200228095819.10750-2-david@redhat.com> (raw)
In-Reply-To: <20200228095819.10750-1-david@redhat.com>

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 <segher@kernel.crashing.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Baoquan He <bhe@redhat.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Wei Yang <richardw.yang@linux.intel.com>
Signed-off-by: David Hildenbrand <david@redhat.com>
---
 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);
 		__remove_section(pfn, cur_nr_pages, map_offset, altmap);
 		map_offset = 0;
 	}
-- 
2.24.1



  reply	other threads:[~2020-02-28  9:58 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-28  9:58 [PATCH v2 0/2] mm/memory_hotplug: __add_pages() and __remove_pages() cleanups David Hildenbrand
2020-02-28  9:58 ` David Hildenbrand [this message]
2020-02-28 10:22   ` [PATCH v2 1/2] mm/memory_hotplug: simplify calculation of number of pages in __remove_pages() Baoquan He
2020-02-28 13:25   ` Wei Yang
2020-03-29 19:19   ` David Hildenbrand
2020-03-29 20:09     ` Linus Torvalds
2020-03-29 20:17       ` David Hildenbrand
2020-03-29 20:26         ` Linus Torvalds
2020-03-29 20:18       ` Linus Torvalds
2020-03-29 20:41         ` David Hildenbrand
2020-03-30 22:14           ` Andrew Morton
2020-03-30 22:27             ` Linus Torvalds
2020-02-28  9:58 ` [PATCH v2 2/2] mm/memory_hotplug: cleanup __add_pages() David Hildenbrand
2020-02-28 10:34   ` Baoquan He
2020-02-28 11:14     ` David Hildenbrand
2020-03-01  5:39       ` Baoquan He
2020-02-28 13:26   ` Wei Yang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200228095819.10750-2-david@redhat.com \
    --to=david@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=bhe@redhat.com \
    --cc=dan.j.williams@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@kernel.org \
    --cc=osalvador@suse.de \
    --cc=richardw.yang@linux.intel.com \
    --cc=segher@kernel.crashing.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).