Skip to content

Commit 9007979

Browse files
arndbakpm00
authored andcommitted
delayacct: fix uapi timespec64 definition
The custom definition of 'struct timespec64' is incompatible with both the kernel's internal definition and the glibc type, at least on big-endian targets that have the tv_nsec field in a different place, and the definition clashes with any userspace that also defines a timespec64 structure. Running the header check with -Wpadding enabled produces this output that warns about the incorrect padding: usr/include/linux/taskstats.h:25:1: error: padding struct size to alignment boundary with 4 bytes [-Werror=padded] Remove the hack and instead use the regular __kernel_timespec type that is meant to be used in uapi definitions. Link: https://lkml.kernel.org/r/20260202095906.1344100-1-arnd@kernel.org Fixes: 29b63f6 ("delayacct: add timestamp of delay max") Signed-off-by: Arnd Bergmann <arnd@arndb.de> Cc: Fan Yu <fan.yu9@zte.com.cn> Cc: Jonathan Corbet <corbet@lwn.net> Cc: xu xin <xu.xin16@zte.com.cn> Cc: Yang Yang <yang.yang29@zte.com.cn> Cc: Balbir Singh <bsingharora@gmail.com> Cc: Jiang Kun <jiang.kun2@zte.com.cn> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 2e171ab commit 9007979

2 files changed

Lines changed: 13 additions & 20 deletions

File tree

include/uapi/linux/taskstats.h

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,7 @@
1818
#define _LINUX_TASKSTATS_H
1919

2020
#include <linux/types.h>
21-
#ifdef __KERNEL__
22-
#include <linux/time64.h>
23-
#else
24-
#ifndef _LINUX_TIME64_H
25-
struct timespec64 {
26-
__s64 tv_sec; /* seconds */
27-
long tv_nsec; /* nanoseconds */
28-
};
29-
#endif
30-
#endif
21+
#include <linux/time_types.h>
3122

3223
/* Format for per-task data returned to userland when
3324
* - a task exits
@@ -242,14 +233,14 @@ struct taskstats {
242233
__u64 irq_delay_min;
243234

244235
/*v17: delay max timestamp record*/
245-
struct timespec64 cpu_delay_max_ts;
246-
struct timespec64 blkio_delay_max_ts;
247-
struct timespec64 swapin_delay_max_ts;
248-
struct timespec64 freepages_delay_max_ts;
249-
struct timespec64 thrashing_delay_max_ts;
250-
struct timespec64 compact_delay_max_ts;
251-
struct timespec64 wpcopy_delay_max_ts;
252-
struct timespec64 irq_delay_max_ts;
236+
struct __kernel_timespec cpu_delay_max_ts;
237+
struct __kernel_timespec blkio_delay_max_ts;
238+
struct __kernel_timespec swapin_delay_max_ts;
239+
struct __kernel_timespec freepages_delay_max_ts;
240+
struct __kernel_timespec thrashing_delay_max_ts;
241+
struct __kernel_timespec compact_delay_max_ts;
242+
struct __kernel_timespec wpcopy_delay_max_ts;
243+
struct __kernel_timespec irq_delay_max_ts;
253244
};
254245

255246

kernel/delayacct.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
do { \
1919
d->type##_delay_max = tsk->delays->type##_delay_max; \
2020
d->type##_delay_min = tsk->delays->type##_delay_min; \
21-
d->type##_delay_max_ts = tsk->delays->type##_delay_max_ts; \
21+
d->type##_delay_max_ts.tv_sec = tsk->delays->type##_delay_max_ts.tv_sec; \
22+
d->type##_delay_max_ts.tv_nsec = tsk->delays->type##_delay_max_ts.tv_nsec; \
2223
tmp = d->type##_delay_total + tsk->delays->type##_delay; \
2324
d->type##_delay_total = (tmp < d->type##_delay_total) ? 0 : tmp; \
2425
d->type##_count += tsk->delays->type##_count; \
@@ -175,7 +176,8 @@ int delayacct_add_tsk(struct taskstats *d, struct task_struct *tsk)
175176

176177
d->cpu_delay_max = tsk->sched_info.max_run_delay;
177178
d->cpu_delay_min = tsk->sched_info.min_run_delay;
178-
d->cpu_delay_max_ts = tsk->sched_info.max_run_delay_ts;
179+
d->cpu_delay_max_ts.tv_sec = tsk->sched_info.max_run_delay_ts.tv_sec;
180+
d->cpu_delay_max_ts.tv_nsec = tsk->sched_info.max_run_delay_ts.tv_nsec;
179181
tmp = (s64)d->cpu_delay_total + t2;
180182
d->cpu_delay_total = (tmp < (s64)d->cpu_delay_total) ? 0 : tmp;
181183
tmp = (s64)d->cpu_run_virtual_total + t3;

0 commit comments

Comments
 (0)