Received: by 2002:ab2:7855:0:b0:1f9:5764:f03e with SMTP id m21csp1085736lqp; Thu, 23 May 2024 08:34:41 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXWKhC1SZNpDXoCZfNZznv/zYZgteAekssSi0k2yDPgUYadXJL0/DvAkD6PJEnGlfC6l0xo0mU4LqewFIMeKym6pbg2Aepu3reLt9kZIg== X-Google-Smtp-Source: AGHT+IGyBO0F7KlBTOziSNRJbKsHZtY/yBNuWEExKQteYcib7WiAKCiCwmFSAoROIBof6sxTjcJU X-Received: by 2002:a05:6a20:3951:b0:1af:41d1:732e with SMTP id adf61e73a8af0-1b1f8ad2b8fmr6301865637.46.1716478480902; Thu, 23 May 2024 08:34:40 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716478480; cv=pass; d=google.com; s=arc-20160816; b=ilKQht9lnf8WcQckGBZtzmNd1wuC40q7pcV/Tbbx8BOxyn9oU6X7qu6QT9wBandIpY OmE3blaTVDTsEooonuWgBGq3Ie282IaCBnZLnN2L+HXtluAXKMCpdwUK2lKzhK8V0jYj mJyRNhPNZtmj1gQI31mwPBZbfwosCddosN247wFZ93TF+aZxSZxFBBr1cJbe9b08jh3d u5zjS/IAwt1KyuAA3pud+YX68OnV0XxbSzxTEJ8UIfGnJbT9kjiVm2JBSYGzOTW0mkXH WqBDm+fQMYaxL8FRg6brTBkm/mxMewqQauvbYcKFsMzVNlhQSocDBPn3gPOadxHXQCBy +Y6A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=ZIHvhELzd5UhchILcKZOt4tYNK+q26kPzDIOyxA1o+U=; fh=ERAwhU+sQQV3J66OLzGMJ29nEeNnQxr78DBh5vhQJ6I=; b=W8EnPbuCFUsfCYIt+hD4AA5k5wVQd8weV5uXT0xTtPs0aeZQuudyGL9Q56AzKA49UT nctxkFMU8E5rfhbtdI3BTGN10KcZbxK04cSZwQHQVvWtG6jImlw6J8+6VdMvohEULrgZ iQdCfu9UxSTP4sGi0HxG5l5oe7zNeEOsrEO/8Ll0pgZbxlnMY+cXhbc7rOoOX2SUG7yH BH+2oawTlCT5WztzFw8stJDRX84Swc00Wi0XPlF/Nlp86fZEXoybXcmJSOcKMgNTv8JM QxN+u+IqK3+WQurULuBOCqo5mWuHTjNGeD+D1eoh6BG8s+cwUBC+swALstxVMfDTkVvQ EJ4A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=FRI1bwmt; 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-187720-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-187720-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 41be03b00d2f7-63d393e63c2si8611819a12.808.2024.05.23.08.34.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 May 2024 08:34:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-187720-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=FRI1bwmt; 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-187720-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-187720-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 835A7281B9E for ; Thu, 23 May 2024 15:34:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 52DDA171A1; Thu, 23 May 2024 15:34:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="FRI1bwmt" Received: from out-177.mta0.migadu.com (out-177.mta0.migadu.com [91.218.175.177]) (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 8430113AF9 for ; Thu, 23 May 2024 15:34:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716478458; cv=none; b=oE2LStIyLzuTBZ4+cuFBwBoKGFEIpAHYNI/nPHCOz3C6JwsJkeDY6EzAD3RWqfIsFBcxaVl5GHz/OpavbNOECOnHgMEOa5PXvgwT0lM+w8TplTJcUSL37w74RJeJyRs7YisK+qP0BWr9UJ9iHxe6XKGf8SvNG7Yp6bx6pqMEgGc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716478458; c=relaxed/simple; bh=IXvAeHORzB9N47O6Gcio6TB3UnH3uZXgM7JC1Q6ZjAE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=TqXO7mAJ3gc2Syd18XyjJWS/5JfFKgHr8GV5v7DsiCWlrdgGqmV9jPU4Pj+Ml4rHQcGUlsjwtKQRUSMj80UrPHmpTlfjCaU96hqySoLJl+2SVdQHcbg+CctGiI/MnLLFg8iiqlFo7/rOfImrmafR6boXWrl66nQBdfCxGzusMdI= 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=FRI1bwmt; arc=none smtp.client-ip=91.218.175.177 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: shakeel.butt@linux.dev DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1716478454; 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=ZIHvhELzd5UhchILcKZOt4tYNK+q26kPzDIOyxA1o+U=; b=FRI1bwmtkW4sTlSM6pNJyAhv33dAfkqpZaEmcdX7J5Hgq98BxUlxtIf4uvR8gTtSjvq6ZI /80Hp73IEwCcfZZksUGHrZYQ/9VNnNbo7vlU7RJTWi7YlV1zUuPaHKo6Kopn4/prSlXczu sCKy15pxcS62iwkjBdUNZnEEHmow8ZU= X-Envelope-To: akpm@linux-foundation.org X-Envelope-To: hannes@cmpxchg.org X-Envelope-To: mhocko@kernel.org X-Envelope-To: muchun.song@linux.dev X-Envelope-To: yosryahmed@google.com 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: Thu, 23 May 2024 08:34:09 -0700 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Roman Gushchin To: Shakeel Butt Cc: Andrew Morton , Johannes Weiner , Michal Hocko , Muchun Song , Yosry Ahmed , 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=us-ascii Content-Disposition: inline In-Reply-To: <20240523034824.1255719-1-shakeel.butt@linux.dev> X-Migadu-Flow: FLOW_OUT On Wed, May 22, 2024 at 08:48:24PM -0700, Shakeel Butt wrote: > Kernel test robot reported [1] performance regression for will-it-scale > test suite's page_fault2 test case for the commit 70a64b7919cb ("memcg: > dynamically allocate lruvec_stats"). After inspection it seems like the > commit has unintentionally introduced false cache sharing. > > After the commit the fields of mem_cgroup_per_node which get read on the > performance critical path share the cacheline with the fields which > get updated often on LRU page allocations or deallocations. This has > caused contention on that cacheline and the workloads which manipulates > a lot of LRU pages are regressed as reported by the test report. > > The solution is to rearrange the fields of mem_cgroup_per_node such that > the false sharing is eliminated. Let's move all the read only pointers > at the start of the struct, followed by memcg-v1 only fields and at the > end fields which get updated often. > > Experiment setup: Ran fallocate1, fallocate2, page_fault1, page_fault2 > and page_fault3 from the will-it-scale test suite inside a three level > memcg with /tmp mounted as tmpfs on two different machines, one a single > numa node and the other one, two node machine. > > $ ./[testcase]_processes -t $NR_CPUS -s 50 > > Results for single node, 52 CPU machine: > > Testcase base with-patch > > fallocate1 1031081 1431291 (38.80 %) > fallocate2 1029993 1421421 (38.00 %) > page_fault1 2269440 3405788 (50.07 %) > page_fault2 2375799 3572868 (50.30 %) > page_fault3 28641143 28673950 ( 0.11 %) > > Results for dual node, 80 CPU machine: > > Testcase base with-patch > > fallocate1 2976288 3641185 (22.33 %) > fallocate2 2979366 3638181 (22.11 %) > page_fault1 6221790 7748245 (24.53 %) > page_fault2 6482854 7847698 (21.05 %) > page_fault3 28804324 28991870 ( 0.65 %) > > Fixes: 70a64b7919cb ("memcg: dynamically allocate lruvec_stats") > Reported-by: kernel test robot > Closes: https://lore.kernel.org/oe-lkp/202405171353.b56b845-oliver.sang@intel.com > Signed-off-by: Shakeel Butt Reviewed-by: Roman Gushchin Thanks!