Skip to content

Commit 9f5f8ec

Browse files
Barry SongChristoph Hellwig
authored andcommitted
dma-mapping: benchmark: use u8 for reserved field in uAPI structure
The original code put five u32 before a u64 expansion[10] array. Five is odd, this will cause trouble in the extension of the structure by adding new features. This patch moves to use u8 for reserved field to avoid future alignment risk. Meanwhile, it also clears the memory of struct map_benchmark in tools, otherwise, if users use old version to run on newer kernel, the random expansion value will cause side effect on newer kernel. Signed-off-by: Barry Song <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]>
1 parent dd86e7f commit 9f5f8ec

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

kernel/dma/map_benchmark.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ struct map_benchmark {
3636
__s32 node; /* which numa node this benchmark will run on */
3737
__u32 dma_bits; /* DMA addressing capability */
3838
__u32 dma_dir; /* DMA data direction */
39-
__u64 expansion[10]; /* For future use */
39+
__u8 expansion[84]; /* For future use */
4040
};
4141

4242
struct map_benchmark_data {

tools/testing/selftests/dma/dma_map_benchmark.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <fcntl.h>
77
#include <stdio.h>
88
#include <stdlib.h>
9+
#include <string.h>
910
#include <unistd.h>
1011
#include <sys/ioctl.h>
1112
#include <sys/mman.h>
@@ -35,7 +36,7 @@ struct map_benchmark {
3536
__s32 node; /* which numa node this benchmark will run on */
3637
__u32 dma_bits; /* DMA addressing capability */
3738
__u32 dma_dir; /* DMA data direction */
38-
__u64 expansion[10]; /* For future use */
39+
__u8 expansion[84]; /* For future use */
3940
};
4041

4142
int main(int argc, char **argv)
@@ -102,6 +103,7 @@ int main(int argc, char **argv)
102103
exit(1);
103104
}
104105

106+
memset(&map, 0, sizeof(map));
105107
map.seconds = seconds;
106108
map.threads = threads;
107109
map.node = node;

0 commit comments

Comments
 (0)