Skip to content

Commit 0eecee3

Browse files
jstancekrostedt
authored andcommitted
tools/rtla: fix collision with glibc sched_attr/sched_set_attr
glibc commit 21571ca0d703 ("Linux: Add the sched_setattr and sched_getattr functions") now also provides 'struct sched_attr' and sched_setattr() which collide with the ones from rtla. In file included from src/trace.c:11: src/utils.h:49:8: error: redefinition of ‘struct sched_attr’ 49 | struct sched_attr { | ^~~~~~~~~~ In file included from /usr/include/bits/sched.h:60, from /usr/include/sched.h:43, from /usr/include/tracefs/tracefs.h:10, from src/trace.c:4: /usr/include/linux/sched/types.h:98:8: note: originally defined here 98 | struct sched_attr { | ^~~~~~~~~~ Define 'struct sched_attr' conditionally, similar to what strace did: https://lore.kernel.org/all/[email protected]/ and rename rtla's version of sched_setattr() to avoid collision. Link: https://lore.kernel.org/8088f66a7a57c1b209cd8ae0ae7c336a7f8c930d.1728572865.git.jstancek@redhat.com Signed-off-by: Jan Stancek <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent 099a840 commit 0eecee3

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

tools/tracing/rtla/src/utils.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ long parse_ns_duration(char *val)
229229

230230
#define SCHED_DEADLINE 6
231231

232-
static inline int sched_setattr(pid_t pid, const struct sched_attr *attr,
232+
static inline int syscall_sched_setattr(pid_t pid, const struct sched_attr *attr,
233233
unsigned int flags) {
234234
return syscall(__NR_sched_setattr, pid, attr, flags);
235235
}
@@ -239,7 +239,7 @@ int __set_sched_attr(int pid, struct sched_attr *attr)
239239
int flags = 0;
240240
int retval;
241241

242-
retval = sched_setattr(pid, attr, flags);
242+
retval = syscall_sched_setattr(pid, attr, flags);
243243
if (retval < 0) {
244244
err_msg("Failed to set sched attributes to the pid %d: %s\n",
245245
pid, strerror(errno));

tools/tracing/rtla/src/utils.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ update_sum(unsigned long long *a, unsigned long long *b)
4646
*a += *b;
4747
}
4848

49+
#ifndef SCHED_ATTR_SIZE_VER0
4950
struct sched_attr {
5051
uint32_t size;
5152
uint32_t sched_policy;
@@ -56,6 +57,7 @@ struct sched_attr {
5657
uint64_t sched_deadline;
5758
uint64_t sched_period;
5859
};
60+
#endif /* SCHED_ATTR_SIZE_VER0 */
5961

6062
int parse_prio(char *arg, struct sched_attr *sched_param);
6163
int parse_cpu_set(char *cpu_list, cpu_set_t *set);

0 commit comments

Comments
 (0)