[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMGffEnKZK_Du+f=v_PxsJEv4PE=L=vnkejXWW3Eu7gw9vpKSw@mail.gmail.com>
Date: Thu, 27 Jun 2024 14:59:27 +0200
From: Jinpu Wang <jinpu.wang@...os.com>
To: Yury Norov <yury.norov@...il.com>
Cc: linux-kernel@...r.kernel.org, "Md. Haris Iqbal" <haris.iqbal@...os.com>,
Jason Gunthorpe <jgg@...pe.ca>, Leon Romanovsky <leon@...nel.org>, linux-rdma@...r.kernel.org,
Alexey Klimov <alexey.klimov@...aro.org>, Bart Van Assche <bvanassche@....org>, Jan Kara <jack@...e.cz>,
Linus Torvalds <torvalds@...ux-foundation.org>, Matthew Wilcox <willy@...radead.org>,
Mirsad Todorovac <mirsad.todorovac@....unizg.hr>, Rasmus Villemoes <linux@...musvillemoes.dk>,
Sergey Shtylyov <s.shtylyov@....ru>
Subject: Re: [PATCH v4 24/40] RDMA/rtrs: optimize __rtrs_get_permit() by using find_and_set_bit_lock()
On Thu, Jun 20, 2024 at 7:58 PM Yury Norov <yury.norov@...il.com> wrote:
>
> The function opencodes find_and_set_bit_lock() with a while-loop polling
> on test_and_set_bit_lock(). Use the dedicated function instead.
>
> Signed-off-by: Yury Norov <yury.norov@...il.com>
lgtm, thx!
Reviewed-by: Jack Wang <jinpu.wang@...os.com>
> ---
> drivers/infiniband/ulp/rtrs/rtrs-clt.c | 16 ++++------------
> 1 file changed, 4 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c
> index 88106cf5ce55..52b7728f6c63 100644
> --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c
> +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c
> @@ -10,6 +10,7 @@
> #undef pr_fmt
> #define pr_fmt(fmt) KBUILD_MODNAME " L" __stringify(__LINE__) ": " fmt
>
> +#include <linux/find_atomic.h>
> #include <linux/module.h>
> #include <linux/rculist.h>
> #include <linux/random.h>
> @@ -72,18 +73,9 @@ __rtrs_get_permit(struct rtrs_clt_sess *clt, enum rtrs_clt_con_type con_type)
> struct rtrs_permit *permit;
> int bit;
>
> - /*
> - * Adapted from null_blk get_tag(). Callers from different cpus may
> - * grab the same bit, since find_first_zero_bit is not atomic.
> - * But then the test_and_set_bit_lock will fail for all the
> - * callers but one, so that they will loop again.
> - * This way an explicit spinlock is not required.
> - */
> - do {
> - bit = find_first_zero_bit(clt->permits_map, max_depth);
> - if (bit >= max_depth)
> - return NULL;
> - } while (test_and_set_bit_lock(bit, clt->permits_map));
> + bit = find_and_set_bit_lock(clt->permits_map, max_depth);
> + if (bit >= max_depth)
> + return NULL;
>
> permit = get_permit(clt, bit);
> WARN_ON(permit->mem_id != bit);
> --
> 2.43.0
>
Powered by blists - more mailing lists