From patchwork Tue Dec 17 11:29:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 11297347 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 84B4B6C1 for ; Tue, 17 Dec 2019 11:31:23 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 47FFC207FF for ; Tue, 17 Dec 2019 11:31:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="o4+ceH3W" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 47FFC207FF 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 6F8C58E0056; Tue, 17 Dec 2019 06:31:22 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 6A8CE8E0040; Tue, 17 Dec 2019 06:31:22 -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 571BC8E0056; Tue, 17 Dec 2019 06:31:22 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0210.hostedemail.com [216.40.44.210]) by kanga.kvack.org (Postfix) with ESMTP id 41CF48E0040 for ; Tue, 17 Dec 2019 06:31:22 -0500 (EST) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with SMTP id C54738249980 for ; Tue, 17 Dec 2019 11:31:21 +0000 (UTC) X-FDA: 76274417562.05.body37_28f580a773a2e X-Spam-Summary: 2,0,0,72b2201a450269d1,d41d8cd98f00b204,laoar.shao@gmail.com,:hannes@cmpxchg.org:mhocko@kernel.org:vdavydov.dev@gmail.com:akpm@linux-foundation.org:viro@zeniv.linux.org.uk::linux-fsdevel@vger.kernel.org:laoar.shao@gmail.com:aaron.lu@intel.com,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1345:1359:1431: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:4321:4605:5007:6119:6261:6653:7514:7901:7903:8603:9413:10004:11026:11473:11658:11914:12043:12048:12296:12297:12517:12519:12555:12895:12986: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:25,LUA_SUMMARY:none X-HE-Tag: body37_28f580a773a2e X-Filterd-Recvd-Size: 4790 Received: from mail-pj1-f68.google.com (mail-pj1-f68.google.com [209.85.216.68]) by imf14.hostedemail.com (Postfix) with ESMTP for ; Tue, 17 Dec 2019 11:31:21 +0000 (UTC) Received: by mail-pj1-f68.google.com with SMTP id o11so4443916pjp.9 for ; Tue, 17 Dec 2019 03:31:21 -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:in-reply-to:references; bh=BpFS4ToaQ+oe6Ip5CmXL+qTNhJ6T5OxwPQOYZvo7h1c=; b=o4+ceH3WOEc9xJ6ASmn6cuSNePCY7AIbZkbZjByDUFDLr1Nv28bSA3NdI8FXR9xoxi 3qgxs0f1HIhpHGG3qotyZRBJdqShtNasVuiSubIk8lJY5L474yxYltqHQnRnYQc9UYbY cQVppl4qcmCarMf6Zg0P3J5WqXrUBh5K0NMb2UK8mfNyCQcBtJH6Ha+ZOEpvPV1na6EZ Clpr5BZpG8Ihzca+Je2gB3IdTyU/qXkjDMQ5ETI0jaGOyPPvM6lzic/WueiBKB6bR0ka 5szd6vJA3mt+AuWm4TQf4JAMggWIzTe4bGejVn7JJ5t7EcsBlvKIZxP0S5TXL/1PBceq RSJQ== 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:in-reply-to :references; bh=BpFS4ToaQ+oe6Ip5CmXL+qTNhJ6T5OxwPQOYZvo7h1c=; b=m1U+zBbNi99/LUmms29Mgg4jWkKRaojlm6mr/xld9auKxc5AdZxSD3qt2ug1HZtdUo 10FI3yAE9f4ulcD3YNYcIF5BJIjiAmdOuru4pSawp0yr30tYfe+maL3/Q5LDkTbY3gXt ma8ix+szy9BW/trru45S1mgZFB203S7BAK+rOCiyM9kUn++XkrQTvdAIV513IKtl3vc7 IBG93swJMNrOYH6M1h0hJAk0+5qKo0FDaU2Pmp0FriYThdcUbY6ueqcsqyzdCHIwuIl/ ErFof/JJUbDGS9/iQ5z2RdDBjCKgrHjxRFoVXIEnX4NtDkyYmc5SwKYgbdaiZFHTeHsM aOjg== X-Gm-Message-State: APjAAAWD0jRV2QU9s0P/00PuDC/Q4J8+kjV7SpOYS9LfS9kbHUByjlxN j30mBTonM8/lOe6MjwZQw/c= X-Google-Smtp-Source: APXvYqwmJ9uXmmvZ0m9A7jESIE+N5e4Bnr6zUDk3KHJOdY7miJJNO8rV7iJrrkPEZCWUKLNEAhQ5mw== X-Received: by 2002:a17:90a:eb06:: with SMTP id j6mr5320406pjz.81.1576582280315; Tue, 17 Dec 2019 03:31:20 -0800 (PST) Received: from dev.localdomain ([203.100.54.194]) by smtp.gmail.com with ESMTPSA id q21sm26246460pff.105.2019.12.17.03.31.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Dec 2019 03:31:19 -0800 (PST) From: Yafang Shao To: hannes@cmpxchg.org, mhocko@kernel.org, vdavydov.dev@gmail.com, akpm@linux-foundation.org, viro@zeniv.linux.org.uk Cc: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, Yafang Shao , Aaron Lu Subject: [PATCH 1/4] mm, memcg: reduce size of struct mem_cgroup by using bit field Date: Tue, 17 Dec 2019 06:29:16 -0500 Message-Id: <1576582159-5198-2-git-send-email-laoar.shao@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1576582159-5198-1-git-send-email-laoar.shao@gmail.com> References: <1576582159-5198-1-git-send-email-laoar.shao@gmail.com> 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. Cc: Aaron Lu Signed-off-by: Yafang Shao --- 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..612a457 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; /* * 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; + + /* Legacy tcp memory accounting */ + unsigned int tcpmem_active : 1; + unsigned int tcpmem_pressure : 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 */