From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com [209.85.167.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9A8EF390230 for ; Tue, 12 May 2026 11:32:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778585562; cv=none; b=fsRvFlVlEwdpPMIhfKLGZ51aH9rx/WlOpIJxY3OpTOVBWqtjetceaTjoHliHZahFMA/g1a/ipSr22cFCWlCUwEHw1xUrRgiwsrs7BBFXfH+So3Anf8GzOHp5xFSM6vPW+Feki0lybjcwG2huU05pD78LGYpc2rvhGM07kVzy7KQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778585562; c=relaxed/simple; bh=6KCFlZc6cCIRptGlnsd1YKM7lcEOYot9WF6/IloFLYI=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=RXOwNzmZ2UpbMmptZRokn5MSFFqYHhAHekk/8MCXSre0tw0aWxCyrxVGDBHMQ2PtocdIsGXA1m9Q2Y7xEWAv8e/CN+R30xlwkYIKkG0E3Utc7nvCTIjzT/8iC3udyh7m1+3EKNEJdvtC23Eh6tuqO7ah2vgnRnqYE+Aowi4KpcY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=mina86.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=SzfBmTKg; arc=none smtp.client-ip=209.85.167.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=mina86.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="SzfBmTKg" Received: by mail-lf1-f47.google.com with SMTP id 2adb3069b0e04-5a865d1547aso5806010e87.1 for ; Tue, 12 May 2026 04:32:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778585559; x=1779190359; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=EMo1QQACmRROcfk1RiIuSX/RDH8PfPQaUba8UjTzx24=; b=SzfBmTKgmazaq7lUuKTwFsf8fKrR8GJhH6C5ASiME2eKDguyQhAW9Lz5e37NCAVH2Y XFwO2OjvxWkKPOcNcgAhwnPS5+sZsftRAgAWCB2/Za8teBT7vXnm0muNv2V5gLMepd9e nb/VbBjdPhuG6OKpITYlkiYDt1uAN3sL/zzyGbGkf2IuHl1cXb3bD8TTZMrQ1uw+bM1i YAJ5D3IAwRp2H59ES1ImIhpyTZHiNAXqx4dfrreLiksX9xVP/AShmdJOqHaKmcVOeZZH v1W+cw7pOInbtL+g/B6oscEljBnj28GKbUvsCwREXbaNR5BvZoh86hCt5p3JsMBDPxio A+eg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778585559; x=1779190359; h=content-transfer-encoding:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:sender:x-gm-gg:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=EMo1QQACmRROcfk1RiIuSX/RDH8PfPQaUba8UjTzx24=; b=XpqvUWU/6C4w+ABZXaqo13pSd9mNnHj4LpLLmBXTIrH6PnMo3kjFCgYmsNcq/U78hG xQTOcn/LaR92aFqA4PVopa17sq6TcPOcAcrMsojkvwYaWUyJ8uhWUl6VoP/NhlCPUKt3 k9qB6KOe6UfPiviXq38JlJVxSTqpAw5HGnGSXEnRT+oebF4kfUuFi1GaQAKztwfwWBUY eKWSOAx55F845nnxHver3+WSPtY/a6XmjwUm6Yk3MRZUEdlR2hNEPlORrQHX/z+IXqYe 9TOz6knUoxjMQRDY1TsXOGi9bg/v3w5Rxx4fMFjwt9PX2+pZ9J2WdtQ7RU9qvvGPPHU4 QV/A== X-Forwarded-Encrypted: i=1; AFNElJ8H16oIVxTN9W/A65dyMIM5vHjRGmPEiStMZhs5bDsHmffpg5CZYj8Jx5fjn8AFaH0JS9RF4QcCW02Udss=@vger.kernel.org X-Gm-Message-State: AOJu0Ywukh+f9bBiAHg4D5vbB5fcSb7ZelwopuHmFJj7Rzf9jIQvY9yy 9P4+3ViS6zI0ZQUyI8auCh/8CxZI72Ek/gqQgeagHYrNYHLExTYxmRKIY9Lwdw== X-Gm-Gg: Acq92OEawSfUwapKkzBuLdnQhtOCBTXkqfEZC4OWbFCgyD14XFX2UrtQajTh9SUHc14 6w2IM+sZYt8Au8+9gzfYuMQQyCf4KsqWxRvFrMileX/KFoPQrfUENAQgarBeVi0YB7/ttdKO1eA auAYrUFrZlGzym1Ul0Wzt5yNyNRo7MOY1ZHuu6g0AG3TfuC4w0KKQR5uvR+lu0LHL9eu/pm8B2v ye3DS/sZT6u1ZoCPnRUbZZxd3c1OWKhxPhlQBMVhPaz35z+ahYFR1DtEtpMKkNK4svkD7M3ehPh ZIrqZUsIrbk/qR2WJy4YDLK8v3EaDNewTiVq+EUtklTyd0A1E1InZ11DbaA0MilH8Eh5p2qUl38 m3fpJXMlB5ArfefKXq/+xB6Esyn9qCJrAYAJrpkgFSQfwkmHrIrQm5ljMhwArqCDawuSbJ+Gucz tUM+liAKy/Z5ArIa5zGAA2M7Mz5UyitpTrwtjNuZvfTRfwM/GdikK9UqXUEwcb X-Received: by 2002:a05:6512:3b9c:b0:5a4:505:f63c with SMTP id 2adb3069b0e04-5a8e0ed4ce4mr1041018e87.11.1778585558345; Tue, 12 May 2026 04:32:38 -0700 (PDT) Received: from erwin (109241130011.warszawa.vectranet.pl. [109.241.130.11]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5a8b6b20ecesm2474334e87.29.2026.05.12.04.32.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 May 2026 04:32:36 -0700 (PDT) Sender: =?UTF-8?Q?Micha=C5=82_Nazarewicz?= From: =?utf-8?Q?Micha=C5=82?= Nazarewicz To: Yi Sun , yi.sun@unisoc.com, yury.norov@gmail.com, akpm@linux-foundation.org Cc: akinobu.mita@gmail.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] lib: bitmap: reduce the number of goto again in bitmap_find_next_zero_area_off() In-Reply-To: <20260512040659.2992142-3-yi.sun@unisoc.com> References: <20260512040659.2992142-1-yi.sun@unisoc.com> <20260512040659.2992142-3-yi.sun@unisoc.com> Date: Tue, 12 May 2026 13:32:36 +0200 Message-ID: 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=utf-8 Content-Transfer-Encoding: quoted-printable On Tue, May 12 2026, Yi Sun wrote: > Finding a contiguous free region in a highly fragmented > bitmap is not easy and may require many repeated attempts. > Therefore, find_next_bit(map, end, index) is not the optimal choice. > This is because there may be multiple scattered free regions > within the range [index, end) and none of them will meet the length > requirement of @nr. > Instead, it's sufficient to directly find the last bit within > the range [index, end), thus reducing unnecessary "goto again" calls. > > Signed-off-by: Yi Sun Acked-by: Micha=C5=82 Nazarewicz > --- > lib/bitmap.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/lib/bitmap.c b/lib/bitmap.c > index b9bfa157e095..53961a7683a4 100644 > --- a/lib/bitmap.c > +++ b/lib/bitmap.c > @@ -442,7 +442,7 @@ unsigned long bitmap_find_next_zero_area_off(unsigned= long *map, > end =3D index + nr; > if (end > size) > return end; > - i =3D find_next_bit(map, end, index); > + i =3D find_last_bit_range(map, end, index); > if (i < end) { > start =3D i + 1; > goto again; --=20 Best regards =E3=83=9F=E3=83=8F=E3=82=A6 =E2=80=9C=F0=9D=93=B6=F0=9D=93=B2=F0=9D=93=B7= =F0=9D=93=AA86=E2=80=9D =E3=83=8A=E3=82=B6=E3=83=AC=E3=83=B4=E3=82=A3=E3=83= =84 =C2=ABIf at first you don=E2=80=99t succeed, give up skydiving=C2=BB