[ofa-general] Re: [PATCH] opensm: serialize osm_state_mgr_process()
Sasha Khapyorsky
sashak at voltaire.com
Tue Aug 28 15:12:38 PDT 2007
On 14:34 Tue 28 Aug , Sasha Khapyorsky wrote:
>
[snip...]
> diff --git a/opensm/opensm/osm_sm.c b/opensm/opensm/osm_sm.c
> index 6fc9496..c052456 100644
> --- a/opensm/opensm/osm_sm.c
> +++ b/opensm/opensm/osm_sm.c
> @@ -69,50 +69,51 @@
>
> /**********************************************************************
> **********************************************************************/
> -void __osm_sm_sweeper(IN void *p_ptr)
> +static void __osm_sm_sweeper(IN void *p_ptr)
> {
> ib_api_status_t status;
> osm_sm_t *const p_sm = (osm_sm_t *) p_ptr;
> + unsigned signals, i;
>
> OSM_LOG_ENTER(p_sm->p_log, __osm_sm_sweeper);
>
> - if (p_sm->thread_state == OSM_THREAD_STATE_INIT) {
> - p_sm->thread_state = OSM_THREAD_STATE_RUN;
> - }
> -
> - /* If the sweep interval was updated before - then run only if
> - * it is not zero. */
> - while (p_sm->thread_state == OSM_THREAD_STATE_RUN &&
> - p_sm->p_subn->opt.sweep_interval != 0) {
> - /* do the sweep only if we are in MASTER state */
> - if (p_sm->p_subn->sm_state == IB_SMINFO_STATE_MASTER ||
> - p_sm->p_subn->sm_state == IB_SMINFO_STATE_DISCOVERING)
> - osm_state_mgr_process(&p_sm->state_mgr,
> - OSM_SIGNAL_SWEEP);
> -
> + while (p_sm->thread_state == OSM_THREAD_STATE_RUN) {
> /*
> * Wait on the event with a timeout.
> * Sweeps may be initiated "off schedule" by simply
> * signaling the event.
> */
> - status = cl_event_wait_on(&p_sm->signal,
> + status = cl_event_wait_on(&p_sm->signal_event,
> + p_sm->p_subn->opt.sweep_interval ?
> p_sm->p_subn->opt.sweep_interval *
> - 1000000, TRUE);
> -
> - if (status == CL_SUCCESS) {
> - if (osm_log_is_active(p_sm->p_log, OSM_LOG_DEBUG)) {
> - osm_log(p_sm->p_log, OSM_LOG_DEBUG,
> - "__osm_sm_sweeper: "
> - "Off schedule sweep signalled\n");
> - }
> - } else {
> - if (status != CL_TIMEOUT) {
> - osm_log(p_sm->p_log, OSM_LOG_ERROR,
> - "__osm_sm_sweeper: ERR 2E01: "
> - "Event wait failed (%s)\n",
> - CL_STATUS_MSG(status));
> - }
> + 1000000 : EVENT_NO_TIMEOUT, TRUE);
> +
> + if (status == CL_SUCCESS)
> + osm_log(p_sm->p_log, OSM_LOG_DEBUG,
> + "__osm_sm_sweeper: "
> + "Off schedule sweep signalled\n");
> + else if (status != CL_TIMEOUT) {
> + osm_log(p_sm->p_log, OSM_LOG_ERROR,
> + "__osm_sm_sweeper: ERR 2E01: "
> + "Event wait failed (%s)\n",
> + CL_STATUS_MSG(status));
> + continue;
> }
> +
> + cl_spinlock_acquire(&p_sm->signal_lock);
> + signals = p_sm->signal_mask;
> + p_sm->signal_mask = 0;
> + cl_spinlock_release(&p_sm->signal_lock);
> +
> + /* do the sweep only if we are in MASTER state */
> + if (status == CL_TIMEOUT &&
> + (p_sm->p_subn->sm_state == IB_SMINFO_STATE_MASTER ||
> + p_sm->p_subn->sm_state == IB_SMINFO_STATE_DISCOVERING))
> + p_sm->signal_mask |= 1 << OSM_SIGNAL_SWEEP;
Actually here should be just:
signals != 1 << OSM_SIGNAL_SWEEP;
> +
> + for (i = 0 ; signals ; signals >>= 1 , i++)
> + if (signals&1)
> + osm_state_mgr_process(&p_sm->state_mgr, i);
> }
>
> OSM_LOG_EXIT(p_sm->p_log);
More information about the general
mailing list