[openib-general] [PATCH] kDAPL: remove dapl_os_assert()
Tom Duffy
tduffy at sun.com
Thu Jun 23 13:25:25 PDT 2005
This patch removes dapl_os_assert(). In most cases, replacing with
BUG_ON(!). Some cases, I just called panic() where others I removed the
assert all together because the next line dereferences the pointer
anyways.
Signed-off-by: Tom Duffy <tduffy at sun.com>
Index: linux-kernel/dat-provider/dapl_cookie.c
===================================================================
--- linux-kernel/dat-provider/dapl_cookie.c (revision 2701)
+++ linux-kernel/dat-provider/dapl_cookie.c (working copy)
@@ -184,7 +184,7 @@ u32 dapl_cb_get(struct dapl_cookie_buffe
u32 dat_status;
int new_head;
- dapl_os_assert(NULL != cookie_ptr);
+ BUG_ON(cookie_ptr == NULL);
new_head = (atomic_read(&buffer->head) + 1) % buffer->pool_size;
Index: linux-kernel/dat-provider/dapl_openib_util.c
===================================================================
--- linux-kernel/dat-provider/dapl_openib_util.c (revision 2701)
+++ linux-kernel/dat-provider/dapl_openib_util.c (working copy)
@@ -783,7 +783,7 @@ u32 dapl_ib_get_gid(struct ib_device *hc
{
int status;
- dapl_os_assert(hca);
+ BUG_ON(!hca);
if (gid) {
status = ib_query_gid(hca, port, 0, gid);
Index: linux-kernel/dat-provider/dapl_openib_qp.c
===================================================================
--- linux-kernel/dat-provider/dapl_openib_qp.c (revision 2701)
+++ linux-kernel/dat-provider/dapl_openib_qp.c (working copy)
@@ -76,7 +76,6 @@ u32 dapl_ib_qp_alloc(struct dapl_ia *ia_
attr = &ep_ptr->param.ep_attr;
- dapl_os_assert(ep_ptr->param.pz != NULL);
ib_pd_handle = ((struct dapl_pz *)ep_ptr->param.pz)->pd;
ib_hca_handle = ia_ptr->hca->ib_hca_handle;
Index: linux-kernel/dat-provider/dapl_openib_dto.h
===================================================================
--- linux-kernel/dat-provider/dapl_openib_dto.h (revision 2701)
+++ linux-kernel/dat-provider/dapl_openib_dto.h (working copy)
@@ -43,8 +43,6 @@ static inline u32 dapl_ib_post_recv(stru
struct ib_sge *sg_list;
int status, i, total_len = 0;
- dapl_os_assert(NULL != cookie);
-
sg_list = ep->recv_iov;
for (i = 0; i < num_segments; i++, sg_list++) {
sg_list->addr = local_iov[i].virtual_address;
@@ -84,8 +82,6 @@ static inline u32 dapl_ib_post_send(stru
struct ib_sge *sg_list;
int status, i, total_len = 0;
- dapl_os_assert(NULL != cookie);
-
sg_list = ep->send_iov;
for (i = 0; i < num_segments; i++, sg_list++) {
sg_list->addr = local_iov[i].virtual_address;
Index: linux-kernel/dat-provider/dapl_ia.c
===================================================================
--- linux-kernel/dat-provider/dapl_ia.c (revision 2701)
+++ linux-kernel/dat-provider/dapl_ia.c (working copy)
@@ -371,13 +371,13 @@ bail:
*/
void dapl_ia_free(struct dapl_ia *ia)
{
- dapl_os_assert(ia->async_error_evd == NULL);
- dapl_os_assert(list_empty(&ia->lmr_list));
- dapl_os_assert(list_empty(&ia->rmr_list));
- dapl_os_assert(list_empty(&ia->ep_list));
- dapl_os_assert(list_empty(&ia->evd_list));
- dapl_os_assert(list_empty(&ia->psp_list));
- dapl_os_assert(list_empty(&ia->rsp_list));
+ BUG_ON(ia->async_error_evd != NULL);
+ BUG_ON(!list_empty(&ia->lmr_list));
+ BUG_ON(!list_empty(&ia->rmr_list));
+ BUG_ON(!list_empty(&ia->ep_list));
+ BUG_ON(!list_empty(&ia->evd_list));
+ BUG_ON(!list_empty(&ia->psp_list));
+ BUG_ON(!list_empty(&ia->rsp_list));
dapl_hca_unlink_ia(ia->hca, ia);
/* no need to destroy ia->common.lock */
Index: linux-kernel/dat-provider/dapl_rmr.c
===================================================================
--- linux-kernel/dat-provider/dapl_rmr.c (revision 2701)
+++ linux-kernel/dat-provider/dapl_rmr.c (working copy)
@@ -126,8 +126,7 @@ static u64 dapl_rmr_get_address(DAT_REGI
* DAT_MEM_TYPE_IA
* DAT_MEM_TYPE_BYPASS
*/
- dapl_os_assert(0);
- return 0;
+ panic("unimplemented or unknown memory type\n");
}
}
Index: linux-kernel/dat-provider/dapl_ep.c
===================================================================
--- linux-kernel/dat-provider/dapl_ep.c (revision 2701)
+++ linux-kernel/dat-provider/dapl_ep.c (working copy)
@@ -675,8 +675,8 @@ u32 dapl_ep_free(struct dat_ep *ep)
*/
(void)dapl_ep_disconnect((struct dat_ep *)ep_ptr,
DAT_CLOSE_ABRUPT_FLAG);
- dapl_os_assert(ep_ptr->param.ep_state == DAT_EP_STATE_DISCONNECTED ||
- ep_ptr->param.ep_state == DAT_EP_STATE_UNCONNECTED);
+ BUG_ON(ep_ptr->param.ep_state != DAT_EP_STATE_DISCONNECTED &&
+ ep_ptr->param.ep_state != DAT_EP_STATE_UNCONNECTED);
/*
* Do verification of parameters and the state change atomically.
@@ -1538,11 +1538,11 @@ u32 dapl_ep_modify(struct dat_ep *ep, en
* occurred. But they're important to the logic of this routine,
* so we check.
*/
- dapl_os_assert(ep1 == ep2);
- dapl_os_assert(ep_attr2.max_recv_dtos == ep_attr1.max_recv_dtos);
- dapl_os_assert(ep_attr2.max_request_dtos == ep_attr1.max_request_dtos);
- dapl_os_assert(ep_attr2.max_recv_iov == ep_attr1.max_recv_iov);
- dapl_os_assert(ep_attr2.max_request_iov == ep_attr1.max_request_iov);
+ BUG_ON(ep1 != ep2);
+ BUG_ON(ep_attr2.max_recv_dtos != ep_attr1.max_recv_dtos);
+ BUG_ON(ep_attr2.max_request_dtos != ep_attr1.max_request_dtos);
+ BUG_ON(ep_attr2.max_recv_iov != ep_attr1.max_recv_iov);
+ BUG_ON(ep_attr2.max_request_iov != ep_attr1.max_request_iov);
copy_of_old_ep = *ep2;
@@ -1607,10 +1607,10 @@ u32 dapl_ep_modify(struct dat_ep *ep, en
* because the parameter validate routine should protect us,
* but it's an important enough point that we assert it.
*/
- dapl_os_assert((ep2->param.ep_state
- != DAT_EP_STATE_PASSIVE_CONNECTION_PENDING)
- && (ep2->param.ep_state
- != DAT_EP_STATE_ACTIVE_CONNECTION_PENDING));
+ BUG_ON(ep2->param.ep_state ==
+ DAT_EP_STATE_PASSIVE_CONNECTION_PENDING ||
+ ep2->param.ep_state ==
+ DAT_EP_STATE_ACTIVE_CONNECTION_PENDING);
new_ep.qp = alloc_ep.qp;
}
Index: linux-kernel/dat-provider/dapl_cr.c
===================================================================
--- linux-kernel/dat-provider/dapl_cr.c (revision 2701)
+++ linux-kernel/dat-provider/dapl_cr.c (working copy)
@@ -271,7 +271,7 @@ static u32 dapl_connection_request(struc
DAT_EP_STATE_TENTATIVE_CONNECTION_PENDING;
} else {
/* RSP */
- dapl_os_assert(sp->sp.type == DAT_SP_TYPE_RSP);
+ BUG_ON(sp->sp.type != DAT_SP_TYPE_RSP);
ep->param.ep_state =
DAT_EP_STATE_PASSIVE_CONNECTION_PENDING;
}
@@ -516,8 +516,7 @@ void dapl_cr_callback(struct dapl_cm_ctx
break;
default:
evd = NULL;
- dapl_os_assert(0); /* shouldn't happen */
- break;
+ panic("unknown callback event\n");
}
if (evd != NULL)
Index: linux-kernel/dat-provider/dapl_evd.c
===================================================================
--- linux-kernel/dat-provider/dapl_evd.c (revision 2701)
+++ linux-kernel/dat-provider/dapl_evd.c (working copy)
@@ -243,7 +243,7 @@ static u32 dapl_evd_dealloc(struct dapl_
u32 status = DAT_SUCCESS;
struct dapl_ia *ia;
- dapl_os_assert(atomic_read(&evd->evd_ref_count) == 0);
+ BUG_ON(atomic_read(&evd->evd_ref_count) != 0);
/*
* Destroy the CQ first, to keep any more callbacks from coming
@@ -330,9 +330,9 @@ static void dapl_evd_post_event(struct d
event->event_number);
status = dapl_rbuf_add(&evd->pending_event_queue, event);
- dapl_os_assert(status == DAT_SUCCESS);
+ BUG_ON(status != DAT_SUCCESS);
- dapl_os_assert(evd->evd_state == DAPL_EVD_STATE_OPEN);
+ BUG_ON(evd->evd_state != DAPL_EVD_STATE_OPEN);
if (evd->evd_producer_locking_needed)
spin_unlock_irqrestore(&evd->common.lock,
@@ -522,10 +522,9 @@ static void dapl_evd_wc_to_event(struct
dto_status = dapl_ib_get_dto_status(wc);
cookie = (struct dapl_cookie *) (unsigned long) wc->wr_id;
- dapl_os_assert(NULL != cookie);
ep = cookie->ep;
- dapl_os_assert(NULL != ep);
+ BUG_ON(ep == NULL);
event->evd = (struct dat_evd *)evd;
@@ -550,26 +549,6 @@ static void dapl_evd_wc_to_event(struct
event_data->user_cookie = cookie->val.dto.cookie;
event_data->status = dto_status;
-#if 0
- /* Currently mthca is not setting the opcode in */
- /* succesful wc. The opcode will be IB_WC_SEND or */
- /* IB_WC_RECV according the is_send bit */
- /* We can not check the following assert for now */
- if (dto_status == DAT_DTO_SUCCESS) {
- enum ib_wc_opcode ib_opcode = wc->opcode;
- enum dapl_dto_type dto_type = cookie->val.dto.type;
- dapl_os_assert((ib_opcode == IB_WC_SEND &&
- dto_type == DAPL_DTO_TYPE_SEND) ||
- (ib_opcode == IB_WC_RECV &&
- dto_type == DAPL_DTO_TYPE_RECV) ||
- (ib_opcide == IB_WC_RDMA_WRITE &&
- dto_type == DAPL_DTO_TYPE_RDMA_WRITE) ||
- (ib_opcode == IB_WC_RDMA_READ &&
- dto_type == DAPL_DTO_TYPE_RDMA_READ));
-
- }
-#endif
-
if (cookie->val.dto.type == DAPL_DTO_TYPE_SEND ||
cookie->val.dto.type == DAPL_DTO_TYPE_RDMA_WRITE) {
/* Get size from DTO; CQE value may be off. */
@@ -593,7 +572,7 @@ static void dapl_evd_wc_to_event(struct
event_data->user_cookie = cookie->val.rmr.cookie;
if (dto_status == DAT_DTO_SUCCESS) {
- dapl_os_assert(wc->opcode == IB_WC_BIND_MW);
+ BUG_ON(wc->opcode != IB_WC_BIND_MW);
event_data->status = DAT_RMR_BIND_SUCCESS;
} else {
dapl_dbg_log(DAPL_DBG_TYPE_DTO_COMP_ERR,
@@ -607,10 +586,7 @@ static void dapl_evd_wc_to_event(struct
break;
}
default:
- {
- dapl_os_assert(!"Invalid Operation type");
- break;
- }
+ panic("Invalid Operation type\n");
} /* end switch */
}
@@ -652,7 +628,7 @@ void dapl_evd_qp_async_error_callback(st
ep->param.ep_state = DAT_EP_STATE_DISCONNECTED;
}
- dapl_os_assert(async_evd != NULL);
+ BUG_ON(async_evd == NULL);
status = dapl_ib_get_async_event(cause, &async_event);
if (status == DAT_SUCCESS) {
@@ -792,9 +768,7 @@ void dapl_evd_connection_callback(struct
default:
spin_unlock_irqrestore(&ep->common.lock, ep->common.flags);
evd = NULL;
-
- dapl_os_assert(0); /* shouldn't happen */
- break;
+ panic("bad event\n");
}
/*
@@ -838,7 +812,7 @@ static void dapl_evd_dto_callback(struct
evd = (struct dapl_evd *)user_context;
- dapl_os_assert(evd->cq == cq);
+ BUG_ON(evd->cq != cq);
/* Read once. */
state = *(volatile enum dapl_evd_state *)&evd->evd_state;
Index: linux-kernel/dat-provider/dapl_util.h
===================================================================
--- linux-kernel/dat-provider/dapl_util.h (revision 2701)
+++ linux-kernel/dat-provider/dapl_util.h (working copy)
@@ -48,15 +48,6 @@
#include <asm/system.h>
#endif
-#define dapl_os_assert(expression) \
- do { \
- if (!(expression)) { \
- panic("ASSERTION fail in %s:%i:%s\n", \
- __FILE__, __LINE__, __func__); \
- } \
- } while (0)
-
-
/* dapl_os_atomic_assign
*
* assign 'new_value' to '*v' if the current value
Index: linux-kernel/dat-provider/dapl_sp.c
===================================================================
--- linux-kernel/dat-provider/dapl_sp.c (revision 2701)
+++ linux-kernel/dat-provider/dapl_sp.c (working copy)
@@ -64,7 +64,7 @@ static struct dapl_sp *dapl_sp_alloc(str
void dapl_sp_dealloc(struct dapl_sp *sp)
{
- dapl_os_assert(list_empty(&sp->cr_list));
+ BUG_ON(!list_empty(&sp->cr_list));
kfree(sp);
}
More information about the general
mailing list