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.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED 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 CD914C4361B for ; Wed, 9 Dec 2020 02:32:35 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3140223A5A for ; Wed, 9 Dec 2020 02:32:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3140223A5A 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 856D16B0088; Tue, 8 Dec 2020 21:32:34 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 807B86B0089; Tue, 8 Dec 2020 21:32:34 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6F63D6B008A; Tue, 8 Dec 2020 21:32:34 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0090.hostedemail.com [216.40.44.90]) by kanga.kvack.org (Postfix) with ESMTP id 560636B0088 for ; Tue, 8 Dec 2020 21:32:34 -0500 (EST) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 157C2180AD815 for ; Wed, 9 Dec 2020 02:32:34 +0000 (UTC) X-FDA: 77572170228.24.pump66_020ee79273ec Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin24.hostedemail.com (Postfix) with ESMTP id F1DC71A4A0 for ; Wed, 9 Dec 2020 02:32:33 +0000 (UTC) X-HE-Tag: pump66_020ee79273ec X-Filterd-Recvd-Size: 4345 Received: from mail-pj1-f67.google.com (mail-pj1-f67.google.com [209.85.216.67]) by imf03.hostedemail.com (Postfix) with ESMTP for ; Wed, 9 Dec 2020 02:32:33 +0000 (UTC) Received: by mail-pj1-f67.google.com with SMTP id p21so38915pjv.0 for ; Tue, 08 Dec 2020 18:32:33 -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=lpLy5o85Uv8KFkEXX1qh8QHfnClzTv7IW4GkyuNRa/I=; b=iol7HVumr2vVfjJpGSYJsjp2//+4swLMulHc2gpp0zagvSLlssLPP9K3PRtq2X6zMy Po5hMnqSAA28ZIbmek9aOm0SSGmzdrpc5dZLVJ4bMUVEj0uC3X3jZ9G6A+z8LrQIi033 +PK6fgSurp1M2od/4Td4FLHZZo1TXLt3GWL1FhWnJIJNmZWuAwNC/TPlLHYR96nthc9V Qj4+z5EjXrBaKWai2A4XYuBgu0phbWuur699cOnNUw7tYen7UJX3dm0rXvKlgUGn6asC wN0X9e+wv9i6vOlueoBI/4+SXBLMYWtrQrWQMYleF0cx+FYfqbfCsfmdDd4SkWvNPLIN I3jg== 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=lpLy5o85Uv8KFkEXX1qh8QHfnClzTv7IW4GkyuNRa/I=; b=PBRCPslAPh38a/APRY04P2kWEd977PS64j7xOw/J9FyArLWXnDVvzzEMNXErGXp+xm b2BQ7jepc8CTnEFSEKJUtNLvS43GQQeBoj+yah7jC7dsky21vWBA5gola/C3/W5XV5PS LFq/bLDSvUHp+vO6yS5Fp5s7rrZN8uPZ8EcOqxFvE8rx1fXsHYO6rRytRDq/FtDTlSwg LxzmmnwU2bnPLThx2SprA7V0NWb0yt/kDd3WDmZPkVLxPbZQYqJfxN4QLr5orJ9GanvD nFCqVrotJUehWacGWV4t1amWECqjzzurX5F4EPR+fq4hWyDfzVXjumqKrnqiU8c5b0IF dO4w== X-Gm-Message-State: AOAM530/cFm4NIxaYeDo25L3zoUesesKR4orJbEPK81wNzgnbeVaN0fb XCQEL9IoPWmxC8GRCNY9uENlStWUb3yeo6yPqVsimw== X-Google-Smtp-Source: ABdhPJzX8i+5maIC4Xaggk0vVkqmpTP5yL9kQGX5Q+FNbLpvsQ7j83OXxXaeEUvRkV17+sEibPsplk/bfiju4XZ2T30= X-Received: by 2002:a17:90a:ae14:: with SMTP id t20mr184105pjq.13.1607481152196; Tue, 08 Dec 2020 18:32:32 -0800 (PST) MIME-Version: 1.0 References: <20201208095132.79383-1-songmuchun@bytedance.com> <20201209022118.GB2385286@carbon.DHCP.thefacebook.com> In-Reply-To: <20201209022118.GB2385286@carbon.DHCP.thefacebook.com> From: Muchun Song Date: Wed, 9 Dec 2020 10:31:55 +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 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. And introduce struct per_cpu_lruvec_stat > > to optimize memory usage. > > > > 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? > > Using longs (s64) allows not to think too much about overflows > and can also be slightly faster on 64-bit machines. > > Thanks! -- Yours, Muchun