* [PATCH] mm/page_alloc: use clamp() to simplify code
@ 2021-10-21 3:48 Wang ShaoBo
2021-10-21 8:50 ` David Hildenbrand
0 siblings, 1 reply; 2+ messages in thread
From: Wang ShaoBo @ 2021-10-21 3:48 UTC (permalink / raw)
To: akpm; +Cc: weiyongjun1, huawei.libin, linux-mm, linux-kernel
This patch uses clamp() to simplify code in init_per_zone_wmark_min().
Signed-off-by: Wang ShaoBo <bobo.shaobowang@huawei.com>
---
mm/page_alloc.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index b37435c274cf..d0449212a824 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -8460,16 +8460,12 @@ int __meminit init_per_zone_wmark_min(void)
lowmem_kbytes = nr_free_buffer_pages() * (PAGE_SIZE >> 10);
new_min_free_kbytes = int_sqrt(lowmem_kbytes * 16);
- if (new_min_free_kbytes > user_min_free_kbytes) {
- min_free_kbytes = new_min_free_kbytes;
- if (min_free_kbytes < 128)
- min_free_kbytes = 128;
- if (min_free_kbytes > 262144)
- min_free_kbytes = 262144;
- } else {
+ if (new_min_free_kbytes > user_min_free_kbytes)
+ min_free_kbytes = clamp(new_min_free_kbytes, 128, 262144);
+ else
pr_warn("min_free_kbytes is not updated to %d because user defined value %d is preferred\n",
new_min_free_kbytes, user_min_free_kbytes);
- }
+
setup_per_zone_wmarks();
refresh_zone_stat_thresholds();
setup_per_zone_lowmem_reserve();
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] mm/page_alloc: use clamp() to simplify code
2021-10-21 3:48 [PATCH] mm/page_alloc: use clamp() to simplify code Wang ShaoBo
@ 2021-10-21 8:50 ` David Hildenbrand
0 siblings, 0 replies; 2+ messages in thread
From: David Hildenbrand @ 2021-10-21 8:50 UTC (permalink / raw)
To: Wang ShaoBo, akpm; +Cc: weiyongjun1, huawei.libin, linux-mm, linux-kernel
On 21.10.21 05:48, Wang ShaoBo wrote:
> This patch uses clamp() to simplify code in init_per_zone_wmark_min().
>
> Signed-off-by: Wang ShaoBo <bobo.shaobowang@huawei.com>
> ---
> mm/page_alloc.c | 12 ++++--------
> 1 file changed, 4 insertions(+), 8 deletions(-)
>
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index b37435c274cf..d0449212a824 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -8460,16 +8460,12 @@ int __meminit init_per_zone_wmark_min(void)
> lowmem_kbytes = nr_free_buffer_pages() * (PAGE_SIZE >> 10);
> new_min_free_kbytes = int_sqrt(lowmem_kbytes * 16);
>
> - if (new_min_free_kbytes > user_min_free_kbytes) {
> - min_free_kbytes = new_min_free_kbytes;
> - if (min_free_kbytes < 128)
> - min_free_kbytes = 128;
> - if (min_free_kbytes > 262144)
> - min_free_kbytes = 262144;
> - } else {
> + if (new_min_free_kbytes > user_min_free_kbytes)
> + min_free_kbytes = clamp(new_min_free_kbytes, 128, 262144);
> + else
> pr_warn("min_free_kbytes is not updated to %d because user defined value %d is preferred\n",
> new_min_free_kbytes, user_min_free_kbytes);
> - }
> +
> setup_per_zone_wmarks();
> refresh_zone_stat_thresholds();
> setup_per_zone_lowmem_reserve();
>
Reviewed-by: David Hildenbrand <david@redhat.com>
--
Thanks,
David / dhildenb
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-10-21 8:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-21 3:48 [PATCH] mm/page_alloc: use clamp() to simplify code Wang ShaoBo
2021-10-21 8:50 ` David Hildenbrand
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).