Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp2687659rwa; Mon, 22 Aug 2022 11:49:02 -0700 (PDT) X-Google-Smtp-Source: AA6agR5nmWUsNjge4vreRlLdbGlGdfIt8ltD1DKuJTRzrurwkd5ZZ9222MIZecELSBs9sNHNtyQG X-Received: by 2002:a17:902:d484:b0:16f:161c:ac3f with SMTP id c4-20020a170902d48400b0016f161cac3fmr21176187plg.107.1661194142485; Mon, 22 Aug 2022 11:49:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661194142; cv=none; d=google.com; s=arc-20160816; b=orEGxODKdF265R5NSnSuS7e+wAphHbZb7IbMgVH3lF8VUubaKAD0dAqWEevhwFInim SQ+GBucKzAmdJVjswqTrQuAr+XF+QDh1HDcblJBDhqHRZlynwXwtTWz6+3Opy26eIosZ OaNKDPHSJYTLlwTv/9tULixZ/eQXyOPXd++Q6DHwXV5eE0JLtufrTFAcRGn8rRnkUpyX dbhUE2tXjM4r2tpGJkImvGgb2Y8ipR2odws/igZSes06qM3adJbC1JQEOUqxxbfiBWlP ZHXW3dCKeIA55YMzEwzKjv2xB5E7yG+VEfy50ku2lr7wNMWWs+DtNSFM9uMP33HiUhwg beTA== 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:dkim-signature:date; bh=859bRFvYP0PwP1RQEaN1BuNqPudeM49yRCMP2gzbo/M=; b=usyYCM1d4hrmEN6BtlfZm1xn9it/k/j2Q/z2ewlkGxqzoE4fbgo8o5m2sfDYbGd8Dp hB1pI8RDy2ABSFAhV38Kgg5csfzK0S94aehJpnDJeLUpti1JvpLcR5I9X+RAaYN14tqA AyGBAwtu+zC40Zi9yfqZGawM91Z42tdSWP+2rjl98dVoz/P8Gyzm3ENRWZg38Np0tJkS aFxkIpJYFWD6enXo/fJio1gzNxitFF08BhZ3gflxQortu7wTNnEdwRdfWMoE+HP9Wgup oUTFbY0PoOk3QLCa9UTobJmwRDp23lTGR5UEbafWb0S7nAkYoIPAV791l1IiNYkKcV7F cMZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=mCGQi+2b; 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=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ix1-20020a170902f80100b0016ca4b6f18fsi8217460plb.63.2022.08.22.11.48.51; Mon, 22 Aug 2022 11:49:02 -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=@linux.dev header.s=key1 header.b=mCGQi+2b; 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=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237358AbiHVS2L (ORCPT + 99 others); Mon, 22 Aug 2022 14:28:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237179AbiHVS2C (ORCPT ); Mon, 22 Aug 2022 14:28:02 -0400 Received: from out2.migadu.com (out2.migadu.com [IPv6:2001:41d0:2:aacc::]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3038C48E84; Mon, 22 Aug 2022 11:27:52 -0700 (PDT) Date: Mon, 22 Aug 2022 11:27:46 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1661192870; 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: in-reply-to:in-reply-to:references:references; bh=859bRFvYP0PwP1RQEaN1BuNqPudeM49yRCMP2gzbo/M=; b=mCGQi+2b3AdYVcCk9kc+RYKSR5DNMp8IBmyH6G+E69Cq3b2l19KvwGFIuMAQgaZ1ip974E Gfuml2lG4ZQJmNqdc9vHZ1ompfYFjZdFzV0Xj/H73RUciXDYNcSERvs7e3WDbYpIjcVsB1 T0npKZERgo9FQlUXzHgUKV2CBE3OL1Y= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Roman Gushchin To: Shakeel Butt Cc: Michal Hocko , Johannes Weiner , 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 , Linux MM , netdev , LKML 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: X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, 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, Aug 22, 2022 at 09:04:59AM -0700, Shakeel Butt wrote: > On Mon, Aug 22, 2022 at 8:15 AM Michal Hocko wrote: > > > > On Mon 22-08-22 08:06:14, Shakeel Butt wrote: > > [...] > > > > > 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? > > > > > > I don't just want the alignment of the structure. I want different > > > fields of this structure to not share the cache line. More > > > specifically the 'high' and 'usage' fields. With this change the usage > > > will be its own cache line, the read-most fields will be on separate > > > cache line and the fields which sometimes get updated on charge path > > > based on some condition will be a different cache line from the > > > previous two. > > > > I do not follow. If you make an explicit requirement for the structure > > alignement then the first field in the structure will be guarantied to > > have that alignement and you achieve the rest to be in the other cache > > line by adding padding behind that. > > Oh, you were talking explicitly about _pad1_, yes, we can remove it > and make the struct cache align. I will do it in the next version. Yes, please, it caught my eyes too. With this change: Acked-by: Roman Gushchin Also, can you, please, include the numbers on the additional memory overhead? I think it still worth it, just think we need to include them for a record. Thanks!