Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp1274445ybk; Thu, 21 May 2020 02:59:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwvfl5pjGO/PZ1IvBIAXRCRrnLCAc2Ox9jIVPFNaNr5nB2uilC8Lh4Y2sZpi/N5QVAOQKH0 X-Received: by 2002:a17:906:c10f:: with SMTP id do15mr2834367ejc.249.1590055153606; Thu, 21 May 2020 02:59:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590055153; cv=none; d=google.com; s=arc-20160816; b=XMwHanwjlVM9sJRUOt1MoyT2GAMXlkWav/U2yZ5wneHRYKKf9ckGacbTORZeX6mkY2 uaAMXdwqmA5Hce6HXxbWTK4LA/sdCa3xa5Sj0WnkYLMqvymAFoICR3d3CDH8MDws0Yrt KnACCE9vMv6MUN5tYtLc+AR4AGQKaIr9icvg8c37HD7ROn3Y/uX0YRb0DOmTpVEIYvmu 9fCUcWgfRwuB719pXNlR3opT5Ig1DxsU31lS1oeDS1oE6skJz7Tcwjqhrx7wvIlsdwA/ lWnVkYeuYLsKTtwBb5YZkMbbFh7OCCWxbn509WhsFL8cjsTm0rsCzU2wWZzim5kf1doV qdXQ== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=KD/vBV17SGMLO1DHxG2kgkP08/xJ/6OHMSI2mYKns7E=; b=H4bGUBYTZHaDksC3D7uVORdMHgkAmF5sTtUo+sysB/r1+MKCDGqjNTXlyB+xTpJP2P QzJbAXlGqr4muO9E8Sk6eI2NdLjy25gBpXkO2d5+iUf6DZeDFAim5IMCwqyLDflWFSAS a+xaleS1uBDelnm4IRkhG6ch3CUzisRimfgjW3+NQTT861jel0nF/UZB3LngTfpZkgcL C0RgwNDZSV8usbKn+O45GyZvMkjV8bdrRc8XoSOFIk2Y4VnJPtNMeXatZhM3bLPoe5Qk 67VYO8/+JkDKz1IrOYjuos+vLu6UGabt7z6vsQ3Fyy40n7zLpFKd+PfhQqdBxmg+0BVL Fi3A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w8si3079159eji.466.2020.05.21.02.58.49; Thu, 21 May 2020 02:59:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727922AbgEUJ5P (ORCPT + 99 others); Thu, 21 May 2020 05:57:15 -0400 Received: from mx2.suse.de ([195.135.220.15]:44010 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726405AbgEUJ5P (ORCPT ); Thu, 21 May 2020 05:57:15 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 39AEEAB76; Thu, 21 May 2020 09:57:16 +0000 (UTC) Subject: Re: [PATCH v3 03/19] mm: memcg: convert vmstat slab counters to bytes To: Roman Gushchin Cc: Andrew Morton , Johannes Weiner , Michal Hocko , linux-mm@kvack.org, kernel-team@fb.com, linux-kernel@vger.kernel.org References: <20200422204708.2176080-1-guro@fb.com> <20200422204708.2176080-4-guro@fb.com> <20200520192652.GA278395@carbon.dhcp.thefacebook.com> From: Vlastimil Babka Message-ID: <21975f76-f58f-14ef-9547-7e32afac1681@suse.cz> Date: Thu, 21 May 2020 11:57:12 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: <20200520192652.GA278395@carbon.dhcp.thefacebook.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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! >