* [PATCH 0/7] cleanup with helper macro K()
@ 2023-08-04 1:25 Peng Zhang
2023-08-04 1:25 ` [PATCH 1/7] mm: remove redundant K() macro definition Peng Zhang
` (7 more replies)
0 siblings, 8 replies; 18+ messages in thread
From: Peng Zhang @ 2023-08-04 1:25 UTC (permalink / raw)
To: linux-mm; +Cc: akpm, wangkefeng.wang, sunnanyong, ZhangPeng
From: ZhangPeng <zhangpeng362@huawei.com>
Use helper macro K() to improve code readability. No functional
modification involved. Remove redundant K() macro definition.
ZhangPeng (7):
mm: remove redundant K() macro definition
mm/swapfile.c: use helper macro K()
mm/swap_state.c: use helper macro K()
mm/shmem.c: use helper macro K()
mm/nommu.c: use helper macro K()
mm/mmap.c: use helper macro K()
mm/hugetlb.c: use helper macro K()
mm/backing-dev.c | 3 +--
mm/hugetlb.c | 2 +-
mm/memcontrol.c | 1 -
mm/mmap.c | 6 +++---
mm/nommu.c | 4 ++--
mm/oom_kill.c | 2 --
mm/shmem.c | 3 +--
mm/swap_state.c | 5 ++---
mm/swapfile.c | 12 ++++++------
9 files changed, 16 insertions(+), 22 deletions(-)
--
2.25.1
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 1/7] mm: remove redundant K() macro definition
2023-08-04 1:25 [PATCH 0/7] cleanup with helper macro K() Peng Zhang
@ 2023-08-04 1:25 ` Peng Zhang
2023-08-07 8:31 ` Kefeng Wang
2023-08-04 1:25 ` [PATCH 2/7] mm/swapfile.c: use helper macro K() Peng Zhang
` (6 subsequent siblings)
7 siblings, 1 reply; 18+ messages in thread
From: Peng Zhang @ 2023-08-04 1:25 UTC (permalink / raw)
To: linux-mm; +Cc: akpm, wangkefeng.wang, sunnanyong, ZhangPeng
From: ZhangPeng <zhangpeng362@huawei.com>
Since commit eb8589b4f8c1 ("mm: move mem_init_print_info() to
mm_init.c"), the K() macro definition has been moved to mm/internal.h.
Therefore, the definitions in mm/memcontrol.c, mm/backing-dev.c and
mm/oom_kill.c are redundant. Drop redundant definitions.
Signed-off-by: ZhangPeng <zhangpeng362@huawei.com>
---
mm/backing-dev.c | 3 +--
mm/memcontrol.c | 1 -
mm/oom_kill.c | 2 --
3 files changed, 1 insertion(+), 5 deletions(-)
diff --git a/mm/backing-dev.c b/mm/backing-dev.c
index 3ffc3cfa7a14..fc44bfbf785e 100644
--- a/mm/backing-dev.c
+++ b/mm/backing-dev.c
@@ -16,6 +16,7 @@
#include <linux/writeback.h>
#include <linux/device.h>
#include <trace/events/writeback.h>
+#include "internal.h"
struct backing_dev_info noop_backing_dev_info;
EXPORT_SYMBOL_GPL(noop_backing_dev_info);
@@ -34,8 +35,6 @@ LIST_HEAD(bdi_list);
/* bdi_wq serves all asynchronous writeback tasks */
struct workqueue_struct *bdi_wq;
-#define K(x) ((x) << (PAGE_SHIFT - 10))
-
#ifdef CONFIG_DEBUG_FS
#include <linux/debugfs.h>
#include <linux/seq_file.h>
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 1ff51d8df84a..e290e7ed05f3 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1626,7 +1626,6 @@ static void memory_stat_format(struct mem_cgroup *memcg, struct seq_buf *s)
WARN_ON_ONCE(seq_buf_has_overflowed(s));
}
-#define K(x) ((x) << (PAGE_SHIFT-10))
/**
* mem_cgroup_print_oom_context: Print OOM information relevant to
* memory controller.
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 612b5597d3af..471061a3a0f5 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -479,8 +479,6 @@ static DECLARE_WAIT_QUEUE_HEAD(oom_victims_wait);
static bool oom_killer_disabled __read_mostly;
-#define K(x) ((x) << (PAGE_SHIFT-10))
-
/*
* task->mm can be NULL if the task is the exited group leader. So to
* determine whether the task is using a particular mm, we examine all the
--
2.25.1
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 2/7] mm/swapfile.c: use helper macro K()
2023-08-04 1:25 [PATCH 0/7] cleanup with helper macro K() Peng Zhang
2023-08-04 1:25 ` [PATCH 1/7] mm: remove redundant K() macro definition Peng Zhang
@ 2023-08-04 1:25 ` Peng Zhang
2023-08-07 15:18 ` David Hildenbrand
2023-08-04 1:25 ` [PATCH 3/7] mm/swap_state.c: " Peng Zhang
` (5 subsequent siblings)
7 siblings, 1 reply; 18+ messages in thread
From: Peng Zhang @ 2023-08-04 1:25 UTC (permalink / raw)
To: linux-mm; +Cc: akpm, wangkefeng.wang, sunnanyong, ZhangPeng
From: ZhangPeng <zhangpeng362@huawei.com>
Use helper macro K() to improve code readability. No functional
modification involved.
Signed-off-by: ZhangPeng <zhangpeng362@huawei.com>
---
mm/swapfile.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/mm/swapfile.c b/mm/swapfile.c
index 0df94c4000ea..d46933adf789 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -46,6 +46,7 @@
#include <asm/tlbflush.h>
#include <linux/swapops.h>
#include <linux/swap_cgroup.h>
+#include "internal.h"
#include "swap.h"
static bool swap_count_continued(struct swap_info_struct *, pgoff_t,
@@ -2635,8 +2636,8 @@ static int swap_show(struct seq_file *swap, void *v)
return 0;
}
- bytes = si->pages << (PAGE_SHIFT - 10);
- inuse = READ_ONCE(si->inuse_pages) << (PAGE_SHIFT - 10);
+ bytes = K(si->pages);
+ inuse = K(READ_ONCE(si->inuse_pages));
file = si->swap_file;
len = seq_file_path(swap, file, " \t\n\\");
@@ -2861,8 +2862,7 @@ static unsigned long read_swap_header(struct swap_info_struct *p,
}
if (last_page > maxpages) {
pr_warn("Truncating oversized swap area, only using %luk out of %luk\n",
- maxpages << (PAGE_SHIFT - 10),
- last_page << (PAGE_SHIFT - 10));
+ K(maxpages), K(last_page));
}
if (maxpages > last_page) {
maxpages = last_page + 1;
@@ -3184,8 +3184,8 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
enable_swap_info(p, prio, swap_map, cluster_info);
pr_info("Adding %uk swap on %s. Priority:%d extents:%d across:%lluk %s%s%s%s\n",
- p->pages<<(PAGE_SHIFT-10), name->name, p->prio,
- nr_extents, (unsigned long long)span<<(PAGE_SHIFT-10),
+ K(p->pages), name->name, p->prio, nr_extents,
+ K((unsigned long long)span),
(p->flags & SWP_SOLIDSTATE) ? "SS" : "",
(p->flags & SWP_DISCARDABLE) ? "D" : "",
(p->flags & SWP_AREA_DISCARD) ? "s" : "",
--
2.25.1
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 3/7] mm/swap_state.c: use helper macro K()
2023-08-04 1:25 [PATCH 0/7] cleanup with helper macro K() Peng Zhang
2023-08-04 1:25 ` [PATCH 1/7] mm: remove redundant K() macro definition Peng Zhang
2023-08-04 1:25 ` [PATCH 2/7] mm/swapfile.c: use helper macro K() Peng Zhang
@ 2023-08-04 1:25 ` Peng Zhang
2023-08-07 15:19 ` David Hildenbrand
2023-08-04 1:25 ` [PATCH 4/7] mm/shmem.c: " Peng Zhang
` (4 subsequent siblings)
7 siblings, 1 reply; 18+ messages in thread
From: Peng Zhang @ 2023-08-04 1:25 UTC (permalink / raw)
To: linux-mm; +Cc: akpm, wangkefeng.wang, sunnanyong, ZhangPeng
From: ZhangPeng <zhangpeng362@huawei.com>
Use helper macro K() to improve code readability. No functional
modification involved.
Signed-off-by: ZhangPeng <zhangpeng362@huawei.com>
---
mm/swap_state.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/mm/swap_state.c b/mm/swap_state.c
index 5a690c79cc13..01f15139b7d9 100644
--- a/mm/swap_state.c
+++ b/mm/swap_state.c
@@ -63,9 +63,8 @@ static atomic_t swapin_readahead_hits = ATOMIC_INIT(4);
void show_swap_cache_info(void)
{
printk("%lu pages in swap cache\n", total_swapcache_pages());
- printk("Free swap = %ldkB\n",
- get_nr_swap_pages() << (PAGE_SHIFT - 10));
- printk("Total swap = %lukB\n", total_swap_pages << (PAGE_SHIFT - 10));
+ printk("Free swap = %ldkB\n", K(get_nr_swap_pages()));
+ printk("Total swap = %lukB\n", K(total_swap_pages));
}
void *get_shadow_from_swap_cache(swp_entry_t entry)
--
2.25.1
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 4/7] mm/shmem.c: use helper macro K()
2023-08-04 1:25 [PATCH 0/7] cleanup with helper macro K() Peng Zhang
` (2 preceding siblings ...)
2023-08-04 1:25 ` [PATCH 3/7] mm/swap_state.c: " Peng Zhang
@ 2023-08-04 1:25 ` Peng Zhang
2023-08-07 15:19 ` David Hildenbrand
2023-08-04 1:25 ` [PATCH 5/7] mm/nommu.c: " Peng Zhang
` (3 subsequent siblings)
7 siblings, 1 reply; 18+ messages in thread
From: Peng Zhang @ 2023-08-04 1:25 UTC (permalink / raw)
To: linux-mm; +Cc: akpm, wangkefeng.wang, sunnanyong, ZhangPeng
From: ZhangPeng <zhangpeng362@huawei.com>
Use helper macro K() to improve code readability. No functional
modification involved.
Signed-off-by: ZhangPeng <zhangpeng362@huawei.com>
---
mm/shmem.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/mm/shmem.c b/mm/shmem.c
index 30e96dcd71a2..7a0c1e19d9f8 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -3881,8 +3881,7 @@ static int shmem_show_options(struct seq_file *seq, struct dentry *root)
struct mempolicy *mpol;
if (sbinfo->max_blocks != shmem_default_max_blocks())
- seq_printf(seq, ",size=%luk",
- sbinfo->max_blocks << (PAGE_SHIFT - 10));
+ seq_printf(seq, ",size=%luk", K(sbinfo->max_blocks));
if (sbinfo->max_inodes != shmem_default_max_inodes())
seq_printf(seq, ",nr_inodes=%lu", sbinfo->max_inodes);
if (sbinfo->mode != (0777 | S_ISVTX))
--
2.25.1
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 5/7] mm/nommu.c: use helper macro K()
2023-08-04 1:25 [PATCH 0/7] cleanup with helper macro K() Peng Zhang
` (3 preceding siblings ...)
2023-08-04 1:25 ` [PATCH 4/7] mm/shmem.c: " Peng Zhang
@ 2023-08-04 1:25 ` Peng Zhang
2023-08-07 15:19 ` David Hildenbrand
2023-08-04 1:25 ` [PATCH 6/7] mm/mmap.c: " Peng Zhang
` (2 subsequent siblings)
7 siblings, 1 reply; 18+ messages in thread
From: Peng Zhang @ 2023-08-04 1:25 UTC (permalink / raw)
To: linux-mm; +Cc: akpm, wangkefeng.wang, sunnanyong, ZhangPeng
From: ZhangPeng <zhangpeng362@huawei.com>
Use helper macro K() to improve code readability. No functional
modification involved.
Signed-off-by: ZhangPeng <zhangpeng362@huawei.com>
---
mm/nommu.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/mm/nommu.c b/mm/nommu.c
index 1fe0ee239860..8dba41cfc44d 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -1800,7 +1800,7 @@ static int __meminit init_user_reserve(void)
{
unsigned long free_kbytes;
- free_kbytes = global_zone_page_state(NR_FREE_PAGES) << (PAGE_SHIFT - 10);
+ free_kbytes = K(global_zone_page_state(NR_FREE_PAGES));
sysctl_user_reserve_kbytes = min(free_kbytes / 32, 1UL << 17);
return 0;
@@ -1821,7 +1821,7 @@ static int __meminit init_admin_reserve(void)
{
unsigned long free_kbytes;
- free_kbytes = global_zone_page_state(NR_FREE_PAGES) << (PAGE_SHIFT - 10);
+ free_kbytes = K(global_zone_page_state(NR_FREE_PAGES));
sysctl_admin_reserve_kbytes = min(free_kbytes / 32, 1UL << 13);
return 0;
--
2.25.1
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 6/7] mm/mmap.c: use helper macro K()
2023-08-04 1:25 [PATCH 0/7] cleanup with helper macro K() Peng Zhang
` (4 preceding siblings ...)
2023-08-04 1:25 ` [PATCH 5/7] mm/nommu.c: " Peng Zhang
@ 2023-08-04 1:25 ` Peng Zhang
2023-08-07 15:19 ` David Hildenbrand
2023-08-04 1:25 ` [PATCH 7/7] mm/hugetlb.c: " Peng Zhang
2023-08-04 3:39 ` [PATCH 0/7] cleanup with " Matthew Wilcox
7 siblings, 1 reply; 18+ messages in thread
From: Peng Zhang @ 2023-08-04 1:25 UTC (permalink / raw)
To: linux-mm; +Cc: akpm, wangkefeng.wang, sunnanyong, ZhangPeng
From: ZhangPeng <zhangpeng362@huawei.com>
Use helper macro K() to improve code readability. No functional
modification involved.
Signed-off-by: ZhangPeng <zhangpeng362@huawei.com>
---
mm/mmap.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/mm/mmap.c b/mm/mmap.c
index bc91d91261ab..35b6bc9c7c95 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -3785,7 +3785,7 @@ static int init_user_reserve(void)
{
unsigned long free_kbytes;
- free_kbytes = global_zone_page_state(NR_FREE_PAGES) << (PAGE_SHIFT - 10);
+ free_kbytes = K(global_zone_page_state(NR_FREE_PAGES));
sysctl_user_reserve_kbytes = min(free_kbytes / 32, 1UL << 17);
return 0;
@@ -3806,7 +3806,7 @@ static int init_admin_reserve(void)
{
unsigned long free_kbytes;
- free_kbytes = global_zone_page_state(NR_FREE_PAGES) << (PAGE_SHIFT - 10);
+ free_kbytes = K(global_zone_page_state(NR_FREE_PAGES));
sysctl_admin_reserve_kbytes = min(free_kbytes / 32, 1UL << 13);
return 0;
@@ -3850,7 +3850,7 @@ static int reserve_mem_notifier(struct notifier_block *nb,
break;
case MEM_OFFLINE:
- free_kbytes = global_zone_page_state(NR_FREE_PAGES) << (PAGE_SHIFT - 10);
+ free_kbytes = K(global_zone_page_state(NR_FREE_PAGES));
if (sysctl_user_reserve_kbytes > free_kbytes) {
init_user_reserve();
--
2.25.1
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 7/7] mm/hugetlb.c: use helper macro K()
2023-08-04 1:25 [PATCH 0/7] cleanup with helper macro K() Peng Zhang
` (5 preceding siblings ...)
2023-08-04 1:25 ` [PATCH 6/7] mm/mmap.c: " Peng Zhang
@ 2023-08-04 1:25 ` Peng Zhang
2023-08-07 15:20 ` David Hildenbrand
2023-08-04 3:39 ` [PATCH 0/7] cleanup with " Matthew Wilcox
7 siblings, 1 reply; 18+ messages in thread
From: Peng Zhang @ 2023-08-04 1:25 UTC (permalink / raw)
To: linux-mm; +Cc: akpm, wangkefeng.wang, sunnanyong, ZhangPeng
From: ZhangPeng <zhangpeng362@huawei.com>
Use helper macro K() to improve code readability. No functional
modification involved.
Signed-off-by: ZhangPeng <zhangpeng362@huawei.com>
---
mm/hugetlb.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index e327a5a7602c..941d1d497b65 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -4775,7 +4775,7 @@ void hugetlb_show_meminfo_node(int nid)
void hugetlb_report_usage(struct seq_file *m, struct mm_struct *mm)
{
seq_printf(m, "HugetlbPages:\t%8lu kB\n",
- atomic_long_read(&mm->hugetlb_usage) << (PAGE_SHIFT - 10));
+ K(atomic_long_read(&mm->hugetlb_usage)));
}
/* Return the number pages of memory we physically have, in PAGE_SIZE units. */
--
2.25.1
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 0/7] cleanup with helper macro K()
2023-08-04 1:25 [PATCH 0/7] cleanup with helper macro K() Peng Zhang
` (6 preceding siblings ...)
2023-08-04 1:25 ` [PATCH 7/7] mm/hugetlb.c: " Peng Zhang
@ 2023-08-04 3:39 ` Matthew Wilcox
7 siblings, 0 replies; 18+ messages in thread
From: Matthew Wilcox @ 2023-08-04 3:39 UTC (permalink / raw)
To: Peng Zhang; +Cc: linux-mm, akpm, wangkefeng.wang, sunnanyong
On Fri, Aug 04, 2023 at 09:25:52AM +0800, Peng Zhang wrote:
> From: ZhangPeng <zhangpeng362@huawei.com>
>
> Use helper macro K() to improve code readability. No functional
> modification involved. Remove redundant K() macro definition.
For the series:
Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 1/7] mm: remove redundant K() macro definition
2023-08-04 1:25 ` [PATCH 1/7] mm: remove redundant K() macro definition Peng Zhang
@ 2023-08-07 8:31 ` Kefeng Wang
2023-08-07 15:20 ` David Hildenbrand
2023-08-08 10:44 ` zhangpeng (AS)
0 siblings, 2 replies; 18+ messages in thread
From: Kefeng Wang @ 2023-08-07 8:31 UTC (permalink / raw)
To: Peng Zhang, linux-mm; +Cc: akpm, sunnanyong
On 2023/8/4 9:25, Peng Zhang wrote:
> From: ZhangPeng <zhangpeng362@huawei.com>
>
> Since commit eb8589b4f8c1 ("mm: move mem_init_print_info() to
> mm_init.c"), the K() macro definition has been moved to mm/internal.h.
> Therefore, the definitions in mm/memcontrol.c, mm/backing-dev.c and
> mm/oom_kill.c are redundant. Drop redundant definitions.
>
> Signed-off-by: ZhangPeng <zhangpeng362@huawei.com>
> ---
> mm/backing-dev.c | 3 +--
> mm/memcontrol.c | 1 -
> mm/oom_kill.c | 2 --
> 3 files changed, 1 insertion(+), 5 deletions(-)
>
...
> diff --git a/mm/oom_kill.c b/mm/oom_kill.c
> index 612b5597d3af..471061a3a0f5 100644
> --- a/mm/oom_kill.c
> +++ b/mm/oom_kill.c
> @@ -479,8 +479,6 @@ static DECLARE_WAIT_QUEUE_HEAD(oom_victims_wait);
>
> static bool oom_killer_disabled __read_mostly;
>
> -#define K(x) ((x) << (PAGE_SHIFT-10))
> -
> /*
> * task->mm can be NULL if the task is the exited group leader. So to
> * determine whether the task is using a particular mm, we examine all the
Please drop "#undef K" in oom_kill.c
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 2/7] mm/swapfile.c: use helper macro K()
2023-08-04 1:25 ` [PATCH 2/7] mm/swapfile.c: use helper macro K() Peng Zhang
@ 2023-08-07 15:18 ` David Hildenbrand
0 siblings, 0 replies; 18+ messages in thread
From: David Hildenbrand @ 2023-08-07 15:18 UTC (permalink / raw)
To: Peng Zhang, linux-mm; +Cc: akpm, wangkefeng.wang, sunnanyong
On 04.08.23 03:25, Peng Zhang wrote:
> From: ZhangPeng <zhangpeng362@huawei.com>
>
> Use helper macro K() to improve code readability. No functional
> modification involved.
>
> Signed-off-by: ZhangPeng <zhangpeng362@huawei.com>
> ---
> mm/swapfile.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/mm/swapfile.c b/mm/swapfile.c
> index 0df94c4000ea..d46933adf789 100644
> --- a/mm/swapfile.c
> +++ b/mm/swapfile.c
> @@ -46,6 +46,7 @@
> #include <asm/tlbflush.h>
> #include <linux/swapops.h>
> #include <linux/swap_cgroup.h>
> +#include "internal.h"
> #include "swap.h"
>
> static bool swap_count_continued(struct swap_info_struct *, pgoff_t,
> @@ -2635,8 +2636,8 @@ static int swap_show(struct seq_file *swap, void *v)
> return 0;
> }
>
> - bytes = si->pages << (PAGE_SHIFT - 10);
> - inuse = READ_ONCE(si->inuse_pages) << (PAGE_SHIFT - 10);
> + bytes = K(si->pages);
> + inuse = K(READ_ONCE(si->inuse_pages));
>
> file = si->swap_file;
> len = seq_file_path(swap, file, " \t\n\\");
> @@ -2861,8 +2862,7 @@ static unsigned long read_swap_header(struct swap_info_struct *p,
> }
> if (last_page > maxpages) {
> pr_warn("Truncating oversized swap area, only using %luk out of %luk\n",
> - maxpages << (PAGE_SHIFT - 10),
> - last_page << (PAGE_SHIFT - 10));
> + K(maxpages), K(last_page));
> }
> if (maxpages > last_page) {
> maxpages = last_page + 1;
> @@ -3184,8 +3184,8 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
> enable_swap_info(p, prio, swap_map, cluster_info);
>
> pr_info("Adding %uk swap on %s. Priority:%d extents:%d across:%lluk %s%s%s%s\n",
> - p->pages<<(PAGE_SHIFT-10), name->name, p->prio,
> - nr_extents, (unsigned long long)span<<(PAGE_SHIFT-10),
> + K(p->pages), name->name, p->prio, nr_extents,
> + K((unsigned long long)span),
> (p->flags & SWP_SOLIDSTATE) ? "SS" : "",
> (p->flags & SWP_DISCARDABLE) ? "D" : "",
> (p->flags & SWP_AREA_DISCARD) ? "s" : "",
Reviewed-by: David Hildenbrand <david@redhat.com>
--
Cheers,
David / dhildenb
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 3/7] mm/swap_state.c: use helper macro K()
2023-08-04 1:25 ` [PATCH 3/7] mm/swap_state.c: " Peng Zhang
@ 2023-08-07 15:19 ` David Hildenbrand
0 siblings, 0 replies; 18+ messages in thread
From: David Hildenbrand @ 2023-08-07 15:19 UTC (permalink / raw)
To: Peng Zhang, linux-mm; +Cc: akpm, wangkefeng.wang, sunnanyong
On 04.08.23 03:25, Peng Zhang wrote:
> From: ZhangPeng <zhangpeng362@huawei.com>
>
> Use helper macro K() to improve code readability. No functional
> modification involved.
>
> Signed-off-by: ZhangPeng <zhangpeng362@huawei.com>
> ---
> mm/swap_state.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/mm/swap_state.c b/mm/swap_state.c
> index 5a690c79cc13..01f15139b7d9 100644
> --- a/mm/swap_state.c
> +++ b/mm/swap_state.c
> @@ -63,9 +63,8 @@ static atomic_t swapin_readahead_hits = ATOMIC_INIT(4);
> void show_swap_cache_info(void)
> {
> printk("%lu pages in swap cache\n", total_swapcache_pages());
> - printk("Free swap = %ldkB\n",
> - get_nr_swap_pages() << (PAGE_SHIFT - 10));
> - printk("Total swap = %lukB\n", total_swap_pages << (PAGE_SHIFT - 10));
> + printk("Free swap = %ldkB\n", K(get_nr_swap_pages()));
> + printk("Total swap = %lukB\n", K(total_swap_pages));
> }
>
> void *get_shadow_from_swap_cache(swp_entry_t entry)
Reviewed-by: David Hildenbrand <david@redhat.com>
--
Cheers,
David / dhildenb
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 4/7] mm/shmem.c: use helper macro K()
2023-08-04 1:25 ` [PATCH 4/7] mm/shmem.c: " Peng Zhang
@ 2023-08-07 15:19 ` David Hildenbrand
0 siblings, 0 replies; 18+ messages in thread
From: David Hildenbrand @ 2023-08-07 15:19 UTC (permalink / raw)
To: Peng Zhang, linux-mm; +Cc: akpm, wangkefeng.wang, sunnanyong
On 04.08.23 03:25, Peng Zhang wrote:
> From: ZhangPeng <zhangpeng362@huawei.com>
>
> Use helper macro K() to improve code readability. No functional
> modification involved.
>
> Signed-off-by: ZhangPeng <zhangpeng362@huawei.com>
> ---
> mm/shmem.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/mm/shmem.c b/mm/shmem.c
> index 30e96dcd71a2..7a0c1e19d9f8 100644
> --- a/mm/shmem.c
> +++ b/mm/shmem.c
> @@ -3881,8 +3881,7 @@ static int shmem_show_options(struct seq_file *seq, struct dentry *root)
> struct mempolicy *mpol;
>
> if (sbinfo->max_blocks != shmem_default_max_blocks())
> - seq_printf(seq, ",size=%luk",
> - sbinfo->max_blocks << (PAGE_SHIFT - 10));
> + seq_printf(seq, ",size=%luk", K(sbinfo->max_blocks));
> if (sbinfo->max_inodes != shmem_default_max_inodes())
> seq_printf(seq, ",nr_inodes=%lu", sbinfo->max_inodes);
> if (sbinfo->mode != (0777 | S_ISVTX))
Reviewed-by: David Hildenbrand <david@redhat.com>
--
Cheers,
David / dhildenb
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 5/7] mm/nommu.c: use helper macro K()
2023-08-04 1:25 ` [PATCH 5/7] mm/nommu.c: " Peng Zhang
@ 2023-08-07 15:19 ` David Hildenbrand
0 siblings, 0 replies; 18+ messages in thread
From: David Hildenbrand @ 2023-08-07 15:19 UTC (permalink / raw)
To: Peng Zhang, linux-mm; +Cc: akpm, wangkefeng.wang, sunnanyong
On 04.08.23 03:25, Peng Zhang wrote:
> From: ZhangPeng <zhangpeng362@huawei.com>
>
> Use helper macro K() to improve code readability. No functional
> modification involved.
>
> Signed-off-by: ZhangPeng <zhangpeng362@huawei.com>
> ---
> mm/nommu.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/mm/nommu.c b/mm/nommu.c
> index 1fe0ee239860..8dba41cfc44d 100644
> --- a/mm/nommu.c
> +++ b/mm/nommu.c
> @@ -1800,7 +1800,7 @@ static int __meminit init_user_reserve(void)
> {
> unsigned long free_kbytes;
>
> - free_kbytes = global_zone_page_state(NR_FREE_PAGES) << (PAGE_SHIFT - 10);
> + free_kbytes = K(global_zone_page_state(NR_FREE_PAGES));
>
> sysctl_user_reserve_kbytes = min(free_kbytes / 32, 1UL << 17);
> return 0;
> @@ -1821,7 +1821,7 @@ static int __meminit init_admin_reserve(void)
> {
> unsigned long free_kbytes;
>
> - free_kbytes = global_zone_page_state(NR_FREE_PAGES) << (PAGE_SHIFT - 10);
> + free_kbytes = K(global_zone_page_state(NR_FREE_PAGES));
>
> sysctl_admin_reserve_kbytes = min(free_kbytes / 32, 1UL << 13);
> return 0;
Reviewed-by: David Hildenbrand <david@redhat.com>
--
Cheers,
David / dhildenb
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 6/7] mm/mmap.c: use helper macro K()
2023-08-04 1:25 ` [PATCH 6/7] mm/mmap.c: " Peng Zhang
@ 2023-08-07 15:19 ` David Hildenbrand
0 siblings, 0 replies; 18+ messages in thread
From: David Hildenbrand @ 2023-08-07 15:19 UTC (permalink / raw)
To: Peng Zhang, linux-mm; +Cc: akpm, wangkefeng.wang, sunnanyong
On 04.08.23 03:25, Peng Zhang wrote:
> From: ZhangPeng <zhangpeng362@huawei.com>
>
> Use helper macro K() to improve code readability. No functional
> modification involved.
>
> Signed-off-by: ZhangPeng <zhangpeng362@huawei.com>
> ---
> mm/mmap.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/mm/mmap.c b/mm/mmap.c
> index bc91d91261ab..35b6bc9c7c95 100644
> --- a/mm/mmap.c
> +++ b/mm/mmap.c
> @@ -3785,7 +3785,7 @@ static int init_user_reserve(void)
> {
> unsigned long free_kbytes;
>
> - free_kbytes = global_zone_page_state(NR_FREE_PAGES) << (PAGE_SHIFT - 10);
> + free_kbytes = K(global_zone_page_state(NR_FREE_PAGES));
>
> sysctl_user_reserve_kbytes = min(free_kbytes / 32, 1UL << 17);
> return 0;
> @@ -3806,7 +3806,7 @@ static int init_admin_reserve(void)
> {
> unsigned long free_kbytes;
>
> - free_kbytes = global_zone_page_state(NR_FREE_PAGES) << (PAGE_SHIFT - 10);
> + free_kbytes = K(global_zone_page_state(NR_FREE_PAGES));
>
> sysctl_admin_reserve_kbytes = min(free_kbytes / 32, 1UL << 13);
> return 0;
> @@ -3850,7 +3850,7 @@ static int reserve_mem_notifier(struct notifier_block *nb,
>
> break;
> case MEM_OFFLINE:
> - free_kbytes = global_zone_page_state(NR_FREE_PAGES) << (PAGE_SHIFT - 10);
> + free_kbytes = K(global_zone_page_state(NR_FREE_PAGES));
>
> if (sysctl_user_reserve_kbytes > free_kbytes) {
> init_user_reserve();
Reviewed-by: David Hildenbrand <david@redhat.com>
--
Cheers,
David / dhildenb
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 7/7] mm/hugetlb.c: use helper macro K()
2023-08-04 1:25 ` [PATCH 7/7] mm/hugetlb.c: " Peng Zhang
@ 2023-08-07 15:20 ` David Hildenbrand
0 siblings, 0 replies; 18+ messages in thread
From: David Hildenbrand @ 2023-08-07 15:20 UTC (permalink / raw)
To: Peng Zhang, linux-mm; +Cc: akpm, wangkefeng.wang, sunnanyong
On 04.08.23 03:25, Peng Zhang wrote:
> From: ZhangPeng <zhangpeng362@huawei.com>
>
> Use helper macro K() to improve code readability. No functional
> modification involved.
>
> Signed-off-by: ZhangPeng <zhangpeng362@huawei.com>
> ---
> mm/hugetlb.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/hugetlb.c b/mm/hugetlb.c
> index e327a5a7602c..941d1d497b65 100644
> --- a/mm/hugetlb.c
> +++ b/mm/hugetlb.c
> @@ -4775,7 +4775,7 @@ void hugetlb_show_meminfo_node(int nid)
> void hugetlb_report_usage(struct seq_file *m, struct mm_struct *mm)
> {
> seq_printf(m, "HugetlbPages:\t%8lu kB\n",
> - atomic_long_read(&mm->hugetlb_usage) << (PAGE_SHIFT - 10));
> + K(atomic_long_read(&mm->hugetlb_usage)));
> }
>
> /* Return the number pages of memory we physically have, in PAGE_SIZE units. */
Reviewed-by: David Hildenbrand <david@redhat.com>
--
Cheers,
David / dhildenb
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 1/7] mm: remove redundant K() macro definition
2023-08-07 8:31 ` Kefeng Wang
@ 2023-08-07 15:20 ` David Hildenbrand
2023-08-08 10:44 ` zhangpeng (AS)
1 sibling, 0 replies; 18+ messages in thread
From: David Hildenbrand @ 2023-08-07 15:20 UTC (permalink / raw)
To: Kefeng Wang, Peng Zhang, linux-mm; +Cc: akpm, sunnanyong
On 07.08.23 10:31, Kefeng Wang wrote:
>
>
> On 2023/8/4 9:25, Peng Zhang wrote:
>> From: ZhangPeng <zhangpeng362@huawei.com>
>>
>> Since commit eb8589b4f8c1 ("mm: move mem_init_print_info() to
>> mm_init.c"), the K() macro definition has been moved to mm/internal.h.
>> Therefore, the definitions in mm/memcontrol.c, mm/backing-dev.c and
>> mm/oom_kill.c are redundant. Drop redundant definitions.
>>
>> Signed-off-by: ZhangPeng <zhangpeng362@huawei.com>
>> ---
>> mm/backing-dev.c | 3 +--
>> mm/memcontrol.c | 1 -
>> mm/oom_kill.c | 2 --
>> 3 files changed, 1 insertion(+), 5 deletions(-)
>>
>
> ...
>> diff --git a/mm/oom_kill.c b/mm/oom_kill.c
>> index 612b5597d3af..471061a3a0f5 100644
>> --- a/mm/oom_kill.c
>> +++ b/mm/oom_kill.c
>> @@ -479,8 +479,6 @@ static DECLARE_WAIT_QUEUE_HEAD(oom_victims_wait);
>>
>> static bool oom_killer_disabled __read_mostly;
>>
>> -#define K(x) ((x) << (PAGE_SHIFT-10))
>> -
>> /*
>> * task->mm can be NULL if the task is the exited group leader. So to
>> * determine whether the task is using a particular mm, we examine all the
>
> Please drop "#undef K" in oom_kill.c
With that
Reviewed-by: David Hildenbrand <david@redhat.com>
--
Cheers,
David / dhildenb
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 1/7] mm: remove redundant K() macro definition
2023-08-07 8:31 ` Kefeng Wang
2023-08-07 15:20 ` David Hildenbrand
@ 2023-08-08 10:44 ` zhangpeng (AS)
1 sibling, 0 replies; 18+ messages in thread
From: zhangpeng (AS) @ 2023-08-08 10:44 UTC (permalink / raw)
To: Kefeng Wang, linux-mm; +Cc: akpm, sunnanyong
On 2023/8/7 16:31, Kefeng Wang wrote:
> On 2023/8/4 9:25, Peng Zhang wrote:
>> From: ZhangPeng <zhangpeng362@huawei.com>
>>
>> Since commit eb8589b4f8c1 ("mm: move mem_init_print_info() to
>> mm_init.c"), the K() macro definition has been moved to mm/internal.h.
>> Therefore, the definitions in mm/memcontrol.c, mm/backing-dev.c and
>> mm/oom_kill.c are redundant. Drop redundant definitions.
>>
>> Signed-off-by: ZhangPeng <zhangpeng362@huawei.com>
>> ---
>> mm/backing-dev.c | 3 +--
>> mm/memcontrol.c | 1 -
>> mm/oom_kill.c | 2 --
>> 3 files changed, 1 insertion(+), 5 deletions(-)
>>
> ...
>> diff --git a/mm/oom_kill.c b/mm/oom_kill.c
>> index 612b5597d3af..471061a3a0f5 100644
>> --- a/mm/oom_kill.c
>> +++ b/mm/oom_kill.c
>> @@ -479,8 +479,6 @@ static DECLARE_WAIT_QUEUE_HEAD(oom_victims_wait);
>> static bool oom_killer_disabled __read_mostly;
>> -#define K(x) ((x) << (PAGE_SHIFT-10))
>> -
>> /*
>> * task->mm can be NULL if the task is the exited group leader. So to
>> * determine whether the task is using a particular mm, we examine
>> all the
>
> Please drop "#undef K" in oom_kill.c
Thanks for your review!
--
Best Regards,
Peng
^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2023-08-08 10:45 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-04 1:25 [PATCH 0/7] cleanup with helper macro K() Peng Zhang
2023-08-04 1:25 ` [PATCH 1/7] mm: remove redundant K() macro definition Peng Zhang
2023-08-07 8:31 ` Kefeng Wang
2023-08-07 15:20 ` David Hildenbrand
2023-08-08 10:44 ` zhangpeng (AS)
2023-08-04 1:25 ` [PATCH 2/7] mm/swapfile.c: use helper macro K() Peng Zhang
2023-08-07 15:18 ` David Hildenbrand
2023-08-04 1:25 ` [PATCH 3/7] mm/swap_state.c: " Peng Zhang
2023-08-07 15:19 ` David Hildenbrand
2023-08-04 1:25 ` [PATCH 4/7] mm/shmem.c: " Peng Zhang
2023-08-07 15:19 ` David Hildenbrand
2023-08-04 1:25 ` [PATCH 5/7] mm/nommu.c: " Peng Zhang
2023-08-07 15:19 ` David Hildenbrand
2023-08-04 1:25 ` [PATCH 6/7] mm/mmap.c: " Peng Zhang
2023-08-07 15:19 ` David Hildenbrand
2023-08-04 1:25 ` [PATCH 7/7] mm/hugetlb.c: " Peng Zhang
2023-08-07 15:20 ` David Hildenbrand
2023-08-04 3:39 ` [PATCH 0/7] cleanup with " Matthew Wilcox
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox