- /* FIXME: start one thread per CPU */
- rc = handle_ras_events_cpu(pevent, 0, page_size);
+ cpus = get_num_cpus();
+ data = calloc(sizeof(*data), cpus);
+ if (!data)
+ goto free_pevent;
+
+ printf("Opening one thread per cpu (%d threads)\n", cpus);
+ for (i = 0; i < cpus; i++) {
+ data[i].pevent = pevent;
+ data[i].cpu = i;
+ data[i].page_size = page_size;
+
+ rc = pthread_create(&data[i].thread, NULL,
+ handle_ras_events_cpu,
+ (void *)&data[i]);
+ if (rc) {
+ while (--i)
+ pthread_cancel(data[i].thread);
+ goto free_threads;
+ }
+ }
+
+ /* Wait for all threads to complete */
+ for (i = 0; i < cpus; i++)
+ pthread_join(data[i].thread, NULL);
+
+free_threads:
+ free(data);