]> www.infradead.org Git - users/mchehab/rasdaemon.git/commitdiff
Check CPUs online, not configured.
authorZeph / Liz Loss-Cutler-Hull <warp-spam_git@aehallh.com>
Sun, 9 Jul 2023 11:57:19 +0000 (04:57 -0700)
committerMauro Carvalho Chehab <mchehab@kernel.org>
Mon, 23 Oct 2023 09:06:23 +0000 (11:06 +0200)
When the number of CPUs detected is greater than the number of CPUs in
the system, rasdaemon will crash when it receives some events.

Looking deeper, we also fail to use the poll method for similar reasons
in this case.

All of this can be prevented by checking to see how many CPUs are
currently online (sysconf(_SC_NPROCESSORS_ONLN)) instead of how many
CPUs the current kernel was configured to support
(sysconf(_SC_NPROCESSORS_CONF)).

For the kernel side of the discussion, see https://lore.kernel.org/lkml/CAM6Wdxft33zLeeXHhmNX5jyJtfGTLiwkQSApc=10fqf+rQh9DA@mail.gmail.com/T/
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
ras-events.c

index a82dab254773d72d9ab762c82ecb6ddc01b5a724..59351631e48395f7853c84701e4cfaee5086b7fe 100644 (file)
@@ -350,7 +350,7 @@ static void parse_ras_data(struct pthread_data *pdata, struct kbuffer *kbuf,
 
 static int get_num_cpus(struct ras_events *ras)
 {
-       return sysconf(_SC_NPROCESSORS_CONF);
+       return sysconf(_SC_NPROCESSORS_ONLN);
 #if 0
        char fname[MAX_PATH + 1];
        int num_cpus = 0;