Received: by 2002:ab2:7855:0:b0:1f9:5764:f03e with SMTP id m21csp782842lqp; Wed, 22 May 2024 22:35:21 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVth52znbA5iNwX5JRFAgaR9R6kQCVc03QDyoKn9KCZnqJgV8o1VmYj03GnPVO9VR3VUD9HSqcaSppHm5dhQGJ9L0jFySR02z04EtoDKQ== X-Google-Smtp-Source: AGHT+IEKHkT0UowZ5oYwwo8oqjB5/ALiHXIKgigb4/W1AZiIdbS20esECNGvM+xgb7KWzxi2GsVZ X-Received: by 2002:a05:6808:1313:b0:3c8:2b77:789 with SMTP id 5614622812f47-3cdb3f5839fmr5540796b6e.5.1716442521156; Wed, 22 May 2024 22:35:21 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716442521; cv=pass; d=google.com; s=arc-20160816; b=At5A/GowrDnnz+3pegwF19fHeoRsExKaAlBRxicHVPiZGaxGwWaILBNU36cZqtPxEf I+aIYkyTxp4t9q8Y9laPNf11K8NYT7crUMBNBa67/46notr8fnioj528BBche4Q/1R4x 6fZ8cho8+Sv/CM/Rb9dvq8qhIzUq2IBfF5121E/PVP2mQ48RCC3rNwdhKvBOg2oIQ+0A MBxc7dLSMnjTjcMy00mPSVrZE3QBztu8neADZBExE0IrRmqlFTXONSimURHJy/E80455 KtXqkU/L50UW6vSCzLREjh8mOn7SX/TYD2QE5mNEH/1Jd5+aGXBWfwfsUwQf21ObFIvx ScNw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=JCNNrN2ieh0YNX+YK2n+Te1/2f1bAXoL3EIWFMUSa3w=; fh=DF+jGKAtFzoalNGE6h7aXSpAitgrfQxNFFx5pXIsPYM=; b=O8ShFGZ5/sezPRoQzVhENATPiArp5Z5AOPeur7Ky56JBnYOaAbD+y3UT8XJtpJiK6t Av9mgyq8ExZcpnCAURdU3Y713lDyZVorzulaZwgfIo7r4W8YBBPXCLu84hc0YZj+tAz5 KIC023eElwNRIMPv/tUfKHXrqBbrED8FC4SaPNrBqqp0zHXQQeEY4K55bdttw+3c+vas H1K0mTSNCkVrudbBb6cZCg3Jt5t1ctOlP0XByC0iitHE+nXxdaUnm0qdlScQuALPBd9D zgK2VHXHnvHJPCIUa8XUAN2SaDyLyosoBOzwYmuaNU3RrTPsneXd+Redc461PgmaEfsD xB5g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=fCHx5jGf; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-187008-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-187008-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-634103f7c49si572820a12.410.2024.05.22.22.35.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 May 2024 22:35:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-187008-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=fCHx5jGf; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-187008-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-187008-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 625B1B22060 for ; Thu, 23 May 2024 05:34:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 05F0613A3F2; Thu, 23 May 2024 05:34:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="fCHx5jGf" Received: from out-183.mta1.migadu.com (out-183.mta1.migadu.com [95.215.58.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 42EA439AF9 for ; Thu, 23 May 2024 05:34:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.183 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716442489; cv=none; b=Q5uh/8evAWoQWHZvIE6hv/FZOvKEidfekr26ojZyYoDEnqJrO1yS9p102IS2Rk1JkWCEtcNkW4pA8NTp+UfUBO1b/zkJSW+xMJALdOdP5MVRcEffhmD3aqK8bKx2lNLiKBvW5sWyaAskwuner6ZZA+hHKloPlD5KLkxy9v3+jxg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716442489; c=relaxed/simple; bh=0bvFLgpRChs3my1ASPJUQCsC+t0BhA8vLmMRSw0BWlU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=fOseMB0D8k2qQu1RuZkNy1GEBygPxzmjHfzfSGhPxOKJO4CnTsNYoZQd+EdOmFTpgvhszSfete/o56CD9CbbZkcy3ybzQIxLZ+xv2VczGyHK/tAEm8uYizr2yjfBneOyGI7v9d9D50U0JP/MWY6tiOStlpGnv53Jx3V2JM2GTE8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=fCHx5jGf; arc=none smtp.client-ip=95.215.58.183 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev X-Envelope-To: yosryahmed@google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1716442484; 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=JCNNrN2ieh0YNX+YK2n+Te1/2f1bAXoL3EIWFMUSa3w=; b=fCHx5jGf40pCBUFth/qkjaUbtaVClmPKnhgJ9jSTtjKEL1aYXE8IJpb3sSXzAmBHJZUlt9 FtXnKSyHvqD6xjbjFeGZio95MXFY+VyBWTosPbjwlnMnzScwqb7e23zTpOZoEotOQQWvEM Ufd3ASj4deKGuQ4DP019lrCcG0Q5vLs= X-Envelope-To: akpm@linux-foundation.org X-Envelope-To: hannes@cmpxchg.org X-Envelope-To: mhocko@kernel.org X-Envelope-To: roman.gushchin@linux.dev X-Envelope-To: muchun.song@linux.dev X-Envelope-To: ying.huang@intel.com X-Envelope-To: feng.tang@intel.com X-Envelope-To: fengwei.yin@intel.com X-Envelope-To: oliver.sang@intel.com X-Envelope-To: kernel-team@meta.com X-Envelope-To: linux-mm@kvack.org X-Envelope-To: linux-kernel@vger.kernel.org Date: Wed, 22 May 2024 22:34:38 -0700 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Shakeel Butt To: Yosry Ahmed Cc: Andrew Morton , Johannes Weiner , Michal Hocko , Roman Gushchin , Muchun Song , ying.huang@intel.com, feng.tang@intel.com, fengwei.yin@intel.com, oliver.sang@intel.com, kernel-team@meta.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] memcg: rearrage fields of mem_cgroup_per_node Message-ID: References: <20240523034824.1255719-1-shakeel.butt@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Migadu-Flow: FLOW_OUT On Wed, May 22, 2024 at 09:35:57PM -0700, Yosry Ahmed wrote: > On Wed, May 22, 2024 at 8:48 PM Shakeel Butt wrote: [...] > > > > struct mem_cgroup_per_node { > > - struct lruvec lruvec; > > + /* Keep the read-only fields at the start */ > > + struct mem_cgroup *memcg; /* Back pointer, we cannot */ > > + /* use container_of */ > > > > struct lruvec_stats_percpu __percpu *lruvec_stats_percpu; > > struct lruvec_stats *lruvec_stats; > > - > > - unsigned long lru_zone_size[MAX_NR_ZONES][NR_LRU_LISTS]; > > - > > - struct mem_cgroup_reclaim_iter iter; > > - > > struct shrinker_info __rcu *shrinker_info; > > > > + /* memcg-v1 only stuff in middle */ > > + > > struct rb_node tree_node; /* RB tree node */ > > unsigned long usage_in_excess;/* Set to the value by which */ > > /* the soft limit is exceeded*/ > > bool on_tree; > > - struct mem_cgroup *memcg; /* Back pointer, we cannot */ > > - /* use container_of */ > > Do we need CACHELINE_PADDING() here (or maybe make struct lruvec > cache-aligned) to make sure the false cacheline sharing doesn't happen > again with the fields below, or is the idea that the fields that get > read in hot paths (memcg, lruvec_stats_percpu, lruvec_stats) are far > at the top, and the memcg v1 elements in the middle act as a buffer? > > IOW, is sharing between the fields below and memcg v1 fields okay > because they are not read in the hot path? If yes, I believe it's > worth a comment. It can be easily missed if the memcg v1 soft limit is > removed later for example. > For 6.10, I wanted to keep the change simple and yes, the memcg v1 stuff as a buffer between the pointers and lruvec/lru_zone_size fields. For 6.11 or later kernels, I am planning to use some asserts to make sure these fields don't share a cacheline, so later when we remove the v1-only stuff, the asserts will make sure we keep the separate cacheline property intact.