* [BUGFIX PATCH v3 0/5] selftests: Fixes for 32bit arch
@ 2019-10-23 4:57 Masami Hiramatsu
2019-10-23 4:57 ` [BUGFIX PATCH v3 1/5] selftests: proc: Make va_max 1MB Masami Hiramatsu
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: Masami Hiramatsu @ 2019-10-23 4:57 UTC (permalink / raw)
To: Shuah Khan
Cc: linux-kselftest, linux-kernel, jaswinder.singh, Alexey Dobriyan,
Anshuman Khandual, Aneesh Kumar K . V, Eric Dumazet,
David S . Miller, Willem de Bruijn, Emilio López
Hi,
Here are the 3rd version of kselftest fixes some on 32bit arch
(e.g. arm)
In this version, I updated [1/5] to make va_max 1MB unconditionally
according to Alexey's comment.
When I built the ksefltest on arm, I hit some 32bit related warnings.
Here are the patches to fix those issues.
- [1/5] va_max was set 2^32 even on 32bit arch. This can make
va_max == 0 and always fail. Make it 1GB unconditionally.
- [2/5] Some VM tests requires 64bit user space, which should
not run on 32bit arch.
- [3/5] For counting the size of large file, we should use
size_t instead of unsinged long.
- [4/5] Gcc warns printf format for size_t and int64_t on
32bit arch. Use %llu and cast it.
- [5/5] Gcc warns __u64 and pointer type castings. It should
once translated to unsigned long.
Thank you,
---
Masami Hiramatsu (5):
selftests: proc: Make va_max 1MB
selftests: vm: Build/Run 64bit tests only on 64bit arch
selftests: net: Use size_t and ssize_t for counting file size
selftests: net: Fix printf format warnings on arm
selftests: sync: Fix cast warnings on arm
tools/testing/selftests/net/so_txtime.c | 4 ++--
tools/testing/selftests/net/tcp_mmap.c | 8 ++++----
tools/testing/selftests/net/udpgso.c | 3 ++-
tools/testing/selftests/net/udpgso_bench_tx.c | 3 ++-
.../selftests/proc/proc-self-map-files-002.c | 6 +++++-
tools/testing/selftests/sync/sync.c | 6 +++---
tools/testing/selftests/vm/Makefile | 5 +++++
tools/testing/selftests/vm/run_vmtests | 10 ++++++++++
8 files changed, 33 insertions(+), 12 deletions(-)
--
Masami Hiramatsu (Linaro) <mhiramat@kernel.org>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [BUGFIX PATCH v3 1/5] selftests: proc: Make va_max 1MB
2019-10-23 4:57 [BUGFIX PATCH v3 0/5] selftests: Fixes for 32bit arch Masami Hiramatsu
@ 2019-10-23 4:57 ` Masami Hiramatsu
2019-10-23 4:57 ` [BUGFIX PATCH v3 2/5] selftests: vm: Build/Run 64bit tests only on 64bit arch Masami Hiramatsu
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Masami Hiramatsu @ 2019-10-23 4:57 UTC (permalink / raw)
To: Shuah Khan
Cc: linux-kselftest, linux-kernel, jaswinder.singh, Alexey Dobriyan
Currently proc-self-map-files-002.c sets va_max (max test address
of user virtual address) to 4GB, but it is too big for 32bit
arch and 1UL << 32 is overflow on 32bit long.
Also since this value should be enough bigger than vm.mmap_min_addr
(64KB or 32KB by default), 1MB should be enough.
Make va_max 1MB unconditionally.
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
---
Changes in v3:
- Make the va_max 1MB unconditionally, according to Alexey's comment.
Changes in v2:
- Make the va_max 1GB according to Alexey's comment.
---
.../selftests/proc/proc-self-map-files-002.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/proc/proc-self-map-files-002.c b/tools/testing/selftests/proc/proc-self-map-files-002.c
index 47b7473dedef..e6aa00a183bc 100644
--- a/tools/testing/selftests/proc/proc-self-map-files-002.c
+++ b/tools/testing/selftests/proc/proc-self-map-files-002.c
@@ -47,7 +47,11 @@ static void fail(const char *fmt, unsigned long a, unsigned long b)
int main(void)
{
const int PAGE_SIZE = sysconf(_SC_PAGESIZE);
- const unsigned long va_max = 1UL << 32;
+ /*
+ * va_max must be enough bigger than vm.mmap_min_addr, which is
+ * 64KB/32KB by default. (depends on CONFIG_LSM_MMAP_MIN_ADDR)
+ */
+ const unsigned long va_max = 1UL << 20;
unsigned long va;
void *p;
int fd;
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [BUGFIX PATCH v3 2/5] selftests: vm: Build/Run 64bit tests only on 64bit arch
2019-10-23 4:57 [BUGFIX PATCH v3 0/5] selftests: Fixes for 32bit arch Masami Hiramatsu
2019-10-23 4:57 ` [BUGFIX PATCH v3 1/5] selftests: proc: Make va_max 1MB Masami Hiramatsu
@ 2019-10-23 4:57 ` Masami Hiramatsu
2019-10-23 4:57 ` [BUGFIX PATCH v3 3/5] selftests: net: Use size_t and ssize_t for counting file size Masami Hiramatsu
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Masami Hiramatsu @ 2019-10-23 4:57 UTC (permalink / raw)
To: Shuah Khan
Cc: linux-kselftest, linux-kernel, jaswinder.singh,
Anshuman Khandual, Aneesh Kumar K . V
Some virtual address range tests requires 64bit address space,
and we can not build and run those tests on the 32bit machine.
Filter the 64bit architectures in Makefile and run_vmtests,
so that those tests are built/run only on 64bit archs.
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Anshuman Khandual <khandual@linux.vnet.ibm.com>
Cc: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
---
tools/testing/selftests/vm/Makefile | 5 +++++
tools/testing/selftests/vm/run_vmtests | 10 ++++++++++
2 files changed, 15 insertions(+)
diff --git a/tools/testing/selftests/vm/Makefile b/tools/testing/selftests/vm/Makefile
index 9534dc2bc929..7f9a8a8c31da 100644
--- a/tools/testing/selftests/vm/Makefile
+++ b/tools/testing/selftests/vm/Makefile
@@ -1,5 +1,7 @@
# SPDX-License-Identifier: GPL-2.0
# Makefile for vm selftests
+uname_M := $(shell uname -m 2>/dev/null || echo not)
+ARCH ?= $(shell echo $(uname_M) | sed -e 's/aarch64.*/arm64/')
CFLAGS = -Wall -I ../../../../usr/include $(EXTRA_CFLAGS)
LDLIBS = -lrt
@@ -16,8 +18,11 @@ TEST_GEN_FILES += on-fault-limit
TEST_GEN_FILES += thuge-gen
TEST_GEN_FILES += transhuge-stress
TEST_GEN_FILES += userfaultfd
+
+ifneq (,$(filter $(ARCH),arm64 ia64 mips64 parisc64 ppc64 riscv64 s390x sh64 sparc64 x86_64))
TEST_GEN_FILES += va_128TBswitch
TEST_GEN_FILES += virtual_address_range
+endif
TEST_PROGS := run_vmtests
diff --git a/tools/testing/selftests/vm/run_vmtests b/tools/testing/selftests/vm/run_vmtests
index 951c507a27f7..a692ea828317 100755
--- a/tools/testing/selftests/vm/run_vmtests
+++ b/tools/testing/selftests/vm/run_vmtests
@@ -58,6 +58,14 @@ else
exit 1
fi
+#filter 64bit architectures
+ARCH64STR="arm64 ia64 mips64 parisc64 ppc64 riscv64 s390x sh64 sparc64 x86_64"
+if [ -z $ARCH ]; then
+ ARCH=`uname -m 2>/dev/null | sed -e 's/aarch64.*/arm64/'`
+fi
+VADDR64=0
+echo "$ARCH64STR" | grep $ARCH && VADDR64=1
+
mkdir $mnt
mount -t hugetlbfs none $mnt
@@ -189,6 +197,7 @@ else
echo "[PASS]"
fi
+if [ $VADDR64 -ne 0 ]; then
echo "-----------------------------"
echo "running virtual_address_range"
echo "-----------------------------"
@@ -210,6 +219,7 @@ if [ $? -ne 0 ]; then
else
echo "[PASS]"
fi
+fi # VADDR64
echo "------------------------------------"
echo "running vmalloc stability smoke test"
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [BUGFIX PATCH v3 3/5] selftests: net: Use size_t and ssize_t for counting file size
2019-10-23 4:57 [BUGFIX PATCH v3 0/5] selftests: Fixes for 32bit arch Masami Hiramatsu
2019-10-23 4:57 ` [BUGFIX PATCH v3 1/5] selftests: proc: Make va_max 1MB Masami Hiramatsu
2019-10-23 4:57 ` [BUGFIX PATCH v3 2/5] selftests: vm: Build/Run 64bit tests only on 64bit arch Masami Hiramatsu
@ 2019-10-23 4:57 ` Masami Hiramatsu
2019-10-23 4:58 ` [BUGFIX PATCH v3 4/5] selftests: net: Fix printf format warnings on arm Masami Hiramatsu
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Masami Hiramatsu @ 2019-10-23 4:57 UTC (permalink / raw)
To: Shuah Khan
Cc: linux-kselftest, linux-kernel, jaswinder.singh, Eric Dumazet,
David S . Miller
Use size_t and ssize_t correctly for counting send file size
instead of unsigned long and long, because long is 32bit on
32bit arch, which is not enough for counting long file size (>4GB).
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Eric Dumazet <edumazet@google.com>
Cc: David S. Miller <davem@davemloft.net>
---
tools/testing/selftests/net/tcp_mmap.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/tools/testing/selftests/net/tcp_mmap.c b/tools/testing/selftests/net/tcp_mmap.c
index 31ced79f4f25..33035d1b3f6d 100644
--- a/tools/testing/selftests/net/tcp_mmap.c
+++ b/tools/testing/selftests/net/tcp_mmap.c
@@ -71,7 +71,7 @@
#define MSG_ZEROCOPY 0x4000000
#endif
-#define FILE_SZ (1UL << 35)
+#define FILE_SZ (1ULL << 35)
static int cfg_family = AF_INET6;
static socklen_t cfg_alen = sizeof(struct sockaddr_in6);
static int cfg_port = 8787;
@@ -155,7 +155,7 @@ void *child_thread(void *arg)
socklen_t zc_len = sizeof(zc);
int res;
- zc.address = (__u64)addr;
+ zc.address = (__u64)((unsigned long)addr);
zc.length = chunk_size;
zc.recv_skip_hint = 0;
res = getsockopt(fd, IPPROTO_TCP, TCP_ZEROCOPY_RECEIVE,
@@ -302,7 +302,7 @@ int main(int argc, char *argv[])
{
struct sockaddr_storage listenaddr, addr;
unsigned int max_pacing_rate = 0;
- unsigned long total = 0;
+ size_t total = 0;
char *host = NULL;
int fd, c, on = 1;
char *buffer;
@@ -417,7 +417,7 @@ int main(int argc, char *argv[])
zflg = 0;
}
while (total < FILE_SZ) {
- long wr = FILE_SZ - total;
+ ssize_t wr = FILE_SZ - total;
if (wr > chunk_size)
wr = chunk_size;
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [BUGFIX PATCH v3 4/5] selftests: net: Fix printf format warnings on arm
2019-10-23 4:57 [BUGFIX PATCH v3 0/5] selftests: Fixes for 32bit arch Masami Hiramatsu
` (2 preceding siblings ...)
2019-10-23 4:57 ` [BUGFIX PATCH v3 3/5] selftests: net: Use size_t and ssize_t for counting file size Masami Hiramatsu
@ 2019-10-23 4:58 ` Masami Hiramatsu
2019-10-23 4:58 ` [BUGFIX PATCH v3 5/5] selftests: sync: Fix cast " Masami Hiramatsu
2019-10-31 11:23 ` [BUGFIX PATCH v3 0/5] selftests: Fixes for 32bit arch Masami Hiramatsu
5 siblings, 0 replies; 7+ messages in thread
From: Masami Hiramatsu @ 2019-10-23 4:58 UTC (permalink / raw)
To: Shuah Khan
Cc: linux-kselftest, linux-kernel, jaswinder.singh, Willem de Bruijn,
David S . Miller
Fix printf format warnings on arm (and other 32bit arch).
- udpgso.c and udpgso_bench_tx use %lu for size_t but it
should be unsigned long long on 32bit arch.
- so_txtime.c uses %ld for int64_t, but it should be
unsigned long long on 32bit arch.
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Willem de Bruijn <willemb@google.com>
Cc: David S. Miller <davem@davemloft.net>
---
tools/testing/selftests/net/so_txtime.c | 4 ++--
tools/testing/selftests/net/udpgso.c | 3 ++-
tools/testing/selftests/net/udpgso_bench_tx.c | 3 ++-
3 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/tools/testing/selftests/net/so_txtime.c b/tools/testing/selftests/net/so_txtime.c
index 53f598f06647..34df4c8882af 100644
--- a/tools/testing/selftests/net/so_txtime.c
+++ b/tools/testing/selftests/net/so_txtime.c
@@ -105,8 +105,8 @@ static void do_recv_one(int fdr, struct timed_send *ts)
tstop = (gettime_ns() - glob_tstart) / 1000;
texpect = ts->delay_us >= 0 ? ts->delay_us : 0;
- fprintf(stderr, "payload:%c delay:%ld expected:%ld (us)\n",
- rbuf[0], tstop, texpect);
+ fprintf(stderr, "payload:%c delay:%lld expected:%lld (us)\n",
+ rbuf[0], (long long)tstop, (long long)texpect);
if (rbuf[0] != ts->data)
error(1, 0, "payload mismatch. expected %c", ts->data);
diff --git a/tools/testing/selftests/net/udpgso.c b/tools/testing/selftests/net/udpgso.c
index b8265ee9923f..cab334e51ac1 100644
--- a/tools/testing/selftests/net/udpgso.c
+++ b/tools/testing/selftests/net/udpgso.c
@@ -448,7 +448,8 @@ static bool __send_one(int fd, struct msghdr *msg, int flags)
if (ret == -1)
error(1, errno, "sendmsg");
if (ret != msg->msg_iov->iov_len)
- error(1, 0, "sendto: %d != %lu", ret, msg->msg_iov->iov_len);
+ error(1, 0, "sendto: %d != %llu", ret,
+ (unsigned long long)msg->msg_iov->iov_len);
if (msg->msg_flags)
error(1, 0, "sendmsg: return flags 0x%x\n", msg->msg_flags);
diff --git a/tools/testing/selftests/net/udpgso_bench_tx.c b/tools/testing/selftests/net/udpgso_bench_tx.c
index ada99496634a..17512a43885e 100644
--- a/tools/testing/selftests/net/udpgso_bench_tx.c
+++ b/tools/testing/selftests/net/udpgso_bench_tx.c
@@ -405,7 +405,8 @@ static int send_udp_segment(int fd, char *data)
if (ret == -1)
error(1, errno, "sendmsg");
if (ret != iov.iov_len)
- error(1, 0, "sendmsg: %u != %lu\n", ret, iov.iov_len);
+ error(1, 0, "sendmsg: %u != %llu\n", ret,
+ (unsigned long long)iov.iov_len);
return 1;
}
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [BUGFIX PATCH v3 5/5] selftests: sync: Fix cast warnings on arm
2019-10-23 4:57 [BUGFIX PATCH v3 0/5] selftests: Fixes for 32bit arch Masami Hiramatsu
` (3 preceding siblings ...)
2019-10-23 4:58 ` [BUGFIX PATCH v3 4/5] selftests: net: Fix printf format warnings on arm Masami Hiramatsu
@ 2019-10-23 4:58 ` Masami Hiramatsu
2019-10-31 11:23 ` [BUGFIX PATCH v3 0/5] selftests: Fixes for 32bit arch Masami Hiramatsu
5 siblings, 0 replies; 7+ messages in thread
From: Masami Hiramatsu @ 2019-10-23 4:58 UTC (permalink / raw)
To: Shuah Khan
Cc: linux-kselftest, linux-kernel, jaswinder.singh, Emilio López
Fix warnings on __u64 and pointer translation on arm and
other 32bit architectures. Since the pointer is 32bits on
those archs, we should not directly cast those types.
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Emilio López <emilio.lopez@collabora.co.uk>
---
tools/testing/selftests/sync/sync.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/testing/selftests/sync/sync.c b/tools/testing/selftests/sync/sync.c
index f3d599f249b9..7741c0518d18 100644
--- a/tools/testing/selftests/sync/sync.c
+++ b/tools/testing/selftests/sync/sync.c
@@ -109,7 +109,7 @@ static struct sync_file_info *sync_file_info(int fd)
return NULL;
}
- info->sync_fence_info = (uint64_t)fence_info;
+ info->sync_fence_info = (uint64_t)(unsigned long)fence_info;
err = ioctl(fd, SYNC_IOC_FILE_INFO, info);
if (err < 0) {
@@ -124,7 +124,7 @@ static struct sync_file_info *sync_file_info(int fd)
static void sync_file_info_free(struct sync_file_info *info)
{
- free((void *)info->sync_fence_info);
+ free((void *)(unsigned long)info->sync_fence_info);
free(info);
}
@@ -152,7 +152,7 @@ int sync_fence_count_with_status(int fd, int status)
if (!info)
return -1;
- fence_info = (struct sync_fence_info *)info->sync_fence_info;
+ fence_info = (struct sync_fence_info *)(unsigned long)info->sync_fence_info;
for (i = 0 ; i < info->num_fences ; i++) {
if (fence_info[i].status == status)
count++;
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [BUGFIX PATCH v3 0/5] selftests: Fixes for 32bit arch
2019-10-23 4:57 [BUGFIX PATCH v3 0/5] selftests: Fixes for 32bit arch Masami Hiramatsu
` (4 preceding siblings ...)
2019-10-23 4:58 ` [BUGFIX PATCH v3 5/5] selftests: sync: Fix cast " Masami Hiramatsu
@ 2019-10-31 11:23 ` Masami Hiramatsu
5 siblings, 0 replies; 7+ messages in thread
From: Masami Hiramatsu @ 2019-10-31 11:23 UTC (permalink / raw)
To: Masami Hiramatsu
Cc: Shuah Khan, linux-kselftest, linux-kernel, jaswinder.singh,
Alexey Dobriyan, Anshuman Khandual, Aneesh Kumar K . V,
Eric Dumazet, David S . Miller, Willem de Bruijn,
Emilio López
Hi,
Would anyone is OK for this fix?
I also found a typo on arm64 build... will send soon.
Thanks,
On Wed, 23 Oct 2019 13:57:30 +0900
Masami Hiramatsu <mhiramat@kernel.org> wrote:
> Hi,
>
> Here are the 3rd version of kselftest fixes some on 32bit arch
> (e.g. arm)
>
> In this version, I updated [1/5] to make va_max 1MB unconditionally
> according to Alexey's comment.
>
> When I built the ksefltest on arm, I hit some 32bit related warnings.
> Here are the patches to fix those issues.
>
>
> - [1/5] va_max was set 2^32 even on 32bit arch. This can make
> va_max == 0 and always fail. Make it 1GB unconditionally.
> - [2/5] Some VM tests requires 64bit user space, which should
> not run on 32bit arch.
> - [3/5] For counting the size of large file, we should use
> size_t instead of unsinged long.
> - [4/5] Gcc warns printf format for size_t and int64_t on
> 32bit arch. Use %llu and cast it.
> - [5/5] Gcc warns __u64 and pointer type castings. It should
> once translated to unsigned long.
>
> Thank you,
>
> ---
>
> Masami Hiramatsu (5):
> selftests: proc: Make va_max 1MB
> selftests: vm: Build/Run 64bit tests only on 64bit arch
> selftests: net: Use size_t and ssize_t for counting file size
> selftests: net: Fix printf format warnings on arm
> selftests: sync: Fix cast warnings on arm
>
>
> tools/testing/selftests/net/so_txtime.c | 4 ++--
> tools/testing/selftests/net/tcp_mmap.c | 8 ++++----
> tools/testing/selftests/net/udpgso.c | 3 ++-
> tools/testing/selftests/net/udpgso_bench_tx.c | 3 ++-
> .../selftests/proc/proc-self-map-files-002.c | 6 +++++-
> tools/testing/selftests/sync/sync.c | 6 +++---
> tools/testing/selftests/vm/Makefile | 5 +++++
> tools/testing/selftests/vm/run_vmtests | 10 ++++++++++
> 8 files changed, 33 insertions(+), 12 deletions(-)
>
> --
> Masami Hiramatsu (Linaro) <mhiramat@kernel.org>
--
Masami Hiramatsu <mhiramat@kernel.org>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2019-10-31 11:23 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-23 4:57 [BUGFIX PATCH v3 0/5] selftests: Fixes for 32bit arch Masami Hiramatsu
2019-10-23 4:57 ` [BUGFIX PATCH v3 1/5] selftests: proc: Make va_max 1MB Masami Hiramatsu
2019-10-23 4:57 ` [BUGFIX PATCH v3 2/5] selftests: vm: Build/Run 64bit tests only on 64bit arch Masami Hiramatsu
2019-10-23 4:57 ` [BUGFIX PATCH v3 3/5] selftests: net: Use size_t and ssize_t for counting file size Masami Hiramatsu
2019-10-23 4:58 ` [BUGFIX PATCH v3 4/5] selftests: net: Fix printf format warnings on arm Masami Hiramatsu
2019-10-23 4:58 ` [BUGFIX PATCH v3 5/5] selftests: sync: Fix cast " Masami Hiramatsu
2019-10-31 11:23 ` [BUGFIX PATCH v3 0/5] selftests: Fixes for 32bit arch Masami Hiramatsu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).