From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-173.mta1.migadu.com (out-173.mta1.migadu.com [95.215.58.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C9BAD46426 for ; Tue, 18 Mar 2025 23:14:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742339665; cv=none; b=o2P7KQVeVFftcyRAxRPkSUt4fR6q6FawdBlQ9ALqF50Vq9SaurIKCbG0uAipuBj8BFwrlVjH7mVx5SIKqWhvquSJ8fbJbLwNkrWDSEZBuvsGqbgi9o3bs/vShH8rzjYBjgo6owl5JyZHc2qPbu5Ks24sym97DmbOoXEjm0l2AH8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742339665; c=relaxed/simple; bh=RRawIH7MSBCWqs5s3zUm1vn0teMZ1dhswZ90zh7oT6Q=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=KmTTdbfv5A2ZjX0jgPjBDZebbdvrQhfVv9XRSuO4NETxTjKn2J2iNTCx75KB1X1Iafj/EqGFk4RhzHhXWSyKIB2CUEZVinTpFk9eqeH0EUdYNnbH5OH8OhYXKcqLibkdQMtuIH2nFLOXWmlLaaicREoDDMk12QWbQCznbrGJZ+8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=qyjvjCTC; arc=none smtp.client-ip=95.215.58.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="qyjvjCTC" Date: Tue, 18 Mar 2025 23:14:02 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1742339651; 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=dEiwYqhjF6BNFFV7jF/tNDaFFyAW5VoJIlRl5arxgCo=; b=qyjvjCTCIdIj6tib4Mpx1MGZVLigYMqTgWhVDJLgUnsBfKxMAVv5fc4xqsqz3ChWfTd9e6 lPCdLPV8yHofkDykLWTZU+hTpDbLx/coTbGEGswaJ2onXy/8xpE3exzSWBbdK0/+N+bA9E veji6WTR2Lcpt+1zwEQft4Ud9/V+tnk= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Yosry Ahmed To: "Sridhar, Kanchana P" 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" <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" , "Accardi, Kristen C" , "Feghali, Wajdi K" , "Gopal, Vinodh" Subject: Re: [PATCH v8 12/14] mm: zswap: Simplify acomp_ctx resource allocation/deletion and mutex lock usage. Message-ID: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Migadu-Flow: FLOW_OUT On Tue, Mar 18, 2025 at 09:09:05PM +0000, Sridhar, Kanchana P wrote: [..] > > > > > > > > > > The only other fallback solution in lieu of the proposed simplification > > that > > > > > I can think of is to keep the lifespan of these resources from pool > > creation > > > > > to deletion, using the CPU hotplug code. Although, it is not totally > > clear > > > > > to me if there is potential for deadlock during pool transitions, as > > noted > > > > above. > > > > > > > > I am not sure what's the deadlock scenario you're worried about, please > > > > clarify. > > > > > > My apologies: I was referring to triggering direct reclaim during pool > > creation, > > > which could, in theory, run into a scenario where the pool switching would > > > have to wait for reclaim to free up enough memory for the acomp_ctx > > > resources allocation: this could cause the system to hang, but not a > > deadlock. > > > This can happen even today, hence trying to see if a better design is > > possible. > > > > I think the concern here is unfounded. We shouldn't care about the > > performance of zswap compressor switching, especially under memory > > pressure. A lot of things will slow down under memory pressure, and > > compressor switching should be the least of our concerns. > > Sounds good. It then appears that making the per-cpu acomp_ctx resources' > lifetime track that of the zswap_pool, is the way to go. These resources > will be allocated as per the requirements of the compressor, i.e., zswap_pool, > and will persist through CPU online/offline transitions through the hotplug > interface. If this plan is acceptable, it appears that acomp_ctx_get_cpu_lock() > and acomp_ctx_put_unlock() can be replaced with mutex_lock()/unlock() in > zswap_[de]compress()? I will incorporate these changes in v9 if this sounds Ok. Sounds good to me. Thanks!