* local MDs. In particular, they signal the completion of a data transmission
* into or out of a MD. They can also be used to hold acknowledgments for
* completed PUT operations and indicate when a MD has been unlinked. Multiple
- * MDs can share a single EQ. An EQ may have an optional event handler
- * associated with it. If an event handler exists, it will be run for each
- * event that is deposited into the EQ.
+ * MDs can share a single EQ. An EQ must have an event handler
+ * associated with it. It will be run for each event that is deposited into
+ * the EQ.
*
* In addition to the struct lnet_eq, the LNet API defines two types
* associated with events: The ::lnet_event_kind defines the kinds of events
* releases these resources and frees the EQ.
* @{ */
struct lnet_eq *
-LNetEQAlloc(unsigned int count_in,
- lnet_eq_handler_t handler);
+LNetEQAlloc(lnet_eq_handler_t handler);
int LNetEQFree(struct lnet_eq *eventq_in);
((type *)((char *)(ptr)-(char *)(&((type *)0)->member)))
struct lnet_eq {
- unsigned long eq_enq_seq;
- unsigned long eq_deq_seq;
- unsigned int eq_size;
lnet_eq_handler_t eq_callback;
- struct lnet_event *eq_events;
int **eq_refs; /* percpt refcount for EQ */
};
if (set_eq) {
the_lnet.ln_ping_target_eq =
- LNetEQAlloc(0, lnet_ping_target_event_handler);
+ LNetEQAlloc(lnet_ping_target_event_handler);
if (IS_ERR(the_lnet.ln_ping_target_eq)) {
rc = PTR_ERR(the_lnet.ln_ping_target_eq);
CERROR("Can't allocate ping buffer EQ: %d\n", rc);
return -EALREADY;
the_lnet.ln_push_target_eq =
- LNetEQAlloc(0, lnet_push_target_event_handler);
+ LNetEQAlloc(lnet_push_target_event_handler);
if (IS_ERR(the_lnet.ln_push_target_eq)) {
rc = PTR_ERR(the_lnet.ln_push_target_eq);
CERROR("Can't allocated push target EQ: %d\n", rc);
lnet_ping_target_update(pbuf, ping_mdh);
- the_lnet.ln_mt_eq = LNetEQAlloc(0, lnet_mt_event_handler);
+ the_lnet.ln_mt_eq = LNetEQAlloc(lnet_mt_event_handler);
if (IS_ERR(the_lnet.ln_mt_eq)) {
rc = PTR_ERR(the_lnet.ln_mt_eq);
CERROR("Can't allocate monitor thread EQ: %d\n", rc);
if (!pbuf)
return -ENOMEM;
- eq = LNetEQAlloc(0, lnet_ping_event_handler);
+ eq = LNetEQAlloc(lnet_ping_event_handler);
if (IS_ERR(eq)) {
rc = PTR_ERR(eq);
CERROR("Can't allocate EQ: %d\n", rc);
#include <lnet/lib-lnet.h>
/**
- * Create an event queue that has room for \a count number of events.
+ * Create an event queue that calls a @callback on each event.
*
- * Note that when EQ handler is specified in \a callback, no event loss
- * can happen, since the handler is run for each event deposited into
- * the EQ.
- *
- * \param count The number of events to be stored in the event queue. It
- * will be rounded up to the next power of two.
* \param callback A handler function that runs when an event is deposited
- * into the EQ. The constant value LNET_EQ_HANDLER_NONE can be used to
- * indicate that no event handler is desired.
+ * into the EQ.
*
* \retval eq On successful return, the newly created EQ is returned.
* On failure, an error code encoded with ERR_PTR() is returned.
* \see lnet_eq_handler_t for the discussion on EQ handler semantics.
*/
struct lnet_eq *
-LNetEQAlloc(unsigned int count, lnet_eq_handler_t callback)
+LNetEQAlloc(lnet_eq_handler_t callback)
{
struct lnet_eq *eq;
LASSERT(the_lnet.ln_refcount > 0);
- /* We need count to be a power of 2 so that when eq_{enq,deq}_seq
- * overflow, they don't skip entries, so the queue has the same
- * apparent capacity at all times */
-
- if (count)
- count = roundup_pow_of_two(count);
-
- if (callback != LNET_EQ_HANDLER_NONE && count != 0) {
- CWARN("EQ callback is guaranteed to get every event, "
- "do you still want to set eqcount %d for polling "
- "event which will have locking overhead? "
- "Please contact with developer to confirm\n", count);
- }
-
- /* count can be 0 if only need callback, we can eliminate
- * overhead of enqueue event */
- if (count == 0 && callback == LNET_EQ_HANDLER_NONE)
+ if (callback == LNET_EQ_HANDLER_NONE)
return ERR_PTR(-EINVAL);
eq = lnet_eq_alloc();
if (eq == NULL)
return ERR_PTR(-ENOMEM);
- if (count != 0) {
- LIBCFS_ALLOC(eq->eq_events, count * sizeof(*eq->eq_events));
- if (eq->eq_events == NULL)
- goto failed;
- /* NB allocator has set all event sequence numbers to 0,
- * so all them should be earlier than eq_deq_seq */
- }
-
- eq->eq_deq_seq = 1;
- eq->eq_enq_seq = 1;
- eq->eq_size = count;
eq->eq_callback = callback;
eq->eq_refs = cfs_percpt_alloc(lnet_cpt_table(),
return eq;
failed:
- if (eq->eq_events != NULL)
- LIBCFS_FREE(eq->eq_events, count * sizeof(*eq->eq_events));
-
if (eq->eq_refs != NULL)
cfs_percpt_free(eq->eq_refs);
int
LNetEQFree(struct lnet_eq *eq)
{
- struct lnet_event *events = NULL;
int **refs = NULL;
int *ref;
int rc = 0;
- int size = 0;
int i;
lnet_res_lock(LNET_LOCK_EX);
}
/* stash for free after lock dropped */
- events = eq->eq_events;
- size = eq->eq_size;
refs = eq->eq_refs;
lnet_eq_free(eq);
lnet_eq_wait_unlock();
lnet_res_unlock(LNET_LOCK_EX);
- if (events != NULL)
- LIBCFS_FREE(events, size * sizeof(*events));
if (refs != NULL)
cfs_percpt_free(refs);
void
lnet_eq_enqueue_event(struct lnet_eq *eq, struct lnet_event *ev)
{
- /* MUST called with resource lock hold but w/o lnet_eq_wait_lock */
- int index;
-
- if (eq->eq_size == 0) {
- LASSERT(eq->eq_callback != LNET_EQ_HANDLER_NONE);
- eq->eq_callback(ev);
- return;
- }
-
- lnet_eq_wait_lock();
- ev->sequence = eq->eq_enq_seq++;
-
- LASSERT(eq->eq_size == LOWEST_BIT_SET(eq->eq_size));
- index = ev->sequence & (eq->eq_size - 1);
-
- eq->eq_events[index] = *ev;
-
- if (eq->eq_callback != LNET_EQ_HANDLER_NONE)
- eq->eq_callback(ev);
-
- lnet_eq_wait_unlock();
+ LASSERT(eq->eq_callback != LNET_EQ_HANDLER_NONE);
+ eq->eq_callback(ev);
}
if (the_lnet.ln_dc_state != LNET_DC_STATE_SHUTDOWN)
return -EALREADY;
- the_lnet.ln_dc_eq = LNetEQAlloc(0, lnet_discovery_event_handler);
+ the_lnet.ln_dc_eq = LNetEQAlloc(lnet_discovery_event_handler);
if (IS_ERR(the_lnet.ln_dc_eq)) {
rc = PTR_ERR(the_lnet.ln_dc_eq);
CERROR("Can't allocate discovery EQ: %d\n", rc);
srpc_data.rpc_state = SRPC_STATE_NI_INIT;
- srpc_data.rpc_lnet_eq = LNetEQAlloc(0, srpc_lnet_ev_handler);
+ srpc_data.rpc_lnet_eq = LNetEQAlloc(srpc_lnet_ev_handler);
if (IS_ERR(srpc_data.rpc_lnet_eq)) {
rc = PTR_ERR(srpc_data.rpc_lnet_eq);
CERROR("LNetEQAlloc() has failed: %d\n", rc);
* because we are guaranteed to get every event via callback,
* so we just set EQ size to 0 to avoid overhread of serializing
* enqueue/dequeue operations in LNet. */
- ptlrpc_eq = LNetEQAlloc(0, ptlrpc_master_callback);
+ ptlrpc_eq = LNetEQAlloc(ptlrpc_master_callback);
if (!IS_ERR(ptlrpc_eq))
return 0;