From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-171.mta1.migadu.com (mta1.migadu.com [37.59.57.117]) (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 86ADD38B7A5 for ; Fri, 7 Aug 2026 08:42:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=37.59.57.117 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786092154; cv=none; b=mkp8saMU9I3l4s99/n0XD1Wj8X5moSRht7CbQzKNAHd+hPje9iUx8fWlpY4kPO1fQDpVsna30Ukg+UG1kcn/CzuLS5qdSBf/9AyHmAzEoDk65yTc0p0V2is+Mw0p7lcp0Ci5WTnwtPZ17qiV5EQ2w87ykYYDUbF9HhyBZdArQAM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786092154; c=relaxed/simple; bh=8a101iy7jAeBp4Dy1gmtbm+AM19rwp3lvFulG3CKDp8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=IZj5QWxTja4dwdu02Rpht2vgDU35UXUjiXJPYfzISJi87cQWhLxeCOhQRqz8N3tcZTIhQm7gK9wf83cQCQIiuGTjo3XGv6ZCNCWhPcgmfHILqyiszuYNrGT1kdsHAb5Pie2qt2iFHR/PZrS6bvzB50XnxhA5n7QTKZ8+/7wns8E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=vjCnZPNk; arc=none smtp.client-ip=37.59.57.117 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="vjCnZPNk" Date: Fri, 7 Aug 2026 16:42:22 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1786092149; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=w+S9uhnLei8sckIfJwmMomkCOBcS3Ge0tU7iysiifkA=; b=vjCnZPNk25axIWyhNnN8qu4Ejr0GgXjiheyWhBE47o5583DSw0Yoy7J+Tganu8JSwSjT+7 FKKISIb5OX8A3PWNd/+sx/67GFt7Iva9vYO831lZls+OY9bGsXYU62gmLPmUTGGTfA+SP/ R9MejnUY1HM70qjBHsI69mzD2XKLk10= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Baoquan He To: Youngjun Park Cc: Andrew Morton , Chris Li , Kairui Song , Kemeng Shi , Nhat Pham , Barry Song , her0gyugyu@gmail.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 0/2] mm/swap: skip empty clusters in the swapoff scan Message-ID: References: <20260806193228.458685-1-youngjun.park@lge.com> <20260806130655.420e16bf621b580cc5f08040@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: X-Migadu-Flow: FLOW_OUT On 08/07/26 at 03:41pm, Youngjun Park wrote: > On Thu, Aug 06, 2026 at 01:06:55PM -0700, Andrew Morton wrote: > > On Fri, 7 Aug 2026 04:32:26 +0900 Youngjun Park wrote: > > > > > find_next_to_unuse() walks a swap device one offset at a time. Slot > > > state now lives in a per cluster swap table, so patch 2 dismisses an > > > empty cluster with one counter read instead of SWAPFILE_CLUSTER table > > > reads. > > > > Thanks. > > > > Can you help us understand how significant this change is for users? > > If "not very" then I'd prefer to defer consideraton of the series until > > after 7.3-rc1. > > Hello Andrew > > "Not very" in the common case, though there is a case where the win is clear. > No bug and no user report. > > For now I would rather defer to after 7.3-rc1. > > And for your reference, here is the details. > > Every swapoff does a little less work now, because the scan steps over an > unused area one cluster at a time. > But IMHO most of the swapoff time goes to unuse_mm() and to reading the pages back in. > > The gain shows on a large swap device that is almost empty, when the last > pages still in use are near the end of it. The scan has to walk up to > them, and today it looks at every slot on the way. Now the empty clusters > in between are skipped in one step. > > I have no measured times yet, since that case has to be set up on purpose. > What I did is the arithmetic for the case that skips best, > For example 1T of swap with 256M slots with SWAPFILE_CLUSTER = 512 > and everything free but the far end: > > - today: 256M table reads > - with the skip: 512K counter reads Maybe just use time to measure swapoff time consuming, just like below as I did on a kvm guest, I guess a bare metal machine with larger system ram could be more obvious? root@fedora:~# free -h total used free shared buff/cache available Mem: 3.8Gi 181Mi 3.6Gi 924Ki 72Mi 3.7Gi Swap: 2.0Gi 18Mi 2.0Gi root@fedora:~# time swapoff /dev/vdb real 0m0.101s user 0m0.001s sys 0m0.017s root@fedora:~# swapon /dev/vdb root@fedora:~# time swapoff /dev/vdb real 0m0.014s user 0m0.003s sys 0m0.001s Not sure if Andrew is asking for this. > > That should be around half a second of scan saved. Yeah, a concrete number is shown.