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=-19.8 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1,USER_IN_DEF_DKIM_WL autolearn=ham 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 3CB29C4361B for ; Mon, 14 Dec 2020 21:50:22 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id ADFAE22210 for ; Mon, 14 Dec 2020 21:50:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org ADFAE22210 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id E00CD6B0036; Mon, 14 Dec 2020 16:50:20 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DB3C46B005D; Mon, 14 Dec 2020 16:50:20 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CD24F6B0068; Mon, 14 Dec 2020 16:50:20 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0239.hostedemail.com [216.40.44.239]) by kanga.kvack.org (Postfix) with ESMTP id B74FA6B0036 for ; Mon, 14 Dec 2020 16:50:20 -0500 (EST) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 7AF671EF3 for ; Mon, 14 Dec 2020 21:50:20 +0000 (UTC) X-FDA: 77593231800.18.toy52_0612ebe2741e Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin18.hostedemail.com (Postfix) with ESMTP id 4913F100ED3C7 for ; Mon, 14 Dec 2020 21:50:20 +0000 (UTC) X-HE-Tag: toy52_0612ebe2741e X-Filterd-Recvd-Size: 6293 Received: from mail-oi1-f194.google.com (mail-oi1-f194.google.com [209.85.167.194]) by imf12.hostedemail.com (Postfix) with ESMTP for ; Mon, 14 Dec 2020 21:50:19 +0000 (UTC) Received: by mail-oi1-f194.google.com with SMTP id l200so20913484oig.9 for ; Mon, 14 Dec 2020 13:50:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=jOxU8kZwhYfdYwRPjwXKdZug7e2Tg+3U90XP5oXdV88=; b=OaHrUT9fYU+oAqziL4DHHzFQZ8epAwywU163d2MuFcMg/MfRQz8NereEj4lKumaYC0 CbIqfGs0dURuxdVZxSUs9h/popHBTuJMLhxuRPVsff1UDpPGIM45gQZznsOJZAh1XV8t vYVR/ZzNiK0C6N92iB4JF7e1YDIV1USc36JmOZaEWw5FKH8xdktORJFmhXxTJJtchcJz nZv7GoThbNrH7+g+0TEd5Z1haOYyireT0d2LLOpNaxCeE7I1RBitPYJ1ktS881iucm5y KbXzcDzHmdqRNiDsQMJc5BbGviVBHdU6zwEyCjRNc0DF2jSb7BX127MlhczV7k9iSfFv SoqQ== 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:in-reply-to:message-id :references:user-agent:mime-version; bh=jOxU8kZwhYfdYwRPjwXKdZug7e2Tg+3U90XP5oXdV88=; b=N5VbfeHzxuUogtfupfkEMao7X2bgKxWbMVHiZ6vEBNj+vP+YmXQxI4cBoEJnirJOak toeEpVBJjhhBVzRKQf+7W6K5JcWrw2Rb0h6AgMgbCwVGLuNTYj3y1sBBEJAEhlu5dqus CAH+pG1Kxk4dUktRpepig2LlMzV5BfbjsA3W33rfVs9t1oN5bLSkUqBzsNX3OGzjiM05 OCcfhuAye6lh4cAJ258OYSiCfbrgu4D8ZAFLAUnJEyRULrHi1guoIIrAgBbml3vW9QgT VmY+1CcmFe5oNZmddhJCxd6fzmeIvDDDS6SuxoQgMnQ4Hi/bPeoL3IBAsfl0u2oMm/FW g+zQ== X-Gm-Message-State: AOAM533oI+0hWK/6/nsxI/hah79mCkY6h9lLTm/APBP3d17Ywa2lEfxE Ak2u/dOJKSnOGr63jEVDfstHUQ== X-Google-Smtp-Source: ABdhPJy7koPk5qAygFqkOdbXjul3bcFcEBkr9ljx5A5AkGpaXS6AD6SpRRXflYHZJpeiyi8sek7Xkw== X-Received: by 2002:aca:3dd7:: with SMTP id k206mr19748236oia.134.1607982618989; Mon, 14 Dec 2020 13:50:18 -0800 (PST) Received: from eggly.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id f201sm4345440oig.21.2020.12.14.13.50.17 (version=TLS1 cipher=ECDHE-ECDSA-AES128-SHA bits=128/128); Mon, 14 Dec 2020 13:50:18 -0800 (PST) Date: Mon, 14 Dec 2020 13:50:16 -0800 (PST) From: Hugh Dickins X-X-Sender: hugh@eggly.anvils To: Yu Zhao cc: Andrew Morton , Hugh Dickins , Alex Shi , Michal Hocko , Johannes Weiner , Vladimir Davydov , Roman Gushchin , Vlastimil Babka , Matthew Wilcox , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 11/11] mm: enlarge the "int nr_pages" parameter of update_lru_size() In-Reply-To: <20201207220949.830352-12-yuzhao@google.com> Message-ID: References: <20201207220949.830352-1-yuzhao@google.com> <20201207220949.830352-12-yuzhao@google.com> User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Mon, 7 Dec 2020, Yu Zhao wrote: > update_lru_sizes() defines an unsigned long argument and passes it as > nr_pages to update_lru_size(). Though this isn't causing any overflows > I'm aware of, it's a bad idea to go through the demotion given that we > have recently stumbled on a related type promotion problem fixed by > commit 2da9f6305f30 ("mm/vmscan: fix NR_ISOLATED_FILE corruption on 64-bit") > > Note that the underlying counters are already in long. This is another > reason we shouldn't have the demotion. > > This patch enlarges all relevant parameters on the path to the final > underlying counters: > update_lru_size(int -> long) > if memcg: > __mod_lruvec_state(int -> long) > if smp: > __mod_node_page_state(long) > else: > __mod_node_page_state(int -> long) > __mod_memcg_lruvec_state(int -> long) > __mod_memcg_state(int -> long) > else: > __mod_lruvec_state(int -> long) > if smp: > __mod_node_page_state(long) > else: > __mod_node_page_state(int -> long) > > __mod_zone_page_state(long) > > if memcg: > mem_cgroup_update_lru_size(int -> long) > > Note that __mod_node_page_state() for the smp case and > __mod_zone_page_state() already use long. So this change also fixes > the inconsistency. > > Signed-off-by: Yu Zhao NAK from me to this 11/11: I'm running happily with your 1-10 on top of mmotm (I'll review them n a few days, but currently more concerned with Rik's shmem huge gfp_mask), but had to leave this one out. You think you are future-proofing with this, but it is present-breaking. It looks plausible (though seems random: why these particular functions use long but others not? why __mod_memcg_state() long, mod_memcg_state() int?), and I was fooled; but fortunately was still testing with memcg moving, for Alex's patchset. Soon got stuck waiting in balance_dirty_pages(), /proc/vmstat showing nr_anon_pages 2263142822377729 nr_mapped 125095217474159 nr_file_pages 225421358649526 nr_dirty 8589934592 nr_writeback 1202590842920 nr_shmem 40501541678768 nr_anon_transparent_hugepages 51539607554 That last (anon THPs) nothing to do with this patch, but illustrates what Muchun is fixing in his 1/7 "mm: memcontrol: fix NR_ANON_THPS accounting in charge moving". The rest of them could be fixed by changing mem_cgroup_move_account()'s "unsigned int nr_pages" to "long nr_pages" in this patch, but I think it's safer just to drop the patch: the promotion of "unsigned int" to "long" does not work as you would like it to. I see that mm/vmscan.c contains several "unsigned int" counts of pages, everything works fine at present so far as I know, and those appeared to work even with your patch; but I am not confident in my test coverage, and not confident in us being able to outlaw unsigned int page counts in future. Hugh