1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

added ability to pin IRQs

This commit is contained in:
Steffen Vogel 2016-06-13 17:16:45 +02:00
parent c53cb80f42
commit f3951afd18
2 changed files with 26 additions and 1 deletions

View file

@ -10,6 +10,8 @@
#ifndef _LINUX_H_
#define _LINUX_H_
#include <stdint.h>
//#include <sys/capability.h>
/** Check if current process has capability \p cap.
@ -61,4 +63,7 @@ int kernel_module_set_param(const char *module, const char *param, const char *v
/** Get cacheline size in bytes */
int kernel_get_cacheline_size();
/** Set SMP affinity of IRQ */
int kernel_irq_setaffinity(unsigned irq, uintmax_t new, uintmax_t *old);
#endif /* _LINUX_H_ */

View file

@ -158,4 +158,24 @@ int kernel_check_cap(cap_value_t cap)
return value == CAP_SET ? 0 : -1;
}
#endif
#endif
int kernel_irq_setaffinity(unsigned irq, uintmax_t new, uintmax_t *old)
{
char fn[64];
FILE *f;
snprintf(fn, sizeof(fn), "/proc/irq/%u/smp_affinity", irq);
f = fopen(fn, "w+");
if (!f)
return -1; /* IRQ does not exist */
if (old)
fscanf(f, "%jx", old);
fprintf(f, "%jx", new);
fclose(f);
return 0;
}