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=-8.5 required=3.0 tests=INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham 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 0033FC32771 for ; Mon, 6 Jan 2020 10:19:52 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A690C20848 for ; Mon, 6 Jan 2020 10:19:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A690C20848 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 0EEB88E0005; Mon, 6 Jan 2020 05:19:51 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 09E048E0001; Mon, 6 Jan 2020 05:19:51 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ECF198E0005; Mon, 6 Jan 2020 05:19:50 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0042.hostedemail.com [216.40.44.42]) by kanga.kvack.org (Postfix) with ESMTP id D74ED8E0001 for ; Mon, 6 Jan 2020 05:19:50 -0500 (EST) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with SMTP id 7108B181AC9CB for ; Mon, 6 Jan 2020 10:19:50 +0000 (UTC) X-FDA: 76346813340.02.sock54_90101b6943147 X-HE-Tag: sock54_90101b6943147 X-Filterd-Recvd-Size: 5005 Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by imf32.hostedemail.com (Postfix) with ESMTP for ; Mon, 6 Jan 2020 10:19:49 +0000 (UTC) Received: by mail-wm1-f67.google.com with SMTP id p17so14708558wma.1 for ; Mon, 06 Jan 2020 02:19:49 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=Sf6POL2Ya0TUSwQ1AwUObzM6OoIpqB8X3PM4VYtAX7g=; b=G9L/Pm5CSnxWf6COn1JidyCdoA7oY6nhhDG7ILJ1A6mZxXSSQwJU6lHr2LOG0qu8mU GM+tx8XgiNwZy+9irwaBp82wbg/K6votfMYKFFNFta8/ZL0MCDBjpE56RRDYncN4aT6u vPn9xMxWdpU0cID+vjnbJDuox5Pd4cHSd5uZuJ3/a05gmWd9HI/4IK1HJraVO7xkbdVs pTCEAndVmy/KqTxrqMVpB0bgjeOZsgQboM2F7JyBWb56qLa06wVEgeZfRFIWd4zLVVuQ I53atkGinTTOzr4gp7Rn4mHpyaxesG77naWFbUFGtXHR3HCGRBDgnI2UqJRWAmzaJq7L BXhA== X-Gm-Message-State: APjAAAXaDQqym1fn/jBJxVYozkOoZlC7EwuKpg10vobFL3WdvjooNoOU 2wRWRgW/wF2YlDycTeSoez0= X-Google-Smtp-Source: APXvYqyGVkGyVjYJd4c/ap7zVcu1SUpvhJsc/Bi/icy8n/bv0+gxvbLdRa4dBxV0/LIWHYSVk7HLvA== X-Received: by 2002:a1c:628b:: with SMTP id w133mr33015900wmb.25.1578305988463; Mon, 06 Jan 2020 02:19:48 -0800 (PST) Received: from localhost (prg-ext-pat.suse.com. [213.151.95.130]) by smtp.gmail.com with ESMTPSA id 60sm75017252wrn.86.2020.01.06.02.19.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2020 02:19:47 -0800 (PST) Date: Mon, 6 Jan 2020 11:19:47 +0100 From: Michal Hocko To: Yafang Shao Cc: guro@fb.com, hannes@cmpxchg.org, vdavydov.dev@gmail.com, akpm@linux-foundation.org, linux-mm@kvack.org Subject: Re: [PATCH] mm, memcg: reduce size of struct mem_cgroup by using bit field Message-ID: <20200106101947.GD12699@dhcp22.suse.cz> References: <1577450633-2098-1-git-send-email-laoar.shao@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1577450633-2098-1-git-send-email-laoar.shao@gmail.com> User-Agent: Mutt/1.12.2 (2019-09-21) 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 Fri 27-12-19 07:43:52, Yafang Shao wrote: > There are some members in struct mem_group can be either 0(false) or > 1(true), so we can define them using bit field to reduce size. With this > patch, the size of struct mem_cgroup can be reduced by 64 bytes in theory, > but as there're some MEMCG_PADDING()s, the real number may be different, > which is relate with the cacheline size. Anyway, this patch could reduce > the size of struct mem_cgroup more or less. Pahole says /* size: 2496, cachelines: 39, members: 48 */ /* sum members: 2364, holes: 8, sum holes: 108 */ /* padding: 24 */ /* forced alignments: 3, forced holes: 2, sum forced holes: 88 */ after the change /* size: 2496, cachelines: 39, members: 48 */ /* sum members: 2352, holes: 7, sum holes: 108 */ /* sum bitfield members: 6 bits, bit holes: 1, sum bit holes: 26 bits */ /* padding: 32 */ /* forced alignments: 3, forced holes: 2, sum forced holes: 88 */ so exactly 0 change. I do not think this reshuffling is worth it. > > Signed-off-by: Yafang Shao > Cc: Roman Gushchin > --- > include/linux/memcontrol.h | 21 ++++++++++++--------- > 1 file changed, 12 insertions(+), 9 deletions(-) > > diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h > index a7a0a1a5..f68a9ef 100644 > --- a/include/linux/memcontrol.h > +++ b/include/linux/memcontrol.h > @@ -229,20 +229,26 @@ struct mem_cgroup { > /* > * Should the accounting and control be hierarchical, per subtree? > */ > - bool use_hierarchy; > + unsigned int use_hierarchy : 1; > + > + /* Legacy tcp memory accounting */ > + unsigned int tcpmem_active : 1; > + unsigned int tcpmem_pressure : 1; > > /* > * Should the OOM killer kill all belonging tasks, had it kill one? > */ > - bool oom_group; > + unsigned int oom_group : 1; > > /* protected by memcg_oom_lock */ > - bool oom_lock; > - int under_oom; > + unsigned int oom_lock : 1; > > - int swappiness; > /* OOM-Killer disable */ > - int oom_kill_disable; > + unsigned int oom_kill_disable : 1; > + > + int under_oom; > + > + int swappiness; > > /* memory.events and memory.events.local */ > struct cgroup_file events_file; > @@ -297,9 +303,6 @@ struct mem_cgroup { > > unsigned long socket_pressure; > > - /* Legacy tcp memory accounting */ > - bool tcpmem_active; > - int tcpmem_pressure; > > #ifdef CONFIG_MEMCG_KMEM > /* Index in the kmem_cache->memcg_params.memcg_caches array */ > -- > 1.8.3.1 -- Michal Hocko SUSE Labs