All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yu Zhao <yuzhao@google.com>
To: Hugh Dickins <hughd@google.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Alex Shi <alex.shi@linux.alibaba.com>,
	Michal Hocko <mhocko@kernel.org>,
	Johannes Weiner <hannes@cmpxchg.org>,
	Vladimir Davydov <vdavydov.dev@gmail.com>,
	Roman Gushchin <guro@fb.com>, Vlastimil Babka <vbabka@suse.cz>,
	Matthew Wilcox <willy@infradead.org>,
	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()
Date: Tue, 15 Dec 2020 17:18:09 -0700	[thread overview]
Message-ID: <X9lSQfI5SjRI/sz0@google.com> (raw)
In-Reply-To: <alpine.LSU.2.11.2012141317351.1925@eggly.anvils>

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 <yuzhao@google.com>
> 
> 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.

  reply	other threads:[~2020-12-16  0:19 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-07 22:09 [PATCH 00/11] mm: lru related cleanups Yu Zhao
2020-12-07 22:09 ` Yu Zhao
2020-12-07 22:09 ` [PATCH 01/11] mm: use add_page_to_lru_list() Yu Zhao
2020-12-07 22:09   ` Yu Zhao
2020-12-08  3:41   ` Alex Shi
2020-12-07 22:09 ` [PATCH 02/11] mm: shuffle lru list addition and deletion functions Yu Zhao
2020-12-07 22:09   ` Yu Zhao
2020-12-07 22:09 ` [PATCH 03/11] mm: don't pass "enum lru_list" to lru list addition functions Yu Zhao
2020-12-07 22:09   ` Yu Zhao
2020-12-08  8:14   ` Alex Shi
2020-12-08  8:24   ` Alex Shi
2020-12-07 22:09 ` [PATCH 04/11] mm: don't pass "enum lru_list" to trace_mm_lru_insertion() Yu Zhao
2020-12-07 22:09   ` Yu Zhao
2020-12-08  8:46   ` Alex Shi
2020-12-07 22:09 ` [PATCH 05/11] mm: don't pass "enum lru_list" to del_page_from_lru_list() Yu Zhao
2020-12-07 22:09   ` Yu Zhao
2020-12-07 22:09 ` [PATCH 06/11] mm: add __clear_page_lru_flags() to replace page_off_lru() Yu Zhao
2020-12-07 22:09   ` Yu Zhao
2020-12-07 22:09 ` [PATCH 07/11] mm: VM_BUG_ON lru page flags Yu Zhao
2020-12-07 22:09   ` Yu Zhao
2020-12-07 22:24   ` Matthew Wilcox
2020-12-16  0:54     ` Yu Zhao
2020-12-16  0:59       ` Matthew Wilcox
2020-12-07 22:09 ` [PATCH 08/11] mm: fold page_lru_base_type() into its sole caller Yu Zhao
2020-12-07 22:09   ` Yu Zhao
2020-12-08  9:02   ` Alex Shi
2020-12-07 22:09 ` [PATCH 09/11] mm: fold __update_lru_size() " Yu Zhao
2020-12-07 22:09   ` Yu Zhao
2020-12-08  9:07   ` Alex Shi
2020-12-07 22:09 ` [PATCH 10/11] mm: make lruvec_lru_size() static Yu Zhao
2020-12-07 22:09   ` Yu Zhao
2020-12-08  9:09   ` Alex Shi
2020-12-07 22:09 ` [PATCH 11/11] mm: enlarge the "int nr_pages" parameter of update_lru_size() Yu Zhao
2020-12-07 22:09   ` Yu Zhao
2020-12-08  9:15   ` Alex Shi
2020-12-14 21:50   ` Hugh Dickins
2020-12-14 21:50     ` Hugh Dickins
2020-12-16  0:18     ` Yu Zhao [this message]
2020-12-10  9:28 ` [PATCH 00/11] mm: lru related cleanups Alex Shi
2020-12-16  0:48   ` Yu Zhao

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=X9lSQfI5SjRI/sz0@google.com \
    --to=yuzhao@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=alex.shi@linux.alibaba.com \
    --cc=guro@fb.com \
    --cc=hannes@cmpxchg.org \
    --cc=hughd@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@kernel.org \
    --cc=vbabka@suse.cz \
    --cc=vdavydov.dev@gmail.com \
    --cc=willy@infradead.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.