From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from lgeamrelo12.lge.com (lgeamrelo12.lge.com [156.147.23.52]) (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 EB4C32F6920 for ; Tue, 11 Aug 2026 13:23:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=156.147.23.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786454634; cv=none; b=mhSO9+N8NKW2BbQuuqQbg2STcDnGBT8r6iZQtH0BT2py2x1oKMLgAOGQDQV3+PqBNUFff3GRacDB5jWR++D/7Q4cg/317Gv2UOR5hDjnR9IvoZpvd/2n11HAuudbUtNQmCv4X4WHvdEKUdJFKJd4/txS824d794oBn+K51tozRk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786454634; c=relaxed/simple; bh=RMFRRqCzqfjnqrkNcjFexTBQKMPCk2gZIl3J9QEVhlA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=nCP0TOs5LpifVBxsnavRaHszlhhf4XLXCmCYc0tLzqDqT5y72ruE5/1xHvrUgT6txR39Pg/jiOSOtnVPcDNQn2yCKpRbhvl7xfx8ECeGx79aUvYuJBN6Y60JirQ01nIXJAD3aWoXPrt/r8IiClJ51fY5LK2nQwrrS5csiNCYwN0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=lge.com; spf=pass smtp.mailfrom=lge.com; arc=none smtp.client-ip=156.147.23.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=lge.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=lge.com Received: from unknown (HELO lgemrelse6q.lge.com) (156.147.1.121) by 156.147.23.52 with ESMTP; 11 Aug 2026 22:23:45 +0900 X-Original-SENDERIP: 156.147.1.121 X-Original-MAILFROM: youngjun.park@lge.com Received: from unknown (HELO yjaykim-PowerEdge-T330) (10.177.112.156) by 156.147.1.121 with ESMTP; 11 Aug 2026 22:23:45 +0900 X-Original-SENDERIP: 10.177.112.156 X-Original-MAILFROM: youngjun.park@lge.com Date: Tue, 11 Aug 2026 22:23:45 +0900 From: Youngjun Park To: Andrew Morton 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: References: <20260809144559.2104856-1-youngjun.park@lge.com> <20260810151642.871c9b5d9cd56f6efd45ff90@linux-foundation.org> 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: <20260810151642.871c9b5d9cd56f6efd45ff90@linux-foundation.org> On Mon, Aug 10, 2026 at 03:16:42PM -0700, Andrew Morton wrote: > 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 False positive. But, more fix needed by different reason. The walk the AI review points at is the large folio swapin path, where swapin pulls the neighboring slots in together with the faulting one. A bad slot cannot show up there. The range comes from present swap entries in the page table or the shmem mapping, so every slot in it was handed out by the allocator, and bad slots never are. The spot is still worth fixing. The range is not pinned between the locked check and the locked recheck, a concurrent free can empty a slot in it, and hibernation can claim the emptied slot from the allocator. The raw count read in the walk then trips the countable assertion under DEBUG_VM, even though the -EBUSY fallback handles the changed range fine. I sent v3 with the shadow requirement of patch 2 extended to that routine. Thanks! Youngjun