Skip to content

Commit

Permalink
Check CPUs online, not configured.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Zeph / Liz Loss-Cutler-Hull authored and mchehab committed Oct 23, 2023
1 parent f63b4c9 commit f1ea763
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion ras-events.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit f1ea763

Please sign in to comment.