[apparmor] [PATCH] parser: add basic support for parallel compiles and loads

Seth Arnold seth.arnold at canonical.com
Mon Nov 30 20:41:27 UTC 2015


On Sat, Nov 28, 2015 at 11:08:05AM -0800, John Johansen wrote:
> +static void setup_parallel_compile(void)
> +{
> +	/* jobs_count and paralell_max set by default, config or args */
> +	long n = sysconf(_SC_NPROCESSORS_ONLN);

We should handle an error return here ..

> +	if (jobs_count == JOBS_AUTO)
> +		jobs_count = n;
> +	if (jobs_max == JOBS_AUTO)
> +		jobs_max = n;
> +	/* jobs_max will be used internally */
> +	jobs_max = min(jobs_count, jobs_max);
> +	if (jobs_max > 8*n) {
> +		PERROR("%s: Invalid maximum number of jobs '%ld' > 8 * # of cpus",
> +		       progname, jobs_max);
> +		exit(1);		
> +	}
> +	else if (jobs_max < 1) {
> +		PERROR("%s: Invalid maximum number of jobs '%ld'",
> +		       progname, jobs_max);
> +		exit(1);
> +	}

.. because this test could be tripped with a -1 return from sysconf().

If sysconf() fails we should probably just go with n = 2 or something
conservative.

I like the cap on eight times the number of CPUs.

Thanks
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <https://lists.ubuntu.com/archives/apparmor/attachments/20151130/f163ec59/attachment.pgp>


More information about the AppArmor mailing list