linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/vmscan.c: Clean code by removing unnecessary assignment
@ 2020-02-29 21:40 mateusznosek0
  2020-03-01  0:11 ` Matthew Wilcox
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: mateusznosek0 @ 2020-02-29 21:40 UTC (permalink / raw)
  To: linux-mm, linux-kernel; +Cc: Mateusz Nosek, akpm

From: Mateusz Nosek <mateusznosek0@gmail.com>

Previously 0 was assigned to variable 'lruvec_size',
but the variable was never read later.
So the assignment can be removed.

Signed-off-by: Mateusz Nosek <mateusznosek0@gmail.com>
---
 mm/vmscan.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index f14c8c6069a6..a605ff36f126 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -2427,10 +2427,8 @@ static void get_scan_count(struct lruvec *lruvec, struct scan_control *sc,
 		case SCAN_FILE:
 		case SCAN_ANON:
 			/* Scan one type exclusively */
-			if ((scan_balance == SCAN_FILE) != file) {
-				lruvec_size = 0;
+			if ((scan_balance == SCAN_FILE) != file)
 				scan = 0;
-			}
 			break;
 		default:
 			/* Look ma, no brain */
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] mm/vmscan.c: Clean code by removing unnecessary assignment
  2020-02-29 21:40 [PATCH] mm/vmscan.c: Clean code by removing unnecessary assignment mateusznosek0
@ 2020-03-01  0:11 ` Matthew Wilcox
  2020-03-02 13:54 ` Wei Yang
  2020-03-03  8:59 ` David Hildenbrand
  2 siblings, 0 replies; 7+ messages in thread
From: Matthew Wilcox @ 2020-03-01  0:11 UTC (permalink / raw)
  To: mateusznosek0; +Cc: linux-mm, linux-kernel, akpm

On Sat, Feb 29, 2020 at 10:40:22PM +0100, mateusznosek0@gmail.com wrote:
> From: Mateusz Nosek <mateusznosek0@gmail.com>
> 
> Previously 0 was assigned to variable 'lruvec_size',
> but the variable was never read later.
> So the assignment can be removed.
> 
> Signed-off-by: Mateusz Nosek <mateusznosek0@gmail.com>

It _was_ used, until commit f87bccde6a7dd1bdb219a4045e8ac111590c9314
which removed lru_pages.  So this is just a left-over, and I agree it's
now superfluous.

Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] mm/vmscan.c: Clean code by removing unnecessary assignment
  2020-02-29 21:40 [PATCH] mm/vmscan.c: Clean code by removing unnecessary assignment mateusznosek0
  2020-03-01  0:11 ` Matthew Wilcox
@ 2020-03-02 13:54 ` Wei Yang
  2020-03-03  8:59 ` David Hildenbrand
  2 siblings, 0 replies; 7+ messages in thread
From: Wei Yang @ 2020-03-02 13:54 UTC (permalink / raw)
  To: mateusznosek0; +Cc: linux-mm, linux-kernel, akpm

On Sat, Feb 29, 2020 at 10:40:22PM +0100, mateusznosek0@gmail.com wrote:
>From: Mateusz Nosek <mateusznosek0@gmail.com>
>
>Previously 0 was assigned to variable 'lruvec_size',
>but the variable was never read later.
>So the assignment can be removed.
>
>Signed-off-by: Mateusz Nosek <mateusznosek0@gmail.com>

Reviewed-by: Wei Yang <richard.weiyang@gmail.com>


-- 
Wei Yang
Help you, Help me


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] mm/vmscan.c: Clean code by removing unnecessary assignment
  2020-02-29 21:40 [PATCH] mm/vmscan.c: Clean code by removing unnecessary assignment mateusznosek0
  2020-03-01  0:11 ` Matthew Wilcox
  2020-03-02 13:54 ` Wei Yang
@ 2020-03-03  8:59 ` David Hildenbrand
  2 siblings, 0 replies; 7+ messages in thread
From: David Hildenbrand @ 2020-03-03  8:59 UTC (permalink / raw)
  To: mateusznosek0, linux-mm, linux-kernel; +Cc: akpm

On 29.02.20 22:40, mateusznosek0@gmail.com wrote:
> From: Mateusz Nosek <mateusznosek0@gmail.com>
> 
> Previously 0 was assigned to variable 'lruvec_size',
> but the variable was never read later.
> So the assignment can be removed.
> 
> Signed-off-by: Mateusz Nosek <mateusznosek0@gmail.com>
> ---
>  mm/vmscan.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index f14c8c6069a6..a605ff36f126 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -2427,10 +2427,8 @@ static void get_scan_count(struct lruvec *lruvec, struct scan_control *sc,
>  		case SCAN_FILE:
>  		case SCAN_ANON:
>  			/* Scan one type exclusively */
> -			if ((scan_balance == SCAN_FILE) != file) {
> -				lruvec_size = 0;
> +			if ((scan_balance == SCAN_FILE) != file)
>  				scan = 0;
> -			}
>  			break;
>  		default:
>  			/* Look ma, no brain */
> 

Reviewed-by: David Hildenbrand <david@redhat.com>

-- 
Thanks,

David / dhildenb



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] mm/vmscan.c: Clean code by removing unnecessary assignment
  2020-03-19 17:13 ` Michal Hocko
@ 2020-03-20 15:55   ` Johannes Weiner
  0 siblings, 0 replies; 7+ messages in thread
