osd: get loadavg per cpu for scrub load threshold check

Signed-off-by: kungf <yang.wang@easystack.cn>
This commit is contained in:
kungf 2017-09-14 14:09:30 +08:00
parent 07159477ee
commit c1dba46084

View File

@ -13,7 +13,7 @@
*
*/
#include "acconfig.h"
#include <unistd.h>
#include <fstream>
#include <iostream>
#include <errno.h>
@ -7099,8 +7099,10 @@ bool OSD::scrub_load_below_threshold()
}
// allow scrub if below configured threshold
if (loadavgs[0] < cct->_conf->osd_scrub_load_threshold) {
dout(20) << __func__ << " loadavg " << loadavgs[0]
long cpus = sysconf(_SC_NPROCESSORS_ONLN);
double loadavg_per_cpu = cpus > 0 ? loadavgs[0] / cpus : loadavgs[0];
if (loadavg_per_cpu < cct->_conf->osd_scrub_load_threshold) {
dout(20) << __func__ << " loadavg per cpu " << loadavg_per_cpu
<< " < max " << cct->_conf->osd_scrub_load_threshold
<< " = yes" << dendl;
return true;