From: David Hildenbrand <david@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: linux-mm@kvack.org, Andrew Morton <akpm@linux-foundation.org>,
Wei Yang <richard.weiyang@gmail.com>
Subject: Re: [PATCH v1 1/2] mm/highmem: reimplement totalhigh_pages() by walking zones
Date: Fri, 7 Jun 2024 23:04:53 +0200 [thread overview]
Message-ID: <b57e5bc4-eb72-40e3-add4-57dfa6e03df6@redhat.com> (raw)
In-Reply-To: <20240607083711.62833-2-david@redhat.com>
On 07.06.24 10:37, David Hildenbrand wrote:
> Can we get rid of the highmem ifdef in adjust_managed_page_count()?
> Likely yes: we don't have that many totalhigh_pages() users, and they
> all don't seem to be very performance critical.
>
> So let's implement totalhigh_pages() like nr_free_highpages(),
> collecting information from all zones. This is now similar to what we do
> in si_meminfo_node() to collect the per-node highmem page count.
>
> In the common case (single node, 3-4 zones), we really shouldn't care.
> We could optimize a bit further (only walk ZONE_HIGHMEM and ZONE_MOVABLE
> if required), but there doesn't seem a real need for that.
>
> Signed-off-by: David Hildenbrand <david@redhat.com>
> ---
> include/linux/highmem-internal.h | 9 ++-------
> mm/highmem.c | 16 +++++++++++++---
> mm/page_alloc.c | 4 ----
> 3 files changed, 15 insertions(+), 14 deletions(-)
>
> diff --git a/include/linux/highmem-internal.h b/include/linux/highmem-internal.h
> index a3028e400a9c6..65f865fbbac04 100644
> --- a/include/linux/highmem-internal.h
> +++ b/include/linux/highmem-internal.h
> @@ -132,7 +132,7 @@ static inline void __kunmap_atomic(const void *addr)
> }
>
> unsigned int __nr_free_highpages(void);
> -extern atomic_long_t _totalhigh_pages;
> +unsigned long __totalhigh_pages(void);
>
> static inline unsigned int nr_free_highpages(void)
> {
> @@ -141,12 +141,7 @@ static inline unsigned int nr_free_highpages(void)
>
> static inline unsigned long totalhigh_pages(void)
> {
> - return (unsigned long)atomic_long_read(&_totalhigh_pages);
> -}
> -
> -static inline void totalhigh_pages_add(long count)
> -{
> - atomic_long_add(count, &_totalhigh_pages);
> + return __totalhigh_pages();
> }
>
> static inline bool is_kmap_addr(const void *x)
> diff --git a/mm/highmem.c b/mm/highmem.c
> index bd48ba445dd41..3c4e9f8c26dcd 100644
> --- a/mm/highmem.c
> +++ b/mm/highmem.c
> @@ -111,9 +111,6 @@ static inline wait_queue_head_t *get_pkmap_wait_queue_head(unsigned int color)
> }
> #endif
>
> -atomic_long_t _totalhigh_pages __read_mostly;
> -EXPORT_SYMBOL(_totalhigh_pages);
> -
> unsigned int __nr_free_highpages(void)
> {
> struct zone *zone;
> @@ -127,6 +124,19 @@ unsigned int __nr_free_highpages(void)
> return pages;
> }
>
> +unsigned long __totalhigh_pages(void)
> +{
> + unsigned long pages = 0;
> + struct zone *zone;
> +
> + for_each_populated_zone(zone) {
> + if (is_highmem(zone))
> + pages += zone_managed_pages(zone);
> + }
> +
> + return pages;
> +}
> +
Another (later than usual, but better late than never) build bot complaint:
diff --git a/mm/highmem.c b/mm/highmem.c
index 3c4e9f8c26dcd..b14771fb05ed1 100644
--- a/mm/highmem.c
+++ b/mm/highmem.c
@@ -136,6 +136,7 @@ unsigned long __totalhigh_pages(void)
return pages;
}
+EXPORT_SYMBOL(__totalhigh_pages);
static int pkmap_count[LAST_PKMAP];
static __cacheline_aligned_in_smp DEFINE_SPINLOCK(kmap_lock);
--
Cheers,
David / dhildenb
next prev parent reply other threads:[~2024-06-07 21:04 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-07 8:37 [PATCH v1 0/2] mm/highmem: don't track highmem pages manually David Hildenbrand
2024-06-07 8:37 ` [PATCH v1 1/2] mm/highmem: reimplement totalhigh_pages() by walking zones David Hildenbrand
2024-06-07 21:04 ` David Hildenbrand [this message]
2024-06-08 0:48 ` Wei Yang
2024-06-10 3:23 ` Oscar Salvador
2024-06-07 8:37 ` [PATCH v1 2/2] mm/highmem: make nr_free_highpages() return "unsigned long" David Hildenbrand
2024-06-08 0:51 ` Wei Yang
2024-06-10 8:23 ` David Hildenbrand
2024-06-10 3:40 ` Oscar Salvador
2024-06-10 8:22 ` David Hildenbrand
2024-06-11 0:56 ` Wei Yang
2024-06-11 9:20 ` David Hildenbrand
2024-06-12 7:01 ` Wei Yang
2024-06-12 7:22 ` David Hildenbrand
2024-06-12 7:34 ` Wei Yang
2024-06-08 0:45 ` [PATCH v1 0/2] mm/highmem: don't track highmem pages manually 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=b57e5bc4-eb72-40e3-add4-57dfa6e03df6@redhat.com \
--to=david@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=richard.weiyang@gmail.com \
/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
Powered by JetHome