Re: [PATCH v2] mm: Simplify shrink_inactive_list()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri 12-04-19 13:55:59, Kirill Tkhai wrote:
> This merges together duplicating patterns of code.

OK, this looks better than the previous version

> Also, replace count_memcg_events() with its
> irq-careless namesake.

Why?

> Signed-off-by: Kirill Tkhai <ktkhai@xxxxxxxxxxxxx>
> 
> v2: Introduce local variable.
> ---
>  mm/vmscan.c |   31 +++++++++----------------------
>  1 file changed, 9 insertions(+), 22 deletions(-)
> 
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index 836b28913bd7..d96efff59a11 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -1907,6 +1907,7 @@ shrink_inactive_list(unsigned long nr_to_scan, struct lruvec *lruvec,
>  	unsigned long nr_taken;
>  	struct reclaim_stat stat;
>  	int file = is_file_lru(lru);
> +	enum vm_event_item item;
>  	struct pglist_data *pgdat = lruvec_pgdat(lruvec);
>  	struct zone_reclaim_stat *reclaim_stat = &lruvec->reclaim_stat;
>  	bool stalled = false;
> @@ -1934,17 +1935,10 @@ shrink_inactive_list(unsigned long nr_to_scan, struct lruvec *lruvec,
>  	__mod_node_page_state(pgdat, NR_ISOLATED_ANON + file, nr_taken);
>  	reclaim_stat->recent_scanned[file] += nr_taken;
>  
> -	if (current_is_kswapd()) {
> -		if (global_reclaim(sc))
> -			__count_vm_events(PGSCAN_KSWAPD, nr_scanned);
> -		count_memcg_events(lruvec_memcg(lruvec), PGSCAN_KSWAPD,
> -				   nr_scanned);
> -	} else {
> -		if (global_reclaim(sc))
> -			__count_vm_events(PGSCAN_DIRECT, nr_scanned);
> -		count_memcg_events(lruvec_memcg(lruvec), PGSCAN_DIRECT,
> -				   nr_scanned);
> -	}
> +	item = current_is_kswapd() ? PGSCAN_KSWAPD : PGSCAN_DIRECT;
> +	if (global_reclaim(sc))
> +		__count_vm_events(item, nr_scanned);
> +	__count_memcg_events(lruvec_memcg(lruvec), item, nr_scanned);
>  	spin_unlock_irq(&pgdat->lru_lock);
>  
>  	if (nr_taken == 0)
> @@ -1955,17 +1949,10 @@ shrink_inactive_list(unsigned long nr_to_scan, struct lruvec *lruvec,
>  
>  	spin_lock_irq(&pgdat->lru_lock);
>  
> -	if (current_is_kswapd()) {
> -		if (global_reclaim(sc))
> -			__count_vm_events(PGSTEAL_KSWAPD, nr_reclaimed);
> -		count_memcg_events(lruvec_memcg(lruvec), PGSTEAL_KSWAPD,
> -				   nr_reclaimed);
> -	} else {
> -		if (global_reclaim(sc))
> -			__count_vm_events(PGSTEAL_DIRECT, nr_reclaimed);
> -		count_memcg_events(lruvec_memcg(lruvec), PGSTEAL_DIRECT,
> -				   nr_reclaimed);
> -	}
> +	item = current_is_kswapd() ? PGSTEAL_KSWAPD : PGSTEAL_DIRECT;
> +	if (global_reclaim(sc))
> +		__count_vm_events(item, nr_reclaimed);
> +	__count_memcg_events(lruvec_memcg(lruvec), item, nr_reclaimed);
>  	reclaim_stat->recent_rotated[0] = stat.nr_activate[0];
>  	reclaim_stat->recent_rotated[1] = stat.nr_activate[1];
>  

-- 
Michal Hocko
SUSE Labs




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux