From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from lgeamrelo13.lge.com (lgeamrelo13.lge.com [156.147.23.53]) (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 CBA243876C5 for ; Wed, 5 Aug 2026 14:30:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=156.147.23.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785940218; cv=none; b=DzFAELPwq0hXCCcYV8YorYqVETGOchkbobxJpqIkBUh6Esn8XTXWDK4xDDS546+zXqGsAEuIXfUFvYICRmP/Ni/BcHVr6OIa5/C06yAJqkz1MQY3Sc0C8pfgGJlzYsTNiFu4iKfFfxTt7YaATunE1Oivx7KGzdEQ5GX/KFMSC1U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785940218; c=relaxed/simple; bh=0dByJ4mdRK98+hbf71KELRBb/RRw110jIk7Hy+YOi60=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=kqUcqjI12cWPaebQY1clAHzE2gxNoHWr2NAQpvvQ4tysA3RhiGBR/UMmZV41jKaJKtMLhiwvM/wKP4vLBXSESfaRm7HO/Vi6CBFXA4j+a9HYlsClmyq7juq21qT3UVp29To40ZLtgoGbNRdqDjL0F2yefXj327aUgUvwt/pFnVk= 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.53 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 lgemrelse7q.lge.com) (156.147.1.151) by 156.147.23.53 with ESMTP; 5 Aug 2026 23:23:21 +0900 X-Original-SENDERIP: 156.147.1.151 X-Original-MAILFROM: youngjun.park@lge.com Received: from unknown (HELO yjaykim-PowerEdge-T330) (10.177.112.156) by 156.147.1.151 with ESMTP; 5 Aug 2026 23:23:21 +0900 X-Original-SENDERIP: 10.177.112.156 X-Original-MAILFROM: youngjun.park@lge.com Date: Wed, 5 Aug 2026 23:23:21 +0900 From: Youngjun Park To: Kairui Song Cc: Youngjun Park , Andrew Morton , Chris Li , Kemeng Shi , Nhat Pham , Baoquan He , Barry Song , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] mm/swap: scan by cluster in find_next_to_unuse() Message-ID: References: <20260728155907.391820-1-youngjun.park@lge.com> <20260728155907.391820-3-youngjun.park@lge.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: ... Hello Kairui Thanks for the review. > > - for (i = prev + 1; i < si->max; i++) { > > - swp_tb = swap_table_get(__swap_offset_to_cluster(si, i), > > - i % SWAPFILE_CLUSTER); > > - if (!swp_tb_is_null(swp_tb) && !swp_tb_is_bad(swp_tb)) > > - break; > > - if ((i % LATENCY_LIMIT) == 0) > > + i = prev + 1; > > + while (i < si->max) { > > + ci = __swap_offset_to_cluster(si, i); > > + ci_off = i % SWAPFILE_CLUSTER; > > + end = min(si->max, i - ci_off + SWAPFILE_CLUSTER); > > Do we need the min here? Table size is always SWAPFILE_CLUSTER aligned. Yes. I remove it. > > + > > + /* > > + * An empty cluster has no slot in use, so skip it whole. > > + * A slot is uncounted only after its folio left the swap > > + * cache, so there is nothing here for try_to_unuse() to act on. > > + */ > > + if (cluster_is_empty(ci)) { > > Hmm, it's not wrong, but this is indeed the only user calling > cluster_is_empty without holding a lock, and not in initilization > path, perhaps we should at least make it READ_ONCE? Maybe KCSAN will > not be happy, I guess? Just nitpick. Right it is better to use READ_ONCE. I also applied it and submited v2! Youngjun