diff mbox

[2/2] IB/core: Add might_sleep() annotation to ib_init_ah_from_wc()

Message ID 20170829173444.4289-2-roland@kernel.org (mailing list archive)
State Accepted
Headers show

Commit Message

Roland Dreier Aug. 29, 2017, 5:34 p.m. UTC
From: Roland Dreier <roland@purestorage.com>

For RoCE, ib_init_ah_from_wc() can follow the path

    ib_init_ah_from_wc() ->
      rdma_addr_find_l2_eth_by_grh() ->
        rdma_resolve_ip()

and rdma_resolve_ip() will sleep in kzalloc() and wait_for_completion().

However, developers will not see any warnings if they use ib_init_ah_from_wc()
in an atomic context and test only on IB, because the function doesn't
sleep in that case.

Add a might_sleep() so that lockdep will catch bugs no matter what hardware is
used to test.

Signed-off-by: Roland Dreier <roland@purestorage.com>
---
 drivers/infiniband/core/verbs.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Doug Ledford Aug. 30, 2017, 2:24 p.m. UTC | #1
On 8/29/2017 1:34 PM, Roland Dreier wrote:
> From: Roland Dreier <roland@purestorage.com>
> 
> For RoCE, ib_init_ah_from_wc() can follow the path
> 
>     ib_init_ah_from_wc() ->
>       rdma_addr_find_l2_eth_by_grh() ->
>         rdma_resolve_ip()
> 
> and rdma_resolve_ip() will sleep in kzalloc() and wait_for_completion().
> 
> However, developers will not see any warnings if they use ib_init_ah_from_wc()
> in an atomic context and test only on IB, because the function doesn't
> sleep in that case.
> 
> Add a might_sleep() so that lockdep will catch bugs no matter what hardware is
> used to test.
> 
> Signed-off-by: Roland Dreier <roland@purestorage.com>

Thanks, will pick this up today too.
diff mbox

Patch

diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c
index b456e3ca1876..84868f76f8b9 100644
--- a/drivers/infiniband/core/verbs.c
+++ b/drivers/infiniband/core/verbs.c
@@ -478,6 +478,8 @@  int ib_init_ah_from_wc(struct ib_device *device, u8 port_num,
 	union ib_gid dgid;
 	union ib_gid sgid;
 
+	might_sleep();
+
 	memset(ah_attr, 0, sizeof *ah_attr);
 	ah_attr->type = rdma_ah_find_type(device, port_num);
 	if (rdma_cap_eth_ah(device, port_num)) {