2020-01-07 19:30:45

by Madhuparna Bhowmik

[permalink] [raw]
Subject: [PATCH 1/3] infiniband: hw: hfi1: verbs.c: Use built-in RCU list checking

From: Madhuparna Bhowmik <[email protected]>

list_for_each_entry_rcu has built-in RCU and lock checking.
Pass cond argument to list_for_each_entry_rcu.

Signed-off-by: Madhuparna Bhowmik <[email protected]>
---
drivers/infiniband/hw/hfi1/verbs.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/infiniband/hw/hfi1/verbs.c b/drivers/infiniband/hw/hfi1/verbs.c
index 089e201d7550..e6abdbcb4ffb 100644
--- a/drivers/infiniband/hw/hfi1/verbs.c
+++ b/drivers/infiniband/hw/hfi1/verbs.c
@@ -515,7 +515,8 @@ static inline void hfi1_handle_packet(struct hfi1_packet *packet,
opa_get_lid(packet->dlid, 9B));
if (!mcast)
goto drop;
- list_for_each_entry_rcu(p, &mcast->qp_list, list) {
+ list_for_each_entry_rcu(p, &mcast->qp_list, list,
+ lock_is_held(&(ibp->rvp.lock).dep_map)) {
packet->qp = p->qp;
if (hfi1_do_pkey_check(packet))
goto drop;
--
2.17.1


2020-01-07 20:35:38

by Jason Gunthorpe

[permalink] [raw]
Subject: Re: [PATCH 1/3] infiniband: hw: hfi1: verbs.c: Use built-in RCU list checking

On Wed, Jan 08, 2020 at 12:59:12AM +0530, [email protected] wrote:
> From: Madhuparna Bhowmik <[email protected]>
>
> list_for_each_entry_rcu has built-in RCU and lock checking.
> Pass cond argument to list_for_each_entry_rcu.
>
> Signed-off-by: Madhuparna Bhowmik <[email protected]>
> drivers/infiniband/hw/hfi1/verbs.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/infiniband/hw/hfi1/verbs.c b/drivers/infiniband/hw/hfi1/verbs.c
> index 089e201d7550..e6abdbcb4ffb 100644
> +++ b/drivers/infiniband/hw/hfi1/verbs.c
> @@ -515,7 +515,8 @@ static inline void hfi1_handle_packet(struct hfi1_packet *packet,
> opa_get_lid(packet->dlid, 9B));
> if (!mcast)
> goto drop;
> - list_for_each_entry_rcu(p, &mcast->qp_list, list) {
> + list_for_each_entry_rcu(p, &mcast->qp_list, list,
> + lock_is_held(&(ibp->rvp.lock).dep_map)) {

Why .dep_map? Does this compile?

Jason

2020-01-09 20:41:30

by Jason Gunthorpe

[permalink] [raw]
Subject: Re: [PATCH 1/3] infiniband: hw: hfi1: verbs.c: Use built-in RCU list checking

On Wed, Jan 08, 2020 at 01:38:50PM +0530, [email protected] wrote:

> Alternatively, it can be lockdep_is_held(ibp->rvp.lock).
> Please refer to the macro(link below) and let me know if the usage of lock_is_held()
> in the patch is correct.

lock_is_held is the normal way to write this

Jason

2020-01-10 15:55:23

by Joel Fernandes

[permalink] [raw]
Subject: Re: [PATCH 1/3] infiniband: hw: hfi1: verbs.c: Use built-in RCU list checking

On Wed, Jan 08, 2020 at 01:35:07PM +0530, [email protected] wrote:
> From: Jason Gunthorpe <[email protected]>
>
> On Wed, Jan 08, 2020 at 12:59:12AM +0530, [email protected] wrote:
> > From: Madhuparna Bhowmik <[email protected]>
> >
> > list_for_each_entry_rcu has built-in RCU and lock checking.
> > Pass cond argument to list_for_each_entry_rcu.
> >
> > Signed-off-by: Madhuparna Bhowmik <[email protected]>
> > drivers/infiniband/hw/hfi1/verbs.c | 3 ++-
> > 1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/infiniband/hw/hfi1/verbs.c b/drivers/infiniband/hw/hfi1/verbs.c
> > index 089e201d7550..e6abdbcb4ffb 100644
> > +++ b/drivers/infiniband/hw/hfi1/verbs.c
> > @@ -515,7 +515,8 @@ static inline void hfi1_handle_packet(struct hfi1_packet *packet,
> > opa_get_lid(packet->dlid, 9B));
> > if (!mcast)
> > goto drop;
> > - list_for_each_entry_rcu(p, &mcast->qp_list, list) {
> > + list_for_each_entry_rcu(p, &mcast->qp_list, list,
> > + lock_is_held(&(ibp->rvp.lock).dep_map)) {
>
> Why .dep_map? Does this compile?

Yeah, have you really compiled this? Don't send patches without at least
compile testing !!

> Alternatively, it can be lockdep_is_held(ibp->rvp.lock).
> Please refer to the macro(link below) and let me know if the usage of lock_is_held()
> in the patch is correct.
>
> https://elixir.bootlin.com/linux/v5.5-rc2/source/include/linux/lockdep.h#L364

Please use lockdep_is_held(). Thanks.

thanks,

- Joel

>
> Thanks,
> Madhuparna
> Jason