From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.3 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 08B29C432C3 for ; Fri, 15 Nov 2019 16:17:30 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9918920692 for ; Fri, 15 Nov 2019 16:17:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=cmpxchg-org.20150623.gappssmtp.com header.i=@cmpxchg-org.20150623.gappssmtp.com header.b="BRKC2o/F" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9918920692 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=cmpxchg.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 32F046B0005; Fri, 15 Nov 2019 11:17:29 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2DEDD6B0006; Fri, 15 Nov 2019 11:17:29 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1F5816B0007; Fri, 15 Nov 2019 11:17:29 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0072.hostedemail.com [216.40.44.72]) by kanga.kvack.org (Postfix) with ESMTP id 0B0B06B0005 for ; Fri, 15 Nov 2019 11:17:29 -0500 (EST) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with SMTP id 9EBAC180AD837 for ; Fri, 15 Nov 2019 16:17:28 +0000 (UTC) X-FDA: 76159016976.29.point15_5e48316049044 X-HE-Tag: point15_5e48316049044 X-Filterd-Recvd-Size: 5217 Received: from mail-pg1-f177.google.com (mail-pg1-f177.google.com [209.85.215.177]) by imf15.hostedemail.com (Postfix) with ESMTP for ; Fri, 15 Nov 2019 16:17:27 +0000 (UTC) Received: by mail-pg1-f177.google.com with SMTP id r18so6197523pgu.13 for ; Fri, 15 Nov 2019 08:17:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=Pbqn4UOLsCUmS2w+1MSU94yBFEcgWrVd3oXN3b1LEx8=; b=BRKC2o/FBEZKJP3PrSUWqd+44yMTJCJlrFCYjmuyln3cjvp9ytyil6MuMCNP4gSUzm dPNz9pehbWI9TUuYKmOK7p2nx0+bVWhzxgSaSOul9QphVp1gkcX1gBSaIS1jxYo4SJnd uQaIw7rPbRJOLVYMpOMO5h5jideGs00NibYy8oj2ctly/HKRUKWOPMCsZpfD7P/8mYFr 96tVb9N69jh03s36MWT6Rokbs47yNDuS66OH2IcINuNaAVIN3W1xDIJQMxpjsYC+ADU7 T+AOIwmgVTqpu4EESHTVdU+yOvW+uerH6aNPRfBaKBXQDyWiWORRrtS/U0sEznq43lZh TUPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=Pbqn4UOLsCUmS2w+1MSU94yBFEcgWrVd3oXN3b1LEx8=; b=qGQOcM81RrR6P/vW75mtg7tNxhFxXd23R88wE5lScE8FQSQDKJ6UGtZSE2IsCPxpKu bvSNdKIwTs335PuA8pD/S55sPtoL11v8Y9zEHMECwboDbVX+Ck8m1+vZsVfVWJIyRs96 0ElI0R+3phBWDFiCTxgXcIEI9I/eUhSfIqz38MM37N5mR8Gt6MxbOGDKsSblGxqm+A+6 M/wQUlPJA75h1ZVTpcVEcX5GPFxM+VIUBktN7t+euESTQqlvWi1dOBLxTsvSL3gP1p6F 7UBfdrFgx00VsaBejSdK6uIMOmSfor8lRdYw7JHwOuZHUIF/7V/haH1VdJO3Mt6Gk88g SopA== X-Gm-Message-State: APjAAAUt5X58/E/njSFuNh3i3s5d1zYV19TF3aQYADAfvtW/aGayVPGa KCFyDQSvktJ9+lJ6hcHFbtTtJQ== X-Google-Smtp-Source: APXvYqxmi24iXu0LREAQssFRJC9yqoJHNzorfijmEqsFdQKPjMycC0crWL0/VvNTKiXaajs6SsaZ8w== X-Received: by 2002:a63:3cd:: with SMTP id 196mr10683792pgd.150.1573834646139; Fri, 15 Nov 2019 08:17:26 -0800 (PST) Received: from localhost ([2620:10d:c090:180::a9db]) by smtp.gmail.com with ESMTPSA id c3sm10597891pfi.91.2019.11.15.08.17.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Nov 2019 08:17:25 -0800 (PST) Date: Fri, 15 Nov 2019 11:17:23 -0500 From: Johannes Weiner To: Qian Cai 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 Message-ID: <20191115161723.GB309754@cmpxchg.org> References: <1573826697-869-1-git-send-email-cai@lca.pw> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1573826697-869-1-git-send-email-cai@lca.pw> User-Agent: Mutt/1.12.2 (2019-09-21) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000018, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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