From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from lgeamrelo07.lge.com (lgeamrelo07.lge.com [156.147.51.103]) (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 349FC322DB7 for ; Thu, 29 Jan 2026 07:20:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=156.147.51.103 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769671216; cv=none; b=kHOYwTMg+FPNfVwAQdDqJc6RTsyVEdBA31yFLHQIXFXNrlGazImccyr2TaxL0kkdF5iyUFal6IvQghScZRQnvDwCu/wcxza0BoiK+B1rkGZHqEh08ulC9QQeK51diMZIpUoraeFNEqRLMUrYjTmFgxOxjgoiat67ZHogk4G2ZZc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769671216; c=relaxed/simple; bh=EZiWTvblPriT+t5IQ0NcqokttsnJomGn5KUvU8eafpI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=mJELODOhNZmR+PCHOkaToI2+B4s+RDhB23kc8yOC/X7z7Ce7ZpEDOUU0G654Xs3+ieDuZL3KOoC+9v/0lvSSY2XtnK6zJi3r2032lDBsdCvdgFppGOLzM8TWIpvE2r+jIJ0Ap8Nkjo7zGTWyJXG9MGYv+MteQAwiRJyDUWs0itk= 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.103 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.103 with ESMTP; 29 Jan 2026 16:05:09 +0900 X-Original-SENDERIP: 10.177.112.156 X-Original-MAILFROM: youngjun.park@lge.com Date: Thu, 29 Jan 2026 16:05:07 +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 09/12] mm, swap: use the swap table to track the swap count Message-ID: References: <20260128-swap-table-p3-v2-0-fe0b67ef0215@tencent.com> <20260128-swap-table-p3-v2-9-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-9-fe0b67ef0215@tencent.com> On Wed, Jan 28, 2026 at 05:28:33PM +0800, Kairui Song wrote: > From: Kairui Song > +/** > + * swap_dup_entries_cluster: Increase the swap count of slots within one cluster. > + * @si: The swap device. > + * @offset: start offset of slots. > + * @nr: number of slots. > + * > + * Context: The specified slots must be pinned by existing swap count or swap > + * cache reference, so they won't be released until this helper returns. > + * Return: 0 on success. -ENOMEM if the swap count maxed out (SWP_TB_COUNT_MAX) > + * and failed to allocate an extended table. > + */ > +static int swap_dup_entries_cluster(struct swap_info_struct *si, > + pgoff_t offset, int nr) > +{ > + int err; > + struct swap_cluster_info *ci; > + unsigned int ci_start, ci_off, ci_end; > + > + ci_start = offset % SWAPFILE_CLUSTER; > + ci_end = ci_start + nr; > + ci_off = ci_start; > + ci = swap_cluster_lock(si, offset); > +restart: > + do { > + err = __swap_cluster_dup_entry(ci, ci_off); > + if (unlikely(err)) { > + if (err == -ENOMEM) { > + spin_unlock(&ci->lock); > + err = swap_extend_table_alloc(si, ci, GFP_ATOMIC); Hello Kairui Just a minor nit. If the extended table already exists but the allocation fails, the operation currently terminates as a failure. It seems swap_extend_table_alloc returns failure even if it holds an extended table. It seems extend_table created while ungrabbing ci->lock. If my assumtion is right, How about adjusting the error handling in swap_extend_table_alloc, or perhaps implementing a non-locking __swap_extend_table_alloc version? (I think the latter is better. it avoids unneeded lock - unlock - lock sequence.) Thanks Youngjun Park