Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp1233294rdb; Fri, 2 Feb 2024 20:21:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IH+mI/KzhBV6VJtVbafPLsOiBxN52N7y9QQsHA4x3UmFzjDEGwpQ+4AOsCy6e+idS5wzKZo X-Received: by 2002:a0c:f2d2:0:b0:685:c42e:8773 with SMTP id c18-20020a0cf2d2000000b00685c42e8773mr236883qvm.8.1706934075306; Fri, 02 Feb 2024 20:21:15 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706934075; cv=pass; d=google.com; s=arc-20160816; b=jOdakNAOTg0gcgq+xAGms9C9g3g3ga3SwAcfLvjNFo4hWe6TFBLe8UTXYqcnoTaZqN 7d2egNCOR3sQ11hqZk4EA97kFQwQJL5ohUpi8jgZjyI3bIMzV6W65OOQWTuXeHHUwEuc Q9uVtjrU/j2Ac5p66GHhYmZcjUOsGLrK9seqw7i1rNPrN2d6OO13yclSkpcmLkBwbqjD GsE6F5PuvrdjF98j8wKYrtm470XvutuqDmvcnuGlTYkALgfwD50RLI+Db6+OcpdRah0Q 2d+3dMdriQH7fVc3OxeTxctUlvK4P1/BvWTk/d6xaD/qWVSsHJcQ1XPKyswF3OtWHrk4 NXtg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=q2yFEK+mYkeNhR2BjzLuPlzJOrsqLmK/m4AY7BXlyUI=; fh=EQ15T/6Mv4mQNFZ+OyIUjAKP791Fi9Awuhuw36tAxeA=; b=c8nSWYh+Xx2jIrykhrVZOyU4gb9zBuei5JE2T5L0ZBCr4t22pRxM/hQ7YhgT8zb036 zG495LjI7M+nCq1zS6b0QML8cgOl8NCCZ0zepIYyGVuIqr0sIIU1/gT6Er9zDEQRGvTa QOwvrAXMKINAiY9Z62qKjjuro3kHaCe4l4QneSY3/0GKYAYi0O7wg1yhM++SBjUPL4PF fW7vIR0sDUKr3vWyUofWPGNwIuWpTxJnt9yB1Yd2Cp0IZccGwp1D4SczDlRC368dBh/Q WPbrd/jcjkQiLynUkoHEsz53LYkRhLWjPwAXZUEIp+8TqkWoKInJ0TyRmHRpt+T+JX8z AZ4Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=SpiDVxQj; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-50911-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50911-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com X-Forwarded-Encrypted: i=1; AJvYcCVDlyW7zRdTslQUjaXus70EMNjy9/twXh4X2al78zx8ShLJE8IM18KZFmxNJ5QQUhL/7MEnfp0dBAF1cTMzzR1bcBBGgddaka3kgThJGA== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id jo15-20020a056214500f00b0068c63f42478si3965852qvb.69.2024.02.02.20.21.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 20:21:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-50911-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=SpiDVxQj; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-50911-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50911-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id DBB311C212F1 for ; Sat, 3 Feb 2024 04:21:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E71243B7AA; Sat, 3 Feb 2024 04:13:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="SpiDVxQj" Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AC2473BB38 for ; Sat, 3 Feb 2024 04:13:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706933619; cv=none; b=Jwv1gdfV67XbYMO2a/hJtJHQbNpli8Dv6mw1sqbkL0vWwJZjgiSj+r8tD5heUQeWPpzvZoKRGGAkc4zznlDcZ/TBEQU/7akpuv1lbZRROkqL6QUvmxTGEfmQBGAiD097W7D6xJQErp9Ge6hVeEda//Zq/EqdIQY0cBTQGTyK8t4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706933619; c=relaxed/simple; bh=aukrydltDtElqxloaQOiwp7MBnZYxbVEKC7CRknU2oE=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=Psh+2fDdbNWZr2Qoa+HURYEAuORYlSJs2POaem4QfN1u00fn6zujO5h9+hiclT6OwZgoLMYpLxj4jfcKEF9iRuXpl70Q4VRkm/BNs3eYk9jm0BAztqyLmz77mpX48J1r0/Hpe51yHznEUMwbx7T91QAJ1godbZbq6N3Brudkne4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=SpiDVxQj; arc=none smtp.client-ip=209.85.214.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-1d5ce88b51cso111585ad.0 for ; Fri, 02 Feb 2024 20:13:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1706933617; x=1707538417; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=q2yFEK+mYkeNhR2BjzLuPlzJOrsqLmK/m4AY7BXlyUI=; b=SpiDVxQjyLF6yj2FkBYdnNxUiyWlv5++g5kOenmNxSjP/0GcE4bR1pjVf+PmTzrstR OaQAbd4QiBULdAgP0XE7dCTIqhHaWuffPQjsJQP8dpLh10hRVyk4uy+YVt0aIeZwSXbt eqiebem7/ao2F2g9vmolHqz0uNkU33qqeAO2LkHFVmK42Wy9ujKEX2Rlns+ry2zIGzHA ey3QQU8I4mhqXZ4WmYsexlt28hwidUCG5puc9YbS6isHIi8whXpDEcz5GgzjviIe4Hw7 2ZhY5kJAS3yxf0P+dDOaFMzkcfbO62xg9B9Da6qxTKgAP+3R8eSzm7tyA9ga8320j06E 28Gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706933617; x=1707538417; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=q2yFEK+mYkeNhR2BjzLuPlzJOrsqLmK/m4AY7BXlyUI=; b=g1jwBZfl0urTjZvRZ/jWpwkRRp2qiD3cqDKaangob5eLohuneTn9kJsdsw+ra2ZyzO RoEEFDnG8wuXPt9U3oK3DSL05D5Bbo6uHw8H9zE2Scn7tKxpAWhwEmdRSM8phC2CscRz ybxzGuwq8TEL8h4N1RV9yrAEDt0uT4upLj9oYR6p11tzeiDadaxOTQ8lC0W55+Puk0rT VYslM8nseM4fDNOEkBcwCYsb5onekLnKDGwxiXIeBGh62JNCGrP81Q3lGfOJK8AnHggx AQ1zIxIv+p/5EX/diyLtdlI4q6hbL+Oz8eIyE8utiq3uVHHKPHBFu6j0UtplYMiKBtlZ KQgQ== X-Gm-Message-State: AOJu0YwDNzvmEA0iuUFGOKLK9z9kTytmWdMvqaGDVzUkbQphlW7jwtf6 wpFr5mCfS4qecN2ChvPURmDhxyK1Yx2H033+lzrG0jGYOTUwX88sTg22brkxI1B67QjMecQAvFf Z1KRcxryNbQDTKpDo1wIHA9Og+9lhJGxcJO7V X-Received: by 2002:a17:902:e750:b0:1d7:6ebd:3867 with SMTP id p16-20020a170902e75000b001d76ebd3867mr74632plf.1.1706933616692; Fri, 02 Feb 2024 20:13:36 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240203003414.1067730-1-yosryahmed@google.com> In-Reply-To: <20240203003414.1067730-1-yosryahmed@google.com> From: Shakeel Butt Date: Fri, 2 Feb 2024 20:13:24 -0800 Message-ID: Subject: Re: [PATCH mm-hotfixes-unstable] mm: memcg: fix struct memcg_vmstats_percpu size and alignment To: Yosry Ahmed Cc: Andrew Morton , Johannes Weiner , Michal Hocko , Roman Gushchin , Muchun Song , cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Greg Thelen Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Feb 2, 2024 at 4:34=E2=80=AFPM Yosry Ahmed = wrote: > > Commit da10d7e140196 ("mm: memcg: optimize parent iteration in > memcg_rstat_updated()") added two additional pointers to the end of > struct memcg_vmstats_percpu with CACHELINE_PADDING to put them in a > separate cacheline. This caused the struct size to increase from 1200 to > 1280 on my config (80 extra bytes instead of 16). > > Upon revisiting, the relevant struct members do not need to be on a > separate cacheline, they just need to fit in a single one. This is a > percpu struct, so there shouldn't be any contention on that cacheline > anyway. Move the members to the beginning of the struct and cachealign > the first member. Add a comment about the members that need to fit > together in a cacheline. > > The struct size is now 1216 on my config with this change. > > Fixes: da10d7e140196 ("mm: memcg: optimize parent iteration in memcg_rsta= t_updated()") > Reported-by: Greg Thelen > Signed-off-by: Yosry Ahmed > --- > mm/memcontrol.c | 19 +++++++++---------- > 1 file changed, 9 insertions(+), 10 deletions(-) > > diff --git a/mm/memcontrol.c b/mm/memcontrol.c > index d9ca0fdbe4ab0..09f09f37e397e 100644 > --- a/mm/memcontrol.c > +++ b/mm/memcontrol.c > @@ -621,6 +621,15 @@ static inline int memcg_events_index(enum vm_event_i= tem idx) > } > > struct memcg_vmstats_percpu { > + /* Stats updates since the last flush */ > + unsigned int stats_updates ____cacheline_align= ed; Why do you need ____cacheline_aligned here? From what I understand for the previous patch you want stats_updates, parent and vmstats on the same cacheline, right? I would say just remove the CACHELINE_PADDING() from the previous patch and we are good. In the followup I plan to add usage of __cacheline_group_begin() and __cacheline_group_end() usage in memcg code. If you want, take a stab at it.