From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qv1-f44.google.com (mail-qv1-f44.google.com [209.85.219.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B77BB334C1C for ; Thu, 18 Dec 2025 13:02:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766062939; cv=none; b=SuY61UOLGlOPegNTIqzLtth3cLkIxR2wX5zh97mb/BULb8E51EhKhRllngy5F+M6FLuRWf7R1ISSZFKuYFRbEsRWoWNpeTfv/LXZQQ0m8gTPpDScgPRTsMsJYQWrFsRTPqh3dtpWwDfyE0VHRVx/4NTMKg9ZGsSzhZYU8Qs2AJQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766062939; c=relaxed/simple; bh=xbOBVQ86yHg6Sin/KsmT4bgAd9KDR20J3UX8UzDsL+Y=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=KpbvMuRL1AtRsfMswDPapeATg9QvtsMaCViIZCLkwQ+H3InEeZe04dFYhlAKuWKQ3HLzjE7c4wlxj6rZPS/bfPSoXO0A1DexJznuCRW+QWqGdySNCmLv8Jva2vXLVjR8aWzyvA+FYpK8KC4biQOUKrK56uiga1J0Z7lxphH72wY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cmpxchg.org; spf=pass smtp.mailfrom=cmpxchg.org; dkim=pass (2048-bit key) header.d=cmpxchg.org header.i=@cmpxchg.org header.b=j9gsOaft; arc=none smtp.client-ip=209.85.219.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cmpxchg.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cmpxchg.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cmpxchg.org header.i=@cmpxchg.org header.b="j9gsOaft" Received: by mail-qv1-f44.google.com with SMTP id 6a1803df08f44-88a3d2f3299so7348606d6.2 for ; Thu, 18 Dec 2025 05:02:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg.org; s=google; t=1766062936; x=1766667736; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=eoMgDKwUqiYQLz/exZipbw/eWEAMXUec9gMtKJ9jU2U=; b=j9gsOaftEUeYRDFefqXzAHNmcjwF5qt39985j3iSSuicnTQpHPkvZFg2qq4q0uvaiK o+yg8UQ/4q4h0NLaa8faOnLbrXnNTLHGZxk0FB56riq/hEMK+0sOOU6sNGPzXJj7f9iv daoC0incAEkBA3LnHl5UvZzSl1CDYJ8Ea676t7rU+zJHVdt2XV0MqsNRNCx464VDUFqF YRi/PWOu24wukZWksBvLVFDEqMQqEN2CSVAqbHE0ovWeVUbhRpH4sVLJvktlwbWkK6Ry cj8GNH6LeuBdbCudRcw3opPHCoqP5z37Mn+XGzRWF3JdyO878Cyaxu2EhSmVUp5iqMFz 1p0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766062936; x=1766667736; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eoMgDKwUqiYQLz/exZipbw/eWEAMXUec9gMtKJ9jU2U=; b=GopDV8HjN76RFEEViVRjqiLjDAzxkQnQx/Tp7L+4yB7LFAKmDf6dyDZC1x3G/cUNFH aNJgGUIfyfApm1S/VWbCwDBOavyb7vugEtL4ksw/eb/wAXcl1lr03L0V1FzM8faLHrdL gQzA86msZDO2dE97C5PyzeiZZjnfaOTTopxySjRXDhfFKkFYkHxf+XyovTRXA+4Enw8+ bvgddV0/sVBogJfK7qTTVKNhDVmfS7+yYs6HkmdykLwOx0DOt/7Ozt+x29DnYnReaR87 bXa6k/n5zguTfRodGv0l+3doT6cX7ikzjDlH93fsTVVX4u0O83kLPsP2yd3Vy1EdEgZa evgw== X-Forwarded-Encrypted: i=1; AJvYcCWBHkYTujFPGdTHYUP9uzhXvfpkhtS8H9lJjbTYtANe/S4biDDiNWVlYF8wDFRN5JsAJvTEgnXK7TOWvX8=@vger.kernel.org X-Gm-Message-State: AOJu0YyMkkge7zjAWCketsn/whxDd8sEZTbhrWzG7CKtp1ZBZyBFgLPe ZO8ogIgc4gdRXF9JSaU8MpxlLCp1JKyMYwgKqrqB+nsi1mUjXPUn4asUiuO1p+GPw4k= X-Gm-Gg: AY/fxX6Z4sg3eiXD+16Fe6Ne11WQmJ520bR/Wd+5QtKOiNkF7Nwg7blAeLJwJ95BpWu E34Rwrk9vOoo4Cg+walfJjk0dFQe3zSus0j6ISYISNb4MTKP1QUfGJQyeQeDZIpR5oTxrFL/Wu1 feR8WzS9lEI5n/d1hgbVwoBdAkIORGEFuPRDsv0ChvF1+Dn3iqnp74QKthn6/5Z+znpkkIvZePw GobMnduQYyk4k3AKbEiWWX2Sd1tRzmk9HyRQ2cltK4N8AJVDB1oHLxu2uArkGuCBNgV3KWQ9Znw AXbDbmnivb93AW9rdPhPQiampZT6UQSFIV7gmYAA5LuMmcNxv1NVjqXKZ0vCfTgMA1Fq4G5KlHC BobGZczkU+In1AKsNLdArPDZs5k1liVQ4fJrjaCUZDrmazAsE3W5v9DFOHgysXedtOZOUDNlqNn IBl+NmbX264w== X-Google-Smtp-Source: AGHT+IHCmTOM62jrKF5e0i3ecD3lTx7BUsHXoHpv+YPi0JwtT9sblxf5OQ9g95krK7LMiJWfCtz3PQ== X-Received: by 2002:a05:6214:2b87:b0:86b:9167:b0e9 with SMTP id 6a1803df08f44-8887feff208mr316576036d6.4.1766062936323; Thu, 18 Dec 2025 05:02:16 -0800 (PST) Received: from localhost ([2603:7000:c01:2716:929a:4aff:fe16:c778]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-88c5e15be44sm16360706d6.20.2025.12.18.05.02.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Dec 2025 05:02:15 -0800 (PST) Date: Thu, 18 Dec 2025 08:02:14 -0500 From: Johannes Weiner To: Qi Zheng Cc: hughd@google.com, mhocko@suse.com, roman.gushchin@linux.dev, shakeel.butt@linux.dev, muchun.song@linux.dev, david@kernel.org, lorenzo.stoakes@oracle.com, ziy@nvidia.com, harry.yoo@oracle.com, imran.f.khan@oracle.com, kamalesh.babulal@oracle.com, axelrasmussen@google.com, yuanchu@google.com, weixugc@google.com, chenridong@huaweicloud.com, mkoutny@suse.com, akpm@linux-foundation.org, hamzamahfooz@linux.microsoft.com, apais@linux.microsoft.com, lance.yang@linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, Muchun Song , Nhat Pham , Chengming Zhou , Qi Zheng Subject: Re: [PATCH v2 20/28] mm: zswap: prevent lruvec release in zswap_folio_swapin() Message-ID: References: <8aee44f5-11ec-410a-9b45-5cb224e9e23a@linux.dev> 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: <8aee44f5-11ec-410a-9b45-5cb224e9e23a@linux.dev> On Thu, Dec 18, 2025 at 03:09:04PM +0800, Qi Zheng wrote: > > > On 12/18/25 6:33 AM, Johannes Weiner wrote: > > On Wed, Dec 17, 2025 at 03:27:44PM +0800, Qi Zheng wrote: > >> From: Muchun Song > >> > >> In the near future, a folio will no longer pin its corresponding > >> memory cgroup. So an lruvec returned by folio_lruvec() could be > >> released without the rcu read lock or a reference to its memory > >> cgroup. > >> > >> In the current patch, the rcu read lock is employed to safeguard > >> against the release of the lruvec in zswap_folio_swapin(). > >> > >> This serves as a preparatory measure for the reparenting of the > >> LRU pages. > >> > >> Signed-off-by: Muchun Song > >> Acked-by: Nhat Pham > >> Reviewed-by: Chengming Zhou > >> Signed-off-by: Qi Zheng > >> Reviewed-by: Harry Yoo > > > > Acked-by: Johannes Weiner > > Thanks! > > > > > Btw, it would make the series shorter if you combined the changes to > > workingset.c, zswap.c etc. It should still be easy to review as long > > as you just stick to making folio_memcg(), folio_lruvec() calls safe. > > I prefer to separate them. For example, as you pointed out, in some > places, it would be more appropriate to switch to use > get_mem_cgroup_from_folio() to handle it. Separating them also makes > subsequent updates and iterations easier. Ok, that works for me!