* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include <stdio.h>
#include <argp.h>
+#include <dirent.h>
+#include <errno.h>
#include <fcntl.h>
-#include <string.h>
+#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <unistd.h>
-#include <sys/types.h>
#include <sys/stat.h>
-#include <errno.h>
+#include <sys/types.h>
#include "kbuffer.h"
#include "event-parse.h"
return 0;
}
+static int get_num_cpus(void)
+{
+ int num_cpus = 0;
+
+ DIR *dir;
+ struct dirent *entry;
+
+ dir = opendir(DEBUGFS "tracing/per_cpu/");
+ if (!dir)
+ return -1;
+
+ for (entry = readdir(dir); entry; entry = readdir(dir)) {
+ if (strstr(entry->d_name, "cpu"))
+ num_cpus++;
+ }
+ closedir(dir);
+
+ return num_cpus;
+}
+
static int handle_ras_events_cpu(struct pevent *pevent, int cpu)
{
int rc, fd;
return errno;
}
+ printf("Number of CPUs: %d. For now, opening just cpu0\n",
+ get_num_cpus());
+
/* FIXME: use select to open for all CPUs */
fd = open(DEBUGFS "tracing/per_cpu/cpu0/trace_pipe_raw",
O_RDONLY);