From patchwork Tue Dec 24 07:53:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 11309157 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 94295138D for ; Tue, 24 Dec 2019 07:55:19 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 619A8206CB for ; Tue, 24 Dec 2019 07:55:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="vaUVC/DH" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 619A8206CB 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 5B0308E0006; Tue, 24 Dec 2019 02:55:18 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 560B18E0001; Tue, 24 Dec 2019 02:55:18 -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 477528E0006; Tue, 24 Dec 2019 02:55:18 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0189.hostedemail.com [216.40.44.189]) by kanga.kvack.org (Postfix) with ESMTP id 2C91A8E0001 for ; Tue, 24 Dec 2019 02:55:18 -0500 (EST) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with SMTP id D06724DB4 for ; Tue, 24 Dec 2019 07:55:17 +0000 (UTC) X-FDA: 76299274674.07.chess43_1115409f0bf59 X-Spam-Summary: 2,0,0,d5152908c803487d,d41d8cd98f00b204,laoar.shao@gmail.com,:hannes@cmpxchg.org:david@fromorbit.com: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,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1345:1359: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:30090,0,RBL:209.85.216.65:@gmail.com:.lbl8.mailshell.net-62.50.0.100 66.100.201.100,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: chess43_1115409f0bf59 X-Filterd-Recvd-Size: 4748 Received: from mail-pj1-f65.google.com (mail-pj1-f65.google.com [209.85.216.65]) by imf32.hostedemail.com (Postfix) with ESMTP for ; Tue, 24 Dec 2019 07:55:17 +0000 (UTC) Received: by mail-pj1-f65.google.com with SMTP id n96so871929pjc.3 for ; Mon, 23 Dec 2019 23:55:17 -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=V1NIvureCn33Tn3ECKZBbHdYOKZ0mZ/srBiMlz7CqOo=; b=vaUVC/DHZHrYVeAmeVTVNycr7RSOOShtL0anFZVIrQTDBEW6y4NcDlgg06k3VdlMIU y28LQYrFnfOe3w4bYy/fP5H1Wr9BNt3v9Udg4OxWCmBsiVVEzFOMYYSZwNNc4zFaL23D X6x4xJJMalWRbUFVaHb4p9ulQUHFOe0aCozmWYUnrMKU8jAADiqGkKTc4KtipzY9oGNn WCPkB/aRAcxCJixLDhLreuTSNJcahFoVfD3fVsUXqZleggWrFMalGnuRnenh2aMf6QcQ GaL/cpTjS9exDf0ECPYMAoEynr5LzVDZyAReYOFPaBIraG7+bf4BvxP40Kmn00cAkuT8 qkHw== 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=V1NIvureCn33Tn3ECKZBbHdYOKZ0mZ/srBiMlz7CqOo=; b=WxMNMWkthuMZItwzJ4iIKJS2GpfrdJENROwIUTndArhtg+ggNBmLlSEnAA4PRQku9v LWDIvDBnAX6JQQUyd2UdBRURlPcp/1CcElBOV1qqCay/Km/BOQA/8jyWl1da6iESsT8U lge/9gXTZ1eSrYfCP+jkLwbK/PQ4gb6psw4YvrVhOaDO7lDnCHHlgaL7osCi6HBuwejt No6XGqGvoEqsC6YuUG0ofIs17PUY9gjjYEqDuvjk+OlIuv4tN5gwO++alWbj9Dok00I5 EDXADbu9acs+j+93QM+BzCtE34B9zMGgGSJJtBjZbrj/O4AQLf25bP/HXeed+byno5RW dQvA== X-Gm-Message-State: APjAAAVlUcVeeLxAZeNRijsdPT+LxQij/zV9k/M6NGSmexaHwWIBqR8c YOlzzv3XxKE6a1InPjv2K4g= X-Google-Smtp-Source: APXvYqyT8qOnAq66pXq7Xp1RgbKisswZoZED+pR98Qm34GbQU76x3QyoL8MQF2ZduR4HUfbhrLxMpA== X-Received: by 2002:a17:90b:f06:: with SMTP id br6mr4174688pjb.125.1577174116520; Mon, 23 Dec 2019 23:55:16 -0800 (PST) Received: from dev.localdomain ([203.100.54.194]) by smtp.gmail.com with ESMTPSA id c2sm2004064pjq.27.2019.12.23.23.55.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Dec 2019 23:55:15 -0800 (PST) From: Yafang Shao To: hannes@cmpxchg.org, david@fromorbit.com, 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 Subject: [PATCH v2 1/5] mm, memcg: reduce size of struct mem_cgroup by using bit field Date: Tue, 24 Dec 2019 02:53:22 -0500 Message-Id: <1577174006-13025-2-git-send-email-laoar.shao@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1577174006-13025-1-git-send-email-laoar.shao@gmail.com> References: <1577174006-13025-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. 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 */