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 B68CE37F72A for ; Thu, 29 Jan 2026 08:36:01 +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=1769675770; cv=none; b=fmuB422L2+I4LxsZOQbukFDksCpwvvooPWqJuuNQXDgDOCIME5Zbgl+sl48OFOaWaM9NHtG57/eyfTdyYKprCwC8GHKFA1oV5byVO/r4RrENBSCqAJ0kRCryAynH13eOYumbjdDSwSrxDNq5a44E5P5BkhOjue+KE04NaTGAPao= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769675770; c=relaxed/simple; bh=RJnWcBuUbqMXDE1KDEFeTaybm335HkFHdhuUfEpUOi4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=aHJ1Nso7vZ8xV1N7OLRVitmq5knMf8bZCbER843/d2aGxlyQcrw8K5KKCH61G1ngwlTwrpn28BUqPuwAFZfvRVb5HfOJEJO9TiJBJE3MCgJjattQPFf0aRjRsJI3OR2aBe56K0ZrUjwVVZXPtZZ96raoLEe2RHNLKjo6UOkOQxg= 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; 29 Jan 2026 17:35:58 +0900 X-Original-SENDERIP: 10.177.112.156 X-Original-MAILFROM: youngjun.park@lge.com Date: Thu, 29 Jan 2026 17:35:58 +0900 From: YoungJun Park To: Kairui Song Cc: linux-mm@kvack.org, Andrew Morton , Kemeng Shi , Nhat Pham , Baoquan He , Barry Song , Johannes Weiner , David Hildenbrand , Lorenzo Stoakes , linux-kernel@vger.kernel.org, Chris Li , Kairui Song Subject: Re: [PATCH v2 02/12] mm, swap: clean up swapon process and locking Message-ID: References: <20260128-swap-table-p3-v2-0-fe0b67ef0215@tencent.com> <20260128-swap-table-p3-v2-2-fe0b67ef0215@tencent.com> 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: <20260128-swap-table-p3-v2-2-fe0b67ef0215@tencent.com> On Wed, Jan 28, 2026 at 05:28:26PM +0800, Kairui Song wrote: > From: Kairui Song > > Slightly clean up the swapon process. Add comments about what swap_lock > protects, introduce and rename helpers that wrap swap_map and > cluster_info setup, and do it outside of the swap_lock lock. > > This lock protection is not needed for swap_map and cluster_info setup > because all swap users must either hold the percpu ref or hold a stable > allocated swap entry (e.g., locking a folio in the swap cache) before > accessing. So before the swap device is exposed by enable_swap_info, > nothing would use the swap device's map or cluster. > > So we are safe to allocate and set up swap data freely first, then > expose the swap device and set the SWP_WRITEOK flag. > > Signed-off-by: Kairui Song > --- > mm/swapfile.c | 87 ++++++++++++++++++++++++++++++++--------------------------- > 1 file changed, 48 insertions(+), 39 deletions(-) > > diff --git a/mm/swapfile.c b/mm/swapfile.c > index 521f7713a7c3..53ce222c3aba 100644 > --- a/mm/swapfile.c > +++ b/mm/swapfile.c > @@ -65,6 +65,13 @@ static void move_cluster(struct swap_info_struct *si, > struct swap_cluster_info *ci, struct list_head *list, > enum swap_cluster_flags new_flags); > > +/* > + * Protects the swap_info array, and the SWP_USED flag. swap_info contains > + * lazily allocated & freed swap device info struts, and SWP_USED indicates Nit. Typo: 'struts' -> 'struct'. Also, using 'swap_info_struct' instead of "swap device info" would be better?? Thanks Youngjun Park