From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 20394C02192 for ; Thu, 6 Feb 2025 01:41:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 244DC6B007B; Wed, 5 Feb 2025 20:41:17 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1F4356B0082; Wed, 5 Feb 2025 20:41:17 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0C5DD6B0083; Wed, 5 Feb 2025 20:41:17 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id E49656B007B for ; Wed, 5 Feb 2025 20:41:16 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 036B1475E5 for ; Thu, 6 Feb 2025 01:41:15 +0000 (UTC) X-FDA: 83087816952.02.B5407C0 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf22.hostedemail.com (Postfix) with ESMTP id F0610C000A for ; Thu, 6 Feb 2025 01:41:13 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=CFbi4n6+; spf=pass (imf22.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1738806074; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=EM+fv56TZqxZiQy5TwGvsOnPrwrS/LPQ6Rsu0jcBzU4=; b=tlmubpUKouG/GUZ5tKKDvmKbxanulB0JiJxQBZINjz8VdmEM7DTGlA1E6OkaCB+un7iQ7k 0ZeKd9IUrvXFJV4LVutzeZ0SiuajD3Y78jZK0/Us4c0Tn/Rn8EjF+S94vxWnyJkilpMyk1 y9cMeGk7UrXS25h9GYUIJ5+EQFY2NzI= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=CFbi4n6+; spf=pass (imf22.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1738806074; a=rsa-sha256; cv=none; b=V+hBQXl2rvbZ6XMgAvcBCejZ4ogjeJLihgXb1pxo9HgabH6MgH6amqxHc92+I7To//YmcL Q2nUmp6c3v8AlKY2tdahdhkCnQlLzhedxTCEmeIPqoRBqe/x0WbuVVAZ+4Up7Ha0aEiV+T 3mFhOwS2m6StQxZ0tHT3JR1q7TXTtUc= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1738806073; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EM+fv56TZqxZiQy5TwGvsOnPrwrS/LPQ6Rsu0jcBzU4=; b=CFbi4n6+KQ3J1msgtmtPi3/wZoeGd3Wg8LNcthOVVr2hiVDQ+zh5jTK4UYBO/4izQ+3kSM tbQ770EbbIzJiIL2UI4R+c795pASDLSAA8HpJ+owHpfGBphgr0obYIoxx9O9PBRwKLx5e/ Ph6vnEy09NkV9BZfqagbz8gVfLTfyn0= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-350-F5z-XJ0TNa-vffyGzskQdw-1; Wed, 05 Feb 2025 20:41:05 -0500 X-MC-Unique: F5z-XJ0TNa-vffyGzskQdw-1 X-Mimecast-MFC-AGG-ID: F5z-XJ0TNa-vffyGzskQdw Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id EBC601956088; Thu, 6 Feb 2025 01:41:03 +0000 (UTC) Received: from localhost (unknown [10.72.112.43]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 92A081955BD4; Thu, 6 Feb 2025 01:41:02 +0000 (UTC) Date: Thu, 6 Feb 2025 09:40:57 +0800 From: Baoquan He To: Kairui Song Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org, chrisl@kernel.org Subject: Re: [PATCH 04/12] mm/swap: skip scanning cluster range if it's empty cluster Message-ID: References: <20250205092721.9395-1-bhe@redhat.com> <20250205092721.9395-5-bhe@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Rspamd-Queue-Id: F0610C000A X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: ugm3jr9h6k9a4zf3hoe9udzr4dzybnoq X-HE-Tag: 1738806073-362795 X-HE-Meta: U2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cvQyqIWL8RD0Z8qBG9i61gJ8fQslErZrq782Xc3xXiYqF1QqjnnsjuMfUq59C8KACCJxs8KyoMCAvfOGcQ9fyuzaX8WZfBrEwA/fZjMHeDnXfOCdijOH7HwxSaphMRZimMlQFv0/57rglY8Z5r4DsJnOEA1d0/LFE4hcLZLB2eGeX5/i9GZuzVHv62/waNPp5+alzSqKrmtKYvxael1QhmNrKg5KOpa/V3uIp2qEkmyZ8KhzdKQhOEWJoMoWAdCLBCIeF9sdgPO/2nW6z6jvEx1crdGqCwpgaBCtW79ZyHKSgtK/fdfxsACb4hW/g== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On 02/06/25 at 01:07am, Kairui Song wrote: > On Wed, Feb 5, 2025 at 5:27 PM Baoquan He wrote: > > > > Since ci->lock has been taken when isolating cluster from > > si->free_clusters or taking si->percpu_cluster->next[order], > > it's unnecessary to scan and check the cluster range availability > > if i'ts empty cluster, and this can accelerate the huge page > > swapping. > > > > Signed-off-by: Baoquan He > > --- > > mm/swapfile.c | 3 +++ > > 1 file changed, 3 insertions(+) > > > > diff --git a/mm/swapfile.c b/mm/swapfile.c > > index 9c9a4ec6d4c6..61efde853eea 100644 > > --- a/mm/swapfile.c > > +++ b/mm/swapfile.c > > @@ -729,6 +729,9 @@ static bool cluster_scan_range(struct swap_info_struct *si, > > unsigned long offset, end = start + nr_pages; > > unsigned char *map = si->swap_map; > > > > + if (cluster_is_empty(ci)) > > + return true; > > + > > Hi Baoquan, > > Thanks for the series. Thanks for your reviewing. > > Most commits are looking great, but this one is a bit questionable. > cluster_scan_range is only called by alloc_swap_scan_cluster, and it > already checks if the cluster has enough empty slots to use, so this > might be redundant. Hmm, maybe no. Assume we want to allocate 2M space on system with 4K page size. Even if a empty cluster is taken into consideration, cluster_scan_range() will loop 512 times to check if each slot is available. That for sure is not necessary in the case, while the added empty cluster checking is very cheap. > > It is possible that cluster_scan_range sees an empty cluster if the > cluster lock was dropped for reclaiming HAS_CACHE, but the chance > should be extremely low, that this might be a negative optimization. It may be not like that. If it's empty cluster, the added checking will return directly. Then 'need_reclaim' is kept false, there's no chance to drop cluster lock to do reclaiming for HAS_CACHE. Means for empty cluster scanning, the ci->lock is kept held. Not sure if I missed anything. Thanks Baoquan