On 5/20/20 9:26 PM, Roman Gushchin wrote: > On Wed, May 20, 2020 at 02:25:22PM +0200, Vlastimil Babka wrote: >> >> However __mod_node_page_state() and mode_node_state() will now branch always. I >> wonder if the "API clean" goal is worth it... > > You mean just adding a special write-side helper which will perform a conversion > and put VM_WARN_ON_ONCE() into generic write-side helpers? What I mean is that maybe node/global helpers should assume page granularity, and lruvec/memcg helpers do the check is they should convert from bytes to pages when calling node/global helpers. Then there would be no extra branches in node/global helpers. But maybe it's not worth saving those branches, dunno. >> >> > --- a/mm/memcontrol.c >> > +++ b/mm/memcontrol.c >> > @@ -1409,9 +1409,8 @@ static char *memory_stat_format(struct mem_cgroup *memcg) >> > (u64)memcg_page_state(memcg, MEMCG_KERNEL_STACK_KB) * >> > 1024); >> > seq_buf_printf(&s, "slab %llu\n", >> > - (u64)(memcg_page_state(memcg, NR_SLAB_RECLAIMABLE) + >> > - memcg_page_state(memcg, NR_SLAB_UNRECLAIMABLE)) * >> > - PAGE_SIZE); >> > + (u64)(memcg_page_state(memcg, NR_SLAB_RECLAIMABLE_B) + >> > + memcg_page_state(memcg, NR_SLAB_UNRECLAIMABLE_B))); >> > seq_buf_printf(&s, "sock %llu\n", >> > (u64)memcg_page_state(memcg, MEMCG_SOCK) * >> > PAGE_SIZE); >> > @@ -1445,11 +1444,9 @@ static char *memory_stat_format(struct mem_cgroup *memcg) >> > PAGE_SIZE); >> > >> > seq_buf_printf(&s, "slab_reclaimable %llu\n", >> > - (u64)memcg_page_state(memcg, NR_SLAB_RECLAIMABLE) * >> > - PAGE_SIZE); >> > + (u64)memcg_page_state(memcg, NR_SLAB_RECLAIMABLE_B)); >> > seq_buf_printf(&s, "slab_unreclaimable %llu\n", >> > - (u64)memcg_page_state(memcg, NR_SLAB_UNRECLAIMABLE) * >> > - PAGE_SIZE); >> > + (u64)memcg_page_state(memcg, NR_SLAB_UNRECLAIMABLE_B)); >> >> So here we are now printing in bytes instead of pages, right? That's fine for >> OOM report, but in sysfs aren't we breaking existing users? >> > > Hm, but it was in bytes previously, look at that x * PAGE_SIZE. Yeah, that's what I managed to overlook, sorry. > Or do you mean that now it can be not rounded to PAGE_SIZE? > If so, I don't think it breaks any expectations. > > Thanks! >