From patchwork Wed Mar 10 00:45:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 12126795 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=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 22A56C433E0 for ; Wed, 10 Mar 2021 00:45:24 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id ACC73650A2 for ; Wed, 10 Mar 2021 00:45:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org ACC73650A2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 6356E8D015D; Tue, 9 Mar 2021 19:45:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 60CF78D0148; Tue, 9 Mar 2021 19:45:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4AE668D015D; Tue, 9 Mar 2021 19:45:21 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0251.hostedemail.com [216.40.44.251]) by kanga.kvack.org (Postfix) with ESMTP id 263138D0148 for ; Tue, 9 Mar 2021 19:45:21 -0500 (EST) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id E0792180EAE02 for ; Wed, 10 Mar 2021 00:45:20 +0000 (UTC) X-FDA: 77902120800.18.979BC45 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf12.hostedemail.com (Postfix) with ESMTP id 3B24A132 for ; Wed, 10 Mar 2021 00:45:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615337120; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JFLVZpqIxshqGVHv9ZZ+a47BjDat3dahvnPbwqiCdNA=; b=JXMpLh7865ii2N140/CDfEAqCk1zUNw5T4VnMelw4WQeCZAldF4A47DQsdX0zu6X2jLaSJ pCbJ+W+LQJN4jpzkMSpdBhPpScTYe0TWBH6/msDueRxAWUsbjI2HmLa6K1Lf/mi14PdBr0 vhhWhVU1JEt6JErSHa6PlUktWtHB6eI= Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-391-r1p5RH2tP8avpoMZ7FdlXA-1; Tue, 09 Mar 2021 19:45:18 -0500 X-MC-Unique: r1p5RH2tP8avpoMZ7FdlXA-1 Received: by mail-qt1-f199.google.com with SMTP id t5so11790846qti.5 for ; Tue, 09 Mar 2021 16:45:18 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=JFLVZpqIxshqGVHv9ZZ+a47BjDat3dahvnPbwqiCdNA=; b=aKMXF43edSOU+zP5QqNfw/sZxu+q2XvQAH47yEc64nDFR3u2ICpQdeVde6cIeA3Co2 PO4x2kDTs7xSX1loDskge+5/XxbOJHGHitkSDnK/yl5nO5/bFf65rSkZ3Nr50A1LU83S u5veK66svL4XB8lxnK7YD0PTrtqAhovSA4TqP4NYdLmVgLeFq+CFedSuuCnIgbnMsjeC HxV2M5wO8XOxIk8nIB5Ts82e4BVSO44F1dWj7sQ1Qxfa6fYJQ9Qq0ATaZcdmoWTNEj5h BtL8udrI6XsP5KmLAo76VyIu6CgeIvc+1YXfG2FbDqIZSMtFnZ/vBSz6QWL3yuCEnYFE 24qA== X-Gm-Message-State: AOAM533GrQ4Ml3/B4TIDmyp7Q4pKPBotie5yAh/EXHsu7CISzudjRGP7 d0Wzd/dnGNfNIIz8JEgrYzPRYGtbGTAD1I8ShxD1DsoSeL4JCzWIv6mdgjV5YOnww+K5d3hJlIO 4pcF6XXrK16/XgT7MlvIX5zHX+fkSgQu3TxdUH8Kc+H/2j/WAAP4E9Xc1rUsH X-Received: by 2002:a05:6214:10e7:: with SMTP id q7mr791960qvt.16.1615337117860; Tue, 09 Mar 2021 16:45:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJw69PXyQlAxcv3DEZcnxIe9QzVj/xgqSFlWClb3XudYfugJ8Jk+oygEdtYP4Lr4LywifoLsEw== X-Received: by 2002:a05:6214:10e7:: with SMTP id q7mr791941qvt.16.1615337117618; Tue, 09 Mar 2021 16:45:17 -0800 (PST) Received: from xz-x1.redhat.com (bras-vprn-toroon474qw-lp130-25-174-95-95-253.dsl.bell.ca. [174.95.95.253]) by smtp.gmail.com with ESMTPSA id b27sm11418173qkl.102.2021.03.09.16.45.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Mar 2021 16:45:17 -0800 (PST) From: Peter Xu To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Axel Rasmussen , Andrew Morton , peterx@redhat.com, Andrea Arcangeli , Nadav Amit Subject: [PATCH 4/5] userfaultfd/selftests: Only dump counts if mode enabled Date: Tue, 9 Mar 2021 19:45:10 -0500 Message-Id: <20210310004511.51996-5-peterx@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210310004511.51996-1-peterx@redhat.com> References: <20210310004511.51996-1-peterx@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=peterx@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 3B24A132 X-Stat-Signature: hqbmrk36uzdot46yzgyseq977ducnrqu Received-SPF: none (redhat.com>: No applicable sender policy available) receiver=imf12; identity=mailfrom; envelope-from=""; helo=us-smtp-delivery-124.mimecast.com; client-ip=216.205.24.124 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1615337117-524365 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: 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. Signed-off-by: Peter Xu --- tools/testing/selftests/vm/userfaultfd.c | 30 ++++++++++++++++-------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/tools/testing/selftests/vm/userfaultfd.c b/tools/testing/selftests/vm/userfaultfd.c index cf0cd4cb327d..5f89d258024a 100644 --- a/tools/testing/selftests/vm/userfaultfd.c +++ b/tools/testing/selftests/vm/userfaultfd.c @@ -173,16 +173,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)