mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Johannes Weiner <hannes@cmpxchg.org>
To: Qian Cai <cai@lca.pw>
Cc: akpm@linux-foundation.org, surenb@google.com, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH -next] mm/vmscan: fix some -Wenum-conversion warnings
Date: Fri, 15 Nov 2019 11:17:23 -0500	[thread overview]
Message-ID: <20191115161723.GB309754@cmpxchg.org> (raw)
In-Reply-To: <1573826697-869-1-git-send-email-cai@lca.pw>

On Fri, Nov 15, 2019 at 09:04:57AM -0500, Qian Cai wrote:
> The -next commit "mm: vmscan: enforce inactive:active ratio at the
> reclaim root" [1] introduced some GCC -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);

Interesting, it doesn't show these for me with gcc-9.2.0.

We should definitely fix these!

> @@ -2213,8 +2213,9 @@ 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,
> +				     (enum node_stat_item)inactive_lru);
> +	active = lruvec_page_state(lruvec, (enum node_stat_item)active_lru);

This is fragile, as it relies on the absolute values being identical,
which we don't guarantee. However, we do guarantee the relative order
between the LRU items, and we use NR_LRU_BASE for the translation.

Please use NR_LRU_BASE + (in)active_lru here.

> @@ -2743,7 +2744,8 @@ 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,
> +				 (enum node_stat_item)LRU_INACTIVE_FILE);

This should just directly use NR_INACTIVE_FILE instead.

Thanks

  reply	other threads:[~2019-11-15 16:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-15 14:04 Qian Cai
2019-11-15 16:17 ` Johannes Weiner [this message]
2019-11-15 16:22   ` Qian Cai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191115161723.GB309754@cmpxchg.org \
    --to=hannes@cmpxchg.org \
    --cc=akpm@linux-foundation.org \
    --cc=cai@lca.pw \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=surenb@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®