From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from lgeamrelo03.lge.com (lgeamrelo03.lge.com [156.147.51.102]) (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 E28EC33D4EC for ; Mon, 9 Mar 2026 08:46:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=156.147.51.102 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773045985; cv=none; b=gDaDEQ4PCIVnQ3IPrzKxGjD5V2gG7TVNpaIZa6BTUQjxgHXclGP+XMfTP8NEMAdtZuo1ycBhBa53qjcRiBnSGSRax7cO/4yjqbN2RBUg6rZ7ERuVD0Bd/pP0MORAbvlJr/P3+BQGjqroEzMF+gqbjYhGKn768FhEeqHLqwCQBUE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773045985; c=relaxed/simple; bh=RGteJiCZQnYmiDR5uFBbpaaRPvGtsAvzAz52A7XRfbE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=qtsgjNBW3OCIaIdv6uclhKZLo3qu2JyaJWP5aQoPqOKViYF5D2MOLEpD5qN3xZNMtCXEANcmPqZdBkyoTMJhLuI3BiCu6zMjDoB4Y1HsHyiK/vsG2am7NWHBvSfzHhmm+Lv/WMUHi+AkW6FgpMGu0oEx13sZuOn3Zm6S6lI8vuQ= 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.51.102 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 yjaykim-PowerEdge-T330) (10.177.112.156) by 156.147.51.102 with ESMTP; 9 Mar 2026 17:46:21 +0900 X-Original-SENDERIP: 10.177.112.156 X-Original-MAILFROM: youngjun.park@lge.com Date: Mon, 9 Mar 2026 17:46:21 +0900 From: YoungJun Park To: Hui Zhu Cc: Andrew Morton , Chris Li , Kairui Song , Kemeng Shi , Nhat Pham , Baoquan He , Barry Song , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Hui Zhu Subject: Re: [PATCH v2 1/2] mm/swap: Add VM_WARN_ON to isolate_lock_cluster() Message-ID: References: <25c1be6b4a54a69d4b57189fd84c7502c4412d7a.1773040982.git.zhuhui@kylinos.cn> 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: <25c1be6b4a54a69d4b57189fd84c7502c4412d7a.1773040982.git.zhuhui@kylinos.cn> On Mon, Mar 09, 2026 at 04:05:41PM +0800, Hui Zhu wrote: > From: Hui Zhu > > swap_cluster_alloc_table() assumes that the caller holds the following > locks: > ci->lock > percpu_swap_cluster.lock > si->global_cluster_lock (required for non-SWP_SOLIDSTATE devices) > > There are five call paths leading to swap_cluster_alloc_table(): > swap_alloc_hibernation_slot->cluster_alloc_swap_entry > ->alloc_swap_scan_list->isolate_lock_cluster->swap_cluster_alloc_table > > swap_alloc_slow->cluster_alloc_swap_entry->alloc_swap_scan_list > ->isolate_lock_cluster->swap_cluster_alloc_table > > swap_alloc_hibernation_slot->cluster_alloc_swap_entry > ->swap_reclaim_full_clusters->isolate_lock_cluster > ->swap_cluster_alloc_table > > swap_alloc_slow->cluster_alloc_swap_entry->swap_reclaim_full_clusters > ->isolate_lock_cluster->swap_cluster_alloc_table > > swap_reclaim_work->swap_reclaim_full_clusters->isolate_lock_cluster > ->swap_cluster_alloc_table > > Other paths correctly acquire the necessary locks before calling > swap_cluster_alloc_table(). > But swap_reclaim_work() doesn't need do that because > swap_reclaim_full_clusters() just isolate si->full_clusters that > the tables of it must be allocated. > Then isolate_lock_cluster() that is called by > swap_reclaim_full_clusters() will never call swap_cluster_alloc_table(). > > This patch add a VM_WARN_ON to warning if a fill cluster will be handle > by swap_cluster_alloc_table() > > Signed-off-by: Hui Zhu > --- > mm/swapfile.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/mm/swapfile.c b/mm/swapfile.c > index 94af29d1de88..3fc2eb30c187 100644 > --- a/mm/swapfile.c > +++ b/mm/swapfile.c > @@ -596,6 +596,9 @@ static struct swap_cluster_info *isolate_lock_cluster( > spin_unlock(&si->lock); > > if (found && !cluster_table_is_alloced(found)) { > + /* Table of full cluster must be allocated. */ > + VM_WARN_ON(ci->flags == CLUSTER_FLAG_FULL); As Kairui suggested, Would a VM_WARN to check if `list == si->free_cluster` be good? Or perhaps `ci->flags != CLUSTER_FLAG_FREE`? This check only cares about CLUSTER_FLAG_FULL, so it might be better to cover other flags except the free flag. Thanks! Youngjun Park