atrun(8): scale default load average limit with the number of CPUs
Previously atrun refused to run jobs if load average was not below fixed limit of 1.5. PR: 173175 Reviewed by: peterj Approved by: trasz (mentor) MFC after: 2 weeks
This commit is contained in:
parent
7a75e881d7
commit
e61e6189e5
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=242372
@ -33,6 +33,9 @@ static const char rcsid[] =
|
|||||||
#include <sys/fcntl.h>
|
#include <sys/fcntl.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#ifdef __FreeBSD__
|
||||||
|
#include <sys/sysctl.h>
|
||||||
|
#endif
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
@ -454,7 +457,12 @@ main(int argc, char *argv[])
|
|||||||
gid_t batch_gid;
|
gid_t batch_gid;
|
||||||
int c;
|
int c;
|
||||||
int run_batch;
|
int run_batch;
|
||||||
|
#ifdef __FreeBSD__
|
||||||
|
size_t ncpu, ncpusz;
|
||||||
|
double load_avg = -1;
|
||||||
|
#else
|
||||||
double load_avg = LOADAVG_MX;
|
double load_avg = LOADAVG_MX;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* We don't need root privileges all the time; running under uid and gid daemon
|
/* We don't need root privileges all the time; running under uid and gid daemon
|
||||||
* is fine.
|
* is fine.
|
||||||
@ -472,8 +480,10 @@ main(int argc, char *argv[])
|
|||||||
case 'l':
|
case 'l':
|
||||||
if (sscanf(optarg, "%lf", &load_avg) != 1)
|
if (sscanf(optarg, "%lf", &load_avg) != 1)
|
||||||
perr("garbled option -l");
|
perr("garbled option -l");
|
||||||
|
#ifndef __FreeBSD__
|
||||||
if (load_avg <= 0.)
|
if (load_avg <= 0.)
|
||||||
load_avg = LOADAVG_MX;
|
load_avg = LOADAVG_MX;
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'd':
|
case 'd':
|
||||||
@ -489,6 +499,15 @@ main(int argc, char *argv[])
|
|||||||
if (chdir(ATJOB_DIR) != 0)
|
if (chdir(ATJOB_DIR) != 0)
|
||||||
perr("cannot change to %s", ATJOB_DIR);
|
perr("cannot change to %s", ATJOB_DIR);
|
||||||
|
|
||||||
|
#ifdef __FreeBSD__
|
||||||
|
if (load_avg <= 0.) {
|
||||||
|
ncpusz = sizeof(size_t);
|
||||||
|
if (sysctlbyname("hw.ncpu", &ncpu, &ncpusz, NULL, 0) < 0)
|
||||||
|
ncpu = 1;
|
||||||
|
load_avg = LOADAVG_MX * ncpu;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Main loop. Open spool directory for reading and look over all the
|
/* Main loop. Open spool directory for reading and look over all the
|
||||||
* files in there. If the filename indicates that the job should be run
|
* files in there. If the filename indicates that the job should be run
|
||||||
* and the x bit is set, fork off a child which sets its user and group
|
* and the x bit is set, fork off a child which sets its user and group
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
.\" $FreeBSD$
|
.\" $FreeBSD$
|
||||||
.Dd June 17, 2007
|
.Dd October 30, 2012
|
||||||
.Dt ATRUN 8
|
.Dt ATRUN 8
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
@ -45,7 +45,7 @@ e.g., locked out or expired.
|
|||||||
.Bl -tag -width indent
|
.Bl -tag -width indent
|
||||||
.It Fl l Ar load_avg
|
.It Fl l Ar load_avg
|
||||||
Specify a limiting load factor, over which batch jobs should
|
Specify a limiting load factor, over which batch jobs should
|
||||||
not be run, instead of the compiled in default of 1.5.
|
not be run, instead of the default of 1.5 * number of active CPUs.
|
||||||
.It Fl d
|
.It Fl d
|
||||||
Debug; print error messages to standard error instead of using
|
Debug; print error messages to standard error instead of using
|
||||||
.Xr syslog 3 .
|
.Xr syslog 3 .
|
||||||
|
Loading…
Reference in New Issue
Block a user