Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp4682339ybc; Fri, 15 Nov 2019 08:25:54 -0800 (PST) X-Google-Smtp-Source: APXvYqzuwfN2ip4RKfx6LucmCvlTp1ayGHMp7eYb37i8EwRuvr69Hh82o1XUUkGPa/p1ERdIBa9B X-Received: by 2002:a17:906:b2c7:: with SMTP id cf7mr1962171ejb.218.1573835154418; Fri, 15 Nov 2019 08:25:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573835154; cv=none; d=google.com; s=arc-20160816; b=o0SRCDkFK/K0ciqHto32GyEywScMdmYuOsCeDr8BVtfgkNGKkNjeyBdaos4x9Ck9Hg iSpYEf0sriysfaAZ9XGnd3GRK5LqHPrn670OLRRNFRbHIzTRHu6vH3UpM+EMqds8t4xU //5E8z4St6YZAlrszsANsIflOTV/U+p7QyWwSiXIvL58VCujrYopuYsaeexCRen3NZen CM1rzrRtE4YInqylEbt+vnJI8WXjHbpC5b84HOj9fXGHptZu7D8o6c32Q5nQTJ9Wbc7t CAMyj88FOCGc8RikQIFTgXp5LR8AroDyP1oNYNZD8QXobYAkkoyACAGqLecbYjrvc4RQ 1+pQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id :dkim-signature; bh=w7jUeJOoUXH4Qqizv6WofWArxITzVZUe1/AouJiaEWs=; b=TlffLtQCdRvgSVhpyfuFWFWrTeP3/uVNIm2dec57YH96Wml6JGQBvylIdFJi8Ofdj3 F63t1l100d6azsI4dgZy0yK0ZIJtLwfklBfddDw8UxEk2tyP6bPVZPmWw9qkXSfb7yZj 4iv2FiJmrA72IidhUvJBdE8/nLM+W3N4dUE20/QLu9pMnuUZl/lfZay1bk3Z8jfaKiJp eKF+do93/M6OSYTFUuxtpfEWDemrEeiNyvk7JQo8meqXhxodglTQ1mup1m9xSTF8Fdsr sTZrKkghyRmRjSng8mtHrvdPzkfcMmh/8dAvczjaMIqi/4Bl1vB02MLsbtr+R+b/kRXN 3TMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lca.pw header.s=google header.b="XPmJB/Tr"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s15si5817795ejb.49.2019.11.15.08.25.28; Fri, 15 Nov 2019 08:25:54 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@lca.pw header.s=google header.b="XPmJB/Tr"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727695AbfKOQWK (ORCPT + 99 others); Fri, 15 Nov 2019 11:22:10 -0500 Received: from mail-qv1-f46.google.com ([209.85.219.46]:36204 "EHLO mail-qv1-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727423AbfKOQWJ (ORCPT ); Fri, 15 Nov 2019 11:22:09 -0500 Received: by mail-qv1-f46.google.com with SMTP id cv8so3834065qvb.3 for ; Fri, 15 Nov 2019 08:22:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lca.pw; s=google; h=message-id:subject:from:to:cc:date:in-reply-to:references :mime-version:content-transfer-encoding; bh=w7jUeJOoUXH4Qqizv6WofWArxITzVZUe1/AouJiaEWs=; b=XPmJB/TrxXdwntPZQn/pG6IoPfqIvTjFs+9AtqLINMFVbip/eogNS3LiL73jcgCDqt qzmOneG1K5ysjBPQWNRkd/re3r84pvUlKqyLRvf/6UxeGHDKbYY0u2IyrGO1BPXCUiQA qwxOnRh6mUS8vkcCXw2gsbSavUaw+O0d6FsOOWrEOpEo02JStDLR5KCW2RJ0k10pYpta siowDyjSw9vKOeMs3VmH7Qu3v3zTjz9b/JKw4CVYUcFMkqQeXKTObbCv1cmZm+hKdkkv NCeUdwxFTXohiIMUyWoLBhStmLB0UF7DP3HPMpGqAwjXfd1xRAq2UCd13nKp//Vlslfy VFxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:mime-version:content-transfer-encoding; bh=w7jUeJOoUXH4Qqizv6WofWArxITzVZUe1/AouJiaEWs=; b=EuvDHdeNpqn83x3QRu96LcEHmuD2imx+3TtppKQSjWJjT4U4TchAocn6hmXP2rI8Gz zWBKITJu7PXEHHLLYrCf14S41rIwzwPv5F1Fi+VV95arcCPFcZ47V29zuF5f+YW9V6ZU wu7B8FNdPs5rh7dqSS/bjymmpBl0qbXnthDLHtDyplAT5dcUnF8R+8EzPWgIjNMV2YtT YciQQ/CmgJcREd9Qa+aMkv056Bd6DMS1a4RYPngA5+8k/djR3kNtJdjyndXlRHSD2W5C uKWRLo+NiAUu4WZmscgWmP9YZsyYsUWyzjZLSBCNwjSru9js0sbx2newjws17Q0QfUxa bmLw== X-Gm-Message-State: APjAAAV07niNVO4gOLDxmLtVBDldxuQBj4ImMuI+w0tRmgQDelXuWdQV 9FzAYWdYGPF4nWIewdrouIQieg== X-Received: by 2002:a0c:a998:: with SMTP id a24mr9881957qvb.117.1573834927156; Fri, 15 Nov 2019 08:22:07 -0800 (PST) Received: from dhcp-41-57.bos.redhat.com (nat-pool-bos-t.redhat.com. [66.187.233.206]) by smtp.gmail.com with ESMTPSA id q17sm5356533qtq.58.2019.11.15.08.22.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Nov 2019 08:22:06 -0800 (PST) Message-ID: <1573834925.5937.127.camel@lca.pw> Subject: Re: [PATCH -next] mm/vmscan: fix some -Wenum-conversion warnings From: Qian Cai To: Johannes Weiner Cc: akpm@linux-foundation.org, surenb@google.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Date: Fri, 15 Nov 2019 11:22:05 -0500 In-Reply-To: <20191115161723.GB309754@cmpxchg.org> References: <1573826697-869-1-git-send-email-cai@lca.pw> <20191115161723.GB309754@cmpxchg.org> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.22.6 (3.22.6-10.el7) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 2019-11-15 at 11:17 -0500, Johannes Weiner wrote: > 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. Sorry, I meant to say it is clang. > > 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