From patchwork Mon Sep 30 22:12:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kanchana P Sridhar X-Patchwork-Id: 13817146 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 09204CEB2CA for ; Mon, 30 Sep 2024 22:12:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 64E7E280034; Mon, 30 Sep 2024 18:12:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5D63E28002D; Mon, 30 Sep 2024 18:12:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 450F8280034; Mon, 30 Sep 2024 18:12:30 -0400 (EDT) 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 07A4228002D for ; Mon, 30 Sep 2024 18:12:30 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id AA2D48071D for ; Mon, 30 Sep 2024 22:12:29 +0000 (UTC) X-FDA: 82622804418.09.C676615 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by imf21.hostedemail.com (Postfix) with ESMTP id 8BD4F1C0007 for ; Mon, 30 Sep 2024 22:12:27 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=h1G+C+gV; spf=pass (imf21.hostedemail.com: domain of kanchana.p.sridhar@intel.com designates 198.175.65.9 as permitted sender) smtp.mailfrom=kanchana.p.sridhar@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1727734222; 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=4lJlNC7s/SkC12bTYrWldJ9+mlN3EU9TgO7LswTLiGA=; b=sjxKJX+dTnJ938T6DOMNWnNs3K8xks3IOJptlatO6Un8jh2CRSdA3VuO0Q+0pfuRSaYw43 vK+gKT3o7WHKdzda2tZmYtCXaaYFBZUochBO5PPJ1on1ZDrlhgZfMMaZX3BQ/U2kmiudSM ZkRDdS6aBNY9zySPWJ/JE9UBUM41KCM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1727734222; a=rsa-sha256; cv=none; b=T+uMey+QDrr6VP5+OL5/CdlJyWkv2pglbfZw7bzwRWu28KmIbxN9CO6xXgIQGGH9j7hYcY 2PODo+HbMapploYDNqNXv6mQExDKHvcGZzsdVwfUHxZv/rvaHPdcIoshszmuw7Na/HX0tK dMrj1DDnfrlHJPGf7XnH08NJow59CBk= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=h1G+C+gV; spf=pass (imf21.hostedemail.com: domain of kanchana.p.sridhar@intel.com designates 198.175.65.9 as permitted sender) smtp.mailfrom=kanchana.p.sridhar@intel.com; dmarc=pass (policy=none) header.from=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1727734348; x=1759270348; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=sH8cQ3w+IHRFjDbPI6y+/ZvrGGUAI7tDyoePLrfKV9c=; b=h1G+C+gVod1avA5DC368myABjj2cfpxAs0yqymR4Y8AWdVCN3d1cfTDt pydCUkUpFQHuBjU3yQgyJdZftFpvQ2cNbYBwwh8KXOYUt7L7MEx8cfDIY kNn+xciSgdm3HOi5IiIAE9JzNoG0oUlz62FQLy0952ZuWUvHYLdSq+Lfz +d0o0jOUHkTS27xir9+TluwP98mdv/Gf9N97R9eiM76/k+6sXJuwW3gn6 2s/CjiZkrf4/VO0N5mlWLAJJgVQIHNiP3A2fMdj4GUJ6DZxWBweeQvAXC gCATrK2UmzcTTZ0z3MB+oANHspxK+iyPnRn52Gr47TZoB+XuBH9qA9QDd g==; X-CSE-ConnectionGUID: svzk8ibKTZ2zTPn7a6XhAg== X-CSE-MsgGUID: jM8jh9WQRwmqAp27Ihe1tQ== X-IronPort-AV: E=McAfee;i="6700,10204,11211"; a="49368428" X-IronPort-AV: E=Sophos;i="6.11,166,1725346800"; d="scan'208";a="49368428" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Sep 2024 15:12:24 -0700 X-CSE-ConnectionGUID: JiNA1XIES2mHOMYswCZ+/w== X-CSE-MsgGUID: RS1ODkyVTHartxBgNoU0aQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,166,1725346800"; d="scan'208";a="77985586" Received: from jf5300-b11a338t.jf.intel.com ([10.242.51.6]) by fmviesa004.fm.intel.com with ESMTP; 30 Sep 2024 15:12:23 -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, willy@infradead.org Cc: nanhai.zou@intel.com, wajdi.k.feghali@intel.com, vinodh.gopal@intel.com, kanchana.p.sridhar@intel.com Subject: [PATCH v9 4/7] mm: Change count_objcg_event() to count_objcg_events() for batch event updates. Date: Mon, 30 Sep 2024 15:12:18 -0700 Message-Id: <20240930221221.6981-5-kanchana.p.sridhar@intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240930221221.6981-1-kanchana.p.sridhar@intel.com> References: <20240930221221.6981-1-kanchana.p.sridhar@intel.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 8BD4F1C0007 X-Stat-Signature: xzi1toqtiw8dim9q9btfc438bafxnpr3 X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1727734347-267439 X-HE-Meta: U2FsdGVkX1/KocpU3e6T7dW0Ru3I+3xPfsMrLMMZ7vjLv40pNVJWBTZfOuupGHikfUSGPQ1eZdBq0d4z11TJUFLg1UCfTGbC32jpQJ5bSabd5GDdcQ65EXTeqeweeTq3BoISQfNiD9PAendI3j9vabR9aPLKt03hL1BTGa5AHeZPGpE9fNIu23Se4mBaMaHVyWZA25Ce+f2/b3H9SFHAk/k0ixKZs2geyXJ94zGIS6oYQkzxcPP/pq52IJAgShdc5Sx/DeEqHWKbDvoKUYhtdxQDPoOfl/H5q6RgPXbIUIrWpIkmhtkgHiGMeW/A7+ywDY8QPYmuUdVzBX3vn2Ip6xq3jEf/z32sUmyk5EDpAWFLpz+7JUnObuyYh7ZACyV7YPkUQXIKXGtzFVL5E+gAsGFmPWMsK/1sHGR7t7fVmNkRbHBAZj1tZfZDKey/fSFftBjKNG2xqHwDMOpJiqf2Vbr359pMHYzGjoC/1b/L8fIxfF+gNuOkmfZmb02bDi9surl3eGu/9nzyqjraJKYCRH4cTIo4zdDAK5kg4CQow3v0Tp7blVahHHux2uSbF2mOeAGYYbcT326uvngDOI6UJOlNBnabtr5XVUgNU06In/NW493sJ+KUBzcOwvIySG0zzt/F+5UEnES1TH2pmlxoXiGldq2HgUpDgfZiKQ0Nd3FDkseKmj9kMXTHoCiwH/eZ8+alyM8Z6BFnXESPbnDFgzgzJVZlL9GROMz9bau2381cP1MOw/OzLLHZK0TdTmsODqxkfNWw7NOyMN1dRqvK62S8UmGQ3G8hHqSAYMwQ3QSzmhAh6XRKbRj0m4NpM4WGJ0iXTIpbVwJo9omuUguzEaXp+5ayBR5UJaeTe4XTIWqbPk34GolbADrBZ+mcpSwuwimQ/epy0bjXvL+SHxGcyivsWxoNngYwYT9XZ+Q1+TVtrO6yuAjSzirYGZEmtjlMFUeA2DWpzS/Ozey/FGT nq5h9yAO Nsj/2M13S5Osl9tim0cvx5ngwrdlM85mH76GQFnVjI0MBVn3MvpdQQg3Uv9lnGOtAsYSmCkzuiy2//83cDXaOOJWiHj/uJJCamL08QD497SeuAChDBuyV9XZSl8UFmuC8u91irZSrl9Xz4t/0MzkiMMVUlQEcVRLBUY2UylVU1D4Trlkx+xqOChw68Em6YBfO1EB64VySqqSmIIMd0irO9HSQa9p0Jn8prnJ2 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(). To facilitate this, the existing count_objcg_event() API is modified to be count_objcg_events() that additionally accepts a count parameter. The only existing calls to count_objcg_event() are in zswap.c - these have been modified to call count_objcg_events() with a count of 1. Signed-off-by: Kanchana P Sridhar Acked-by: Yosry Ahmed Reviewed-by: Nhat Pham Acked-by: Johannes Weiner --- include/linux/memcontrol.h | 12 +++++++----- mm/zswap.c | 6 +++--- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 15c2716f9aa3..524006313b0d 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -1764,8 +1764,9 @@ static inline int memcg_kmem_id(struct mem_cgroup *memcg) struct mem_cgroup *mem_cgroup_from_slab_obj(void *p); -static inline void count_objcg_event(struct obj_cgroup *objcg, - enum vm_event_item idx) +static inline void count_objcg_events(struct obj_cgroup *objcg, + enum vm_event_item idx, + unsigned long count) { struct mem_cgroup *memcg; @@ -1774,7 +1775,7 @@ static inline void count_objcg_event(struct obj_cgroup *objcg, rcu_read_lock(); memcg = obj_cgroup_memcg(objcg); - count_memcg_events(memcg, idx, 1); + count_memcg_events(memcg, idx, count); rcu_read_unlock(); } @@ -1829,8 +1830,9 @@ static inline struct mem_cgroup *mem_cgroup_from_slab_obj(void *p) return NULL; } -static inline void count_objcg_event(struct obj_cgroup *objcg, - enum vm_event_item idx) +static inline void count_objcg_events(struct obj_cgroup *objcg, + enum vm_event_item idx, + unsigned long count) { } diff --git a/mm/zswap.c b/mm/zswap.c index 0f281e50a034..69b9c025fd47 100644 --- a/mm/zswap.c +++ b/mm/zswap.c @@ -1053,7 +1053,7 @@ static int zswap_writeback_entry(struct zswap_entry *entry, count_vm_event(ZSWPWB); if (entry->objcg) - count_objcg_event(entry->objcg, ZSWPWB); + count_objcg_events(entry->objcg, ZSWPWB, 1); zswap_entry_free(entry); @@ -1482,7 +1482,7 @@ bool zswap_store(struct folio *folio) if (objcg) { obj_cgroup_charge_zswap(objcg, entry->length); - count_objcg_event(objcg, ZSWPOUT); + count_objcg_events(objcg, ZSWPOUT, 1); } /* @@ -1576,7 +1576,7 @@ bool zswap_load(struct folio *folio) count_vm_event(ZSWPIN); if (entry->objcg) - count_objcg_event(entry->objcg, ZSWPIN); + count_objcg_events(entry->objcg, ZSWPIN, 1); if (swapcache) { zswap_entry_free(entry);