From patchwork Mon Mar 23 13:37:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Norbert Manthey X-Patchwork-Id: 11452991 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AAD001392 for ; Mon, 23 Mar 2020 13:40:34 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 86C6720735 for ; Mon, 23 Mar 2020 13:40:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.de header.i=@amazon.de header.b="hvaQEC0O" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 86C6720735 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jGNIE-0000lj-OA; Mon, 23 Mar 2020 13:39:02 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jGNID-0000lX-MM for xen-devel@lists.xenproject.org; Mon, 23 Mar 2020 13:39:01 +0000 X-Inumbo-ID: a781059a-6d0b-11ea-82d5-12813bfff9fa Received: from smtp-fw-4101.amazon.com (unknown [72.21.198.25]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id a781059a-6d0b-11ea-82d5-12813bfff9fa; Mon, 23 Mar 2020 13:39:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1584970741; x=1616506741; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=mIn+She3Up5TtWgnP2Z/bljW0ooT4ae9labqk5XxODU=; b=hvaQEC0OqDDGiulkxgC5KVoNaNYq6LuU0qc0+hXU8i5iUnZGOzdwy0UK +3APWe0gJQkszHLbRDPIQjLJ9LV97M3Xf8hGHlCiHeZYbGNKQPi7lrAjq U/ykWeF8w7vIw/d2pZjVtm21kVRsuC6UrDQ0Umpk/ow73HVfY7/xhdOLo 4=; IronPort-SDR: 3JOhp+xvPSr+nI2Xri7IoAMRy2rJmkDSzvasn5YMH2Ddmucw/UceVOq6eUPCzOwsYo1gyuOuNi PrTMPGmR3yqQ== X-IronPort-AV: E=Sophos;i="5.72,296,1580774400"; d="scan'208";a="22498450" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-1e-303d0b0e.us-east-1.amazon.com) ([10.43.8.6]) by smtp-border-fw-out-4101.iad4.amazon.com with ESMTP; 23 Mar 2020 13:38:49 +0000 Received: from EX13MTAUEA002.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan3.iad.amazon.com [10.40.159.166]) by email-inbound-relay-1e-303d0b0e.us-east-1.amazon.com (Postfix) with ESMTPS id 3894AA060F; Mon, 23 Mar 2020 13:38:48 +0000 (UTC) Received: from EX13D05EUB004.ant.amazon.com (10.43.166.115) by EX13MTAUEA002.ant.amazon.com (10.43.61.77) with Microsoft SMTP Server (TLS) id 15.0.1236.3; Mon, 23 Mar 2020 13:38:48 +0000 Received: from EX13MTAUWC001.ant.amazon.com (10.43.162.135) by EX13D05EUB004.ant.amazon.com (10.43.166.115) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 23 Mar 2020 13:38:47 +0000 Received: from u6fc700a6f3c650.ant.amazon.com (10.95.138.2) by mail-relay.amazon.com (10.43.162.232) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Mon, 23 Mar 2020 13:38:44 +0000 From: Norbert Manthey To: Andrew Cooper , Date: Mon, 23 Mar 2020 14:37:01 +0100 Message-ID: <20200323133701.21728-5-nmanthey@amazon.de> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200323133701.21728-1-nmanthey@amazon.de> References: <20200323133701.21728-1-nmanthey@amazon.de> MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH XTF benchmark v1 4/4] perf: measure MMUEXT_MARK_SUPER test X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Pawel Wieczorkiewicz , Norbert Manthey Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" A first simple test is to call a hypercall in a tight loop. To measure implementation aspects of the hypervisor, we picked a hypercall that is not implemented and hence results in a no-op, namely the hypercall mmuext_op with the command MMUEXT_MARK_SUPER. The test calibrates the execution time for 1000 calls to the hypercall, and next calculates the number of calls to take about 5 minutes. Signed-off-by: Norbert Manthey Reviewed-by: Bjoern Doebel --- tests/perf-PV-MMUEXT_MARK_SUPER-noop/Makefile | 9 +++ tests/perf-PV-MMUEXT_MARK_SUPER-noop/main.c | 80 +++++++++++++++++++ 2 files changed, 89 insertions(+) create mode 100644 tests/perf-PV-MMUEXT_MARK_SUPER-noop/Makefile create mode 100644 tests/perf-PV-MMUEXT_MARK_SUPER-noop/main.c diff --git a/tests/perf-PV-MMUEXT_MARK_SUPER-noop/Makefile b/tests/perf-PV-MMUEXT_MARK_SUPER-noop/Makefile new file mode 100644 --- /dev/null +++ b/tests/perf-PV-MMUEXT_MARK_SUPER-noop/Makefile @@ -0,0 +1,9 @@ +include $(ROOT)/build/common.mk + +NAME := perf-PV-MMUEXT_MARK_SUPER-noop +CATEGORY := benchmark +TEST-ENVS := pv64 + +obj-perenv += main.o + +include $(ROOT)/build/gen.mk diff --git a/tests/perf-PV-MMUEXT_MARK_SUPER-noop/main.c b/tests/perf-PV-MMUEXT_MARK_SUPER-noop/main.c new file mode 100644 --- /dev/null +++ b/tests/perf-PV-MMUEXT_MARK_SUPER-noop/main.c @@ -0,0 +1,80 @@ +/** + * Copyright (C) Amazon.com, Inc. or its affiliates. + * Author: Norbert Manthey + * + * @file tests/perf-PV-MMUEXT_MARK_SUPER-noop/main.c + * @ref test-perf-PV-MMUEXT_MARK_SUPER-noop + * + * @page perf-PV-MMUEXT_MARK_SUPER-noop + * + * This test runs the hypercall mmuext_op with the command MMUEXT_MARK_SUPER in + * a tight loop, and measures how much time it takes for all loops. Finally, the + * test prints this time. + * + * Since this is a performance test, the actual value is furthermore printed + * using the predefined pattern on a separate line. The reported value + * represents the time it takes to run the mmuext_op hypercall in nano seconds. + * The average is calculated by running the call for about 5 minutes. + * + * perf + * + * @see tests/perf-PV-MMUEXT_MARK_SUPER-noop/main.c + */ + +/* To improve precision of the measurement, try to run the hypercall for this + amount of seconds. As the time per call can be different for test machines, + we measure the time for the below number of calls, and estimate the number of + calls to perform accordingly. */ +#define MEASUREMENT_SECONDS 300 + +/* This number of calls to the function under test will be used to estimate how + many times we need to call the function to measure for about 5 minutes. */ +#define CALIBRATION_CALLS 1000 + +#include +#include + +const char test_title[] = "Test perf-MMUEXT_MARK_SUPER"; + +/* Use a global struct to avoid local variables in call_MMUEXT_MARK_SUPER */ +mmuext_op_t op = +{ + .cmd = MMUEXT_MARK_SUPER, + .arg1.mfn = 1, +}; + +/* Schedule a no-op hypercall */ +int call_MMUEXT_MARK_SUPER(void) +{ + return hypercall_mmuext_op(&op, 1, NULL, DOMID_SELF); +} + +void test_main(void) +{ + int rc = 0; + + /* Test whether the hypercall is implemented as expected */ + rc = call_MMUEXT_MARK_SUPER(); + if(rc != -EOPNOTSUPP && rc != -EINVAL && rc != -ENOSYS) + return xtf_error("Unexpected MMUEXT_MARK_SUPER, rc %d\n", rc); + + /* Measuring average execution time for given function, and print stats */ + measure_performance(test_title, + "mmuext_op(MMUEXT_MARK_SUPER, ...)", + call_MMUEXT_MARK_SUPER, + MEASUREMENT_SECONDS, + CALIBRATION_CALLS, + 1); + + return xtf_success("Success: performed MMUEXT_MARK_SUPER hypercall with expected result\n"); +} + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */