From patchwork Fri Dec 27 12:43:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 11311143 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 043DF138C for ; Fri, 27 Dec 2019 12:44:14 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B091321582 for ; Fri, 27 Dec 2019 12:44:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="A5MQNm+r" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B091321582 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id CEF598E0005; Fri, 27 Dec 2019 07:44:12 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id C9F768E0001; Fri, 27 Dec 2019 07:44:12 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B68C48E0005; Fri, 27 Dec 2019 07:44:12 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0040.hostedemail.com [216.40.44.40]) by kanga.kvack.org (Postfix) with ESMTP id A2A5B8E0001 for ; Fri, 27 Dec 2019 07:44:12 -0500 (EST) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with SMTP id 25551181AEF07 for ; Fri, 27 Dec 2019 12:44:12 +0000 (UTC) X-FDA: 76310889144.13.bear80_5edbdc6a0c849 X-Spam-Summary: 2,0,0,14fcecba10797098,d41d8cd98f00b204,laoar.shao@gmail.com,:guro@fb.com:hannes@cmpxchg.org:mhocko@kernel.org:vdavydov.dev@gmail.com:akpm@linux-foundation.org::laoar.shao@gmail.com,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1345:1437:1534:1541:1711:1730:1747:1777:1792:2393:2553:2559:2562:3138:3139:3140:3141:3142:3353:3865:3866:3867:3868:3870:3871:3872:4250:4605:5007:6119:6261:6653:7514:7901:7903:8603:9413:10004:11026:11473:11658:11914:12043:12048:12296:12297:12517:12519:12555:12895:13069:13138:13161:13229:13231:13311:13357:14096:14181:14384:14394:14687:14721:21080:21444:21450:21451:21627:21666:21972:30034:30054:30056:30064:30090,0,RBL:error,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: bear80_5edbdc6a0c849 X-Filterd-Recvd-Size: 4513 Received: from mail-pg1-f195.google.com (mail-pg1-f195.google.com [209.85.215.195]) by imf36.hostedemail.com (Postfix) with ESMTP for ; Fri, 27 Dec 2019 12:44:11 +0000 (UTC) Received: by mail-pg1-f195.google.com with SMTP id l24so14418192pgk.2 for ; Fri, 27 Dec 2019 04:44:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=2tSs6Xwh7ExrQOSn1wcUFEmlSxhnvg83KrPtJe+BQUM=; b=A5MQNm+rVfj+ZTlWoYmMXwNdEdeoZe7tPgOKdqMOYMPocW00I3eR9ZChmpk+QjFAFl u7owwGByGlFcI2iNeRcv3Vjlt1m+SXhN2injiRVP19XcnkdQWWr9nCM0qNXcR+UnIiZ+ sVSrWExjXPbDId08avejyXtR45ZtBIQKgqDi3/zZu4QfCpRuEAib/gV/C/PLcQ4+DA+s 7gLqKeaQXPxH3WVN6shOv9tqiODpvs51bXt2AG3Pss6eSkyI63e5eK87pgp1cQUuZ3l6 G1HHOhrFRjbXw2OUnkAVWCMS0m2P+KMpuB47lod8rRO4kw5hKP1VQtJgMN2DsLgG6GqM kWyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=2tSs6Xwh7ExrQOSn1wcUFEmlSxhnvg83KrPtJe+BQUM=; b=ijiA0dMzbAqX+mV7DecDETXGhVeiFr9tMkbnr4Vw4Uid5cJF43pZjcw/6eoqn2Q6wG GTZaXwKK9fyJtYtMFKe8W4zN2GFsk7ieMMQi7dE2zJO+dQbZR+he/ega6X6Zl/XhXLgd vD73/S/izzY83TJUmTaIWtwI1Pjhy0gWqqpiBv97lXsUd/gHo3o9262Zqiv8C70S5c0x +i2nfOhGI1ER2b3bNmrTYcOlpzRM2AoY9JnxHKMk5yIiEAq3K5QuXLoDL1HJ2Nkrth7k T2tRoP2cM5UeO6yYRv9bvi1CwFW2clTd7pQWHxi+wOXwzX8Na71vdY0aitrnqmG9mdtB cg0g== X-Gm-Message-State: APjAAAXCUJf71Gl/mhUtn5633QI8RFhYIy1RiLnomaq5CQpyB9EWnCWv xPtt54whmmIO3VNWd8d9ctI= X-Google-Smtp-Source: APXvYqwAxlWJtC7ScBDsLbaZt1lcJHOmv7PmGAqggHUOUJzImsELvodf7j8M+YeXHEhTpnnzi5ghqg== X-Received: by 2002:aa7:86d4:: with SMTP id h20mr50108489pfo.232.1577450650795; Fri, 27 Dec 2019 04:44:10 -0800 (PST) Received: from dev.localdomain ([203.100.54.194]) by smtp.gmail.com with ESMTPSA id c2sm14125591pjq.27.2019.12.27.04.44.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 27 Dec 2019 04:44:10 -0800 (PST) From: Yafang Shao To: guro@fb.com, hannes@cmpxchg.org, mhocko@kernel.org, vdavydov.dev@gmail.com, akpm@linux-foundation.org Cc: linux-mm@kvack.org, Yafang Shao Subject: [PATCH] mm, memcg: reduce size of struct mem_cgroup by using bit field Date: Fri, 27 Dec 2019 07:43:52 -0500 Message-Id: <1577450633-2098-1-git-send-email-laoar.shao@gmail.com> X-Mailer: git-send-email 1.8.3.1 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: 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. 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 */