From patchwork Fri Feb 28 18:34:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?C=C3=A9dric_Le_Goater?= X-Patchwork-Id: 1246790 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48Tdcy6xlJz9sQt for ; Sat, 29 Feb 2020 05:40:02 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=kaod.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 48Tdcy64t2zDr9H for ; Sat, 29 Feb 2020 05:40:02 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=kaod.org (client-ip=46.105.74.148; helo=10.mo173.mail-out.ovh.net; envelope-from=clg@kaod.org; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=kaod.org X-Greylist: delayed 312 seconds by postgrey-1.36 at bilbo; Sat, 29 Feb 2020 05:39:51 AEDT Received: from 10.mo173.mail-out.ovh.net (10.mo173.mail-out.ovh.net [46.105.74.148]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 48Tdcl27LrzDr5D for ; Sat, 29 Feb 2020 05:39:48 +1100 (AEDT) Received: from player695.ha.ovh.net (unknown [10.108.35.159]) by mo173.mail-out.ovh.net (Postfix) with ESMTP id EF47F1339BE for ; Fri, 28 Feb 2020 19:34:29 +0100 (CET) Received: from kaod.org (82-64-250-170.subs.proxad.net [82.64.250.170]) (Authenticated sender: clg@kaod.org) by player695.ha.ovh.net (Postfix) with ESMTPSA id 032B1FC6EAE2; Fri, 28 Feb 2020 18:34:24 +0000 (UTC) From: =?utf-8?q?C=C3=A9dric_Le_Goater?= To: skiboot@lists.ozlabs.org Date: Fri, 28 Feb 2020 19:34:19 +0100 Message-Id: <20200228183419.13612-1-clg@kaod.org> X-Mailer: git-send-email 2.21.1 MIME-Version: 1.0 X-Ovh-Tracer-Id: 6716274422471691225 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedugedrleekgdduudefucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkffogggtgfesthekredtredtjeenucfhrhhomhepveorughrihgtucfnvgcuifhorghtvghruceotghlgheskhgrohgurdhorhhgqeenucfkpheptddrtddrtddrtddpkedvrdeigedrvdehtddrudejtdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhhouggvpehsmhhtphdqohhuthdphhgvlhhopehplhgrhigvrheileehrdhhrgdrohhvhhdrnhgvthdpihhnvghtpedtrddtrddtrddtpdhmrghilhhfrhhomheptghlgheskhgrohgurdhorhhgpdhrtghpthhtohepshhkihgsohhotheslhhishhtshdrohiilhgrsghsrdhorhhg Subject: [Skiboot] [RFC PATCH] core/opal: Add OPAL call statistics X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" Here is a proposal to collect OPAL call statistics, counts and duration, and track areas we could possibly improve. With a small Linux driver to dump the stats in debugfs, here is what we get on a P9 after boot: OPAL_CONSOLE_WRITE : #22318 0/0/47 OPAL_RTC_READ : #9 0/4/15 OPAL_READ_NVRAM : #3468 0/0/6 OPAL_HANDLE_INTERRUPT : #4724 0/57/10026 OPAL_POLL_EVENTS : #508 2/141/10033 OPAL_PCI_CONFIG_READ_BYTE : #3623 0/0/4 OPAL_PCI_CONFIG_READ_HALF_WORD : #5579 0/0/8 OPAL_PCI_CONFIG_READ_WORD : #6156 0/0/7 OPAL_PCI_CONFIG_WRITE_BYTE : #2 0/0/0 OPAL_PCI_CONFIG_WRITE_HALF_WORD : #1282 0/0/1 OPAL_PCI_CONFIG_WRITE_WORD : #1335 0/0/1 OPAL_PCI_EEH_FREEZE_STATUS : #11123 0/0/2 OPAL_CONSOLE_WRITE_BUFFER_SPACE : #139088 0/0/11 OPAL_PCI_EEH_FREEZE_CLEAR : #148 1/2/8 OPAL_PCI_PHB_MMIO_ENABLE : #22 0/0/0 OPAL_PCI_SET_PHB_MEM_WINDOW : #22 0/0/1 OPAL_PCI_MAP_PE_MMIO_WINDOW : #56 0/0/0 OPAL_PCI_SET_PE : #44 279/284/293 OPAL_PCI_SET_PELTV : #66 0/0/0 OPAL_PCI_SET_XIVE_PE : #1123 0/0/1 OPAL_GET_MSI_64 : #1120 0/0/0 OPAL_START_CPU : #238 8/21/35 OPAL_QUERY_CPU_STATUS : #357 0/11/69 OPAL_PCI_MAP_PE_DMA_WINDOW : #16 0/0/1 OPAL_PCI_MAP_PE_DMA_WINDOW_REAL : #16 0/0/1 OPAL_PCI_RESET : #35 0/471/851 OPAL62 : #6 0/10/46 OPAL_XSCOM_READ : #26 0/0/2 OPAL_XSCOM_WRITE : #8 0/0/1 OPAL_REINIT_CPUS : #4 348/8247/11061 OPAL_CHECK_TOKEN : #134112 0/0/0 OPAL_GET_MSG : #30 0/0/1 OPAL87 : #1 0/0/0 OPAL_PCI_SET_PHB_CAPI_MODE : #2 0/60/121 OPAL_SLW_SET_REG : #1080 3/3/13 OPAL_IPMI_SEND : #53 0/5/11 OPAL_IPMI_RECV : #53 0/0/2 OPAL_I2C_REQUEST : #20 6/10/19 OPAL_FLASH_READ : #10 19/10452/58305 OPAL_PRD_MSG : #1 0/3/3 OPAL_CONSOLE_FLUSH : #134079 0/0/12 OPAL_PCI_GET_PRESENCE_STATE : #7 1/1/3 OPAL_PCI_GET_POWER_STATE : #9 0/0/0 OPAL_PCI_TCE_KILL : #20 1/8/133 OPAL_NMMU_SET_PTCR : #3 253/255/257 OPAL_XIVE_RESET : #3 0/114709/115403 OPAL_XIVE_GET_IRQ_INFO : #1427 0/0/6 OPAL_XIVE_SET_IRQ_CONFIG : #1113 0/125/2810 OPAL_XIVE_GET_QUEUE_INFO : #240 0/0/2 OPAL_XIVE_SET_QUEUE_INFO : #360 0/60/1216 OPAL_XIVE_ALLOCATE_VP_BLOCK : #2 0/59/60 OPAL_XIVE_GET_VP_INFO : #240 0/0/0 OPAL_XIVE_SET_VP_INFO : #360 0/298/3080 OPAL_XIVE_ALLOCATE_IRQ : #240 0/0/3 OPAL140 : #119 0/253/1109 OPAL_IMC_COUNTERS_INIT : #60 9/10/20 OPAL_IMC_COUNTERS_STOP : #36 0/0/2 OPAL_PCI_GET_PBCQ_TUNNEL_BAR : #1 2/2/2 OPAL_PCI_SET_PBCQ_TUNNEL_BAR : #1 1/1/1 OPAL_NX_COPROC_INIT : #2 3/4/5 Signed-off-by: Cédric Le Goater --- core/opal.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/core/opal.c b/core/opal.c index dc9944dcac5d..5712a42ebe94 100644 --- a/core/opal.c +++ b/core/opal.c @@ -44,6 +44,27 @@ static uint64_t opal_dynamic_events; extern uint32_t attn_trigger; extern uint32_t hir_trigger; +/* Call stats */ +struct opal_call_stat { + uint64_t count; + uint64_t sum; + uint64_t min; + uint64_t max; +}; + +static struct opal_call_stat opal_call_stats[OPAL_LAST+1]; + +static void opal_call_stat_update(uint64_t token, uint64_t call_time) +{ + struct opal_call_stat *s = &opal_call_stats[token]; + + s->count++; + s->sum += call_time; + if (call_time > s->max) + s->max = call_time; + if (call_time < s->min) + s->min = call_time; +} void opal_table_init(void) { @@ -55,6 +76,10 @@ void opal_table_init(void) while(s < e) { opal_branch_table[s->token] = function_entry_address(s->func); opal_num_args[s->token] = s->nargs; + opal_call_stats[s->token].count = 0; + opal_call_stats[s->token].min = 0xFFFFFFFFF; + opal_call_stats[s->token].max = 0; + opal_call_stats[s->token].sum = 0; s++; } } @@ -190,6 +215,8 @@ int64_t opal_exit_check(int64_t retval, struct stack_frame *eframe) call_time, token); } + opal_call_stat_update(token, tb_to_usecs(now - cpu->entered_opal_call_at)); + cpu->current_token = 0; return retval; @@ -420,6 +447,9 @@ void add_opal_node(void) add_opal_firmware_node(); add_associativity_ref_point(); memcons_add_properties(); + + dt_add_property_u64(opal_node, "ibm,opal-call-stats", + (uint64_t) &opal_call_stats); } static struct lock evt_lock = LOCK_UNLOCKED;