History

taskstats: fix struct taskstats breaks backward compatibility since version 15

Problem ======== commit 658eb5ab916d ("delayacct: add delay max to record delay peak") - adding more fields commit f65c64f311ee ("delayacct: add delay min to record delay peak") - adding more fields commit b016d0873777 ("taskstats: modify taskstats version") - version bump to 15 Since version 15 (TASKSTATS_VERSION=15) the new layout of the structure adds fields in the middle of the structure, rendering all old software incompatible with newer kernels and software compiled against the new kernel headers incompatible with older kernels. Solution ========= move delay max and delay min to the end of taskstat, and bump the version to 16 after the change [wang.yaxin@zte.com.cn: adjust indentation] Link: https://lkml.kernel.org/r/202505192131489882NSciXV4EGd8zzjLuwoOK@zte.com.cn Link: https://lkml.kernel.org/r/20250510155413259V4JNRXxukdDgzsaL0Fo6a@zte.com.cn Fixes: f65c64f311ee ("delayacct: add delay min to record delay peak") Signed-off-by: Wang Yaxin <wang.yaxin@zte.com.cn> Signed-off-by: xu xin <xu.xin16@zte.com.cn> Signed-off-by: Kun Jiang <jiang.kun2@zte.com.cn> Reviewed-by: Yang Yang <yang.yang29@zte.com.cn> Cc: Balbir Singh <bsingharora@gmail.com> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

Wang Yaxin committed 1 year ago

Commit 0bf2d831 parent 66f28ff1 file · +29 −18Browse files

Showing the changes to include/uapi/linux (1 of 1 file). Show all

Unified · Split

include/uapi/linux/taskstats.h+29−18
@@ -34,7 +34,7 @@ · 33 unmodified lines
3434 */
3535
3636
37−#define TASKSTATS_VERSION 15
37+#define TASKSTATS_VERSION 16
3838 #define TS_COMM_LEN 32 /* should be >= TASK_COMM_LEN
3939 * in linux/sched.h */
4040
@@ -72,8 +72,6 @@ struct taskstats { · 31 unmodified lines
7272 */
7373 __u64 cpu_count __attribute__((aligned(8)));
7474 __u64 cpu_delay_total;
75− __u64 cpu_delay_max;
76− __u64 cpu_delay_min;
7775
7876 /* Following four fields atomically updated using task->delays->lock */
7977
@@ -82,14 +80,10 @@ struct taskstats { · 2 unmodified lines
8280 */
8381 __u64 blkio_count;
8482 __u64 blkio_delay_total;
85− __u64 blkio_delay_max;
86− __u64 blkio_delay_min;
8783
8884 /* Delay waiting for page fault I/O (swap in only) */
8985 __u64 swapin_count;
9086 __u64 swapin_delay_total;
91− __u64 swapin_delay_max;
92− __u64 swapin_delay_min;
9387
9488 /* cpu "wall-clock" running time
9589 * On some architectures, value will adjust for cpu time stolen
@@ -172,14 +166,11 @@ struct taskstats { · 76 unmodified lines
172166 /* Delay waiting for memory reclaim */
173167 __u64 freepages_count;
174168 __u64 freepages_delay_total;
175− __u64 freepages_delay_max;
176− __u64 freepages_delay_min;
169+
177170
178171 /* Delay waiting for thrashing page */
179172 __u64 thrashing_count;
180173 __u64 thrashing_delay_total;
181− __u64 thrashing_delay_max;
182− __u64 thrashing_delay_min;
183174
184175 /* v10: 64-bit btime to avoid overflow */
185176 __u64 ac_btime64; /* 64-bit begin time */
@@ -187,8 +178,6 @@ struct taskstats { · 1 unmodified line
187178 /* v11: Delay waiting for memory compact */
188179 __u64 compact_count;
189180 __u64 compact_delay_total;
190− __u64 compact_delay_max;
191− __u64 compact_delay_min;
192181
193182 /* v12 begin */
194183 __u32 ac_tgid; /* thread group ID */
@@ -210,15 +199,37 @@ struct taskstats { · 15 unmodified lines
210199 /* v13: Delay waiting for write-protect copy */
211200 __u64 wpcopy_count;
212201 __u64 wpcopy_delay_total;
213− __u64 wpcopy_delay_max;
214− __u64 wpcopy_delay_min;
215202
216203 /* v14: Delay waiting for IRQ/SOFTIRQ */
217204 __u64 irq_count;
218205 __u64 irq_delay_total;
219− __u64 irq_delay_max;
220− __u64 irq_delay_min;
221− /* v15: add Delay max */
206+
207+ /* v15: add Delay max and Delay min */
208+
209+ /* v16: move Delay max and Delay min to the end of taskstat */
210+ __u64 cpu_delay_max;
211+ __u64 cpu_delay_min;
212+
213+ __u64 blkio_delay_max;
214+ __u64 blkio_delay_min;
215+
216+ __u64 swapin_delay_max;
217+ __u64 swapin_delay_min;
218+
219+ __u64 freepages_delay_max;
220+ __u64 freepages_delay_min;
221+
222+ __u64 thrashing_delay_max;
223+ __u64 thrashing_delay_min;
224+
225+ __u64 compact_delay_max;
226+ __u64 compact_delay_min;
227+
228+ __u64 wpcopy_delay_max;
229+ __u64 wpcopy_delay_min;
230+
231+ __u64 irq_delay_max;
232+ __u64 irq_delay_min;
222233 };
223234
224235