From patchwork Thu Dec 28 07:30:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shakeel Butt X-Patchwork-Id: 13505654 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 4316CC3DA6E for ; Thu, 28 Dec 2023 07:31:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 65DEF8D0007; Thu, 28 Dec 2023 02:31:10 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 60E728D0001; Thu, 28 Dec 2023 02:31:10 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4FD438D0007; Thu, 28 Dec 2023 02:31:10 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 40F048D0001 for ; Thu, 28 Dec 2023 02:31:10 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 0C40140776 for ; Thu, 28 Dec 2023 07:31:10 +0000 (UTC) X-FDA: 81615405900.09.B991221 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) by imf13.hostedemail.com (Postfix) with ESMTP id 6634C20014 for ; Thu, 28 Dec 2023 07:31:08 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=qR86q9jb; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf13.hostedemail.com: domain of 3OySNZQgKCOoeTMWQQXNSaaSXQ.OaYXUZgj-YYWhMOW.adS@flex--shakeelb.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=3OySNZQgKCOoeTMWQQXNSaaSXQ.OaYXUZgj-YYWhMOW.adS@flex--shakeelb.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1703748668; 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: references:dkim-signature; bh=NREzK8/wmujY6hf4hjlWHbSO7quR4xEc0yBGUCASod4=; b=go3O085Mj0Ny2+sqs8ST2SvugpWIoo5q7uFL6BECScEo4xxWuJIJxUbfHRtOuu+4Fj1vVI 6JGWOkQGEDyBoGta/86OCMi+grz5DuDF3y6GTY3I7JkCW1Mb7yt1JZGCTG0i+dcBfMFPDD jfmXBbg6L+Yqsy68lm8Mu/xOqUMKUGU= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=qR86q9jb; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf13.hostedemail.com: domain of 3OySNZQgKCOoeTMWQQXNSaaSXQ.OaYXUZgj-YYWhMOW.adS@flex--shakeelb.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=3OySNZQgKCOoeTMWQQXNSaaSXQ.OaYXUZgj-YYWhMOW.adS@flex--shakeelb.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1703748668; a=rsa-sha256; cv=none; b=H6e80CJs5IMbjJC7ju0+nK0mTZr0nixz0f7WHr6IkLm6x/UVWM4EfPAHmTK7TkB/mpaZkS aaCqU64Oa7Fx674A3LzlWMiqfmmMW6Jef8oHZIiDZ1L+XsK2vTG+ILSNAAWdsoLtFwJ2jU cLcn14fG6wO6RiSfJFjpvpnTtgAxrlk= Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-5e73bd9079eso109019837b3.2 for ; Wed, 27 Dec 2023 23:31:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1703748667; x=1704353467; darn=kvack.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=NREzK8/wmujY6hf4hjlWHbSO7quR4xEc0yBGUCASod4=; b=qR86q9jb31kfqBEHritLTC/L1EppYyemwBj+6Ro2iM4l0xCXuvL+5ZyYyXi7NVphte Q7aBFoA5qjf+rCaNbHs2fB0pqf7M/ou5chGU/jJQFAdsZ4G3LOoBA/N6NQmQTwS1Tbso x82Ag9NTpZ4Gkb/zfyzhnp/jKdhU+2fd66AiuHophrhrFkA5YlJsU7cl3ATXq2ROHNGj 508GLnQhcxRTVrjIgnBTTXfqjSqnrM+2/mD2PsS6BP5V6tVZ39yzmlGHJc7gbWe/54+o Cy7/5g0hLv2/jYN0T0N7r5Z4k2ZkwoepCP8HcId+AdivyZcgUJVNTpxAVNw8Uhy7Oq47 FDIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703748667; x=1704353467; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=NREzK8/wmujY6hf4hjlWHbSO7quR4xEc0yBGUCASod4=; b=JtDYv3BBgMYpUhPNNwX+niQRidEVT+kv01LyC84efPMZKLbF4ukMCPsKsyNaLhUqej M8ws1GwSPUSqNk3XPPFOG/HCXfevUaPJWVpQhxXnS3vNbwJXZbisB2J17iHEu7UNspXm S6yOSRv7TJkQ8ZIlc8uNFdUhJCyOBxCaR8qe1C61idEofIIi2o9Z1wjZ299LLMVXSx/O a7/SmM74QcQNjgRR8AjgUyjsZqt25O70SmkaTNHFZY/XR7K1G54+ohCqQ8LI5IJdrHyr Kb0cAx752G7wxWF2OuWJt8ZZAcb/wcKgUhoiWY6fZRCmjBOppU2kM2aJjwkfBD4Z0OY+ vizA== X-Gm-Message-State: AOJu0YzgkFg8o3I4F3YcGMfTN9bD3+0LbXkmZco1Kl0YVCT2LHsVG92c j0SPAl7/kDJFjLQHjs5U9zCw6TqNnvf7Ot/bFfQJ X-Google-Smtp-Source: AGHT+IGaA30rkF4pNPWE7IN7ftUo+1evzpA09h7euNCR6pksQ2NRwRhyHGW5wC1NyNJI/mF/D74/Qfyabzc0Rg== X-Received: from shakeelb.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:262e]) (user=shakeelb job=sendgmr) by 2002:a05:690c:b0d:b0:5d3:84d4:eb35 with SMTP id cj13-20020a05690c0b0d00b005d384d4eb35mr5018905ywb.3.1703748667481; Wed, 27 Dec 2023 23:31:07 -0800 (PST) Date: Thu, 28 Dec 2023 07:30:55 +0000 Mime-Version: 1.0 X-Mailer: git-send-email 2.43.0.472.g3155946c3a-goog Message-ID: <20231228073055.4046430-1-shakeelb@google.com> Subject: [PATCH] mm: ratelimit stat flush from workingset shrinker From: Shakeel Butt To: Andrew Morton , Yosry Ahmed , Johannes Weiner , Yu Zhao Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Shakeel Butt X-Rspamd-Queue-Id: 6634C20014 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: f11hs13q7zr1y1fod914a6y6sefyxo5r X-HE-Tag: 1703748668-242172 X-HE-Meta: U2FsdGVkX1/5FBrS+jSqY6ITVL16esHSUBaO4o57V49JmJTcHhZkdOyIAypLGDzvOg3HmW3pylJHdOM27Uta0Xayhg2AIZwd+XgWWXNVadklyIWs0kB1UHGbBhMvPyH4XzaZLZhumV32ohMJNrIvam/R1hDbxJ0drbBWjr3ipjSIJ+kyLX1vHzQAfHsHncCmCA7v6V3K9NnwkqDN0k6UyciaFheYGNTWIMrwEqFxSBjRXsB52kCn8vgUJBSxekEGsGtN2WcesUXK5fyPlhERWUKdtM8L6HGZGtplPOBm9lmJWgGu5xcStOma/fqt1hMQitjTqnDmWIj35XhuEMxS08xYT6NLgaxaSogN/IV2Hmq45pWt23GCJhKd1vEOBwOawHXVGpbx7GCpx0StUYWwnV5TTUoDTOPVTJeOr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j1NRza3FOG1c74jMsy3OhQYoph2l8dt7IsO+jBTjBTp7OiMSaqIFjdi6GXWhRy5kTyJi1++oeHxYIFsL6u+SiSvU5nSovITCZkJ+UADJLeVla7E7kWOuh/nJNG/mv4Rd9SekommQk8Wn5dA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.153961, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: One of our internal workload regressed on newer upstream kernel and on further investigation, it seems like the cause is the always synchronous rstat flush in the count_shadow_nodes() added by the commit f82e6bf9bb9b ("mm: memcg: use rstat for non-hierarchical stats"). On further inspection it seems like we don't really need accurate stats in this function as it was already approximating the amount of appropriate shadow entried to keep for maintaining the refault information. Since there is already 2 sec periodic rstat flush, we don't need exact stats here. Let's ratelimit the rstat flush in this code path. Fixes: f82e6bf9bb9b ("mm: memcg: use rstat for non-hierarchical stats") Signed-off-by: Shakeel Butt --- mm/workingset.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/workingset.c b/mm/workingset.c index 2a2a34234df9..226012974328 100644 --- a/mm/workingset.c +++ b/mm/workingset.c @@ -680,7 +680,7 @@ static unsigned long count_shadow_nodes(struct shrinker *shrinker, struct lruvec *lruvec; int i; - mem_cgroup_flush_stats(sc->memcg); + mem_cgroup_flush_stats_ratelimited(sc->memcg); lruvec = mem_cgroup_lruvec(sc->memcg, NODE_DATA(sc->nid)); for (pages = 0, i = 0; i < NR_LRU_LISTS; i++) pages += lruvec_page_state_local(lruvec,