From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from SHSQR01.spreadtrum.com (unknown [222.66.158.135]) (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 6F87438C2BF for ; Mon, 1 Jun 2026 09:43:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=222.66.158.135 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780307011; cv=none; b=c0QlyB2jVNGNnUZKm5SAhaoGNyhoiQOluye7AXu6L1UtDuh952jkCRcro0G1+yTWRnb+cKokwRQrqKpdFYqpoW1KAoLthh/F0OSYt4gGNR+1ISjL1OusQfYknYT8DrQeqGsUnWZQU+Xkz4Slj7D6ahdaqqkdg8fP89vIMqZTDbU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780307011; c=relaxed/simple; bh=Hu6SBwXF4hcR+eWNVprRfQbOvI4082QtRoox/Ulwe1A=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=bEORSG1flK5Bl7kRjTYnydKB4iSV4tjF4lsUYr2dI6WONj7zd+GvbyOzrYFs9oR4n9UHCvTNbCblz3+67wEzJ6TOwvjnLynP9p0xiwCFpDNHXS7gWU/nEer4K5W31jUOqn7YfPqbaOF0WqwyXmbrZ1dZWLHDjUt8mOCaXh4imGk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=unisoc.com; spf=pass smtp.mailfrom=unisoc.com; dkim=pass (2048-bit key) header.d=unisoc.com header.i=@unisoc.com header.b=H6Brw8ud; arc=none smtp.client-ip=222.66.158.135 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=unisoc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=unisoc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=unisoc.com header.i=@unisoc.com header.b="H6Brw8ud" Received: from dlp.unisoc.com ([10.29.3.86]) by SHSQR01.spreadtrum.com with ESMTP id 6519gdUu008877; Mon, 1 Jun 2026 17:42:39 +0800 (+08) (envelope-from Yi.Sun@unisoc.com) Received: from SHDLP.spreadtrum.com (BJMBX02.spreadtrum.com [10.0.64.8]) by dlp.unisoc.com (SkyGuard) with ESMTPS id 4gTTRc1K0Cz2M0bYC; Mon, 1 Jun 2026 17:38:36 +0800 (CST) Received: from tj10379pcu.spreadtrum.com (10.5.32.15) by BJMBX02.spreadtrum.com (10.0.64.8) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Mon, 1 Jun 2026 17:42:36 +0800 From: Yi Sun To: , CC: , , , , , Subject: [PATCH v4 0/2] Improve the performance of bitmap_find_next_zero_area_off() Date: Mon, 1 Jun 2026 17:42:32 +0800 Message-ID: <20260601094234.103863-1-yi.sun@unisoc.com> X-Mailer: git-send-email 2.34.1 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="y" Content-Transfer-Encoding: 8bit X-ClientProxiedBy: SHCAS03.spreadtrum.com (10.0.1.207) To BJMBX02.spreadtrum.com (10.0.64.8) X-MAIL:SHSQR01.spreadtrum.com 6519gdUu008877 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unisoc.com; s=default; t=1780306969; bh=MdoMqlO/aSWwFVZbVDKDlB8osk22lk1/+BPkvxsLBaw=; h=From:To:CC:Subject:Date; b=H6Brw8udWbG/GSYPDmUjnFS6C67+LtnMR6sSV/I5joS9p+liwzLiMVRrKrK7zOqnI eteBV4wllMUR5Ntsa5hd2GV9rs84HBIBeFpvxk5Z0z3GibjtvKz4fxDeu9UhJtAHZO OqaWiwKi0LEFyMnc2XNhcr28EYroKtzFdbwNYOlkCyeZWoH1sG7nFbxuB9A9rPSRT2 o4sYIegc5bQEyOaHs39gwwYrnTU5R93qQZjdYsnn2i4dR0HADPBglquGbeViZLsvu7 cohSpuH94KDCdvWnHwTXM45JWWhhvreaBe5bVTaavd9SGiCbi9ACDNrbwRo2apifBn 37apUqhc05mdg== Test code has been added to PATCH v2. No new APIs were introduced. Testing with the test code showed a performance improvement of approximately 70%. Test result(random): orig_ns orig_cnt orig_average new_ns new_cnt new_average ratio test1 1388885 1154 1203 462923 1308 353 70.7% test2 1393616 1324 1052 736193 1212 607 42.3% test3 1391693 1216 1144 735808 1260 583 49% test4 1393231 1275 1092 742731 1402 529 51.6% test5 1390731 1260 1103 737231 1274 578 47.6% Test result(sparse): orig_ns orig_cnt orig_average new_ns new_cnt new_average ratio test1 4496077 322477 13 2419462 322480 7 46.2% test2 7514731 322482 23 5785808 322476 17 26.1% test3 7490692 322493 23 7654423 322483 23 0% test4 7474500 322469 23 7628230 322483 23 0% test5 7452692 322481 23 7663116 322478 23 0% Test result explanation: Test both random and sparse five times. @orig_ns/cnt: Original version results. @new_ns/cnt: Optimized test results. @orig_average = orig_ns / orig_cnt @new_average = new_ns / new_cnt @ratio = (orig_average - new_average) / orig_average The test results show that the optimized version improved performance in almost every test. --- v3: https://lore.kernel.org/all/20260514090607.231387-1-yi.sun@unisoc.com - Based on MichaƂ Nazarewicz's suggestion, code optimization was performed on PATCH v1. v2: https://lore.kernel.org/all/20260514035644.4118050-1-yi.sun@unisoc.com - Do not introduce find_last_bit_from(). v1: https://lore.kernel.org/all/20260512040659.2992142-1-yi.sun@unisoc.com Yi Sun (2): lib: bitmap: reduce the number of goto again in bitmap_find_next_zero_area_off() lib/bitmap: add tests for bitmap_find_next_zero_area_off() lib/bitmap.c | 10 +++++++--- lib/find_bit_benchmark.c | 17 +++++++++++++++++ lib/test_bitmap.c | 28 ++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+), 3 deletions(-) -- 2.34.1