From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from SHSQR01.spreadtrum.com (mx1.unisoc.com [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 5B9E63AEF4C for ; Mon, 22 Jun 2026 13:09:18 +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=1782133762; cv=none; b=rZlHkCo39lWSHbjWC3UuI9Y/N0beaqGrpT61w3EFrTol6j4KWRCPJg/JkYiqq1Y0oFzWM3DS+vC0IP5wstVGeE8USAyWgVuIH88I0zOsCoTlnZdIfj+E/3IQTPZ/d2Chx+ll+va/Sc27n0lQQOchDE1d33ASRMWBmc9URnTfKOg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782133762; c=relaxed/simple; bh=nvrvDq23GInzOw44k58PKAtraxfkUfj413yXtwnGzKo=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=m08/X0aZ7vUealLMFq6RlMDy1OoX5wv5hwHTOzUXE2hrcLfSLsZuqKhlk0+XVj6DhOoNuqgG+D0l1aWIQcrJCfuJVrCnUVFhSrJUZTt+vJr5tmqj66dXVdc/zviQ84S3vkqTxammDaGPdpsoBex3gKuaAmFTDWlcO4M+68RZJK0= 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=AHFrrjs0; 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="AHFrrjs0" Received: from dlp.unisoc.com ([10.29.3.86]) by SHSQR01.spreadtrum.com with ESMTPS id 65MD96H7084743 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Mon, 22 Jun 2026 21:09:06 +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 4gkT1J1xZPz2Mx99x; Mon, 22 Jun 2026 21:04:20 +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, 22 Jun 2026 21:09:03 +0800 From: Yi Sun To: CC: , <279644543@qq.com>, , , , , , , , , , , , Subject: [PATCH v8 0/2] Improve the performance of bitmap_find_next_zero_area_off() Date: Mon, 22 Jun 2026 21:08:57 +0800 Message-ID: <20260622130859.1973637-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-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SHCAS03.spreadtrum.com (10.0.1.207) To BJMBX02.spreadtrum.com (10.0.64.8) X-MAIL:SHSQR01.spreadtrum.com 65MD96H7084743 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unisoc.com; s=default; t=1782133751; bh=tQX53rbUqTQ24SKf4Z7HhFqML6IF3lE+/VWbmoaeKXU=; h=From:To:CC:Subject:Date; b=AHFrrjs0rRK6ACPXV2/o3EdR2cMJ5fcnvVf7XZtV3LpNLUbzMiqSbogrFUXDE4WFi nP+kfNFDp5WKv3lz2tbQt/GpEh46ytipD8eH/731Q+Jgfq0ud5hza1TsxEMH3xpveQ q7am98hrs3ERX6kM/WJuxHB1fzchJ+HAsQOHW2NqpdiAj3sftike6G1gdnGOGhdPpn KlBuN9E8Wd+VKv0l4/hV3LjgiqGRlRGr8XMcvufPiVknWpIJ+UWQUVl7bInjvFecQw j6kuGyDuR7gwRG5DSAIHFZo6CbhA7FvuPLidWEhlEpt8DlizrtYDJIQhZnnbfjAlH+ hXEnbcMSv+yHg== Use lib/find_bit_benchmark.c for testing. Test results showed a 40% improvement in dense cases, and almost no change in sparse cases. Performance test results on my hardware: before(ns) after(ns) change p-value dense 1211 688 -43.2% 8.3e-11 sparse 13.3 13.4 0.8% 0.27 Version 8 improve test code. When original bitmap_find_next_zero_area_off() fails, it returns end, where end is greater than size. Therefore, patch1 should use >. expect_eq_uint(1, bitmap_find_next_zero_area_off(bmap, 192, 0, 33, 0, 0) > 192); When new bitmap_find_next_zero_area_off() fails, it returns size. Therefore, patch2 should be changed to =. expect_eq_uint(192, bitmap_find_next_zero_area_off(bmap, 192, 0, 33, 0, 0)); --- v7: https://lore.kernel.org/all/20260622030036.1744080-1-yi.sun@unisoc.com - Only changed the alignment format of the test code. v6: https://lore.kernel.org/all/20260618133518.4079981-1-yi.sun@unisoc.com - Improve test code. - Change infinite for loop to for_each_clear_bit_from. v5: https://lore.kernel.org/all/20260618015252.3601554-1-yi.sun@unisoc.com - Improve test code. - Change the "goto again" code structure to a for loop. v4: https://lore.kernel.org/all/20260601094234.103863-1-yi.sun@unisoc.com - Test code has been added to PATCH v2. v3: https://lore.kernel.org/all/20260514090607.231387-1-yi.sun@unisoc.com - 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: add tests for bitmap_find_next_zero_area_off() lib: bitmap: optimize bitmap_find_next_zero_area_off() lib/bitmap.c | 31 ++++++++++++++++--------------- lib/find_bit_benchmark.c | 17 +++++++++++++++++ lib/test_bitmap.c | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+), 15 deletions(-) -- 2.34.1