From: Alexander Zarochentsev Date: Wed, 23 Jul 2014 20:10:24 +0000 (-0700) Subject: LU-5397 obdclass: optimize busy loop wait X-Git-Tag: 2.6.51~77 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=7887a397220d84db8b38c6fc4892c3f5c5f3ad01 LU-5397 obdclass: optimize busy loop wait two optimizations in the busy loop wait in class_cleanup(): (1) remove unnecessary spinlocks protecting obd_conn_inprogress access (2) replace cond_resched by more suitable yield to unconditionally yield the CPU if the condition check fails. Xyratex-bug-id: MRP-1991 Signed-off-by: Alexander Zarochentsev Change-Id: I9079b2d04afda7d6db902392c6dcb216706a7ae4 Reviewed-on: http://review.whamcloud.com/11198 Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Dmitry Eremin Tested-by: Jenkins Reviewed-by: Oleg Drokin --- diff --git a/lustre/obdclass/obd_config.c b/lustre/obdclass/obd_config.c index 645e5aa..3914193 100644 --- a/lustre/obdclass/obd_config.c +++ b/lustre/obdclass/obd_config.c @@ -624,16 +624,12 @@ int class_cleanup(struct obd_device *obd, struct lustre_cfg *lcfg) } /* Leave this on forever */ obd->obd_stopping = 1; + spin_unlock(&obd->obd_dev_lock); /* wait for already-arrived-connections to finish. */ - while (obd->obd_conn_inprogress > 0) { - spin_unlock(&obd->obd_dev_lock); - - cond_resched(); - - spin_lock(&obd->obd_dev_lock); - } - spin_unlock(&obd->obd_dev_lock); + while (obd->obd_conn_inprogress > 0) + yield(); + smp_rmb(); if (lcfg->lcfg_bufcount >= 2 && LUSTRE_CFG_BUFLEN(lcfg, 1) > 0) { for (flag = lustre_cfg_string(lcfg, 1); *flag != 0; flag++)