// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB /* * Copyright (c) 2016 Mellanox Technologies Ltd. All rights reserved. * Copyright (c) 2015 System Fabric Works, Inc. All rights reserved.
*/
/* AH objects are unique in that the create_ah verb * can be called in atomic context. If the create_ah * call is not sleepable use GFP_ATOMIC.
*/
gfp_flags = sleepable ? GFP_KERNEL : GFP_ATOMIC;
if (sleepable)
might_sleep();
err = xa_alloc_cyclic(&pool->xa, &elem->index, NULL, pool->limit,
&pool->next, gfp_flags); if (err < 0) goto err_cnt;
/* erase xarray entry to prevent looking up * the pool elem from its index
*/
xa_ret = xa_erase(xa, elem->index);
WARN_ON(xa_err(xa_ret));
/* if this is the last call to rxe_put complete the * object. It is safe to touch obj->elem after this since * it is freed below
*/
__rxe_put(elem);
/* wait until all references to the object have been * dropped before final object specific cleanup and * return to rdma-core
*/ if (sleepable) { if (!completion_done(&elem->complete)) {
ret = wait_for_completion_timeout(&elem->complete,
msecs_to_jiffies(50000));
/* Shouldn't happen. There are still references to * the object but, rather than deadlock, free the * object or pass back to rdma-core.
*/ if (WARN_ON(!ret))
err = -ETIMEDOUT;
}
} else { unsignedlong until = jiffies + RXE_POOL_TIMEOUT;
/* AH objects are unique in that the destroy_ah verb * can be called in atomic context. This delay * replaces the wait_for_completion call above * when the destroy_ah call is not sleepable
*/ while (!completion_done(&elem->complete) &&
time_before(jiffies, until))
mdelay(1);
if (WARN_ON(!completion_done(&elem->complete)))
err = -ETIMEDOUT;
}
if (pool->cleanup)
pool->cleanup(elem);
atomic_dec(&pool->num_elem);
return err;
}
int __rxe_get(struct rxe_pool_elem *elem)
{ return kref_get_unless_zero(&elem->ref_cnt);
}
int __rxe_put(struct rxe_pool_elem *elem)
{ return kref_put(&elem->ref_cnt, rxe_elem_release);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.