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 E4B5DC282D1 for ; Thu, 6 Mar 2025 19:43:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 899C9680007; Thu, 6 Mar 2025 14:43:01 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 84BB9680001; Thu, 6 Mar 2025 14:43:01 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 739F5680007; Thu, 6 Mar 2025 14:43:01 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 5747D680001 for ; Thu, 6 Mar 2025 14:43:01 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id AB1C61CE419 for ; Thu, 6 Mar 2025 19:43:03 +0000 (UTC) X-FDA: 83192149446.20.C08BFA3 Received: from out-189.mta0.migadu.com (out-189.mta0.migadu.com [91.218.175.189]) by imf02.hostedemail.com (Postfix) with ESMTP id CA54B80008 for ; Thu, 6 Mar 2025 19:43:01 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=BrXza8wq; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf02.hostedemail.com: domain of yosry.ahmed@linux.dev designates 91.218.175.189 as permitted sender) smtp.mailfrom=yosry.ahmed@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1741290182; a=rsa-sha256; cv=none; b=LOdo6ivHXVnk6gjMFlSE7d2sBREHRvJ3Ny69ZVlvjsiibn7Es47jUx2uUvlNiBMeW408mK wlJj+AzvlJSBD/yxy+C5KcrDYI8l3mUEHaK36rkB6p+eOSBIh5C9hbNEAwbTywE0Ef/cFb Xo6KK1gFHyRtE+Ii9edR6xXb8aDhU3Q= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=BrXza8wq; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf02.hostedemail.com: domain of yosry.ahmed@linux.dev designates 91.218.175.189 as permitted sender) smtp.mailfrom=yosry.ahmed@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1741290182; 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=VgoJ7d5Va9BAZXYpGq4C2//c7YKoou3T9bz0+JoLsBo=; b=ykUWpYQZQQ7fh6uUBTM4MyaM+8MR7oAcf6ad3n3KFSjCo43hjUQJZKV6mb++rGOLOMQcHh cNEqRYv/Cf1ljtcfOLpjjBzNX3WlQzgtQEz2hTigBXT5JD/Ze+Fbu5n0mGkUAg2pTHY26Y 4e9v5x+o6ywwPuM6arbee9TxNpbY7Ag= Date: Thu, 6 Mar 2025 19:42:52 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1741290179; 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=VgoJ7d5Va9BAZXYpGq4C2//c7YKoou3T9bz0+JoLsBo=; b=BrXza8wqQyE6QPXncYpu7CYcgmKyBl5VH2VDa31/Ox5/mXeaYRMOe5mc1SGMxtNlLnxE3S MK8K63oyC91haUhkdlOtHNfiFpvQWSwfGr2VTENFD0g6pQG73r4bm0WYM/tv9N32z6b+x7 pk1FV1JC3MZXpUmA3816HuEqvj90IK8= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Yosry Ahmed To: Kanchana P Sridhar Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, hannes@cmpxchg.org, nphamcs@gmail.com, chengming.zhou@linux.dev, usamaarif642@gmail.com, ryan.roberts@arm.com, 21cnbao@gmail.com, ying.huang@linux.alibaba.com, akpm@linux-foundation.org, linux-crypto@vger.kernel.org, herbert@gondor.apana.org.au, davem@davemloft.net, clabbe@baylibre.com, ardb@kernel.org, ebiggers@google.com, surenb@google.com, kristen.c.accardi@intel.com, wajdi.k.feghali@intel.com, vinodh.gopal@intel.com Subject: Re: [PATCH v8 12/14] mm: zswap: Simplify acomp_ctx resource allocation/deletion and mutex lock usage. Message-ID: References: <20250303084724.6490-1-kanchana.p.sridhar@intel.com> <20250303084724.6490-13-kanchana.p.sridhar@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20250303084724.6490-13-kanchana.p.sridhar@intel.com> X-Migadu-Flow: FLOW_OUT X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: CA54B80008 X-Stat-Signature: mprmq3w47egt6iqasg7mxab7xky55w1s X-Rspam-User: X-HE-Tag: 1741290181-554521 X-HE-Meta: U2FsdGVkX1/INeL5z59Z+EPz0lQEfdGYawfGCjIh3c+TP1A8CU39zwpTWa1RJmdo0qxutR6w5rvewf8HGeYKg2AH4TvM5qAwrFc3+4lMQM+Zx6AHPe0V64D/lA+5/EtPPHNdEeOROxCdXqNsjq5JH+Og67ghF4GEqmgHBciXNpmdszv/MJHr6FxkImu+nO/qQfAkqhoTii4S3q0KJYqNPA9k7rkKJJTvTdaRZYBOW69pLwPFWuheMO1In4lP+yQmccCRU/MaVMhV+6AvVE+2ihdK9wb996PcOKblRWDhqB6GiufQAlPBRwYtqxDqhHJjhWNEx81MqPltOoy8W1dkcOahZVO47h0KXUlng4gAG4Uj2TEmj788P3CTOvC2OK6NbvYobTgGtI3hVH0YT75W0YemyJr0742s5BfkzUU+9cxWcCO/uPHfiN8tqCi6ZGs1c4ZY7dEFEQ4M9mB+nCDebhHfi1zkx3n282HahhWtjREjCJny6Frw6dOOzxJYnxYjiZk9n5VCiGiSPCl8hCLzfasjzjGBKypseA0tLfJ78ubdESUlKyZWS49E9ZvBzhiE5gpWV88Dygw9mUH82zu/TiQ2wC6uhVAVfLK7LPZqcLBqlbr/5dfM8rAe6namsr/JJEDHEd2JxzISbT0EbQ7DSSZEvhuobdrfZXKJKIFRR12YGlI7ukTzmc9gUUUcvD27hFsmQW9NdHk5u1pszJg0cCdAYGrIHnMpohr6DCl+DhCcayKj/WNBKkyh4g7NBnsqnuZt1m7L0T/h7wjJnxxAJrR/R2tLdKkqW8FgXJqNE7CxzbRUFstxyZseUXysCg1AhtYtSfZRU+556N4LYWu9sv5FcdqkNLxeekK8/M+3yklPrG6pE9YLOdbZ6nT9ZuqqlmQdjy1uor0Z+MoIxYcjw/ZP3auC+8bihUkPPdV1LQ/znDb1/F8Hlj9QiCXFlJtAO/YUI/Ex8PiHjIbTPzZ wN2sekEs No+iA75vC4+ZuFGLWNuTv5ZgH9AYFr3POv4lPfiybPgNRPynZ7XzuMYhr6FtfpmGYZc/1KzWRT3DLfs1zBadyUW2ni2QA2EMu+GzwCpc3JEo45ISSF37iQjIqD+nzfhUZ+uDbSkdFd9e3QYM5/yJrLGMp9vinEb0NHoGwDpK8Ef8JtrRsps68t3kuluUATLEj6hfPL1MKGEBoXxm8n26//wwS7MH1X1LufuRv3UW+XuWV2MNoAPAx/ki2K2IVNNKkgjVlMWo5huQjBCo= 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 Mon, Mar 03, 2025 at 12:47:22AM -0800, Kanchana P Sridhar wrote: > This patch modifies the acomp_ctx resources' lifetime to be from pool > creation to deletion. A "bool __online" and "u8 nr_reqs" are added to > "struct crypto_acomp_ctx" which simplify a few things: > > 1) zswap_pool_create() will initialize all members of each percpu acomp_ctx > to 0 or NULL and only then initialize the mutex. > 2) CPU hotplug will set nr_reqs to 1, allocate resources and set __online > to true, without locking the mutex. > 3) CPU hotunplug will lock the mutex before setting __online to false. It > will not delete any resources. > 4) acomp_ctx_get_cpu_lock() will lock the mutex, then check if __online > is true, and if so, return the mutex for use in zswap compress and > decompress ops. > 5) CPU onlining after offlining will simply check if either __online or > nr_reqs are non-0, and return 0 if so, without re-allocating the > resources. > 6) zswap_pool_destroy() will call a newly added zswap_cpu_comp_dealloc() to > delete the acomp_ctx resources. > 7) Common resource deletion code in case of zswap_cpu_comp_prepare() > errors, and for use in zswap_cpu_comp_dealloc(), is factored into a new > acomp_ctx_dealloc(). > > The CPU hot[un]plug callback functions are moved to "pool functions" > accordingly. > > The per-cpu memory cost of not deleting the acomp_ctx resources upon CPU > offlining, and only deleting them when the pool is destroyed, is as follows: > > IAA with batching: 64.8 KB > Software compressors: 8.2 KB I am assuming this is specifically on x86_64, so let's call that out.