From patchwork Sat Sep 28 02:16:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Sridhar, Kanchana P" X-Patchwork-Id: 13814599 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 01F18CF6493 for ; Sat, 28 Sep 2024 02:16:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BB1736B0165; Fri, 27 Sep 2024 22:16:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B351F6B0166; Fri, 27 Sep 2024 22:16:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9882A6B0167; Fri, 27 Sep 2024 22:16:31 -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 7558E6B0165 for ; Fri, 27 Sep 2024 22:16:31 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 2878D816D9 for ; Sat, 28 Sep 2024 02:16:31 +0000 (UTC) X-FDA: 82612532982.14.839B60A Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) by imf04.hostedemail.com (Postfix) with ESMTP id 18C3140002 for ; Sat, 28 Sep 2024 02:16:28 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=Em1i62wD; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf04.hostedemail.com: domain of kanchana.p.sridhar@intel.com designates 192.198.163.13 as permitted sender) smtp.mailfrom=kanchana.p.sridhar@intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1727489689; a=rsa-sha256; cv=none; b=hRE2z3+/w2mHA80SL9QYyc953CjWbbZbHCY/T6I1vIC/SJPpsJzVIAvyX5DhnZ2iWOfuu9 hTfzO4qBuiXTwXhYqGdnDLvebgYglwgWSbsiS/84UVAWWLH9Wrg6OHhWi6/NdsYnvGAZIq gpEo3fxSz2WsHQ+CM6JCrIZ8/brxBmM= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=Em1i62wD; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf04.hostedemail.com: domain of kanchana.p.sridhar@intel.com designates 192.198.163.13 as permitted sender) smtp.mailfrom=kanchana.p.sridhar@intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1727489689; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=tSkTkvc4RK/mABhfoBCo5mPE67SOGg9cBUxR5H6C1eE=; b=GqPC2ojfU4ltswR7EB6SrqpFUGgcglomTtNrpFbqQ+G1Fg0jzDLpWq+6YCBc1CDSvjBXh+ X6zcg/Qtf6vTcI8DlQZxaEqd5WJRoFnS7ENh+KN34+zWNGlwHHs8HPTE0ip82kYQ3ZvsNI UdeUK+bnGObBqfWN8WIGptBAlDdRRGc= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1727489789; x=1759025789; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=QHKnkJGGdaPi/P8pWr1YVsvSRJmDf6+suHy+r3IyAYQ=; b=Em1i62wDc1UmSwrxuKE8zqHbXvFipfr3H26GbhjHnYj7t1yDbWJn5clW unCEPM6iLwomcMF9qTLI+TqwV88nVfCU+CmPp018qXUlFNfJ4q0CIMhum 1pWcu4PM8dHSaA8tMULe0sUU0euSbplKqTJXFFKR1SmDVvynQsQ4EGUCy CZpa91619oX7FNHXz+ImkDZzTuUdRimwG9k4PkGFr0anfcQt7FviPR3gQ PNN+OXHz7/JUmeQhhGZvlS1eEGlyUv7OcuaBeHDpZJDXZlIaGSWlvG5SS Dh/JRUYmKABTLkywggT0616274bMudvAoL1W/7TS3leDFASV6yQlIPB3H g==; X-CSE-ConnectionGUID: V6SC6ZM6R4qTcNRHed9bsQ== X-CSE-MsgGUID: 4n49zgAOSsSYTpdcTxF+Kg== X-IronPort-AV: E=McAfee;i="6700,10204,11208"; a="29526886" X-IronPort-AV: E=Sophos;i="6.11,160,1725346800"; d="scan'208";a="29526886" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Sep 2024 19:16:21 -0700 X-CSE-ConnectionGUID: NLInsGB0QhKm+ll4bJ7x3w== X-CSE-MsgGUID: VaCbO+f5T0Sm7iNs63SZkw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,160,1725346800"; d="scan'208";a="73507123" Received: from jf5300-b11a338t.jf.intel.com ([10.242.51.6]) by orviesa008.jf.intel.com with ESMTP; 27 Sep 2024 19:16:21 -0700 From: Kanchana P Sridhar To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, hannes@cmpxchg.org, yosryahmed@google.com, nphamcs@gmail.com, chengming.zhou@linux.dev, usamaarif642@gmail.com, shakeel.butt@linux.dev, ryan.roberts@arm.com, ying.huang@intel.com, 21cnbao@gmail.com, akpm@linux-foundation.org Cc: nanhai.zou@intel.com, wajdi.k.feghali@intel.com, vinodh.gopal@intel.com, kanchana.p.sridhar@intel.com Subject: [PATCH v8 4/8] mm: Provide a new count_objcg_events() API for batch event updates. Date: Fri, 27 Sep 2024 19:16:16 -0700 Message-Id: <20240928021620.8369-5-kanchana.p.sridhar@intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240928021620.8369-1-kanchana.p.sridhar@intel.com> References: <20240928021620.8369-1-kanchana.p.sridhar@intel.com> MIME-Version: 1.0 X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 18C3140002 X-Stat-Signature: ns3wd16n1g9aknzcsmqtftmxgrza9n56 X-Rspam-User: X-HE-Tag: 1727489788-116013 X-HE-Meta: U2FsdGVkX1/o3Xq6bV/V0KWIsaH71Gtp/Wxu0R6OdnhJiq3Zwkov0UOa29Vo49DmTvCfEgDqWNt1JxC8KNQODt+PbHA5CDnDEIFie5okyf6y0u340Qz5Dq75Ynb8SMxaDAhh8R6pUtmKXJbKrqkKMAookgJFXSKsenpA1oAM4AyjZIMG3/URP72jkp+C9B28uCsilvwfQKDLsvuA7qj0Fii+FM25+f69LdzodcMakYzK39DyNNXVZvdp+SWjSgMX44PlGWR4eMQBgd+MOjDy2rb4jIFuZOSCRupw0A8p+u7WToTMlFK6fPobSqccKDtljTHbP/RVwg8Cpaics3zedI4z30GTrBT0SlpucI1S04PIXPZwRGnpvY9T4w9D5eoKm62Slwmvh01FM+kPRopRFstNA2HmdysvNGLlte9dugzgodG38nxGiARn5HGhNiQ6Jql/oVbHd6npnsgxEROXD2a/ESJ5FvlF9YQpGpkwqUz1nnbVNzeYwQV7XzBjZm7A/iZCo9Bv2Vb45Z9ZJvtA07zp+hmoYJnrDSxnl51ICc1U8lCWGye7U54oDLcrSEfU7sChcmYJ/wPC7nd65MjGowxD4rEVxCCQ/cxVoPOrkfgsJFbCC6wRL2KBX0m+dAfVZlCb8lzATgpMyXYb3i10CMtVC0aKN+G/pNqSBZf3qxao7S1qBzGUYlZ8Vx+5CEqvmVHd3WqFDDpjVc0zV1ALQsE1XtOoP7w0jd5G/6TjObpdtQ0vYi6wOkuC5wi9gxC/fb0vZX9Zm2TLd374gr0WJ5+6aSYlWQkD9XoyE6vRYuvKBXCgOYXYVeMEwyqHwCn20zlzzc4nXM3lwe6OcCQ/n5/yIOO07+wZVbMgchYFTwTMI32A+hTyEUsKfplWay+g20X02F1n+fdbYC3Qk9xIUoM4yevwscd2vX2AWXrKOcijqhM6t0Yz42D3goOKDB2NmSIYy95yXlSJRYnFwo/ W8OKn3Fj lIkj94rDyAQrk+CLHer6I30U+tZ2IlaJThZ+eLZ7qBIVJGg1dJHwuUqIvpwTZ2xQy5Bp2WN45a+vXxzFDI0f4pU1yt11yYMcDVXd/eZk/lDK3a6eCuq1GEk4kd9kRSaZlhvMFC0nPs/rb71lZCNiNQcBtxiN15lbXQLXUuFyEXEREYiLxzOtlUJZ8pIbn5c6h36U4MWp6efdWI8Jsv79fMxh+ItLPnl69wjvI 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: With the introduction of zswap_store() swapping out large folios, we need to efficiently update the objcg's memcg events once per successfully stored folio. For instance, the 'ZSWPOUT' event needs to be incremented by folio_nr_pages(). Signed-off-by: Kanchana P Sridhar --- include/linux/memcontrol.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 15c2716f9aa3..f47fd00c5eea 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -1778,6 +1778,21 @@ static inline void count_objcg_event(struct obj_cgroup *objcg, rcu_read_unlock(); } +static inline void count_objcg_events(struct obj_cgroup *objcg, + enum vm_event_item idx, + unsigned long count) +{ + struct mem_cgroup *memcg; + + if (!memcg_kmem_online()) + return; + + rcu_read_lock(); + memcg = obj_cgroup_memcg(objcg); + count_memcg_events(memcg, idx, count); + rcu_read_unlock(); +} + #else static inline bool mem_cgroup_kmem_disabled(void) { @@ -1834,6 +1849,11 @@ static inline void count_objcg_event(struct obj_cgroup *objcg, { } +static inline void count_objcg_events(struct obj_cgroup *objcg, + enum vm_event_item idx, + unsigned long count) +{ +} #endif /* CONFIG_MEMCG */ #if defined(CONFIG_MEMCG) && defined(CONFIG_ZSWAP)