From: Yury Norov <yury.norov@gmail.com>
To: linux-kernel@vger.kernel.org, Karsten Keil <isdn@linux-pingi.de>,
Marcel Holtmann <marcel@holtmann.org>,
Johan Hedberg <johan.hedberg@gmail.com>,
Luiz Augusto von Dentz <luiz.dentz@gmail.com>,
Yury Norov <yury.norov@gmail.com>,
netdev@vger.kernel.org, linux-bluetooth@vger.kernel.org
Cc: Jan Kara <jack@suse.cz>,
Mirsad Todorovac <mirsad.todorovac@alu.unizg.hr>,
Matthew Wilcox <willy@infradead.org>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Maxim Kuvyrkov <maxim.kuvyrkov@linaro.org>,
Alexey Klimov <klimov.linux@gmail.com>
Subject: [PATCH 28/34] bluetooth: optimize cmtp_alloc_block_id()
Date: Sat, 18 Nov 2023 07:50:59 -0800 [thread overview]
Message-ID: <20231118155105.25678-29-yury.norov@gmail.com> (raw)
In-Reply-To: <20231118155105.25678-1-yury.norov@gmail.com>
Instead of polling every bit in blockids, switch it to using a
dedicated find_and_set_bit(), and make the function a simple one-liner.
Signed-off-by: Yury Norov <yury.norov@gmail.com>
---
net/bluetooth/cmtp/core.c | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/net/bluetooth/cmtp/core.c b/net/bluetooth/cmtp/core.c
index 90d130588a3e..b1330acbbff3 100644
--- a/net/bluetooth/cmtp/core.c
+++ b/net/bluetooth/cmtp/core.c
@@ -88,15 +88,9 @@ static void __cmtp_copy_session(struct cmtp_session *session, struct cmtp_connin
static inline int cmtp_alloc_block_id(struct cmtp_session *session)
{
- int i, id = -1;
+ int id = find_and_set_bit(&session->blockids, 16);
- for (i = 0; i < 16; i++)
- if (!test_and_set_bit(i, &session->blockids)) {
- id = i;
- break;
- }
-
- return id;
+ return id < 16 ? id : -1;
}
static inline void cmtp_free_block_id(struct cmtp_session *session, int id)
--
2.39.2
next prev parent reply other threads:[~2023-11-18 15:51 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-18 15:50 [PATCH 00/34] biops: add atomig find_bit() operations Yury Norov
2023-11-18 15:50 ` [PATCH 01/34] lib/find: add atomic find_bit() primitives Yury Norov
2023-11-18 16:23 ` Bart Van Assche
2023-11-18 15:50 ` [PATCH 19/34] sfc: switch to using atomic find_bit() API where appropriate Yury Norov
2023-11-21 19:46 ` Edward Cree
2023-11-18 15:50 ` [PATCH 24/34] mISDN: optimize get_free_devid() Yury Norov
2023-11-18 15:50 ` [PATCH 26/34] ethernet: rocker: optimize ofdpa_port_internal_vlan_id_get() Yury Norov
2023-11-18 15:50 ` Yury Norov [this message]
2023-11-18 15:51 ` [PATCH 29/34] net: smc: fix opencoded find_and_set_bit() in smc_wr_tx_get_free_slot_index() Yury Norov
2023-11-20 8:43 ` Alexandra Winter
2023-11-21 13:41 ` Yury Norov
2023-11-21 15:39 ` Alexandra Winter
2023-11-20 9:56 ` Tony Lu
2023-11-18 16:18 ` [PATCH 00/34] biops: add atomig find_bit() operations Bart Van Assche
2023-11-18 19:06 ` Sergey Shtylyov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231118155105.25678-29-yury.norov@gmail.com \
--to=yury.norov@gmail.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=isdn@linux-pingi.de \
--cc=jack@suse.cz \
--cc=johan.hedberg@gmail.com \
--cc=klimov.linux@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=luiz.dentz@gmail.com \
--cc=marcel@holtmann.org \
--cc=maxim.kuvyrkov@linaro.org \
--cc=mirsad.todorovac@alu.unizg.hr \
--cc=netdev@vger.kernel.org \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox