mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-08-22 18:17:09 +00:00
parser: Add the ability to turn off jobs to ease with debugging
The parser currently uses a fork model to do job processing. For consistency even when the number of jobs is set to 1 a single work process is forked. However this makes using gdb more difficult and can be even worse for other debugging tools. Make -j 0 disable all job spawning so all processing happens in the main process. PR: https://gitlab.com/apparmor/apparmor/merge_requests/105 Signed-off-by: John Johansen <john.johansen@canonical.com> Acked-by: Steve Beattie <steve@nxnw.org>
This commit is contained in:
parent
06d9a8eff0
commit
48a32b78b1
@ -304,6 +304,7 @@ Use --help=dump to see a full list of which dump flags are supported
|
|||||||
Set the number of jobs used to compile the specified policy. Where n can
|
Set the number of jobs used to compile the specified policy. Where n can
|
||||||
be
|
be
|
||||||
|
|
||||||
|
0 - disable jobs and use the main process for all compilation
|
||||||
# - a specific number of jobs
|
# - a specific number of jobs
|
||||||
auto - the # of cpus in the in the system
|
auto - the # of cpus in the in the system
|
||||||
x# - # * number of cpus
|
x# - # * number of cpus
|
||||||
|
@ -82,10 +82,10 @@ int debug_cache = 0;
|
|||||||
|
|
||||||
/* for jobs_max and jobs
|
/* for jobs_max and jobs
|
||||||
* LONG_MAX : no limit
|
* LONG_MAX : no limit
|
||||||
* 0 : auto = detect system processing cores
|
* LONG_MIN : auto = detect system processing cores
|
||||||
* n : use that number of processes/threads to compile policy
|
* n : use that number of processes/threads to compile policy
|
||||||
*/
|
*/
|
||||||
#define JOBS_AUTO 0
|
#define JOBS_AUTO LONG_MIN
|
||||||
long jobs_max = -8; /* 8 * cpus */
|
long jobs_max = -8; /* 8 * cpus */
|
||||||
long jobs = JOBS_AUTO; /* default: number of processor cores */
|
long jobs = JOBS_AUTO; /* default: number of processor cores */
|
||||||
long njobs = 0;
|
long njobs = 0;
|
||||||
@ -597,6 +597,8 @@ static int process_arg(int c, char *optarg)
|
|||||||
break;
|
break;
|
||||||
case 'j':
|
case 'j':
|
||||||
jobs = process_jobs_arg("-j", optarg);
|
jobs = process_jobs_arg("-j", optarg);
|
||||||
|
if (jobs == 0)
|
||||||
|
jobs_max = 0;
|
||||||
break;
|
break;
|
||||||
case 136:
|
case 136:
|
||||||
jobs_max = process_jobs_arg("max-jobs", optarg);
|
jobs_max = process_jobs_arg("max-jobs", optarg);
|
||||||
@ -1017,12 +1019,11 @@ do { \
|
|||||||
|
|
||||||
#define work_spawn(WORK, RESULT) \
|
#define work_spawn(WORK, RESULT) \
|
||||||
do { \
|
do { \
|
||||||
/* what to do to avoid fork() overhead when single threaded \
|
if (jobs == 0) { \
|
||||||
if (jobs == 1) { \
|
/* no parallel work so avoid fork() overhead */ \
|
||||||
// no parallel work so avoid fork() overhead \
|
|
||||||
RESULT(WORK); \
|
RESULT(WORK); \
|
||||||
break; \
|
break; \
|
||||||
}*/ \
|
} \
|
||||||
if (jobs_scale) { \
|
if (jobs_scale) { \
|
||||||
long n = sysconf(_SC_NPROCESSORS_ONLN); \
|
long n = sysconf(_SC_NPROCESSORS_ONLN); \
|
||||||
if (n > jobs_max) \
|
if (n > jobs_max) \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user