Skip to contentSkip to conversation

mm/vmscan: fix some -Wenum-conversion warnings

PATCH In review Qian Cai 2 participants 5 messages Nov 15, 2019 – Nov 18, 2019

Subsystems (3)
lore
Share & tools
lore

Qian Cai

author
#0 lore raw

PATCH v2 1/1 mm/vmscan: fix some -Wenum-conversion warnings

The -next commit "mm: vmscan: enforce inactive:active ratio at the reclaim root" [1] introduced some Clang -Wenum-conversion warnings,

mm/vmscan.c:2216:39: warning: implicit conversion from enumeration type 'enum lru_list' to different enumeration type 'enum node_stat_item' [-Wenum-conversion]

        inactive = lruvec_page_state(lruvec, inactive_lru);
                   ~~~~~~~~~~~~~~~~~         ^~~~~~~~~~~~
mm/vmscan.c:2217:37: warning: implicit conversion from enumeration type
'enum lru_list' to different enumeration type 'enum node_stat_item'
[-Wenum-conversion]
        active = lruvec_page_state(lruvec, active_lru);
                 ~~~~~~~~~~~~~~~~~         ^~~~~~~~~~
mm/vmscan.c:2746:42: warning: implicit conversion from enumeration type
'enum lru_list' to different enumeration type 'enum node_stat_item'
[-Wenum-conversion]
        file = lruvec_page_state(target_lruvec, LRU_INACTIVE_FILE);
               ~~~~~~~~~~~~~~~~~                ^~~~~~~~~~~~~~~~~

Since it guarantees the relative order between the LRU items, fix it by using NR_LRU_BASE for the translation.

[1] http://lkml.kernel.org/r/[email protected]

---

v2: use NR_LRU_BASE/NR_INACTIVE_FILE per Johannes.

 mm/vmscan.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
mm/vmscan.c +3 -3
index 122b3920aaa4..c8e88f4d9932 100644
@@ -2213,8 +2213,8 @@ static bool inactive_is_low(struct lruvec *lruvec, enum lru_list inactive_lru)
 	unsigned long inactive_ratio;
 	unsigned long gb;
 
-	inactive = lruvec_page_state(lruvec, inactive_lru);
-	active = lruvec_page_state(lruvec, active_lru);
+	inactive = lruvec_page_state(lruvec, NR_LRU_BASE + inactive_lru);
+	active = lruvec_page_state(lruvec, NR_LRU_BASE + active_lru);
 
 	gb = (inactive + active) >> (30 - PAGE_SHIFT);
 	if (gb)
@@ -2743,7 +2743,7 @@ static bool shrink_node(pg_data_t *pgdat, struct scan_control *sc)
 	 * thrashing, try to reclaim those first before touching
 	 * anonymous pages.
 	 */
-	file = lruvec_page_state(target_lruvec, LRU_INACTIVE_FILE);
+	file = lruvec_page_state(target_lruvec, NR_INACTIVE_FILE);
 	if (file >> sc->priority && !(sc->may_deactivate & DEACTIVATE_FILE))
 		sc->cache_trim_mode = 1;
 	else
Signature · 1 line
1.8.3.1
maintainer Acked-by on v2 1/1
#1 lore raw
Quoted 19 lines · Qian Cai

The -next commit "mm: vmscan: enforce inactive:active ratio at the reclaim root" [1] introduced some Clang -Wenum-conversion warnings,

mm/vmscan.c:2216:39: warning: implicit conversion from enumeration type 'enum lru_list' to different enumeration type 'enum node_stat_item' [-Wenum-conversion]

        inactive = lruvec_page_state(lruvec, inactive_lru);
                   ~~~~~~~~~~~~~~~~~         ^~~~~~~~~~~~
mm/vmscan.c:2217:37: warning: implicit conversion from enumeration type
'enum lru_list' to different enumeration type 'enum node_stat_item'
[-Wenum-conversion]
        active = lruvec_page_state(lruvec, active_lru);
                 ~~~~~~~~~~~~~~~~~         ^~~~~~~~~~
mm/vmscan.c:2746:42: warning: implicit conversion from enumeration type
'enum lru_list' to different enumeration type 'enum node_stat_item'
[-Wenum-conversion]
        file = lruvec_page_state(target_lruvec, LRU_INACTIVE_FILE);
               ~~~~~~~~~~~~~~~~~                ^~~~~~~~~~~~~~~~~
Quoted 6 lines

Since it guarantees the relative order between the LRU items, fix it by using NR_LRU_BASE for the translation.

[1] http://lkml.kernel.org/r/[email protected]

Thanks Qian!

Andrew, this is a fix for "mm: vmscan: enforce inactive:active ratio at the reclaim root". Could you please fold this into that?

maintainer
#2 lore raw
Quoted 25 lines · Johannes Weiner
Quoted 24 lines · Qian Cai

The -next commit "mm: vmscan: enforce inactive:active ratio at the reclaim root" [1] introduced some Clang -Wenum-conversion warnings,

mm/vmscan.c:2216:39: warning: implicit conversion from enumeration type 'enum lru_list' to different enumeration type 'enum node_stat_item' [-Wenum-conversion]

        inactive = lruvec_page_state(lruvec, inactive_lru);
                   ~~~~~~~~~~~~~~~~~         ^~~~~~~~~~~~
mm/vmscan.c:2217:37: warning: implicit conversion from enumeration type
'enum lru_list' to different enumeration type 'enum node_stat_item'
[-Wenum-conversion]
        active = lruvec_page_state(lruvec, active_lru);
                 ~~~~~~~~~~~~~~~~~         ^~~~~~~~~~
mm/vmscan.c:2746:42: warning: implicit conversion from enumeration type
'enum lru_list' to different enumeration type 'enum node_stat_item'
[-Wenum-conversion]
        file = lruvec_page_state(target_lruvec, LRU_INACTIVE_FILE);
               ~~~~~~~~~~~~~~~~~                ^~~~~~~~~~~~~~~~~

Since it guarantees the relative order between the LRU items, fix it by using NR_LRU_BASE for the translation.

[1] http://lkml.kernel.org/r/[email protected]

Quoted 8 lines
Quoted 1 line

Thanks Qian!

Andrew, this is a fix for "mm: vmscan: enforce inactive:active ratio at the reclaim root". Could you please fold this into that?

nvm, I see you already picked it up. Thank you!

author
#3 lore raw
Quoted 28 lines · Johannes Weiner
Quoted 27 lines · Johannes Weiner
Quoted 25 lines · Qian Cai

The -next commit "mm: vmscan: enforce inactive:active ratio at the reclaim root" [1] introduced some Clang -Wenum-conversion warnings,

mm/vmscan.c:2216:39: warning: implicit conversion from enumeration type 'enum lru_list' to different enumeration type 'enum node_stat_item' [-Wenum-conversion]

        inactive = lruvec_page_state(lruvec, inactive_lru);
                   ~~~~~~~~~~~~~~~~~         ^~~~~~~~~~~~
mm/vmscan.c:2217:37: warning: implicit conversion from enumeration type
'enum lru_list' to different enumeration type 'enum node_stat_item'
[-Wenum-conversion]
        active = lruvec_page_state(lruvec, active_lru);
                 ~~~~~~~~~~~~~~~~~         ^~~~~~~~~~
mm/vmscan.c:2746:42: warning: implicit conversion from enumeration type
'enum lru_list' to different enumeration type 'enum node_stat_item'
[-Wenum-conversion]
        file = lruvec_page_state(target_lruvec, LRU_INACTIVE_FILE);
               ~~~~~~~~~~~~~~~~~                ^~~~~~~~~~~~~~~~~

Since it guarantees the relative order between the LRU items, fix it by using NR_LRU_BASE for the translation.

[1] http://lkml.kernel.org/r/[email protected]

Quoted 8 lines
Quoted 6 lines

Thanks Qian!

Andrew, this is a fix for "mm: vmscan: enforce inactive:active ratio at the reclaim root". Could you please fold this into that?

nvm, I see you already picked it up. Thank you!

Hmm, I don't see Andrew picked it yet.

author
#4 lore raw
Quoted 31 lines · Qian Cai
Quoted 30 lines · Johannes Weiner
Quoted 29 lines · Johannes Weiner
Quoted 19 lines · Qian Cai

The -next commit "mm: vmscan: enforce inactive:active ratio at the reclaim root" [1] introduced some Clang -Wenum-conversion warnings,

mm/vmscan.c:2216:39: warning: implicit conversion from enumeration type 'enum lru_list' to different enumeration type 'enum node_stat_item' [-Wenum-conversion]

        inactive = lruvec_page_state(lruvec, inactive_lru);
                   ~~~~~~~~~~~~~~~~~         ^~~~~~~~~~~~
mm/vmscan.c:2217:37: warning: implicit conversion from enumeration type
'enum lru_list' to different enumeration type 'enum node_stat_item'
[-Wenum-conversion]
        active = lruvec_page_state(lruvec, active_lru);
                 ~~~~~~~~~~~~~~~~~         ^~~~~~~~~~
mm/vmscan.c:2746:42: warning: implicit conversion from enumeration type
'enum lru_list' to different enumeration type 'enum node_stat_item'
[-Wenum-conversion]
        file = lruvec_page_state(target_lruvec, LRU_INACTIVE_FILE);
               ~~~~~~~~~~~~~~~~~                ^~~~~~~~~~~~~~~~~
Quoted 6 lines

Since it guarantees the relative order between the LRU items, fix it by using NR_LRU_BASE for the translation.

[1] http://lkml.kernel.org/r/[email protected]

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

Thanks Qian!

Andrew, this is a fix for "mm: vmscan: enforce inactive:active ratio at the reclaim root". Could you please fold this into that?

nvm, I see you already picked it up. Thank you!

Hmm, I don't see Andrew picked it yet.

Ah, I saw it now. Too many emails, so I'll setup a filter.