Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2457390pxu; Mon, 7 Dec 2020 07:09:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJwBBkXrmwnSIYCioJDrKC58wESo7+3dQk5ALecJau+8V6qPud0XoiWKKhnzbCR2XAgLawxq X-Received: by 2002:aa7:d459:: with SMTP id q25mr20142568edr.279.1607353746751; Mon, 07 Dec 2020 07:09:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607353746; cv=none; d=google.com; s=arc-20160816; b=NXZUECvz04IoVu3NU0aR9spyYem7d0Y4ZnLR8xuB/5Fvy2gkDqqeeMEDJbQ1ZowHjv h8NkNkN+Ghe2sUxQfJTH82Sncy3jdboDQxztW9FD6V+NfU3GfL7z8/QkPXDgwQBIEuIr GPyn9YDnpzPUx5uLdCgLWelZdFLzd5kVvEjKSAoSGwf39v6+813kWrEb6l+mu5cLcWfC +XiAaX1QLDYPKdizhIHFroRaGFZfe2+8mfJiAZ8na0BiAxTTWplY9dIdxr1tMYYz4uPI yJSV4YGjO78oQ4OPA6d51M33n1GbpW8yELB0sueBeEvfJOYp08dOESdgN9Yr6EVDHqSR f5RQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=W9xHKa0FHxvAY5lMXiXo+4bSevtfetGYjc7M1Qiyftw=; b=Vb3o5qkWBclKgCKmeuhMIbzqZwgbqzQwblFxqIkhFWmxcsJmlblELS24eFjoKLHPl1 /BGzqjVf8rKaPrxT1MOssq8QeUaa8k9O+h3rNk2oPAT+oH/XwOF0MzG4jTpLqbDOFySP SrEoIDKzP11go4j/jKDmuAeI8iWSrxKvBNEFgXNk5HCXKpS7PptmenwCEDd1G/TYWLl9 rIBfcHUvP8IWz+pKXYWirl3yRXo3fZnE2S3il1Uv+zSx+Qdk7q73HtirdoOpUWrjj5ch +K+U3G342iw6T5JNji9TLMv0ds4upNZUFdpw7CQ5fmRNX4Ql9odM3X+1CCNsj6SyQoB4 DQAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=FnFflSv8; 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; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id re10si7503784ejb.754.2020.12.07.07.08.41; Mon, 07 Dec 2020 07:09:06 -0800 (PST) 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; dkim=pass header.i=@suse.com header.s=susede1 header.b=FnFflSv8; 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; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727151AbgLGPDm (ORCPT + 99 others); Mon, 7 Dec 2020 10:03:42 -0500 Received: from mx2.suse.de ([195.135.220.15]:55558 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727134AbgLGPDm (ORCPT ); Mon, 7 Dec 2020 10:03:42 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1607353375; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=W9xHKa0FHxvAY5lMXiXo+4bSevtfetGYjc7M1Qiyftw=; b=FnFflSv8rzalFIyNLjcUy7ngp2i44jvG1FEWcNn7jC3d+hDQcfKh0lVVHNeI/o/sZimsvr eQVcvH5Q2lMWef8fp3aSgRVYGaswMY1kVzgXWO9EkGp22XgMfXXXNYFu5+yGa0hrv2PcsY CmZGpPtTTlzg4iTd4Ch1sfoHjrMfHck= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 8F742ACBD; Mon, 7 Dec 2020 15:02:55 +0000 (UTC) Date: Mon, 7 Dec 2020 16:02:54 +0100 From: Michal Hocko To: Muchun Song Cc: Greg KH , rafael@kernel.org, Alexey Dobriyan , Andrew Morton , Johannes Weiner , Vladimir Davydov , Hugh Dickins , Will Deacon , Roman Gushchin , Mike Rapoport , Thomas Gleixner , esyr@redhat.com, peterx@redhat.com, krisman@collabora.com, Suren Baghdasaryan , avagin@openvz.org, Marco Elver , Randy Dunlap , Joonsoo Kim , LKML , linux-fsdevel , Linux Memory Management List , Cgroups Subject: Re: [External] Re: [RESEND PATCH v2 00/12] Convert all vmstat counters to pages or bytes Message-ID: <20201207150254.GL25569@dhcp22.suse.cz> References: <20201206101451.14706-1-songmuchun@bytedance.com> <20201207130018.GJ25569@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon 07-12-20 22:52:30, Muchun Song wrote: > On Mon, Dec 7, 2020 at 9:00 PM Michal Hocko wrote: > > > > On Sun 06-12-20 18:14:39, Muchun Song wrote: > > > Hi, > > > > > > This patch series is aimed to convert all THP vmstat counters to pages > > > and some KiB vmstat counters to bytes. > > > > > > The unit of some vmstat counters are pages, some are bytes, some are > > > HPAGE_PMD_NR, and some are KiB. When we want to expose these vmstat > > > counters to the userspace, we have to know the unit of the vmstat counters > > > is which one. It makes the code complex. Because there are too many choices, > > > the probability of making a mistake will be greater. > > > > > > For example, the below is some bug fix: > > > - 7de2e9f195b9 ("mm: memcontrol: correct the NR_ANON_THPS counter of hierarchical memcg") > > > - not committed(it is the first commit in this series) ("mm: memcontrol: fix NR_ANON_THPS account") > > > > > > This patch series can make the code simple (161 insertions(+), 187 deletions(-)). > > > And make the unit of the vmstat counters are either pages or bytes. Fewer choices > > > means lower probability of making mistakes :). > > > > > > This was inspired by Johannes and Roman. Thanks to them. > > > > It would be really great if you could summarize the current and after > > the patch state so that exceptions are clear and easier to review. The > > Agree. Will do in the next version. Thanks. > > > > existing situation is rather convoluted but we have at least units part > > of the name so it is not too hard to notice that. Reducing exeptions > > sounds nice but I am not really sure it is such an improvement it is > > worth a lot of code churn. Especially when it comes to KB vs B. Counting > > There are two vmstat counters (NR_KERNEL_STACK_KB and > NR_KERNEL_SCS_KB) whose units are KB. If we do this, all > vmstat counter units are either pages or bytes in the end. When > we expose those counters to userspace, it can be easy. You can > reference to: > > [RESEND PATCH v2 11/12] mm: memcontrol: make the slab calculation consistent > > From this point of view, I think that it is worth doing this. Right? Well, unless I am missing something, we have two counters in bytes, two in kB, both clearly distinguishable by the B/KB suffix. Changing KB to B will certainly reduce the different classes of units, no question about that, but I am not really sure this is worth all the code churn. Maybe others will think otherwise. As I've said the THP accounting change makes more sense to me because it allows future changes which are already undergoing so there is more merit in those. -- Michal Hocko SUSE Labs