Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp2181529rwa; Mon, 22 Aug 2022 03:44:38 -0700 (PDT) X-Google-Smtp-Source: AA6agR4JhBHqCz4sp8nJxNHMyLYsqjXFch/19E5nlgeXe/wYTC+QtdARxUTVCC8TY+VmHBBDpyGt X-Received: by 2002:a17:907:2c5b:b0:73d:6dca:62e5 with SMTP id hf27-20020a1709072c5b00b0073d6dca62e5mr5168717ejc.341.1661165077817; Mon, 22 Aug 2022 03:44:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661165077; cv=none; d=google.com; s=arc-20160816; b=VCW6BmSDZv81iP0BQ+TTjg1vKtaDidkXx4otEK5Clcf/y0SxlB6V851x8R0kM/ERtc Ga7ENMsO1uR542LsRzbqOTfHn+hQ6H+bm9jjgFs40zDDkEZF6SjSrUEbRcQg9YyxFAS/ PaQSeQ683iL0DzBqKMC1+Da1C0UWWtFXYjQ49Ef9FSs05zbgBrj7jpn5xj978mvVUZ68 T8C6gDcFBi1/uI/JkNUeqh+uxI6lPpjjjLN/m5za+zw2FcdgqX8GN+g7s3CVzO9+9+Jd sU6jeWgNmTEAkpDZCCyQA2Yc+wBO2sY8dJcLPXbTV2W6fFV6Kj61rXU9MkdwWl2s1aUo DMlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=j6DA5JV/xBctQH5nuRHZUWkpbX6v+MFm5keA2ZXaxSA=; b=ONtaoIDXTNCo3L8ELkevD+AIFP1h/mNa6XBk8PC3NJJDC+NQoaNC+CYeSF2wmPZEvJ iJG2Q7y1XB2XF5/2JsDl7ciWwjUqfPTJTYsVOIHTS2DNe2xV+EVKE+8QEU5FrdWfkBWj 6OG/QK3ziRv0KYClMSeAjoafwtt79B4MH5L7yAaIuG8go5JwrGaGUVXa71u3ZMjuDAoV ggST/M5koEgcB+MURdwGVGJxTKj6sQu5xy99VNY3FOoMBii5H+Lud3/jql53kdPuUXLC uRfwBjCR05kOqO1aldlzepLftloNBAg95zuNug4TzGRwwN3gHbIFaI7yju8n0KGjMl3N 2Xlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=QQrP649z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h9-20020a05640250c900b00445cdd8f83fsi9896648edb.334.2022.08.22.03.44.12; Mon, 22 Aug 2022 03:44:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=QQrP649z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233815AbiHVKXY (ORCPT + 99 others); Mon, 22 Aug 2022 06:23:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233772AbiHVKXQ (ORCPT ); Mon, 22 Aug 2022 06:23:16 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E84762EE; Mon, 22 Aug 2022 03:23:13 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id A263533B1E; Mon, 22 Aug 2022 10:23:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1661163792; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=j6DA5JV/xBctQH5nuRHZUWkpbX6v+MFm5keA2ZXaxSA=; b=QQrP649zCsQCKo3EnL+Xa2ZecsXEXDqz5yumYBnvABc0sm6JVGU7u8tCxVfmiea46WMGP5 epxhcBw4e9+LlRIAB6Slbt6tTUIjW4n5bngJCEm7XEhgT/zJKNOdVhF8yH3MDTsL0NO4GQ 5S6PhHH5h+ElUvGVbbSSmMY9xxvfMZs= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 802681332D; Mon, 22 Aug 2022 10:23:12 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id VrwXHBBZA2O5DAAAMHmgww (envelope-from ); Mon, 22 Aug 2022 10:23:12 +0000 Date: Mon, 22 Aug 2022 12:23:11 +0200 From: Michal Hocko To: Shakeel Butt Cc: Johannes Weiner , Roman Gushchin , Muchun Song , Michal =?iso-8859-1?Q?Koutn=FD?= , Eric Dumazet , Soheil Hassas Yeganeh , Feng Tang , Oliver Sang , Andrew Morton , lkp@lists.01.org, cgroups@vger.kernel.org, linux-mm@kvack.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/3] mm: page_counter: rearrange struct page_counter fields Message-ID: References: <20220822001737.4120417-1-shakeelb@google.com> <20220822001737.4120417-3-shakeelb@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220822001737.4120417-3-shakeelb@google.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon 22-08-22 00:17:36, Shakeel Butt wrote: > With memcg v2 enabled, memcg->memory.usage is a very hot member for > the workloads doing memcg charging on multiple CPUs concurrently. > Particularly the network intensive workloads. In addition, there is a > false cache sharing between memory.usage and memory.high on the charge > path. This patch moves the usage into a separate cacheline and move all > the read most fields into separate cacheline. > > To evaluate the impact of this optimization, on a 72 CPUs machine, we > ran the following workload in a three level of cgroup hierarchy with top > level having min and low setup appropriately. More specifically > memory.min equal to size of netperf binary and memory.low double of > that. Again the workload description is not particularly useful. I guess the only important aspect is the netserver part below and the number of CPUs because min and low setup doesn't have much to do with this, right? At least that is my reading of the memory.high mentioned above. > $ netserver -6 > # 36 instances of netperf with following params > $ netperf -6 -H ::1 -l 60 -t TCP_SENDFILE -- -m 10K > > Results (average throughput of netperf): > Without (6.0-rc1) 10482.7 Mbps > With patch 12413.7 Mbps (18.4% improvement) > > With the patch, the throughput improved by 18.4%. > > One side-effect of this patch is the increase in the size of struct > mem_cgroup. However for the performance improvement, this additional > size is worth it. In addition there are opportunities to reduce the size > of struct mem_cgroup like deprecation of kmem and tcpmem page counters > and better packing. > > Signed-off-by: Shakeel Butt > Reported-by: kernel test robot > --- > include/linux/page_counter.h | 34 +++++++++++++++++++++++----------- > 1 file changed, 23 insertions(+), 11 deletions(-) > > diff --git a/include/linux/page_counter.h b/include/linux/page_counter.h > index 679591301994..8ce99bde645f 100644 > --- a/include/linux/page_counter.h > +++ b/include/linux/page_counter.h > @@ -3,15 +3,27 @@ > #define _LINUX_PAGE_COUNTER_H > > #include > +#include > #include > #include > > +#if defined(CONFIG_SMP) > +struct pc_padding { > + char x[0]; > +} ____cacheline_internodealigned_in_smp; > +#define PC_PADDING(name) struct pc_padding name > +#else > +#define PC_PADDING(name) > +#endif > + > struct page_counter { > + /* > + * Make sure 'usage' does not share cacheline with any other field. The > + * memcg->memory.usage is a hot member of struct mem_cgroup. > + */ > + PC_PADDING(_pad1_); Why don't you simply require alignment for the structure? Other than that, looks good to me and it makes sense. -- Michal Hocko SUSE Labs