From: Johannes Weiner @ 2020-03-20 15:55 UTC (permalink / raw)
  To: Michal Hocko; +Cc: mateusznosek0, linux-mm, linux-kernel, akpm

On Thu, Mar 19, 2020 at 06:13:34PM +0100, Michal Hocko wrote:
> It is usually preferable to Cc author of the code (added Johannes)
> 
> On Thu 19-03-20 17:59:38, mateusznosek0@gmail.com wrote:
> > From: Mateusz Nosek <mateusznosek0@gmail.com>
> > 
> > Previously 0 was assigned to 'sc->skipped_deactivate'. It could happen only
> > if 'sc->skipped_deactivate' was 0 so the assignment is unnecessary and can
> > be removed.
> 
> The above wording was a bit hard to understdand for me. I would go with
> "
> sc->memcg_low_skipped resets skipped_deactivate to 0 but this is not
> needed as this code path is never reachable with skipped_deactivate != 0
> due to previous sc->skipped_deactivate branch.
> "

Yeah that sounds good.

> > Signed-off-by: Mateusz Nosek <mateusznosek0@gmail.com>
> 
> The patch is correct. I am not sure it results in a better code though.
> I will defer to Johannes here. I suspect he simply wanted to express
> that skipped_deactivate should be always reset when retrying the direct
> reclaim. After this patch this could be lost in future changes so the
> code would be more subtle. But I am only guessing here.

It's a valid concern, but I think in this case specifically we're very
unlikely to change the ordering here - violate memory.low before going
after active pages of unprotected cgroups.

I indeed just kept it stupid: reset everything, then retry. But it
appears that the unnecessary assignment trips people up and wastes
their time, so I'm in favor of removing it.

Acked-by: Johannes Weiner <hannes@cmpxchg.org>


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] mm/vmscan.c: Clean code by removing unnecessary assignment
  2020-03-19 16:59 mateusznosek0
@ 2020-03-19 17:13 ` Michal Hocko
  2020-03-20 15:55   ` Johannes Weiner
  0 siblings, 1 reply; 7+ messages in thread
From: Michal Hocko @ 2020-03-19 17:13 UTC (permalink / raw)
  To: mateusznosek0; +Cc: linux-mm, linux-kernel, akpm, Johannes Weiner

It is usually preferable to Cc author of the code (added Johannes)

On Thu 19-03-20 17:59:38, mateusznosek0@gmail.com wrote:
> From: Mateusz Nosek <mateusznosek0@gmail.com>
> 
> Previously 0 was assigned to 'sc->skipped_deactivate'. It could happen only
> if 'sc->skipped_deactivate' was 0 so the assignment is unnecessary and can
> be removed.

The above wording was a bit hard to understdand for me. I would go with
"
sc->memcg_low_skipped resets skipped_deactivate to 0 but this is not
needed as this code path is never reachable with skipped_deactivate != 0
due to previous sc->skipped_deactivate branch.
"

> Signed-off-by: Mateusz Nosek <mateusznosek0@gmail.com>

The patch is correct. I am not sure it results in a better code though.
I will defer to Johannes here. I suspect he simply wanted to express
that skipped_deactivate should be always reset when retrying the direct
reclaim. After this patch this could be lost in future changes so the
code would be more subtle. But I am only guessing here.

> ---
>  mm/vmscan.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index dca623db51c8..453ff2abcb58 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -3093,7 +3093,6 @@ static unsigned long do_try_to_free_pages(struct zonelist *zonelist,
>  	if (sc->memcg_low_skipped) {
>  		sc->priority = initial_priority;
>  		sc->force_deactivate = 0;
> -		sc->skipped_deactivate = 0;
>  		sc->memcg_low_reclaim = 1;
>  		sc->memcg_low_skipped = 0;
>  		goto retry;
> -- 
> 2.17.1

-- 
Michal Hocko
SUSE Labs


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] mm/vmscan.c: Clean code by removing unnecessary assignment
@ 2020-03-19 16:59 mateusznosek0
  2020-03-19 17:13 ` Michal Hocko
  0 siblings, 1 reply; 7+ messages in thread
From: mateusznosek0 @ 2020-03-19 16:59 UTC (permalink / raw)
  To: linux-mm, linux-kernel; +Cc: Mateusz Nosek, akpm

From: Mateusz Nosek <mateusznosek0@gmail.com>

Previously 0 was assigned to 'sc->skipped_deactivate'. It could happen only
if 'sc->skipped_deactivate' was 0 so the assignment is unnecessary and can
be removed.

Signed-off-by: Mateusz Nosek <mateusznosek0@gmail.com>
---
 mm/vmscan.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index dca623db51c8..453ff2abcb58 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -3093,7 +3093,6 @@ static unsigned long do_try_to_free_pages(struct zonelist *zonelist,
 	if (sc->memcg_low_skipped) {
 		sc->priority = initial_priority;
 		sc->force_deactivate = 0;
-		sc->skipped_deactivate = 0;
 		sc->memcg_low_reclaim = 1;
 		sc->memcg_low_skipped = 0;
 		goto retry;
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-03-20 15:55 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-29 21:40 [PATCH] mm/vmscan.c: Clean code by removing unnecessary assignment mateusznosek0
2020-03-01  0:11 ` Matthew Wilcox
2020-03-02 13:54 ` Wei Yang
2020-03-03  8:59 ` David Hildenbrand
2020-03-19 16:59 mateusznosek0
2020-03-19 17:13 ` Michal Hocko
2020-03-20 15:55   ` Johannes Weiner

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).