[PATCH v1 2/3] policycoreutils/setfiles: use all CPU cores by default
jboero <[email protected]>
| Newsgroups | org.kernel.vger.selinux |
|---|---|
| Message-ID | <[email protected]> |
From: Johnny Boero <[email protected]> setfiles(8) and restorecon(8) have supported parallel relabeling via -T since commit 93902fc8b0b0 ("setfiles/restorecon: support parallel relabeling"), but default to a single thread, so anything that does not pass -T explicitly relabels on one core. That is most callers. RPM scriptlets, fixfiles(8) and hand-run restorecon invocations all use the default, and on a machine with a high core count the result is a long, almost entirely idle relabel: a package upgrade on an 88 core system spent hours in restorecon with 87 cores doing nothing. Default nthreads to 0, i.e. one thread per available CPU core. The relabeling is already serialized where it needs to be, and -T 1 remains available for callers that want the previous behaviour. Relabeling /usr/share (~588k files, dry run) on an 88 core system: -T 1 20.43s -T 0 15.78s Link: https://github.com/SELinuxProject/selinux/issues/489 Signed-off-by: Johnny Boero <[email protected]> --- policycoreutils/setfiles/restorecon.8 | 2 +- policycoreutils/setfiles/setfiles.8 | 2 +- policycoreutils/setfiles/setfiles.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/policycoreutils/setfiles/restorecon.8 b/policycoreutils/setfiles/restorecon.8 index 443f29ab..8d7b46f0 100644 --- a/policycoreutils/setfiles/restorecon.8 +++ b/policycoreutils/setfiles/restorecon.8 @@ -186,7 +186,7 @@ from crossing file system boundaries. use up to .I nthreads threads. Specify 0 to create as many threads as there are available -CPU cores; 1 to use only a single thread (default); or any positive +CPU cores (default); 1 to use only a single thread; or any positive number to use the given number of threads (if possible). .TP .SH "ARGUMENTS" diff --git a/policycoreutils/setfiles/setfiles.8 b/policycoreutils/setfiles/setfiles.8 index b521df22..53cb97cc 100644 --- a/policycoreutils/setfiles/setfiles.8 +++ b/policycoreutils/setfiles/setfiles.8 @@ -191,7 +191,7 @@ produces input suitable for this mode. use up to .I nthreads threads. Specify 0 to create as many threads as there are available -CPU cores; 1 to use only a single thread (default); or any positive +CPU cores (default); 1 to use only a single thread; or any positive number to use the given number of threads (if possible). .TP .B \-A diff --git a/policycoreutils/setfiles/setfiles.c b/policycoreutils/setfiles/setfiles.c index c86cc0c9..4c860755 100644 --- a/policycoreutils/setfiles/setfiles.c +++ b/policycoreutils/setfiles/setfiles.c @@ -168,7 +168,7 @@ int main(int argc, char **argv) const char *input_filename = NULL; int use_input_file = 0; char *buf = NULL; - size_t buf_len = 0, nthreads = 1; + size_t buf_len = 0, nthreads = 0; const char *base; int errors = 0; const char *ropts = "ce:f:hijIDlmno:pqrsvFURW0xT:"; -- 2.55.0