From patchwork Thu Jul 1 01:48:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 12353125 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 48322C11F69 for ; Thu, 1 Jul 2021 01:48:55 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id F3C9E61090 for ; Thu, 1 Jul 2021 01:48:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F3C9E61090 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 7C9E88D01F4; Wed, 30 Jun 2021 21:48:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7A0EC8D01D0; Wed, 30 Jun 2021 21:48:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6693E8D01F4; Wed, 30 Jun 2021 21:48:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0185.hostedemail.com [216.40.44.185]) by kanga.kvack.org (Postfix) with ESMTP id 3E9CA8D01D0 for ; Wed, 30 Jun 2021 21:48:54 -0400 (EDT) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 189FA1801A832 for ; Thu, 1 Jul 2021 01:48:54 +0000 (UTC) X-FDA: 78312335388.11.A3AD7CF Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf08.hostedemail.com (Postfix) with ESMTP id CFE4B30000A5 for ; Thu, 1 Jul 2021 01:48:53 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 6E9066120C; Thu, 1 Jul 2021 01:48:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1625104133; bh=HRL8VpJjpH2u4FSHjGZdMu7W0aM7i2zTf2sdnsmrkcs=; h=Date:From:To:Subject:In-Reply-To:From; b=MDoGtfY/oaCp/PaGRzUUk4DfhJWBfMDGppD1Ji27maKXOoMCFmgwBNqGhTfpjaEaR MDGgcVFw8qQsUiNF8oO41GM/5LARD5aq/Xhj8qexcZM1Gh/MEmiVXXQDIwNZAg77qC 6wQNsfCgKlB/Bz6239H4swpyRZcMOD9ZOiEhY+qk= Date: Wed, 30 Jun 2021 18:48:52 -0700 From: Andrew Morton To: aarcange@redhat.com, akpm@linux-foundation.org, almasrymina@google.com, axelrasmussen@google.com, bgeffon@google.com, dgilbert@redhat.com, hughd@google.com, jglisse@redhat.com, joe@perches.com, kirill@shutemov.name, linux-mm@kvack.org, lokeshgidra@google.com, mike.kravetz@oracle.com, mm-commits@vger.kernel.org, oupton@google.com, peterx@redhat.com, rppt@linux.vnet.ibm.com, sfr@canb.auug.org.au, shli@fb.com, shuah@kernel.org, torvalds@linux-foundation.org, viro@zeniv.linux.org.uk, wangqing@vivo.com Subject: [patch 033/192] userfaultfd/selftests: only dump counts if mode enabled Message-ID: <20210701014852.RuvkWyfWK%akpm@linux-foundation.org> In-Reply-To: <20210630184624.9ca1937310b0dd5ce66b30e7@linux-foundation.org> User-Agent: s-nail v14.8.16 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: CFE4B30000A5 X-Stat-Signature: o8488rdo8q3q9mkpd77h4ufwunmcpkar Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b="MDoGtfY/"; dmarc=none; spf=pass (imf08.hostedemail.com: domain of akpm@linux-foundation.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org X-HE-Tag: 1625104133-163413 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Peter Xu Subject: userfaultfd/selftests: only dump counts if mode enabled 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 Reviewed-by: Axel Rasmussen Cc: Alexander Viro Cc: Andrea Arcangeli Cc: Brian Geffon Cc: "Dr . David Alan Gilbert" Cc: Hugh Dickins Cc: Jerome Glisse Cc: Joe Perches Cc: Kirill A. Shutemov Cc: Lokesh Gidra Cc: Mike Kravetz Cc: Mike Rapoport Cc: Mina Almasry Cc: Oliver Upton Cc: Shaohua Li Cc: Shuah Khan Cc: Stephen Rothwell Cc: Wang Qing Signed-off-by: Andrew Morton --- tools/testing/selftests/vm/userfaultfd.c | 30 ++++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) --- a/tools/testing/selftests/vm/userfaultfd.c~userfaultfd-selftests-only-dump-counts-if-mode-enabled +++ a/tools/testing/selftests/vm/userfaultfd.c @@ -171,16 +171,26 @@ static void uffd_stats_report(struct uff 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)