mm/page_alloc: use clamp() to simplify code
This patch uses clamp() to simplify code in init_per_zone_wmark_min(). Link: https://lkml.kernel.org/r/20211021034830.1049150-1-bobo.shaobowang@huawei.com Signed-off-by: Wang ShaoBo <bobo.shaobowang@huawei.com> Reviewed-by: David Hildenbrand <david@redhat.com> Cc: Wei Yongjun <weiyongjun1@huawei.com> Cc: Li Bin <huawei.libin@huawei.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
committed by
Linus Torvalds
parent
9c25cbfcb3
commit
59d336bdf6
+4
-8
@@ -8477,16 +8477,12 @@ int __meminit init_per_zone_wmark_min(void)
|
|||||||
lowmem_kbytes = nr_free_buffer_pages() * (PAGE_SIZE >> 10);
|
lowmem_kbytes = nr_free_buffer_pages() * (PAGE_SIZE >> 10);
|
||||||
new_min_free_kbytes = int_sqrt(lowmem_kbytes * 16);
|
new_min_free_kbytes = int_sqrt(lowmem_kbytes * 16);
|
||||||
|
|
||||||
if (new_min_free_kbytes > user_min_free_kbytes) {
|
if (new_min_free_kbytes > user_min_free_kbytes)
|
||||||
min_free_kbytes = new_min_free_kbytes;
|
min_free_kbytes = clamp(new_min_free_kbytes, 128, 262144);
|
||||||
if (min_free_kbytes < 128)
|
else
|
||||||
min_free_kbytes = 128;
|
|
||||||
if (min_free_kbytes > 262144)
|
|
||||||
min_free_kbytes = 262144;
|
|
||||||
} else {
|
|
||||||
pr_warn("min_free_kbytes is not updated to %d because user defined value %d is preferred\n",
|
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);
|
new_min_free_kbytes, user_min_free_kbytes);
|
||||||
}
|
|
||||||
setup_per_zone_wmarks();
|
setup_per_zone_wmarks();
|
||||||
refresh_zone_stat_thresholds();
|
refresh_zone_stat_thresholds();
|
||||||
setup_per_zone_lowmem_reserve();
|
setup_per_zone_lowmem_reserve();
|
||||||
|
|||||||
Reference in New Issue
Block a user