* [PATCH] selftests: vm: remove duplicated macro and use swap() to make code cleaner
@ 2022-03-01 1:44 cgel.zte
2022-03-01 15:29 ` Shuah Khan
0 siblings, 1 reply; 2+ messages in thread
From: cgel.zte @ 2022-03-01 1:44 UTC (permalink / raw)
To: akpm
Cc: shuah, linux-mm, linux-kselftest, linux-kernel,
Lv Ruyi (CGEL ZTE),
Zeal Robot
From: "Lv Ruyi (CGEL ZTE)" <lv.ruyi@zte.com.cn>
The macro is duplicated, so remove one. And use swap to make code cleaner.
Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Lv Ruyi (CGEL ZTE) <lv.ruyi@zte.com.cn>
---
tools/testing/selftests/vm/userfaultfd.c | 13 ++-----------
1 file changed, 2 insertions(+), 11 deletions(-)
diff --git a/tools/testing/selftests/vm/userfaultfd.c b/tools/testing/selftests/vm/userfaultfd.c
index ab394e6bff43..100f08362164 100644
--- a/tools/testing/selftests/vm/userfaultfd.c
+++ b/tools/testing/selftests/vm/userfaultfd.c
@@ -121,9 +121,6 @@ struct uffd_stats {
#define swap(a, b) \
do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while (0)
-#define swap(a, b) \
- do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while (0)
-
const char *examples =
"# Run anonymous memory test on 100MiB region with 99999 bounces:\n"
"./userfaultfd anon 100 99999\n\n"
@@ -1424,7 +1421,6 @@ static void userfaultfd_pagemap_test(unsigned int test_pgsize)
static int userfaultfd_stress(void)
{
void *area;
- char *tmp_area;
unsigned long nr;
struct uffdio_register uffdio_register;
struct uffd_stats uffd_stats[nr_cpus];
@@ -1535,13 +1531,8 @@ static int userfaultfd_stress(void)
count_verify[nr], nr);
/* prepare next bounce */
- tmp_area = area_src;
- area_src = area_dst;
- area_dst = tmp_area;
-
- tmp_area = area_src_alias;
- area_src_alias = area_dst_alias;
- area_dst_alias = tmp_area;
+ swap(area_src, area_dst);
+ swap(area_src_alias, area_dst_alias);
uffd_stats_report(uffd_stats, nr_cpus);
}
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] selftests: vm: remove duplicated macro and use swap() to make code cleaner
2022-03-01 1:44 [PATCH] selftests: vm: remove duplicated macro and use swap() to make code cleaner cgel.zte
@ 2022-03-01 15:29 ` Shuah Khan
0 siblings, 0 replies; 2+ messages in thread
From: Shuah Khan @ 2022-03-01 15:29 UTC (permalink / raw)
To: cgel.zte, akpm
Cc: shuah, linux-mm, linux-kselftest, linux-kernel,
Lv Ruyi (CGEL ZTE),
Zeal Robot, Shuah Khan
On 2/28/22 6:44 PM, cgel.zte@gmail.com wrote:
> From: "Lv Ruyi (CGEL ZTE)" <lv.ruyi@zte.com.cn>
>
> The macro is duplicated, so remove one. And use swap to make code cleaner.
>
> Reported-by: Zeal Robot <zealci@zte.com.cn>
> Signed-off-by: Lv Ruyi (CGEL ZTE) <lv.ruyi@zte.com.cn>
> ---
> tools/testing/selftests/vm/userfaultfd.c | 13 ++-----------
> 1 file changed, 2 insertions(+), 11 deletions(-)
>
> diff --git a/tools/testing/selftests/vm/userfaultfd.c b/tools/testing/selftests/vm/userfaultfd.c
> index ab394e6bff43..100f08362164 100644
> --- a/tools/testing/selftests/vm/userfaultfd.c
> +++ b/tools/testing/selftests/vm/userfaultfd.c
> @@ -121,9 +121,6 @@ struct uffd_stats {
> #define swap(a, b) \
> do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while (0)
>
> -#define swap(a, b) \
> - do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while (0)
> -
> const char *examples =
> "# Run anonymous memory test on 100MiB region with 99999 bounces:\n"
> "./userfaultfd anon 100 99999\n\n"
> @@ -1424,7 +1421,6 @@ static void userfaultfd_pagemap_test(unsigned int test_pgsize)
> static int userfaultfd_stress(void)
> {
> void *area;
> - char *tmp_area;
> unsigned long nr;
> struct uffdio_register uffdio_register;
> struct uffd_stats uffd_stats[nr_cpus];
> @@ -1535,13 +1531,8 @@ static int userfaultfd_stress(void)
> count_verify[nr], nr);
>
> /* prepare next bounce */
> - tmp_area = area_src;
> - area_src = area_dst;
> - area_dst = tmp_area;
> -
> - tmp_area = area_src_alias;
> - area_src_alias = area_dst_alias;
> - area_dst_alias = tmp_area;
> + swap(area_src, area_dst);
> + swap(area_src_alias, area_dst_alias);
Where is swap() defined? Does this patch compile? I reverted a
change like this one reported by Zeal Robot recently. Let's
make sure this change compiles and runs.
>
> uffd_stats_report(uffd_stats, nr_cpus);
> }
>
thanks,
-- Shuah
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-03-01 15:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-01 1:44 [PATCH] selftests: vm: remove duplicated macro and use swap() to make code cleaner cgel.zte
2022-03-01 15:29 ` Shuah Khan
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.