]> git.baikalelectronics.ru Git - kernel.git/commitdiff
userfaultfd/selftests: only dump counts if mode enabled
authorPeter Xu <peterx@redhat.com>
Thu, 1 Jul 2021 01:48:52 +0000 (18:48 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 1 Jul 2021 03:47:27 +0000 (20:47 -0700)
WP and MINOR modes are conditionally enabled on specific memory types.
This patch avoids dumping tons of zeros for those cases when the modes are
not supported at all.

Link: https://lkml.kernel.org/r/20210412232753.1012412-5-peterx@redhat.com
Signed-off-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Axel Rasmussen <axelrasmussen@google.com>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: Brian Geffon <bgeffon@google.com>
Cc: "Dr . David Alan Gilbert" <dgilbert@redhat.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Jerome Glisse <jglisse@redhat.com>
Cc: Joe Perches <joe@perches.com>
Cc: Kirill A. Shutemov <kirill@shutemov.name>
Cc: Lokesh Gidra <lokeshgidra@google.com>
Cc: Mike Kravetz <mike.kravetz@oracle.com>
Cc: Mike Rapoport <rppt@linux.vnet.ibm.com>
Cc: Mina Almasry <almasrymina@google.com>
Cc: Oliver Upton <oupton@google.com>
Cc: Shaohua Li <shli@fb.com>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: Wang Qing <wangqing@vivo.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
tools/testing/selftests/vm/userfaultfd.c

index 387b9360ae64fdf594503a01f6460de5702dc9bd..da2374bda5a347c3e06a4dcb8ae3880edb3bb37c 100644 (file)
@@ -171,16 +171,26 @@ static void uffd_stats_report(struct uffd_stats *stats, int n_cpus)
                minor_total += stats[i].minor_faults;
        }
 
-       printf("userfaults: %llu missing (", miss_total);
-       for (i = 0; i < n_cpus; i++)
-               printf("%lu+", stats[i].missing_faults);
-       printf("\b), %llu wp (", wp_total);
-       for (i = 0; i < n_cpus; i++)
-               printf("%lu+", stats[i].wp_faults);
-       printf("\b), %llu minor (", minor_total);
-       for (i = 0; i < n_cpus; i++)
-               printf("%lu+", stats[i].minor_faults);
-       printf("\b)\n");
+       printf("userfaults: ");
+       if (miss_total) {
+               printf("%llu missing (", miss_total);
+               for (i = 0; i < n_cpus; i++)
+                       printf("%lu+", stats[i].missing_faults);
+               printf("\b) ");
+       }
+       if (wp_total) {
+               printf("%llu wp (", wp_total);
+               for (i = 0; i < n_cpus; i++)
+                       printf("%lu+", stats[i].wp_faults);
+               printf("\b) ");
+       }
+       if (minor_total) {
+               printf("%llu minor (", minor_total);
+               for (i = 0; i < n_cpus; i++)
+                       printf("%lu+", stats[i].minor_faults);
+               printf("\b)");
+       }
+       printf("\n");
 }
 
 static int anon_release_pages(char *rel_area)