From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 EC19F1EE7C6 for ; Mon, 10 Aug 2026 22:16:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786400205; cv=none; b=KMPcUB8JE8nKTffCjggVL9H77pkvRFYU6EyaTdISqELoJ1oa/9v8aSOK+coXNF5E1ti+MLh4D18J+iTa4d6VmRmNNy3zVXH77qjiHob7kQ4okAS9K2Xj1WWIP14Jf8lShFa9kNIdJHtwYwrh4n1DUCX924PYqho7ECVPdDQX4T8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786400205; c=relaxed/simple; bh=QbZcIlCN5lPKtAACcA59ej0XUwyBBMKLKbW3p5Vj+Xw=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=kM6Q448vCr5zSfiJZXebg2V7MwgEP/2EvfEYN17mG9N5ZEWjuZ3zevNENoXtpa2lzZHGb91HBdU4IvJ9iTEwodAHCH9BVVvPAvCL2TpksfDdL0lWoB5FsziyiaymZhrcKvIbEvmUsGAWvHtcgcD22k0HFNgj7jB0Ag6hcmTX/CU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=i1O0I4Om; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="i1O0I4Om" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1F4851F000E9; Mon, 10 Aug 2026 22:16:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1786400203; bh=mfPD0y6Vyt+IkmC/2uT8T0rxNYXqQ/3bdmJoo9LdWMc=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=i1O0I4OmaU6cNpeU3DYLQ1h0VJZsd7MRb+DfGkbegHB220v8Lf83Rx2Odj8Kz/J/G y3RoP/IvsG1dEIEpQru62AeaFtI13q/CB6CNf4P7hwrpSeKGeaiVvwObhy9qclXnbx NgIqV1bWxe15b6VY03TjWnKyH5ohHl3P0sGHV2Mg= Date: Mon, 10 Aug 2026 15:16:42 -0700 From: Andrew Morton To: Youngjun Park Cc: Chris Li , Kairui Song , Kemeng Shi , Nhat Pham , Baoquan He , Barry Song , Jianyue Wu , her0gyugyu@gmail.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 0/4] mm, swap: keep hibernation swap slots out of the swap cache Message-Id: <20260810151642.871c9b5d9cd56f6efd45ff90@linux-foundation.org> In-Reply-To: <20260809144559.2104856-1-youngjun.park@lge.com> References: <20260809144559.2104856-1-youngjun.park@lge.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) 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-Transfer-Encoding: 7bit On Sun, 9 Aug 2026 23:45:55 +0900 Youngjun Park wrote: > Cluster readahead walks a raw page_cluster sized window of offsets around > the faulting entry. A hibernation slot looks like an ordinary swapped out > slot, so __swap_cache_add_check() lets it in. Readahead reads the offset > off the device into a folio and puts that folio in the swap table where the > hibernation entry was. This has been possible for a long time. It only > wasted a folio and a read. > > That changed with commit 0d6af9bcf383 ("mm, swap: use the swap table to > track the swap count"). A slot with a folio in the swap cache should only > be freed when the folio leaves the cache. swap_put_entries_cluster() still > does that, but the conversion left swap_free_hibernation_slot() freeing the > slot either way. Nothing points at the folio after that, and when reclaim > drops it later, it writes to the table entry at the old offset, which > someone else may own by then. > > Patch 1 is the fix and the only patch for stable. It puts the missing > check back, so both free paths behave the same again. > > The rest removes the cause. Readahead should not touch these slots at all, > so patch 2 lets only swapped out slots into the swap cache, which also puts > back a bad slot check the swap cache rework dropped, patch 3 gives > hibernation slots their own swap table entry type so that check covers them > too, and patch 4 drops the guard and the reclaim, since no such folio can > exist any more. Thanks. It's late and review is only partial. I'd prefer to wait until after 7.3-rc1 to process this series. AI review suggests that more such fixing is needed in __swap_cache_add_check(): https://sashiko.dev/#/patchset/20260809144559.2104856-1-youngjun.park@lge.com