2022-03-28 22:27:21

by Miaohe Lin

[permalink] [raw]
Subject: [PATCH] mm/memcg: remove unneeded nr_scanned

The local variable nr_scanned is unneeded as mem_cgroup_soft_reclaim always
does *total_scanned += nr_scanned. So we can pass total_scanned directly to
the mem_cgroup_soft_reclaim to simplify the code and save some cpu cycles
of adding nr_scanned to total_scanned.

Signed-off-by: Miaohe Lin <[email protected]>
---
mm/memcontrol.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index b686ec4f42c6..79341365ec90 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -3384,7 +3384,6 @@ unsigned long mem_cgroup_soft_limit_reclaim(pg_data_t *pgdat, int order,
int loop = 0;
struct mem_cgroup_tree_per_node *mctz;
unsigned long excess;
- unsigned long nr_scanned;

if (order > 0)
return 0;
@@ -3412,11 +3411,9 @@ unsigned long mem_cgroup_soft_limit_reclaim(pg_data_t *pgdat, int order,
if (!mz)
break;

- nr_scanned = 0;
reclaimed = mem_cgroup_soft_reclaim(mz->memcg, pgdat,
- gfp_mask, &nr_scanned);
+ gfp_mask, total_scanned);
nr_reclaimed += reclaimed;
- *total_scanned += nr_scanned;
spin_lock_irq(&mctz->lock);
__mem_cgroup_remove_exceeded(mz, mctz);

--
2.23.0


2022-03-28 22:40:28

by David Hildenbrand

[permalink] [raw]
Subject: Re: [PATCH] mm/memcg: remove unneeded nr_scanned

On 28.03.22 13:41, Miaohe Lin wrote:
> The local variable nr_scanned is unneeded as mem_cgroup_soft_reclaim always
> does *total_scanned += nr_scanned. So we can pass total_scanned directly to
> the mem_cgroup_soft_reclaim to simplify the code and save some cpu cycles
> of adding nr_scanned to total_scanned.
>
> Signed-off-by: Miaohe Lin <[email protected]>
> ---
> mm/memcontrol.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index b686ec4f42c6..79341365ec90 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -3384,7 +3384,6 @@ unsigned long mem_cgroup_soft_limit_reclaim(pg_data_t *pgdat, int order,
> int loop = 0;
> struct mem_cgroup_tree_per_node *mctz;
> unsigned long excess;
> - unsigned long nr_scanned;
>
> if (order > 0)
> return 0;
> @@ -3412,11 +3411,9 @@ unsigned long mem_cgroup_soft_limit_reclaim(pg_data_t *pgdat, int order,
> if (!mz)
> break;
>
> - nr_scanned = 0;
> reclaimed = mem_cgroup_soft_reclaim(mz->memcg, pgdat,
> - gfp_mask, &nr_scanned);
> + gfp_mask, total_scanned);
> nr_reclaimed += reclaimed;
> - *total_scanned += nr_scanned;
> spin_lock_irq(&mctz->lock);
> __mem_cgroup_remove_exceeded(mz, mctz);
>

Reviewed-by: David Hildenbrand <[email protected]>

--
Thanks,

David / dhildenb

2022-04-01 12:21:13

by Wei Yang

[permalink] [raw]
Subject: Re: [PATCH] mm/memcg: remove unneeded nr_scanned

On Mon, Mar 28, 2022 at 07:41:44PM +0800, Miaohe Lin wrote:
>The local variable nr_scanned is unneeded as mem_cgroup_soft_reclaim always
>does *total_scanned += nr_scanned. So we can pass total_scanned directly to
>the mem_cgroup_soft_reclaim to simplify the code and save some cpu cycles
>of adding nr_scanned to total_scanned.
>
>Signed-off-by: Miaohe Lin <[email protected]>
>---

Reviewed-by: Wei Yang <[email protected]>

Thanks

--
Wei Yang
Help you, Help me