From patchwork Wed Jan 25 07:35:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonardo Bras X-Patchwork-Id: 13115050 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 52B7FC54E94 for ; Wed, 25 Jan 2023 07:36:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E27466B007E; Wed, 25 Jan 2023 02:36:19 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D614A6B0080; Wed, 25 Jan 2023 02:36:19 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B17AD6B0081; Wed, 25 Jan 2023 02:36:19 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 9C6C16B007E for ; Wed, 25 Jan 2023 02:36:19 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 1E403A08C7 for ; Wed, 25 Jan 2023 07:36:19 +0000 (UTC) X-FDA: 80392513278.24.BC4D6CD Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf29.hostedemail.com (Postfix) with ESMTP id D237A120008 for ; Wed, 25 Jan 2023 07:36:16 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=fJDjSUtZ; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf29.hostedemail.com: domain of leobras@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=leobras@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1674632177; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=i0PZh+yTsPG9Po4mo5Kh71H2anPuGxn31rIFI1zWHXw=; b=E5BB9frte3ujN3TJO5Q/2bCsxlLdfsil8pZt30B0vGwszhLy0KIKQfyGLDr4Ja+ptUE/x4 thGCN3HAN3blr2UwtS6AVyssxHJvrH9h4YIDdTox98H7KGKnInRAnUFDAM4Oom4oPeUrZ0 v7J2x1NP3dckAmJS29mOK/L4qp/QMzU= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=fJDjSUtZ; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf29.hostedemail.com: domain of leobras@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=leobras@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1674632177; a=rsa-sha256; cv=none; b=25nAxaObUVFi2YDSTNGsJMB2xBfpNtiGk9riOnvsVXC7S9Mu/UkoLtE2X59npu54qR2tPD P8/h/asoShahRDfOIVXopAQAwKfyLPDLqZeFXm9WteFaus+otvuyv363oZ+r4of9WnDB4V 9skn97/aHZG9J3BgS1Gx/F+J34bO0IU= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1674632176; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=i0PZh+yTsPG9Po4mo5Kh71H2anPuGxn31rIFI1zWHXw=; b=fJDjSUtZZw3RUOLTxlL4fZgdCMI7Xfm+Tq+7ISCwQLMZa0d6ABZdmJDrxzBfRPxG2xm7+Q hrIfS+YBHvuGGJYTLiP9tbzmogBVTUSiCVxNQGe8xoB+dw2qGzZI3tQ3HrzN4A2vo1ysnI pCOGX2aabJCzAQ1pnR1Wsu1E0FBFF+w= Received: from mail-ot1-f70.google.com (mail-ot1-f70.google.com [209.85.210.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-649-LqxRd6sDPe20fGmJo8OcmQ-1; Wed, 25 Jan 2023 02:35:59 -0500 X-MC-Unique: LqxRd6sDPe20fGmJo8OcmQ-1 Received: by mail-ot1-f70.google.com with SMTP id e20-20020a9d5614000000b0068401872536so8726855oti.3 for ; Tue, 24 Jan 2023 23:35:59 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=i0PZh+yTsPG9Po4mo5Kh71H2anPuGxn31rIFI1zWHXw=; b=o9JB1dOPTJ1qdmNYvEZFJAvivBxP1uJCJaSeg/78Pl5Uok6BlqoNjpsS4Nm+s+FsZ1 OTiIRzol+50WOCpAu4goNgNUpDILaXWuxAYQA6fZKo5G44kpIYTE91wnf6xkFY/El9jj AVeqC08qoGARRQrkoBlR6gMmXjbP7Ai5dUD0JTIXdTAJ158X04a5phMecbmBqf4Osr6m lVFvmcv79VNg+gd3Wfm5vgwGbhEeTOr8S6egp23gAHB5BSILpQaXzyfY+27yKmIU9G5W vRObybSEfG+Un+XYuE0rtt228cmMJYrwlqj0oJmicKSbX/4vlayrc7WGFHM/BNMMKp0m u3cw== X-Gm-Message-State: AO0yUKVzBYl/okhsIAzEa7pDU4rC9/jqNy3e6vH5SdD7uPkzS5KOvzjt 2bPMHCIPdFbr875787T9jEMNN/q+PRS5lThlNdNBYA7NY3tKSGilF0936RtTeZuEvLCMrWMzG9g AJNhsJfKk+RY= X-Received: by 2002:a05:6870:a788:b0:163:2d2d:beb with SMTP id x8-20020a056870a78800b001632d2d0bebmr1040182oao.26.1674632159219; Tue, 24 Jan 2023 23:35:59 -0800 (PST) X-Google-Smtp-Source: AK7set8+5KjsnMLSgwOG2ncR10Nu23wlcmyAQ1nW0yNjNQg2bEEedKAnOT5WZ8vqhPBMDlxLuA4+1w== X-Received: by 2002:a05:6870:a788:b0:163:2d2d:beb with SMTP id x8-20020a056870a78800b001632d2d0bebmr1040175oao.26.1674632158988; Tue, 24 Jan 2023 23:35:58 -0800 (PST) Received: from LeoBras.redhat.com ([2804:1b3:a800:14fa:9361:c141:6c70:c877]) by smtp.gmail.com with ESMTPSA id x189-20020a4a41c6000000b0050dc79bb80esm1538802ooa.27.2023.01.24.23.35.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Jan 2023 23:35:58 -0800 (PST) From: Leonardo Bras To: Johannes Weiner , Michal Hocko , Roman Gushchin , Shakeel Butt , Muchun Song , Andrew Morton , Marcelo Tosatti Cc: Leonardo Bras , cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 3/5] mm/memcontrol: Reorder memcg_stock_pcp members to avoid holes Date: Wed, 25 Jan 2023 04:35:00 -0300 Message-Id: <20230125073502.743446-4-leobras@redhat.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230125073502.743446-1-leobras@redhat.com> References: <20230125073502.743446-1-leobras@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Rspamd-Queue-Id: D237A120008 X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: agpbz6bmctkq7t11ywm4nxtordn1tp48 X-HE-Tag: 1674632176-870714 X-HE-Meta: U2FsdGVkX18EVHHy8ezxg/FfrLMoCEXwZN4jmm1AwFab5W/YtNpsSf/ZoGEiwBthBuiR2L3sXvxqv/+vIdHNdMPk3+ZYkpV5nqGtLQrCI0k55uS8a0KEw1atWYIG9jC87EEgw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O94P2FqWh+uJeCnKf8lKNBfM90WDrET9S1TIvA5vkBYSsOma5p/N4PtTq8wdoEPMBkN3H6ISiolTxW160HS3zn065oJj5kt5TDrrtK+IjvBvB20tp52Ek4jqiMppnSxjKIdKCZzMklfl/p5mPaZcg/M2gn7jqmnZyFOi6SSlV+xXqLsH+XqxkGV9NDT96MzoOEdbjqu9XMx8KNNYpPNeoBjkZ7Qkhw== 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: In 64-bit architectures, the current layout of memcg_stock_pcp should look like this: struct memcg_stock_pcp { spinlock_t stock_lock; /* 0 4 */ /* 4 bytes hole */ struct mem_cgroup * cached; /* 8 8 */ unsigned int nr_pages; /* 16 4 */ /* 4 bytes hole */ [...] }; This happens because pointers will have 8 bytes (64-bit) and ints will have 4 bytes. Those 2 holes are avoided if we reorder nr_pages and cached, effectivelly putting nr_pages in the first hole, and saving 8 bytes. Signed-off-by: Leonardo Bras --- mm/memcontrol.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 1d5c108413c83..373fa78c4d881 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -2173,8 +2173,8 @@ void unlock_page_memcg(struct page *page) struct memcg_stock_pcp { spinlock_t stock_lock; /* Protects the percpu struct */ - struct mem_cgroup *cached; /* this never be root cgroup */ unsigned int nr_pages; + struct mem_cgroup *cached; /* this never be root cgroup */ #ifdef CONFIG_MEMCG_KMEM struct obj_cgroup *cached_objcg;