From patchwork Tue Jun 16 23:12:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ahmed Karaman X-Patchwork-Id: 280293 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=-9.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, 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 CA22FC433DF for ; Tue, 16 Jun 2020 23:13:56 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (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 937C6207D3 for ; Tue, 16 Jun 2020 23:13:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NPs992Hu" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 937C6207D3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:44918 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jlKmB-0003q0-NA for qemu-devel@archiver.kernel.org; Tue, 16 Jun 2020 19:13:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54242) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jlKlH-0002WS-Rv for qemu-devel@nongnu.org; Tue, 16 Jun 2020 19:12:59 -0400 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:39119) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jlKlG-0006uF-Df for qemu-devel@nongnu.org; Tue, 16 Jun 2020 19:12:59 -0400 Received: by mail-wm1-x344.google.com with SMTP id t194so88682wmt.4 for ; Tue, 16 Jun 2020 16:12:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=J6ZyVPWxE4rUpNMsUOcvfAQU0YaltDpuLYEOTXm+nBw=; b=NPs992HuvCRmWPp97bKClU5zyJ9dYklHXZlnoRjeRVrTX/jtFPUsdpBCDsxwHaFx6y GE/B2+KcPHHtymgxFh3WDUUE3xlXvlu+HBaah1AWuKvMZaXk0FZSMaIm8qToZYPdZjj2 Rvh8bhsHg0o92uRczKsc54Au2Um8WCoZElnnO3j4lLyyG3vlZ4kSsjds9JftfMmSqTVJ DzuoOjO/UmMhl51Fg/w3sgU3L1dYzgCWp3JSlC07OnZQz/i8m3ShhrCibS3GraxRU73d yPDipNC8LD4RtPJWPeM9yM3aYpRKF1Kg2Ouux+G5afroDYfgKqnzMHWNLLILpC1TCh9+ ZWrA== 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; bh=J6ZyVPWxE4rUpNMsUOcvfAQU0YaltDpuLYEOTXm+nBw=; b=pkYZykdaNS14yE2EMSihLpZiN31bLXEEUhmMwwD1jw6dhRopOFM9SWalwOxrNayl/F 3ZgPIt/+sddBn9ncsI1JDTokfNq0J2Eyt4Pdfw62jpYHUf9qsxgQzWARLWrwa3r74WUC XQ5WXrKxgA9WVYURzw9edsgBxd5B/I3xqQUJZLnW7TYrsPpivMdqiyLZtLuH46P4l2z1 7nbYM8XniMiMVipudoRckJjbFgKwSat6SwOlAPDOlCJqGO0XrUx/t9yIaXNQYnMyhAr+ /gInBLIwe2KsDdPv2ac/8T84fifCGe6gyHwhixE3gr20EfLy94muPxcqw0tssxnWSOXO pQsA== X-Gm-Message-State: AOAM533VYt+b1OUYFRax378OEZ675EE+tOq7vAo0u8GTcVgfpvI2kax8 48vUq2sEkQ8ZPyvuFsHq/9/f2h5qwIU= X-Google-Smtp-Source: ABdhPJx2IBnHr1A13sYggnwPRN+i3kFokqrVuY1lshd9gLGGju3In+2/UfmQxbV3o09nx6xwe8I/Sg== X-Received: by 2002:a7b:cc08:: with SMTP id f8mr5772413wmh.106.1592349176891; Tue, 16 Jun 2020 16:12:56 -0700 (PDT) Received: from AK-L.domain.name ([197.58.89.86]) by smtp.gmail.com with ESMTPSA id o9sm2384226wrs.1.2020.06.16.16.12.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jun 2020 16:12:56 -0700 (PDT) From: Ahmed Karaman To: qemu-devel@nongnu.org, rth@twiddle.net, aleksandar.qemu.devel@gmail.com, alex.bennee@linaro.org, eblake@redhat.com, ldoktor@redhat.com, ehabkost@redhat.com, crosa@redhat.com Subject: [PATCH 1/3] MAINTAINERS: Add 'Miscellaneous' section Date: Wed, 17 Jun 2020 01:12:02 +0200 Message-Id: <20200616231204.8850-2-ahmedkhaledkaraman@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200616231204.8850-1-ahmedkhaledkaraman@gmail.com> References: <20200616231204.8850-1-ahmedkhaledkaraman@gmail.com> Received-SPF: pass client-ip=2a00:1450:4864:20::344; envelope-from=ahmedkhaledkaraman@gmail.com; helo=mail-wm1-x344.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ahmed Karaman Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" This new section includes the 'Performance Tools and Tests' subsection which will contain the the performance scripts and benchmarks written as a part of the 'TCG Continuous Benchmarking' project. Signed-off-by: Ahmed Karaman --- MAINTAINERS | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 955cc8dd5c..68f668ae2a 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2974,3 +2974,10 @@ M: Peter Maydell S: Maintained F: docs/conf.py F: docs/*/conf.py + +Miscellaneous +------------- +Performance Tools and Tests +M: Ahmed Karaman +S: Maintained +F: scripts/performance/ \ No newline at end of file From patchwork Tue Jun 16 23:12:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ahmed Karaman X-Patchwork-Id: 280292 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=-9.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, 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 A6C73C433DF for ; Tue, 16 Jun 2020 23:15:22 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (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 6E67C207D3 for ; Tue, 16 Jun 2020 23:15:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="G7/89ryh" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6E67C207D3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:49756 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jlKnZ-00064x-Ny for qemu-devel@archiver.kernel.org; Tue, 16 Jun 2020 19:15:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54310) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jlKla-000341-Qd for qemu-devel@nongnu.org; Tue, 16 Jun 2020 19:13:18 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]:44100) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jlKlZ-0006wn-1C for qemu-devel@nongnu.org; Tue, 16 Jun 2020 19:13:18 -0400 Received: by mail-wr1-x434.google.com with SMTP id b6so329103wrs.11 for ; Tue, 16 Jun 2020 16:13:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=t3VP6WWaLEUXrw5hSPEQzC1W88S05EoRcbRI+Zf7OEE=; b=G7/89ryh/FU+6PVotPSJOhs8ymD5/zqFU4jby/um/RijMhiuoZcw0/4j0CZItTCvP3 c8KILQH6c9jnHEqv32p1qWxWqrT8OnFJGXzHSE4wqwLmGK5j6lELr5rgA/z+RbLEKddB m8A6xQ7IzAjHeGjF+TjMPIIL3bwC91w1d/FHSVYOzSmP0UetmwcuSZdCsSwVYr4bC54a i5htcySduGVxeWZ1TStXWE25GNT0MUreAh0mTOQ6rTalFjFqHL42KRRopqvQQX33TX72 IYfa0Ka6mipyyxa4+DCA01tuHOgfqZLpkTRugG42daD5sKZ32ssnUNvgJRlT75UOb9ro 84uw== 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; bh=t3VP6WWaLEUXrw5hSPEQzC1W88S05EoRcbRI+Zf7OEE=; b=dODol49pr31OeUeKt2ej88DFSANoHF+mfBHTXwG90Ec7WVtTaYzXRGSpZU2hRRvaLe 2cWNl+IAFrJYmsmsHCYQ4UpkJqM0SCAkg5A9NXGKeTz5qqXgoaFN2uk2xeEMyj5AqHQu XykfZhDQcreefpHQ0xHTNvSACTcsmg3Nkk/ianpzMnM2fh9MZiLX22inacWCxZPVUGHP fw/Boh13sKQLrBs+AjiJwR627Fz2aSMhHojy25QfbYWUNQhsIO0ca8igOf9zfALOZ0u5 cA+12q5wbw382o22gVuX9HjeRJYTWjZ9FZeVswGSaFRJ4tcFQXuDpeLh8ML5dSadgZDC C8Bg== X-Gm-Message-State: AOAM531XSLt3zIMagT/sUsWKle4c1FvEimu3F1dGBa+Ff/pyTt6ItbWw vtNNlPpTjJrXOHpITJHkV5S1GPYhNcQ= X-Google-Smtp-Source: ABdhPJxC3RU2gkoYY68FJZnGIBh8uw/Zo+OEXUUD3FlTTmOCpVklYCF4YC1gdTBHQ/WKUsIqtfnSBw== X-Received: by 2002:a05:6000:1185:: with SMTP id g5mr5715494wrx.39.1592349195486; Tue, 16 Jun 2020 16:13:15 -0700 (PDT) Received: from AK-L.domain.name ([197.58.89.86]) by smtp.gmail.com with ESMTPSA id o9sm2384226wrs.1.2020.06.16.16.13.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jun 2020 16:13:15 -0700 (PDT) From: Ahmed Karaman To: qemu-devel@nongnu.org, rth@twiddle.net, aleksandar.qemu.devel@gmail.com, alex.bennee@linaro.org, eblake@redhat.com, ldoktor@redhat.com, ehabkost@redhat.com, crosa@redhat.com Subject: [PATCH 3/3] scripts/performance: Add perf_top_25.py script Date: Wed, 17 Jun 2020 01:12:04 +0200 Message-Id: <20200616231204.8850-4-ahmedkhaledkaraman@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200616231204.8850-1-ahmedkhaledkaraman@gmail.com> References: <20200616231204.8850-1-ahmedkhaledkaraman@gmail.com> Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=ahmedkhaledkaraman@gmail.com; helo=mail-wr1-x434.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ahmed Karaman Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Python script that prints the top 25 most executed functions in QEMU using perf. Signed-off-by: Ahmed Karaman --- scripts/performance/perf_top_25.py | 82 ++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 scripts/performance/perf_top_25.py diff --git a/scripts/performance/perf_top_25.py b/scripts/performance/perf_top_25.py new file mode 100644 index 0000000000..eaa8cce3c3 --- /dev/null +++ b/scripts/performance/perf_top_25.py @@ -0,0 +1,82 @@ +#!/usr/bin/env python3 + +# Print the top 25 most executed functions in QEMU using perf. +# Example Usage: +# perf_top_25.py /x86_64-linux-user/qemu-x86_64 executable +# +# This file is a part of the project "TCG Continuous Benchmarking". +# +# Copyright (C) 2020 Ahmed Karaman +# Copyright (C) 2020 Aleksandar Markovic +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +import os +import sys + +# Ensure sufficient arguments +if len(sys.argv) < 3: + print('Insufficient Script Arguments!') + sys.exit(1) + +# Get the qemu path and the executable + its arguments +(qemu_path, executable) = (sys.argv[1], ' '.join(sys.argv[2:])) + +# Run perf repcord and report +os.system('sudo perf record {} {} 2> /dev/null \ + && sudo perf report --stdio > tmp.perf.data' + .format(qemu_path, executable)) + +# Line number with the top function +first_func_line = 11 + +# Perf report output +perf_data = [] + +# Open perf report output and store it in perf_data +with open('tmp.perf.data', 'r') as data: + perf_data = data.readlines() + +# Number of functions recorded by perf +number_of_functions = len(perf_data) - first_func_line + +# Limit the number of top functions to 25 +number_of_top_functions = (25 if number_of_functions > + 25 else number_of_functions) + +# Store the data of the top functions in top_functions[] +top_functions = perf_data[first_func_line:first_func_line + + number_of_top_functions] + +# Print information headers +print('{:>4} {:>10} {:<25} {}\n{} {} {} {}'.format('No.', + 'Percentage', + 'Name', + 'Caller', + '-' * 4, + '-' * 10, + '-' * 25, + '-' * 25, + )) + +# Print top 25 functions +for (index, function) in enumerate(top_functions, start=1): + function_data = function.split() + print('{:>4} {:>10} {:<25} {}'.format(index, + function_data[0], + function_data[-1], + ' '.join(function_data[2:-2]))) + +# Remove intermediate files +os.system('sudo rm perf.data tmp.perf.data')