Commit 9f5f8ec5 authored by Barry Song's avatar Barry Song Committed by Christoph Hellwig

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: default avatarBarry Song <song.bao.hua@hisilicon.com>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
parent dd86e7fa
...@@ -36,7 +36,7 @@ struct map_benchmark { ...@@ -36,7 +36,7 @@ struct map_benchmark {
__s32 node; /* which numa node this benchmark will run on */ __s32 node; /* which numa node this benchmark will run on */
__u32 dma_bits; /* DMA addressing capability */ __u32 dma_bits; /* DMA addressing capability */
__u32 dma_dir; /* DMA data direction */ __u32 dma_dir; /* DMA data direction */
__u64 expansion[10]; /* For future use */ __u8 expansion[84]; /* For future use */
}; };
struct map_benchmark_data { struct map_benchmark_data {
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include <fcntl.h> #include <fcntl.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include <unistd.h> #include <unistd.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <sys/mman.h> #include <sys/mman.h>
...@@ -35,7 +36,7 @@ struct map_benchmark { ...@@ -35,7 +36,7 @@ struct map_benchmark {
__s32 node; /* which numa node this benchmark will run on */ __s32 node; /* which numa node this benchmark will run on */
__u32 dma_bits; /* DMA addressing capability */ __u32 dma_bits; /* DMA addressing capability */
__u32 dma_dir; /* DMA data direction */ __u32 dma_dir; /* DMA data direction */
__u64 expansion[10]; /* For future use */ __u8 expansion[84]; /* For future use */
}; };
int main(int argc, char **argv) int main(int argc, char **argv)
...@@ -102,6 +103,7 @@ int main(int argc, char **argv) ...@@ -102,6 +103,7 @@ int main(int argc, char **argv)
exit(1); exit(1);
} }
memset(&map, 0, sizeof(map));
map.seconds = seconds; map.seconds = seconds;
map.threads = threads; map.threads = threads;
map.node = node; map.node = node;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment