From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id DDFBFC369C2 for ; Tue, 22 Apr 2025 11:41:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9EA0E6B000D; Tue, 22 Apr 2025 07:41:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 972696B0010; Tue, 22 Apr 2025 07:41:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8133B6B0011; Tue, 22 Apr 2025 07:41:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 55E326B000D for ; Tue, 22 Apr 2025 07:41:21 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id B13B5BF403 for ; Tue, 22 Apr 2025 11:41:22 +0000 (UTC) X-FDA: 83361489204.21.8F1F05D Received: from out-177.mta0.migadu.com (out-177.mta0.migadu.com [91.218.175.177]) by imf19.hostedemail.com (Postfix) with ESMTP id C89821A0005 for ; Tue, 22 Apr 2025 11:41:20 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b="OrJ4b/Ry"; spf=pass (imf19.hostedemail.com: domain of yosry.ahmed@linux.dev designates 91.218.175.177 as permitted sender) smtp.mailfrom=yosry.ahmed@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1745322081; h=from:from:sender: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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=aGjfUa0VdFNE7pAhfj1k3sXWx23PmVKsC+WEqb2v1XU=; b=cWvPEqHYap8BFhMaUImHF88PHwtwIwwCpSZMiNDd+82SpEUH/6VQ35XVRxBNSwOZ4HGvs+ jsLkrxQdtylq9Y4v+9HFn44YARIL4MhrgDkR6JvLOg1dCNY/eBnRpR25wQd/ZKTVsFI8AC dDZHMttaX9HlQIbOrYlPpTwtbtRaTH4= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b="OrJ4b/Ry"; spf=pass (imf19.hostedemail.com: domain of yosry.ahmed@linux.dev designates 91.218.175.177 as permitted sender) smtp.mailfrom=yosry.ahmed@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1745322081; a=rsa-sha256; cv=none; b=fPxRIpAQCfIkCx5xu3CzumncJWK+DyhqkG3fNCtf2gl4rGcD7Q8Nub+YVyUK1TZp9Si8du nculQZRoNhUmevO3tuqZSymaAshhSbCqW5qXVz8Cs07kQSe29ux+3xNm7aF4gh0XPgY/au mVyyrJc036LYXsO9I2yw/8J+sVw0M+M= Date: Tue, 22 Apr 2025 04:41:13 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1745322078; 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=aGjfUa0VdFNE7pAhfj1k3sXWx23PmVKsC+WEqb2v1XU=; b=OrJ4b/RydEPGLVaiWvtAx95vFvpu/zp46RuMAmWS9/Cr+90MRK1LqVWwpdv/Hz+Mt82UTo trAATCdjYc4rBJ3UmmsIKTRGqbBcib7sjLJG2PWf19npjz+4cbk+5UFlL72k1dEN3aJHDt ggPkHh9W7H6TCuUS83qhIBmwtwMDZmI= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Yosry Ahmed To: Shakeel Butt Cc: Andrew Morton , Johannes Weiner , Michal Hocko , Roman Gushchin , Muchun Song , Waiman Long , linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, Meta kernel team Subject: Re: [PATCH v2] memcg: optimize memcg_rstat_updated Message-ID: References: <20250410025752.92159-1-shakeel.butt@linux.dev> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20250410025752.92159-1-shakeel.butt@linux.dev> X-Migadu-Flow: FLOW_OUT X-Stat-Signature: h3bymqgoid4t59tmdxizp39xou7q9s9g X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: C89821A0005 X-Rspam-User: X-HE-Tag: 1745322080-168401 X-HE-Meta: U2FsdGVkX19Vh/FSBfOfwjJGfRFs9NJ1IbPlImgzXKUz4zWVk1DcfR8NFcmYL1iwU//oqVgOEoTQ+e4sEBgvwEGoNyJEATAulLayz4idZhKqNyxjVNDq0B6WnSNjnYnjcJxtEhHFg/WFR5++rseW6Vm2XmAx9VskGk0t+EMrxnCRbGHWd8mHJ3wtDCddvgUTqsgM3S5Xv6pG5+xvJZlerRvWwtWd11jJnAmv+iFCVMhg2UFcwJMJgel8Yvf3aJid4VhMHinIuMy5MuwlHWE7cGCcJHtgJiZ7yt1AfkqmzRFulwgD/d3fc2xwUIBTyR+ls1rTOQ9Ou3wOPz+XXMmgQ0WUtCRkUMmwlX3rMJun9tMd41ndJqXedLNZgEisuf2eebwmJSMGPenwszbzicrHcKPZoCEr9OHPhfLZZiZ7Dg2ZovCKmOc1RlO64Zdjpsi8SVVAZ2xQlSiRiDPDRtNn0Z5KkqD/tJpgecxvzm3zr2yZvNBkYjDbEiqyU+92Dxf9zG7rDP/WEsn/Ov5YnnwqsXHBhM8oJil+pQIbC3DfkZkzPsxVbUtvWq3VGKjs0vOsmXHp51A3nER6mNPzxg7hnrNsLgSHBx5ktJDWRS131hYTOsP5ytbyO778yvxs+8JYOxZRHrmc7mDkr7USBZu3GdtXIrFAgAJTZVMUPTj5OS3IVbudExI85iQlkFKWpvxwc+OSW9TucyuJCWCsMB44Thy9/GKi87aXR5il+TTuU+h6IbBjTp8mfpJhuFD519P429OeZ4wT9eXipaMWTlcfS0Fi1aCc5+lsEm1j2Stmgu3jlW2MKOb/nijwHdbir3v32yciD4I4iog8Rl6l5vxzXNsRR4Qa325gk2GjNuhri662mEqmuJnVeSz7/Qkdro1vPRskXiYBaC/WNsyoOTfo9CyDv5dmImTjrU9wyW+xWudx3IPAVv2iwbibvQptYAVfdjXyFjwrUiKj+m6iqfn v+40YK5f Ot2Ax/ZL/PAK9qnMJW+2o1OhfYylsUhgez+NzurG/E8ijoOzno5VAVgdPQ/yKodrmhrcNe4bYxEG1XgiSY94EdRa2CaT0WIEdCYlJioxKUF4YMZUfWqiU9p1D7hPxrBLI3PfJJdGM010qx9wVsUdUgRm+VmwEzACV1hFM5wAB6amKkR6nofFHPOEz5WVJfkRa6ACou3QJ/FkAunzlX6y6qmo+1rsjRVB+v+JWfHBoxt4SbRQ= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Wed, Apr 09, 2025 at 07:57:52PM -0700, Shakeel Butt wrote: > Currently the kernel maintains the stats updates per-memcg which is > needed to implement stats flushing threshold. On the update side, the > update is added to the per-cpu per-memcg update of the given memcg and > all of its ancestors. However when the given memcg has passed the > flushing threshold, all of its ancestors should have passed the > threshold as well. There is no need to traverse up the memcg tree to > maintain the stats updates. Nice. We also skip updating the per-CPU stats updates counter, which is unnecessary in this case as well. > > Perf profile collected from our fleet shows that memcg_rstat_updated is > one of the most expensive memcg function i.e. a lot of cumulative CPU > is being spent on it. So, even small micro optimizations matter a lot. > This patch is microbenchmarked with multiple instances of netperf on a > single machine with locally running netserver and we see couple of > percentage of improvement. > > Signed-off-by: Shakeel Butt Reviewed-by: Yosry Ahmed