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=-18.3 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_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 9239AC4361B for ; Wed, 16 Dec 2020 00:18:17 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3C8E222D06 for ; Wed, 16 Dec 2020 00:18:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3C8E222D06 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 684D06B0036; Tue, 15 Dec 2020 19:18:16 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 60CE36B005D; Tue, 15 Dec 2020 19:18:16 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4D5366B0068; Tue, 15 Dec 2020 19:18:16 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0124.hostedemail.com [216.40.44.124]) by kanga.kvack.org (Postfix) with ESMTP id 30F436B0036 for ; Tue, 15 Dec 2020 19:18:16 -0500 (EST) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id E7B8C181AEF1F for ; Wed, 16 Dec 2020 00:18:15 +0000 (UTC) X-FDA: 77597233350.21.trees48_48147e727427 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin21.hostedemail.com (Postfix) with ESMTP id CBA88180442C7 for ; Wed, 16 Dec 2020 00:18:15 +0000 (UTC) X-HE-Tag: trees48_48147e727427 X-Filterd-Recvd-Size: 6649 Received: from mail-io1-f66.google.com (mail-io1-f66.google.com [209.85.166.66]) by imf04.hostedemail.com (Postfix) with ESMTP for ; Wed, 16 Dec 2020 00:18:15 +0000 (UTC) Received: by mail-io1-f66.google.com with SMTP id i18so22322754ioa.1 for ; Tue, 15 Dec 2020 16:18:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=T5QmzgOoeP4SUmIL1zNOjJKDNzzGZxipYccNq8PFO7M=; b=Lus2wCU1FkRr0MgFcxgyLdvioHAqJljlRWXBQ7o74VbCh5I46Bh2UZglCG4azwiBcS dkdDUiJSZw4M0P/yFeWWSCB4StSboVNN6+AHlufUTuoyDT4uhcCegw1yjGkVaybsy8f/ +A1z3JDCpw1Aho6CgcmIsR0WK/cBn44BEXlIJ51sUR74pzE4uD+AEl7D/LImkiWX2k1e Fc99Tv5A6w3PSVgLOn3XO81ylQ8STLHq5mADC6wDoPcj2xW5TbFov9Gq6formWjkR7ww Woxdl4oux9S1ppOvf9ZQupMWx16fCMS9RctPX3oHddxe0INtA8+7DtUbu8/uoX/Pwe7N ZXFA== 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; bh=T5QmzgOoeP4SUmIL1zNOjJKDNzzGZxipYccNq8PFO7M=; b=TvyZKdpPi6QrbB9g9hn3OBFzsoEKeh6wMIvcwO1mzeLHlDw+rGCcTieSvDQhd91uXZ w7MMk6Ssgh/XgNLworxXKO/dNPZLnupHiOLcN+63Xx7m8rsgbu7qi6+B/ZHoYM4K3+G1 dyPUMzPb2c+DUuFTUT3VfG8OHDedNexvbFFbecZe16Ig9gSgcg/rUFGhOxUtRzw4auqk WYhYsa/L9xubJTzLNy4h5yKjK4/HYSODtb9u1Yy9BHt0HINF6JznTHDPG5Wp9P0IUUDM kHbB+Xx7hXr/8zJvO4NHcyQFz3/K0fS1HTHDz1rBztRFL3NnVQcxDZzJ4DwXI/KVHcNu 72jw== X-Gm-Message-State: AOAM530+WumS9IPs/5xJY42eVYc9pGiZPSKzsyMHKRtzGXcjVna732eR ZZaNpE+UtXA0HtpBxTRvbo2KGw== X-Google-Smtp-Source: ABdhPJzLDDvU0tcE98mIDOgQvXKlAJoZx3CXaPsT21ctYvqDkh/iEE3QszoIzvgFbJ/QyJYMP5UFkA== X-Received: by 2002:a02:7152:: with SMTP id n18mr35743366jaf.127.1608077894475; Tue, 15 Dec 2020 16:18:14 -0800 (PST) Received: from google.com ([2620:15c:183:200:7220:84ff:fe09:2d90]) by smtp.gmail.com with ESMTPSA id m18sm11748979ioy.44.2020.12.15.16.18.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Dec 2020 16:18:13 -0800 (PST) Date: Tue, 15 Dec 2020 17:18:09 -0700 From: Yu Zhao To: Hugh Dickins Cc: Andrew Morton , 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() Message-ID: References: <20201207220949.830352-1-yuzhao@google.com> <20201207220949.830352-12-yuzhao@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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, Dec 14, 2020 at 01:50:16PM -0800, Hugh Dickins wrote: > 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. My apologies. The patch was fully tested on 4.15. Apparently I didn't pay enough attention to what's changed in mem_cgroup_move_account() nor had any test coverage on it when rebasing this patch. > 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. I'll just drop this one. Thanks.