From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1AA3EC4361B for ; Wed, 9 Dec 2020 07:06:32 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 478A2206D5 for ; Wed, 9 Dec 2020 07:06:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 478A2206D5 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=bytedance.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 843226B00A2; Wed, 9 Dec 2020 02:06:30 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7F2ED6B00A3; Wed, 9 Dec 2020 02:06:30 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6B9F56B00A4; Wed, 9 Dec 2020 02:06:30 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 4EEE96B00A2 for ; Wed, 9 Dec 2020 02:06:30 -0500 (EST) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 05481181AEF1E for ; Wed, 9 Dec 2020 07:06:30 +0000 (UTC) X-FDA: 77572860540.10.tin06_1a140e0273ed Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin10.hostedemail.com (Postfix) with ESMTP id DA16116A0AE for ; Wed, 9 Dec 2020 07:06:29 +0000 (UTC) X-HE-Tag: tin06_1a140e0273ed X-Filterd-Recvd-Size: 5042 Received: from mail-pj1-f65.google.com (mail-pj1-f65.google.com [209.85.216.65]) by imf38.hostedemail.com (Postfix) with ESMTP for ; Wed, 9 Dec 2020 07:06:29 +0000 (UTC) Received: by mail-pj1-f65.google.com with SMTP id p21so299455pjv.0 for ; Tue, 08 Dec 2020 23:06:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=kkn786HNMnRJCcN2vJ93qEyfsAgh7pkxJtiGF06J3yU=; b=JXrRB0nWVA5bEbEvNjxEzu/NNeNa7aKnAuns8JTBIx/sW/F+SxwH6QRAtQ0iiTX8h0 Pac4yR3jIe7TZKkrxsjkSHBXB2sYr2OJpHc4wBiXDQyKPB3oQF+wkfxiqHFAC5c0jW7g yo4V3RXknI3qJ4Zrh7cHk1tdTj2f/wUWuSdQ0Liblz9+qjFB+QluSTdO+wyA/78lMxRC 4SI1SKgLSphvUkVovLeGAhK4IvUiJWFmOARy7q+vYzadZQLrsrDAK5jLog+gVokidCMh 31bF/AgWkPzKCdrxRNqlXaWLaA7X84nL2vH4nv0L3kZXAoY4FkkzIMz2vDn4MF3KTUap yVnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=kkn786HNMnRJCcN2vJ93qEyfsAgh7pkxJtiGF06J3yU=; b=sv51pPTQF49LbfyF5Ie8/QZyDqnNUbyLYp2CgAQRDnvo8XlX9wehd44rOL4qpRyBzt rQIf/5b0flhnnDqn9pFcE3GR29Cs2emoT+4D7WodIqA3y2hmddAS2KQ+4HFul+rXJmN/ Vru8ZlJBL6rEgC/iSsM+k5pjDYmLB5DVRNDIy+gUfluUoz6sxKywhUFiMKj5W4Kl5u3W GeGH3YrcBJrhr8W5Dc4VDRMMvEaFxFfunpCKaOpFzSRonJy9X/4VVCyi3eRQztzFB4Ja Qi5YD/LpmcfNzZKG8lYkyupxxZ8ZAi651FU1PFkZMNSsAbRsXcahHU0F1Q4fCcX4Kyil /xUw== X-Gm-Message-State: AOAM532uJdyo9kk8sgIuwT7LzCeZ3eUevHojSJw8g9quSbuN3ZU0BkQe rHJCvFrkOYh5ZESIhMjkL0trfGdrAkAbwjwv/is7ig== X-Google-Smtp-Source: ABdhPJyqvToolagl8ieU1B5JnTy01mh7I3u/Qdo1C4b/4NaYIk2VlSrMTXjvguF/PaTMidy6INo/h29mnjEw/Azl95c= X-Received: by 2002:a17:902:bb92:b029:d9:e9bf:b775 with SMTP id m18-20020a170902bb92b02900d9e9bfb775mr1108490pls.24.1607497587958; Tue, 08 Dec 2020 23:06:27 -0800 (PST) MIME-Version: 1.0 References: <20201208095132.79383-1-songmuchun@bytedance.com> <20201209022118.GB2385286@carbon.DHCP.thefacebook.com> <20201209031115.GA2390587@carbon.lan> In-Reply-To: <20201209031115.GA2390587@carbon.lan> From: Muchun Song Date: Wed, 9 Dec 2020 15:05:49 +0800 Message-ID: Subject: Re: [External] Re: [PATCH v2] mm: memcontrol: optimize per-lruvec stats counter memory usage To: Roman Gushchin Cc: Johannes Weiner , Michal Hocko , Vladimir Davydov , Andrew Morton , Shakeel Butt , Stephen Rothwell , Chris Down , Yafang Shao , richard.weiyang@gmail.com, LKML , Cgroups , Linux Memory Management List Content-Type: text/plain; charset="UTF-8" X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, Dec 9, 2020 at 11:52 AM Roman Gushchin wrote: > > On Wed, Dec 09, 2020 at 10:31:55AM +0800, Muchun Song wrote: > > On Wed, Dec 9, 2020 at 10:21 AM Roman Gushchin wrote: > > > > > > On Tue, Dec 08, 2020 at 05:51:32PM +0800, Muchun Song wrote: > > > > The vmstat threshold is 32 (MEMCG_CHARGE_BATCH), so the type of s32 > > > > of lruvec_stat_cpu is enough. > > Actually the threshold can be as big as MEMCG_CHARGE_BATCH * PAGE_SIZE. > It still fits into s32, but without explicitly saying it it's hard to > understand why not choosing s8, as in vmstat.c. Yeah, here I need to update the commit log. > > > > > > > > > The size of struct lruvec_stat is 304 bytes on 64 bits system. As it > > > > is a per-cpu structure. So with this patch, we can save 304 / 2 * ncpu > > > > bytes per-memcg per-node where ncpu is the number of the possible CPU. > > > > If there are c memory cgroup (include dying cgroup) and n NUMA node in > > > > the system. Finally, we can save (152 * ncpu * c * n) bytes. > > > > > > Honestly, I'm not convinced. > > > Say, ncpu = 32, n = 2, c = 500. We're saving <5Mb of memory. > > > If the machine has 128Gb of RAM, it's .000000003%. > > > > Hi Roman, > > > > When the cpu hotplug is enabled, the ncpu can be 256 on > > some configurations. Also, the c can be more large when > > there are many dying cgroup in the system. > > > > So the savings depends on the environment and > > configurations. Right? > > Of course, but machines with more CPUs tend to have more RAM as well. Here I mean possible CPU not online CPU. The number of possible CPUs may be greater than online CPUs. The per-cpu allocator is based on the number of possible CPUs. Right? Thanks. > > Thanks! -- Yours, Muchun