Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp478985ybk; Wed, 20 May 2020 04:38:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwFfgKAzz0fcbl2nKe8fWH5fr+KLjzi6WSNwz/CBCQPPsfsSlesndJ4C3gzIY2d2Jd8pyCA X-Received: by 2002:a17:906:c155:: with SMTP id dp21mr3178498ejc.92.1589974689087; Wed, 20 May 2020 04:38:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589974689; cv=none; d=google.com; s=arc-20160816; b=vnyjXxs4U7krI8mXo0eUPIK3j7joqHID86OLp9AAx5kyvm/d9J1P3uVvv6fpT1Yb6D UNBYuclR22VvjxyojGQR8W8NCfULV+sW5wtAAX6AmqmFvs/a1Vq5eWNPYg12bCMxYLoM u5Bh9EobNe0ODbmUBJUpj7eM3kiDbraO+ZjKjo43ioA3i8+XClD0+XfuRvy4L7YVFNGs +bxj9OP2sSVtX0zOG/P5lgmn1GaeEF0sUI0uJ+sPh5QtT7OB2LvMT1drZ2n4SHfw2Q0c 5tWSR6XMTqkyRsGRLfJ8bBlcWatz8M/hsKLWuG6LYAbPE5c9pJin55cMljD5Xv3rA1an yFBg== 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:references:cc:to:from:subject; bh=vEq0f1ypSPE5MZK3BICZOI8nEqg/MH0PMJ7wc01r2RQ=; b=ArmvX4gazkq8EuDq4aGhRC4fJgBxRrq4nKSnyZjC9s84UnFZVu08n27b3FqHPapvhI sGup4ofPQ5JQ/KAu/iqzu5zHwxu0N+CCA0hdSARp25nxLuZ/9oejq/Lut2iaieAU2vrz FrwPvvbimkvq1H7aVeb15Qh+0txuON/a9Uz9DtD6ZiELoiu/+e58DrcjxrTVJcJ0HAXC t2YVK0tOzvNnkA3Ru5eIxGeR3oukvxk3CqqL3kGdPi0JrPkwl52NRS+mYkHQTcqwtBLA ud4W1twBD1YR+i98oLc82CJoMqL2u5gmQO2K26P12M6dPEVfVg4L7+RG3Qk1L82c6fha CoIg== 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 b9si1349282edu.30.2020.05.20.04.37.46; Wed, 20 May 2020 04:38:09 -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 S1726560AbgETLgM (ORCPT + 99 others); Wed, 20 May 2020 07:36:12 -0400 Received: from mx2.suse.de ([195.135.220.15]:52826 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726486AbgETLgL (ORCPT ); Wed, 20 May 2020 07:36:11 -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 B5FDBAE61; Wed, 20 May 2020 11:36:12 +0000 (UTC) Subject: Re: [PATCH v3 02/19] mm: memcg: prepare for byte-sized vmstat items From: Vlastimil Babka To: Roman Gushchin , Andrew Morton Cc: 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-3-guro@fb.com> Message-ID: Date: Wed, 20 May 2020 13:36:09 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: 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 1:31 PM, Vlastimil Babka wrote: > On 4/22/20 10:46 PM, Roman Gushchin wrote: >> To implement per-object slab memory accounting, we need to >> convert slab vmstat counters to bytes. Actually, out of >> 4 levels of counters: global, per-node, per-memcg and per-lruvec >> only two last levels will require byte-sized counters. >> It's because global and per-node counters will be counting the >> number of slab pages, and per-memcg and per-lruvec will be >> counting the amount of memory taken by charged slab objects. >> >> Converting all vmstat counters to bytes or even all slab >> counters to bytes would introduce an additional overhead. >> So instead let's store global and per-node counters >> in pages, and memcg and lruvec counters in bytes. >> >> To make the API clean all access helpers (both on the read >> and write sides) are dealing with bytes. >> >> To avoid back-and-forth conversions a new flavor of helpers >> is introduced, which always returns values in pages: >> node_page_state_pages() and global_node_page_state_pages(). >> >> Actually new helpers are just reading raw values. Old helpers are >> simple wrappers, which perform a conversion if the vmstat items are >> in bytes. Because at the moment no one actually need bytes, >> there are WARN_ON_ONCE() macroses inside to warn about inappropriate >> use cases. >> >> Thanks to Johannes Weiner for the idea of having the byte-sized API >> on top of the page-sized internal storage. >> >> Signed-off-by: Roman Gushchin > > Reviewed-By: Vlastimil Babka > > But it's somewhat complicated, so it would be great to document it in comments > of e.g. include/linux/vmstat.h that what the API returns as unsigned long, can > be either bytes or pages depending on vmstat_item_in_bytes(). Also forgot to add that if those WARN_ON_ONCEs are going to stay, they should rather become VM_WARN_ON_ONCEs