From patchwork Sat Mar 2 00:59:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 209154 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp247609dyc; Fri, 1 Mar 2024 17:00:35 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUuyRlGFNAMFEwL1OxiGtYFU6mXLppMINQVPO1C7irrmKzvgLRCUm+7Xi3NcvRl9BXzCUh0W6W47+ndOelqqPAnqMnwdw== X-Google-Smtp-Source: AGHT+IFk4hG2fSAkhF0gx/nV3wa8k4vyawaEZeYK8BYZynPv96K3a8AoJNxuZ5OBci3XXFnQvhx8 X-Received: by 2002:a50:c90d:0:b0:565:471b:c047 with SMTP id o13-20020a50c90d000000b00565471bc047mr2678057edh.0.1709341234786; Fri, 01 Mar 2024 17:00:34 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709341234; cv=pass; d=google.com; s=arc-20160816; b=jSArbuWtcgIevijVIeAqW7puTyiONwen++XscCJnBI+OjlfFgIDNs8VKFEE4fC899g CH4XG2pzFEtGKhD3YFmAoDdYRK/hQjIU3Tbujv2e+KSvPjhwLr0vZmoBP3xHgvhzRGDB R+I0M10q9G1fTsg0uGFTpQRNYQWtxdSOd2vihexx3nH6KROYFOJxRbDIbz2fETPu6DEM YbGDZQs8G00MpH5TScX8PFU/FjRLdIyfgeTuLyyb0owu8S4Ftw/0nIy1+WrXoW2eIvRg 0O2Rw7fAT/8jWYoGBLGTVJhuIZnWrVoSdfdII2q/T8cqK3RF/C6vba0seeXIMvfc4Fbw efug== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:from:subject:references:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:in-reply-to:date :dkim-signature; bh=FZPkGRhHwcNWwVteqhq4++b4hJ8f8BvedCtUPDM725Y=; fh=OeiuXCH3Dk75QjPF6SmY/mW2/HCjBpY0R4+6A043swE=; b=okDTH/qydcJqrVLcN+NIg8scHiyfyRwdcrL9WWLOXyo9G8O5UATpSKL5pQm/KrVqT8 snwMcBu9SqSia6972+qIoyPTgqXATTcJrFeTwApIDU3EAkFtKNlkPw3fyyUtHHnvGZ4L R8DJDEEAVVUJpz/N3nspVU4rfO9mTczYr0QOMTnZV/O33yKx842jUQQ/EMk83WxW5pqT YuK3OAMNqpXZwvEABxc5P6vUo+1ZwQbOLOe7FJzanGvV73Mj8ddO+thl7ub6xQdHwXeX AyyzcOtySt0Ywd6ehsBZAsovwlSl+ktLLSM7g3OGE/DWYnt1Vr81YNgiraokaOLlOK3i 6hsA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=D+k4w4qd; arc=pass (i=1 spf=pass spfdomain=flex--irogers.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-89275-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89275-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id w17-20020a05640234d100b0056454c5a90bsi1900014edc.106.2024.03.01.17.00.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 17:00:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-89275-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=D+k4w4qd; arc=pass (i=1 spf=pass spfdomain=flex--irogers.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-89275-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89275-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 694DD1F23BB6 for ; Sat, 2 Mar 2024 01:00:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 959C2749F; Sat, 2 Mar 2024 01:00:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="D+k4w4qd" Received: from mail-pl1-f201.google.com (mail-pl1-f201.google.com [209.85.214.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4CEB8DDB0 for ; Sat, 2 Mar 2024 01:00:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709341202; cv=none; b=ZKzhb9RDBoerVPP3LVfHseiVhkpWCdHgQNyEBtvk2r8XkEubVZZfcak6RgikWE6J7t64KpffltkWgAfZElvpliErGkyrDuQwt+KldgDhj7Dc6s0SKm+t+xXu7QYr8XcZkoZW/0X8fl+FRs1/SM5uwuxdrHn1wD3cwnGBl1iBFjI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709341202; c=relaxed/simple; bh=Q8r8JCAtkGCJmmXhKhiAJOofwbQwry+nv4WJ1Szla+w=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=dMF8cbRcK0eSrU2WONffOniBfUV+hRUI++iOAzpypo98M7YIDz8oPvUQLG6Zfz63Fog/x+1tFyubQKW1AvWmweK07uvwznC/7IXpCSbxN8QHbGJgeXID1B+Fy5lQiZZOIWz8f2RavTnw0XsCrezWxGMj1g++G8/Sn1kLnMiXB6o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=D+k4w4qd; arc=none smtp.client-ip=209.85.214.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Received: by mail-pl1-f201.google.com with SMTP id d9443c01a7336-1dcaff13db5so26478575ad.3 for ; Fri, 01 Mar 2024 17:00:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709341200; x=1709946000; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=FZPkGRhHwcNWwVteqhq4++b4hJ8f8BvedCtUPDM725Y=; b=D+k4w4qdK0KSO0PU3Qk5EpR+BUWjjWv9Mp//dUGjJaHhPwGc0wgLKoreWgWeXIicBu 3MrEVzhmztJ9sy6Y+IxVsyZ3psvuWbZaEtlnBplOLC1fk0zEDT0XXOfOUfvcapNSvTyG bV2MSLnNWTWZEcTsv2Pz2+GxaG1bW64w0UtPufc4LoIWOMUJLhKtUFWVwwI6Qd90Fvy6 TEghm/bIgRq8byQtxtlPwW1hpCs9FWC7uh3K2dMV528Zf3kUyqd9dD7FVSgEE/ZzcM6V ZiZCfzHq60PClDcodmT4JM6QMYwiniFxtI7+9i7MCZK2/zCUvgK0ntunllCCaXGry5tL GZbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709341200; x=1709946000; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=FZPkGRhHwcNWwVteqhq4++b4hJ8f8BvedCtUPDM725Y=; b=ht+25+a6BgOP4F6uyPfDcql+nv8fKZBWfqWE6m5sg7XPpViFCM7TZ2KCxo0dH7hh4N zXvZQM8aOrNAcmfeOAXVJEX0Bs4CEhWS6T7Mt/M+UrAno2BXIzuMCfrTO4d7EXw1zgAu spL3XhheXUgUspNxgZpnHmZFKN5GbGCmsF18h6PLd/R4DpPtb5gGjb9fXLHOAVqGu0Sp 4pVeGaKFOfJNFyFowe/1uwZzn4FoHjX92lzup7KRPzAVrryZ85c9KI/ChJHAyEsmg7R9 OCzqZWaz4OS3HKdcRjTArVyKsX3GjpKndx3QPYdT1aW6F014KHwAayEMxT/Wn8i+oUFU JXhQ== X-Forwarded-Encrypted: i=1; AJvYcCXdGUYlKRXMauQlp3mIe8QdZM/DnTOfOTuLvPW+D3UmmvRbqjBEjmgtzsRXk9OkT/XwN0HNDCIlRhZUVd9VMCbd0wfxvc6D3SdlPMIQ X-Gm-Message-State: AOJu0Yw3c9Tp81eq+QyTmpX16AEQ+4K24P2bkOcTccss4AoHzCmmCyMi 6zY/OmjoAx8ydXVZjBNXJRQKnKEb6fs/hO7btwq60fnkjCciDNO2r7CSvy7m+q20BL1OHaHJl2j X91XLQw== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:aba7:66c5:3365:7114]) (user=irogers job=sendgmr) by 2002:a17:902:c40f:b0:1db:e9ed:bbb8 with SMTP id k15-20020a170902c40f00b001dbe9edbbb8mr143679plk.9.1709341200314; Fri, 01 Mar 2024 17:00:00 -0800 (PST) Date: Fri, 1 Mar 2024 16:59:39 -0800 In-Reply-To: <20240302005950.2847058-1-irogers@google.com> Message-Id: <20240302005950.2847058-2-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240302005950.2847058-1-irogers@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v2 01/12] perf jevents: Allow multiple metricgroups.json files From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , John Garry , Kan Liang , Jing Zhang , Thomas Richter , James Clark , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Andi Kleen , Kajol Jain , Sandipan Das , Ravi Bangoria , Perry Taylor , Samantha Alt , Caleb Biggers , Weilin Wang , Edward Baker , Stephane Eranian X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792374194656540585 X-GMAIL-MSGID: 1792374194656540585 Allow multiple metricgroups.json files by handling any file ending with metricgroups.json as a metricgroups file. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/jevents.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/perf/pmu-events/jevents.py b/tools/perf/pmu-events/jevents.py index 2c7e5d61ce92..65ab03ce5064 100755 --- a/tools/perf/pmu-events/jevents.py +++ b/tools/perf/pmu-events/jevents.py @@ -603,7 +603,7 @@ def preprocess_one_file(parents: Sequence[str], item: os.DirEntry) -> None: if not item.is_file() or not item.name.endswith('.json'): return - if item.name == 'metricgroups.json': + if item.name.endswith('metricgroups.json'): metricgroup_descriptions = json.load(open(item.path)) for mgroup in metricgroup_descriptions: assert len(mgroup) > 1, parents @@ -653,7 +653,7 @@ def process_one_file(parents: Sequence[str], item: os.DirEntry) -> None: # Ignore other directories. If the file name does not have a .json # extension, ignore it. It could be a readme.txt for instance. - if not item.is_file() or not item.name.endswith('.json') or item.name == 'metricgroups.json': + if not item.is_file() or not item.name.endswith('.json') or item.name.endswith('metricgroups.json'): return add_events_table_entries(item, get_topic(item.name)) From patchwork Sat Mar 2 00:59:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 209155 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp247761dyc; Fri, 1 Mar 2024 17:00:48 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVQBXAQk92arojzarTAxYLbBkfmoN0EXPFqSGQ6NVfq78IARgmiL2tlMNhLOwjw2CaUmaONUsMDSCtptwxWjvMwpvmxdQ== X-Google-Smtp-Source: AGHT+IHbMvzLR+AXNp9iGK5wQF2xMV8TkjMSiMTBhJYM2owlwo1SWwvLo0Qbwq04IB81Y4VHzs78 X-Received: by 2002:a17:906:a404:b0:a3f:cd6b:80fd with SMTP id l4-20020a170906a40400b00a3fcd6b80fdmr2653111ejz.7.1709341248709; Fri, 01 Mar 2024 17:00:48 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709341248; cv=pass; d=google.com; s=arc-20160816; b=KoeOwLTRu/IbL2EygggNsgb/mKqA1n1/qC7qt9c6J7EI4mUYExwnzDz+Wfv9Xj0vVW nEsIB3tQA3FTgCyqNVbjCJ+Qpfn+jWX1zLZPiWW6LjRckkSisZv5xKmaTHC5DzMRbufX 2rnlkB1CkQuJ1TSUT2Fi2wsXGj6V5un3CdiMCoZW0x7ReOEcGHVZl9Pv0Vtb7PQsYdYp bgvLeIhp1m28vH5ldYPNCt5EniteIiZH5KgI7831Wt6+jaI0l+4H3kA2+AwyYcA0bCLu IRGrKUgoFx1DDAQhaeYafHq/kJ5QRYbi6NzdB6y8AS8XIafEMEqVh0k7ldqWIfCNcEdL UB0Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:from:subject:references:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:in-reply-to:date :dkim-signature; bh=KxFo9HXrMBHPfRGQr1WhtYDEqITe1Fw0obEsjgP5vwk=; fh=RKhnVfKIBOQliE8+phZT4a0jWwfr3Q2yN9YRmZliIGE=; b=WqoeBWdcnMiIFJ6YvDh8+PPsAPkjAvzjtPgJs80dKw96ZhIatXxXfI5hQ7w4a34H/K KQ6htgQ9FDbgiA6hxxAE0wdo572SJKwyv6u4R6T/32hhp8W0fTi/8gwl8Ra9owsY0Nst 8weQdeUcFKUojTqyHdn82RJPY5KDbNJQoBkYtl5N57EbFvRwC4jHXDAQCjSv2rQOHICb pq+wUyOgqxS4ethw/bsKU05cerCqApbnk2KwBGJ+Vyltmu98VQfJA74o9uuYJzwD4anD luoaF/ikT4PBQyUZxsRnt7nm7aBOeJxuO2n9JaTGH6v9qiYeK+xmDvQZb7LE0cYmccTT IP9Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=AFk8W1dH; arc=pass (i=1 spf=pass spfdomain=flex--irogers.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-89276-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89276-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id s8-20020a170906354800b00a441a40c035si1872379eja.279.2024.03.01.17.00.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 17:00:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-89276-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=AFk8W1dH; arc=pass (i=1 spf=pass spfdomain=flex--irogers.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-89276-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89276-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 559FA1F23ACF for ; Sat, 2 Mar 2024 01:00:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 03991101F7; Sat, 2 Mar 2024 01:00:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="AFk8W1dH" Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 926B25CA1 for ; Sat, 2 Mar 2024 01:00:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709341205; cv=none; b=MjSeVe2uHrCmOok3zwfMP8tkOue8Q1x4y2DLCOwANhpZARmrdC2cYyeioqV6uaodKE7nOkowPoMWsEESV1IIupBIhDQLYDKhXSyt62AI2wTwPDlZXV6v3rnGPtE6ITRR+ptej4wOePU4ffTQ9rMe+JhH/dy6GpAdFd4j9Z9tDUE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709341205; c=relaxed/simple; bh=hLfRLYYEBDGHVllbq1W2MRKFt2uEVseZ3ckqP7HQcJs=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=CIgsCuCFekDqrEB4qp4fXEDQ15wc+pBDqFD6nSrqQE6U7LRjKJIoIVQnkapd03y7rRwbYNUEclBoQFlkFdSSXTt4PjKc/YBui2W0RYKDbEvba1ZQwZyXUvSOTEZB+bAt8bWWM1hcAbbDf2mKx9wvVzsKd5xRWboiGBEGRaQI/wA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=AFk8W1dH; arc=none smtp.client-ip=209.85.219.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-dc6dbdcfd39so5227213276.2 for ; Fri, 01 Mar 2024 17:00:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709341203; x=1709946003; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=KxFo9HXrMBHPfRGQr1WhtYDEqITe1Fw0obEsjgP5vwk=; b=AFk8W1dHLucI1lzV9klBxz+8G+cQ/sXQjH2CxBpRsZQwpR38Ri68XuEv5uSefbaDDv 9PusemxFaGn+WxpkCXDjwhcrLlrA7+lXHeOJLdsLFWohYIJo2Ao1mbK6YztCF8NeuR1P 9wibUWh2mP6xD94pZ8fVzbhpG+bBkgCEudKC3epFPaAXvOtYAYUBt+Jr6Dn5/Uz3WNPg ESSkDfNL4qPCNvJPZPwPFBFW/A2HAznQvxis7ROGx2CAcREa2h8pPMZEMcKaN6qK6S8N DegiEgPqYqmzNZOMuldmg3Ci2iNzN6QcsRleOYlKEuGM3/Yy97nKFR7NWXP5YIqppC2u EzuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709341203; x=1709946003; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=KxFo9HXrMBHPfRGQr1WhtYDEqITe1Fw0obEsjgP5vwk=; b=gld+wDFPDGfVEQ3fPcp4SxKSKujrMtIAnf1+S3utd4NufjUEdS00kYXzMB5nS12ezp xzjDqzo/4osYJlj1jKpBszHJ4wAPF+V79eukRZpDiYCoE8NmvovDeuukrk4oe0kE4xRP j4OSARCwSDsN6BqSy/gojVZJHgIuMqf2Fdb+tx9QnsrOVGe3uJEnNe1Uvs9ly/inoSBi UHSn3B0uSdSqwzRXPTVKXCC0TppyBtwc7QaCgs2gwvdZiiekOAlJ1p35zIAp8cx0EBFu HpW+uahT57UAdQbkeACyXOztAyxYqUQyjVbQsulWAGtB3uGGjEka4d6bG/lYA6MY6PdW +pgw== X-Forwarded-Encrypted: i=1; AJvYcCX8jNnTt7zz8LFTblqn7BeDEbRsseN20e6g9BFTqOXCUSV01fUYgzBWfAZ3DNRSBQ0P3nCz9GPDGqCJuznGp8dkSZODiUw8VqGyBhUm X-Gm-Message-State: AOJu0YyR+56u/dJpQflA47iJicFW9Uy8md9ddrsC/5SgiAAj5/W/lHhX lajYZJpSwEqrEBIEB4aVPvkwAMY05PxI/JOEgbFymtySMbVY+5p+CngWaltSPfY6ZZDEerWheyx TnZZLTA== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:aba7:66c5:3365:7114]) (user=irogers job=sendgmr) by 2002:a05:6902:100a:b0:dc7:5aad:8965 with SMTP id w10-20020a056902100a00b00dc75aad8965mr766000ybt.0.1709341202870; Fri, 01 Mar 2024 17:00:02 -0800 (PST) Date: Fri, 1 Mar 2024 16:59:40 -0800 In-Reply-To: <20240302005950.2847058-1-irogers@google.com> Message-Id: <20240302005950.2847058-3-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240302005950.2847058-1-irogers@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v2 02/12] perf jevents: Update metric constraint support From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , John Garry , Kan Liang , Jing Zhang , Thomas Richter , James Clark , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Andi Kleen , Kajol Jain , Sandipan Das , Ravi Bangoria , Perry Taylor , Samantha Alt , Caleb Biggers , Weilin Wang , Edward Baker , Stephane Eranian X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792374209325575754 X-GMAIL-MSGID: 1792374209325575754 Previous metric constraints were binary, either none or don't group when the NMI watchdog is present. Update to match the definitions in 'enum metric_event_groups' in pmu-events.h. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/metric.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tools/perf/pmu-events/metric.py b/tools/perf/pmu-events/metric.py index 92acd89ed97a..8a718dd4b1fe 100644 --- a/tools/perf/pmu-events/metric.py +++ b/tools/perf/pmu-events/metric.py @@ -4,8 +4,14 @@ import ast import decimal import json import re +from enum import Enum from typing import Dict, List, Optional, Set, Tuple, Union +class MetricConstraint(Enum): + GROUPED_EVENTS = 0 + NO_GROUP_EVENTS = 1 + NO_GROUP_EVENTS_NMI = 2 + NO_GROUP_EVENTS_SMT = 3 class Expression: """Abstract base class of elements in a metric expression.""" @@ -423,14 +429,14 @@ class Metric: groups: Set[str] expr: Expression scale_unit: str - constraint: bool + constraint: MetricConstraint def __init__(self, name: str, description: str, expr: Expression, scale_unit: str, - constraint: bool = False): + constraint: MetricConstraint = MetricConstraint.GROUPED_EVENTS): self.name = name self.description = description self.expr = expr.Simplify() @@ -464,8 +470,8 @@ class Metric: 'MetricExpr': self.expr.ToPerfJson(), 'ScaleUnit': self.scale_unit } - if self.constraint: - result['MetricConstraint'] = 'NO_NMI_WATCHDOG' + if self.constraint != MetricConstraint.GROUPED_EVENTS: + result['MetricConstraint'] = self.constraint.name return result From patchwork Sat Mar 2 00:59:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 209156 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp247889dyc; Fri, 1 Mar 2024 17:01:04 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUFqwWq/Zc1iAcEaKvj889+7S7koWc0snmoy32M+Wc8NZStJff1o2vt1Kv5rNYXB8YfgLUHTSd3sjr5E1iJ4j265/znyg== X-Google-Smtp-Source: AGHT+IGRTM5XFr4n2TQqjAnG9ibzQbxb2LnhxIR6O41ltK9Wqh9P2cHRrovOKm0qt/l6wTlnLj5B X-Received: by 2002:a17:902:f682:b0:1dc:7101:58c0 with SMTP id l2-20020a170902f68200b001dc710158c0mr10352023plg.22.1709341264004; Fri, 01 Mar 2024 17:01:04 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709341263; cv=pass; d=google.com; s=arc-20160816; b=vCJOg3VNpQunyF0yVUOCd2ZWv1fgZhqKTDktjp5JzOAOhPuGWtuwtxe6/PuwIQBzNH rwMmHKNyGDtlYFjQw3bRbQb5TOiOa4j/GUhEAkRn+yQRTm/2vrUFOUZkKPSGPjSdYWef tweWEGNXqH7bQr0ufg1x+JWI7JnKSjeD4WYWA7KFs9N5kVwBIC5sBRvebZq92BeAkRxq YgVXUknmPDPkwqN73gpkS9mvHIJHtZvk3ZwN3f5icsW4Ltgx4xIhBUQFHgHKOss2bdf8 gDpsn7O8CeXVDbdWWWaLkE7EcFkRdcXIHiIwg6mE7I06oPY/kQDnpcPCcy1YwqtlUlVo ZwlQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:from:subject:references:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:in-reply-to:date :dkim-signature; bh=cnw+7frKkpFIuv39tcYmSQZnvJ8fkaJfcm6LBjLqiJc=; fh=BMkRC0jL7DfKo9K2fBApyx3uFWPSFYbLM1A1WRxdjVM=; b=m4v3+vNXwb7+YhcyZPf9mHCYL720PHO7+WQhW7d7DeVRVZHc4xZLwqQBPnqxOaV3vL KIwNfjBgVQM/mCjqCjZdUwvu8HBqvuUqLsuffRtRrdLPEAX/rXV0NlURfpy0JrDNjq6t rE8O8b9bCX0yiCsdTHci8Ogx/QqbcmJVP7Kb+UHoQTi6bXZ1FjAbWf1aIgUG49p47H6K IuqShcBH8tJvdnfsV5Sl9gzHPYsyOA5zoheQdw3Zrrilv5PmmKvvhcopmaGYAp6YpOwM vPJEFgsVlKBDcnGCvXSHyg5jW8zghgCQChSkp8Pmi4vfkHLxF9Wtc8JVaiueCBL8h1Z8 dzOA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=lqMq4sXT; arc=pass (i=1 spf=pass spfdomain=flex--irogers.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-89277-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89277-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id l16-20020a170903245000b001dcb306f032si4659364pls.118.2024.03.01.17.01.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 17:01:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-89277-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=lqMq4sXT; arc=pass (i=1 spf=pass spfdomain=flex--irogers.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-89277-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89277-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id C1F1F286EF9 for ; Sat, 2 Mar 2024 01:01:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 627BFDF41; Sat, 2 Mar 2024 01:00:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="lqMq4sXT" Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F17BC79F6 for ; Sat, 2 Mar 2024 01:00:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709341207; cv=none; b=sFoftPHEolxbaFZGIcAMIAXFrkgQbmiEMsAlvFmriD7Byux6FhtWSR9Qxtxw7HdPOh8XOGsWM9WqaLLd+3tCerl1DxDUdNEcUTlPkj66Zl7GnkN34BrfZsRNkAVPetCDVmOTlk5tP31V//ml4M9ZmJYeRgwqx2pFxEWZLf4pb3k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709341207; c=relaxed/simple; bh=GN4Y68feIoyK84NORTnkVtG7K1dAvlvEPxB9mo8klN0=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=WY/jtcctyEPAm7969p/rS8WGtoHZAhJJPY6xN6LL7+kqR+WOhA6R33ow8x37mWeXdqYXWgxObU4nmHPwVvlTzQdx4xvO6JUhSCFED3bJKn3YUqzT0XmFutqRo2p4DqsyEZ36zc3CwKjyz9EuSK5Bf1oljpQ9XVHU+9pjmSEuAd4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=lqMq4sXT; arc=none smtp.client-ip=209.85.219.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-dcc58cddb50so4696377276.0 for ; Fri, 01 Mar 2024 17:00:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709341205; x=1709946005; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=cnw+7frKkpFIuv39tcYmSQZnvJ8fkaJfcm6LBjLqiJc=; b=lqMq4sXTlul76pp7I2oLoCW6U/v5uVo6CEQD4cpCawLPRu5lJlYZuqybKp+AQmLDnD jzTwNCgCke0KYsGqOlh25zFNKJDWjSbE+IPa2t3LMXjAcm/EAvQiKM1ofM4WwJINFBMZ LOs6NvatFNkFFHYQS8GQQDbN6+9zPaNNt75s76eoiZHXLXrxxRI+PeQOolQ+JjaI3sRm E0yxTt4tcA1cUPliGxbNqOfv6GghntCHwSIDBRJj4QY5/jdiA7DA0V0PjxB0L5XBvFIe 6pPdr6LweaA3CrTkxDUq6i/91bBTdJWEh6lYfVZN+WJaVBMjYScUUcUW6vGEwENrOm37 zmyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709341205; x=1709946005; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=cnw+7frKkpFIuv39tcYmSQZnvJ8fkaJfcm6LBjLqiJc=; b=qw70wLIrDayENU0CYcE4PosFSO7PzGeqPmEmDTG3BKwKG8EARHFBPntS2iSfwsVkjB n1RZtNssxYmhQIAfSZ0hBWZEgSTP91ubIo6pvMbqvt3gmDCOy3WZl4RQbSrD5K14/yIH M/AnIreTPy5OoUaeYuP0NFhwis9PZOnAltxQ6WtgC7GMcq9J8rckH0dxqHY6WgYXAOZM 1wAVtmIHnYJTZaIJJy6ESdLH4eFMg72w6eHv5DWn3VNM59opC4Q8pAAJbkP1ldlYul9x 9c3bzSjX2Pd1A/fGbLzeCtGFCOt5QBBLhqqkj0ft3wAik/Toua/J/EJCyIV5IVuA/6md pXYw== X-Forwarded-Encrypted: i=1; AJvYcCX1ueAror3Y2UuTzNPwUDpJcQ1aopBp7Y1u9n9kV11JojoxibCpe+7rzhQaS/P/rOX5dSOBsUcMoPIdtm+WOpIk5xTZ5uKxvBkfLBUL X-Gm-Message-State: AOJu0YzjmyU0E1IlQ/QU1+/fxbsy+Vnjb6FFbqH+j3FtIHzApQh/HG0F ZDqTTolBj/62m5/KmYsB+8Sgr0uKEX6lxs0TepbZvCKRA8a3wmWXTXq6LmwS8MZ0wdrx2WLW8jq BMYSIRw== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:aba7:66c5:3365:7114]) (user=irogers job=sendgmr) by 2002:a05:6902:1004:b0:dc2:3441:897f with SMTP id w4-20020a056902100400b00dc23441897fmr721544ybt.6.1709341205149; Fri, 01 Mar 2024 17:00:05 -0800 (PST) Date: Fri, 1 Mar 2024 16:59:41 -0800 In-Reply-To: <20240302005950.2847058-1-irogers@google.com> Message-Id: <20240302005950.2847058-4-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240302005950.2847058-1-irogers@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v2 03/12] perf jevents: Add descriptions to metricgroup abstraction From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , John Garry , Kan Liang , Jing Zhang , Thomas Richter , James Clark , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Andi Kleen , Kajol Jain , Sandipan Das , Ravi Bangoria , Perry Taylor , Samantha Alt , Caleb Biggers , Weilin Wang , Edward Baker , Stephane Eranian X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792374225269104041 X-GMAIL-MSGID: 1792374225269104041 Add a function to recursively generate metric group descriptions. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/metric.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tools/perf/pmu-events/metric.py b/tools/perf/pmu-events/metric.py index 8a718dd4b1fe..1de4fb72c75e 100644 --- a/tools/perf/pmu-events/metric.py +++ b/tools/perf/pmu-events/metric.py @@ -475,6 +475,8 @@ class Metric: return result + def ToMetricGroupDescriptions(self, root: bool = True) -> Dict[str, str]: + return {} class _MetricJsonEncoder(json.JSONEncoder): """Special handling for Metric objects.""" @@ -493,10 +495,12 @@ class MetricGroup: which can facilitate arrangements similar to trees. """ - def __init__(self, name: str, metric_list: List[Union[Metric, - 'MetricGroup']]): + def __init__(self, name: str, + metric_list: List[Union[Metric, 'MetricGroup']], + description: Optional[str] = None): self.name = name self.metric_list = metric_list + self.description = description for metric in metric_list: metric.AddToMetricGroup(self) @@ -516,6 +520,12 @@ class MetricGroup: def ToPerfJson(self) -> str: return json.dumps(sorted(self.Flatten()), indent=2, cls=_MetricJsonEncoder) + def ToMetricGroupDescriptions(self, root: bool = True) -> Dict[str, str]: + result = {self.name: self.description} if self.description else {} + for x in self.metric_list: + result.update(x.ToMetricGroupDescriptions(False)) + return result + def __str__(self) -> str: return self.ToPerfJson() From patchwork Sat Mar 2 00:59:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 209157 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp248042dyc; Fri, 1 Mar 2024 17:01:18 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUQHcwZFXMpFWu2kAhsrSpTOqaHkYDPOWtxMqDGZ0inyp6wyWJjv5nOS32b5LR7rrWi73pOvhGaP/P5GzlyVUF2WcoyHA== X-Google-Smtp-Source: AGHT+IFGkexL3QPjURghYWvlGKqyDRQ2/jDK3UVAbHW3WSsvQZdDWhv8DaM0bpjJwdvINGdYzkZf X-Received: by 2002:a05:6214:1786:b0:690:521b:df12 with SMTP id ct6-20020a056214178600b00690521bdf12mr3588512qvb.8.1709341278439; Fri, 01 Mar 2024 17:01:18 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709341278; cv=pass; d=google.com; s=arc-20160816; b=jLqTwKklSIcfDx6bLbM+5CDFFBeiFS+Zx2zhbSYVKTRB/sNMg2wk7n/tmNzo4DNUKF 979HDvzN+oemIz72DV8yxFCRXSYSyvumlCkgPQcjULzAUDFNLrqkyANJljFrIlP73Gn0 g/Z5gbLRVxzvr6L+9Z97lR2b0wnpase+1CNs1zJ2xzeU0e7XjgPr2qjFJ84A6mA5YkAp q84itPMuEGi04IkRjGlufJNPo+D+XdOeERXHsiA+mzbLckA/NAw4XeJo8V3aW/5i8AvK KoVjDURQfx+7MzE/q8OQglvFYvmbxH6AhOorJuAzYEKlkXVE9mlUvYSTsK8SpNqlOdYP kQUw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:from:subject:references:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:in-reply-to:date :dkim-signature; bh=0l9FS4zSa3KVc8IImImj1SVx9SNoPylTIMS2zSJSapM=; fh=Pa5EZPoDmFhldCqaw0CToD6ur18etrTLFA8ewJaEYyg=; b=dFEmjwBtP3ITphL3eVm0VXc4T52AI4K6CvH0jISsLzb48HWBKVxGLil//48OchhZ3b wkL88fb27Pny0zFWJ3dP52GHJsJ9Z5QywqnH8lMUHPnj+bl2Inru42t7sgQ5AOgZbjZd 4PxaHmagy32pCnPxIWI4FzuBKyGNQ+Yl6Crwtd0XTSIF0ok3N1+Rls2jWemqj1isLBOR ZODa59sZ/Lpib8xXxdh2PznwT4s13t0krynVGqaIGI5VbWBas5jZpbuwDgEP3NROURdk +bnT8auYaaqoeLYEXphxRCwtoRAy6k1XbK0LkR5SsikLQv81LZVG5r26luVIB1T+24B1 6Etw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=hSUiKKTZ; arc=pass (i=1 spf=pass spfdomain=flex--irogers.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-89278-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89278-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id eo13-20020ad4594d000000b0069017323b96si4741349qvb.208.2024.03.01.17.01.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 17:01:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-89278-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=hSUiKKTZ; arc=pass (i=1 spf=pass spfdomain=flex--irogers.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-89278-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89278-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 3D3511C2160C for ; Sat, 2 Mar 2024 01:01:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B375312B80; Sat, 2 Mar 2024 01:00:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="hSUiKKTZ" Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 98EE310A23 for ; Sat, 2 Mar 2024 01:00:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709341210; cv=none; b=Raljo1ze8dpsAArjkwV5HAv+nVFfBPGx7E2x0UmeXm9skJa4bHnMCZ6qQOt+fN0ATaHJ+6Q3AvONhpeGAYgr+oM5k5jebSx1w+fbY9aUMi7AQ3r5NUA3jdXxzKks6PqgeEAedHCwllaNyrxuk8PxdDVl/FfbkVeMRmwTbXjYUPc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709341210; c=relaxed/simple; bh=0IeSdmWuvcjIVBTAhF6kJkhdSlGmwLTCZHLsTn46VzI=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=sV+GLo1rRBcZM/AsGgJgGcC2WoqLrxUkzXmBJ3VpPJVDRf08IVuMKyjYOGtJPoNRcgGpRy6uD1h8ZHRPp835nBZDWVKaZCkWGnHoZDu1P/TxZ1sEJWOUVdSyZzYi+amKSO1ttBMG4+wlyXKIfYaqR2kqr4rOKdO8IUUp4mzqJZY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=hSUiKKTZ; arc=none smtp.client-ip=209.85.219.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-dc6b269686aso4064752276.1 for ; Fri, 01 Mar 2024 17:00:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709341207; x=1709946007; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=0l9FS4zSa3KVc8IImImj1SVx9SNoPylTIMS2zSJSapM=; b=hSUiKKTZMo51O4TPXi6JpFPqXDNBdygWk1alNNT5UMxotiYh9mVdfQhPB97foUdymr GdZNLnjq8z2Q8tLWlM1Q2vk4nhV9Rb4An47vFsQVVnbcb0uIkhakLLDsx0H3ojz422vr DhD/BoXxAMunHTqXPJ195BYsv/Ak3mbVzjC9Fni3/s5YkIQ4cGpGcgmfBEZPA8V4e4U7 AI1+2gjO9kx+wbxvdDL06vD7QZVdEh5ONgYkjkv9rb7UqVSbCibY+VAgEshDgSPjEkOM d59LTJDnFVa3jYvaFFZT0+jI9pgGNYAbKSzWfSIepmM8TYxUCURGsZt58QAveSQlo4kR o6+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709341207; x=1709946007; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=0l9FS4zSa3KVc8IImImj1SVx9SNoPylTIMS2zSJSapM=; b=UaVxZ/+vvUVMMrfvruLTUTJZeSMXxrA+jYFWC3Huso/s9YoTaK2IAYSnXqJrn2L+En /11JXTfFCS61hT8Q1tC3KX3WOMXZACAb62o4HNvUFw0ZinckWK81kx1K3gxyHNG8/EL1 9GNiAQkHxYHTM3pHlXh0B+zQhVFwjEzQVEbEO2dgk/CxI7ID1wOFilvXfFdW1Mvn7KTx Ao1bsaaI7PdbfSiFKh7hTw7TZYjusxtiujyKzkLs5MgurzXsdkEMhO3tZhYOYH+O8DGN UV9YmLzMh3SbPaYQMgjlcNjOhCotwGhH3DUTRlyFkrec2sCYPHXhgRx0T7n3H3ZSk2Ye fG6g== X-Forwarded-Encrypted: i=1; AJvYcCV6LmaA6OIg4JNpVl/4r4PVDQYHmHjAcVyfbDFzN2dwstZPbSecXqORdlxL4L/J++P+XHQbgQ55G4stp7EuegR8uz19MqIwjURVsro+ X-Gm-Message-State: AOJu0Yz/+cpaQeiiv5O9QZ2Mt8UHh3iZaTQekJ9ozNsLQHlPDnzt/k2M Phq/oUp/b3pUl4WK2ZT1mvmo8sxTdxfnYX7tBSqWASM9yRMHIWl/HOfaDo7aQsPjS84u4LsYCYG YefBheA== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:aba7:66c5:3365:7114]) (user=irogers job=sendgmr) by 2002:a05:6902:1142:b0:dce:5218:c89b with SMTP id p2-20020a056902114200b00dce5218c89bmr130999ybu.5.1709341207587; Fri, 01 Mar 2024 17:00:07 -0800 (PST) Date: Fri, 1 Mar 2024 16:59:42 -0800 In-Reply-To: <20240302005950.2847058-1-irogers@google.com> Message-Id: <20240302005950.2847058-5-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240302005950.2847058-1-irogers@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v2 04/12] perf jevents: Allow metric groups not to be named From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , John Garry , Kan Liang , Jing Zhang , Thomas Richter , James Clark , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Andi Kleen , Kajol Jain , Sandipan Das , Ravi Bangoria , Perry Taylor , Samantha Alt , Caleb Biggers , Weilin Wang , Edward Baker , Stephane Eranian X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792374240287543463 X-GMAIL-MSGID: 1792374240287543463 It can be convenient to have unnamed metric groups for the sake of organizing other metrics and metric groups. An unspecified name shouldn't contribute to the MetricGroup json value, so don't record it. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/metric.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/perf/pmu-events/metric.py b/tools/perf/pmu-events/metric.py index 1de4fb72c75e..847b614d40d5 100644 --- a/tools/perf/pmu-events/metric.py +++ b/tools/perf/pmu-events/metric.py @@ -455,7 +455,8 @@ class Metric: def AddToMetricGroup(self, group): """Callback used when being added to a MetricGroup.""" - self.groups.add(group.name) + if group.name: + self.groups.add(group.name) def Flatten(self) -> Set['Metric']: """Return a leaf metric.""" From patchwork Sat Mar 2 00:59:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 209158 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp248146dyc; Fri, 1 Mar 2024 17:01:29 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV598ieAll9hIBYWdPwbN/f/BArF6iJlJOZV4brVH9cmbKEisr+93l8chs3kXGihO5p1ofXU/CgExrQbapM0HHNC9K4oQ== X-Google-Smtp-Source: AGHT+IGoR9GakjjrjTk2M9f9XLqc5kpfkaLzoVrH4jS09ZzposAvTGtLnFQ2cgrmL91nM22QVHHB X-Received: by 2002:ad4:57c7:0:b0:690:5744:e910 with SMTP id y7-20020ad457c7000000b006905744e910mr3059621qvx.23.1709341289045; Fri, 01 Mar 2024 17:01:29 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709341289; cv=pass; d=google.com; s=arc-20160816; b=oIgLtwq0sJuRS1JXv0BoRzF8SP8nt+crbk3Y0cuvbLKfOPdbfHOw5licjrxqDLOFQJ JUwjw7LYRSkhwfjSWF1W72A7pjmZc6DDFkIvaq6z498Nh8zUq8OGmxf9zbKrBxsxGA4C OcqDaZf/7qX9aIlNIfxg1sm9JNAYK07Q8+vO5I4HQZw9FcVYE6eThQcQuvmO2QInVnM0 xMFV81B7fd+K7Q2+kHLtc1a4i2ylkkZsVDlQs5hpMzJK3qU8wcInonSAM1X16wiAB73q LSgHNxNzsH773AMM+hqDbEVbSuy96BI7h/nLASZFXUNuIgIIu/CP7RNJWM9Eovk/Zax6 2VGQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:from:subject:references:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:in-reply-to:date :dkim-signature; bh=bBWDWJvSshoSjEVW3Suakt0O9q+vGDdTpywx5NXn+PM=; fh=jwNDYwY46+9SCY1l4rEWRDOKXPomZVmjasCY5hxmh5g=; b=FWI7taHe3p1ND9zKU8EYJ+W14Ee/prruqEig6vDxgNN1P4HXHryYlqHiQvtIw9Fihr fK3ovlXB1JiQttbaNbz0E5eUZY27UWqFm5RK0D9TT/798jCc4RWOqTn2AAVJ8pVJkPzw d9NXiUgTxl5RK44OHX7Sf5kqb9o+k8Bt8oqpxiAHqRO3+J3znMLv3yVsO+HgVE8aH+My S6VHuSh9VG9tCccWGcTHTMAgw7mxCXtwQDszv56w1SolankVVrQQR7Kbg0Op7o3cHz8k j/5DMH6OXmcoDLk5o4cT6tEqknUz20/pSroSkesB27UtVbjaLYEYmgtIJ5kkL66eOBJf 104A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=sao89wZT; arc=pass (i=1 spf=pass spfdomain=flex--irogers.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-89279-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89279-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id p8-20020ad45f48000000b0068f555f3253si4719496qvg.57.2024.03.01.17.01.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 17:01:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-89279-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=sao89wZT; arc=pass (i=1 spf=pass spfdomain=flex--irogers.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-89279-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89279-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id D00141C209D7 for ; Sat, 2 Mar 2024 01:01:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0E16C13AD4; Sat, 2 Mar 2024 01:00:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="sao89wZT" Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BC8F811724 for ; Sat, 2 Mar 2024 01:00:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709341212; cv=none; b=devDlZst1qgJMPPzFobwCagf7o+uG9DbwZchkWt7/oi61+WHfAO3tQ1bKV0cZUSZ2pSmgcJ3PG52HlPmYoD+u37PQUxNz/LCidpa9dpom60C4iJ4LN2aWmm4A0xemutRQzj97IFEXz+VqpeDGuAePKIBanAqQuwPEYQyCi9VDsY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709341212; c=relaxed/simple; bh=j1Uteud1mWr9qwRDjsafkmahAN/I9mDRvh5Ckh8gIQo=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=QJ5xowguVym3KsardYe4oLkYkHxo5jPnouqQRFcQlhft94rsIFLjcpfeV3yoNWk6Nr/PKmVjIMdgHUltDlFktvfGBzPAi7t92Dw/fmVFCCHSKbbGxKlz27IMUKGo3WRHjLQxX+zRoJujD9ujHu6lqyBMD2zTDCCHNp2Wcg6tFRE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=sao89wZT; arc=none smtp.client-ip=209.85.128.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-608ac8c5781so48532217b3.3 for ; Fri, 01 Mar 2024 17:00:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709341210; x=1709946010; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=bBWDWJvSshoSjEVW3Suakt0O9q+vGDdTpywx5NXn+PM=; b=sao89wZTY/KDVvh69F/w/NIM2DGgIH5hpEanldAlBkfnbUUwcaODWWGmvCAK+oe9oq tqu5ByTR/EGnpwH90MmYHFLKQpYDRwhLDIzOUJXHBQ/4NeCdmO6+9WzhmXY7yHKU0Sh9 o0Qoh7Q7BL+UjYc4+8SNjBRJuagJ+Fk8GEtQk0uokganZTvatbrrwFvP5F+JbIfKkhl3 EI5rPaxnpG7zvW7XfCVu8sLfe0hLjhKVcLU6ps7/W9cdqpeFZLHgR0pkTK/iWYGd2/Lx jobjo9K47qaeD8sVmhHBr7/AwailPdR3pwWA3iavnk8xk0ByoBaD/8IZel0It8809U4+ QJzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709341210; x=1709946010; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=bBWDWJvSshoSjEVW3Suakt0O9q+vGDdTpywx5NXn+PM=; b=VrIWwZ5ysfTuWj+CJcdc6Yqce4A5qP7KAi1O00Qvau3ejB/YYu5zU3KJBjimeaJ3zK WWqyIJaDr7zXsjVbfrOooyT2hz+PKF7OJ7HLzyJHmIU8QOQVQA1TEBVtg6V1aJ3qdyiS H/FGp88MsT+UGGSpeoPpb9cjICrTuo1c0X7b7sbAssliOT2/eSMAW4LJQVZv7jXwonyT hYyCWnytT/UF0KcPdWMWmWxBPzDWCf8byYYUUBO+6SNCRI5ic6e+W9+I/h2TeVNulj0x alCvEbCpN3G+h5e1q13u4Jn8HB0cikmLqhS+tQrNClDKMkRobtBC+CVQSzHkJqODQi4K sRNw== X-Forwarded-Encrypted: i=1; AJvYcCUzfRF4EEaOTCHtXFBWZmAz+SYRw4f0SJduESd5PgYfNmEvfeROprH3e38JP6tgEB+8Lds0uWlqRVaGUNKh+QFbrZECeGO2sD1m6/eP X-Gm-Message-State: AOJu0YwQhpb8VwUXgiG6wxvOZ1w65ngFhDB20SVUeWwbCHwZHxDC7Mc0 lTyFxibLunMHhZLw/euLU6qfWYR0W7u4ePnyDaSxl2eGxp40fXuwPVA4wXIrQ6lRrO3h/VpLys9 aigelAg== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:aba7:66c5:3365:7114]) (user=irogers job=sendgmr) by 2002:a25:dbc9:0:b0:dc6:dfc6:4207 with SMTP id g192-20020a25dbc9000000b00dc6dfc64207mr714766ybf.10.1709341209852; Fri, 01 Mar 2024 17:00:09 -0800 (PST) Date: Fri, 1 Mar 2024 16:59:43 -0800 In-Reply-To: <20240302005950.2847058-1-irogers@google.com> Message-Id: <20240302005950.2847058-6-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240302005950.2847058-1-irogers@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v2 05/12] perf jevents: Support parsing negative exponents From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , John Garry , Kan Liang , Jing Zhang , Thomas Richter , James Clark , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Andi Kleen , Kajol Jain , Sandipan Das , Ravi Bangoria , Perry Taylor , Samantha Alt , Caleb Biggers , Weilin Wang , Edward Baker , Stephane Eranian X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792374251731855551 X-GMAIL-MSGID: 1792374251731855551 Support negative exponents when parsing from a json metric string by making the numbers after the 'e' optional in the 'Event' insertion fix up. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/metric.py | 2 +- tools/perf/pmu-events/metric_test.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/perf/pmu-events/metric.py b/tools/perf/pmu-events/metric.py index 847b614d40d5..31eea2f45152 100644 --- a/tools/perf/pmu-events/metric.py +++ b/tools/perf/pmu-events/metric.py @@ -573,7 +573,7 @@ def ParsePerfJson(orig: str) -> Expression: # a double by the Bison parser py = re.sub(r'0Event\(r"[xX]([0-9a-fA-F]*)"\)', r'Event("0x\1")', py) # Convert accidentally converted scientific notation constants back - py = re.sub(r'([0-9]+)Event\(r"(e[0-9]+)"\)', r'\1\2', py) + py = re.sub(r'([0-9]+)Event\(r"(e[0-9]*)"\)', r'\1\2', py) # Convert all the known keywords back from events to just the keyword keywords = ['if', 'else', 'min', 'max', 'd_ratio', 'source_count', 'has_event', 'strcmp_cpuid_str'] for kw in keywords: diff --git a/tools/perf/pmu-events/metric_test.py b/tools/perf/pmu-events/metric_test.py index ee22ff43ddd7..8acfe4652b55 100755 --- a/tools/perf/pmu-events/metric_test.py +++ b/tools/perf/pmu-events/metric_test.py @@ -61,6 +61,10 @@ class TestMetricExpressions(unittest.TestCase): after = before self.assertEqual(ParsePerfJson(before).ToPerfJson(), after) + before = r'a + 3e-12 + b' + after = before + self.assertEqual(ParsePerfJson(before).ToPerfJson(), after) + def test_IfElseTests(self): # if-else needs rewriting to Select and back. before = r'Event1 if #smt_on else Event2' From patchwork Sat Mar 2 00:59:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 209159 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp248354dyc; Fri, 1 Mar 2024 17:01:50 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW0epMqNGi6zWuaJH9JeZ42aS3WfW6T/Qwm9XEldrHWo9Bw+ndqFRPTbubCjMJ2RktINy1fOJv+Q7eg4mYKylyywnokCg== X-Google-Smtp-Source: AGHT+IFhoxZHOU1ecn0kGJgR24CSpV0HggDnjZtjvQ4Ol/NtA9wrVOGFfYhaFpHZu/Q96ksmalz3 X-Received: by 2002:a17:906:c355:b0:a3e:7d36:62b1 with SMTP id ci21-20020a170906c35500b00a3e7d3662b1mr2582464ejb.46.1709341309853; Fri, 01 Mar 2024 17:01:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709341309; cv=pass; d=google.com; s=arc-20160816; b=wOdX0U5ouCrAaAgusTGMTaUcxYla8knkKW//6UeH19borWlW52LLrTAbXVyOaVywq2 3LVhvMd8HUVVhklVLxmlVrIFa0+BZ+ujY0+3PjSs80qp9yAWQY8HMtyuLfvJLfGpszUA 4Vjmo2T8FdlIbUDdi5KONXouP1QlzTS/mGOIEg56nD2/JYSAKeJ0vWLtPPN3W8TmSrpA uwDwiUIK7Q2suu3Uj+4Fn6ro1f5xgDSS1/wprSxcriUgf5gWKkaPt3sJ6vnlcYGf4RDT m5X3gOvKbdd0h54t/O1OMKv/a6uW1osq1PPlA3z4LOg1G1cOLNmDfUJXWKkkcWSUBBJ9 3Qdw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:from:subject:references:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:in-reply-to:date :dkim-signature; bh=F9W2L65moWfkRODZWtj1+8FpZZOCQB/UnzNIcvAZEKE=; fh=P1AWSOYOh43WMozk473SoXBQAqABUq1PsGlPSy/dnhM=; b=0QE1axXyHaHOkZHCn6AjXPD/tmnHGUbTHbA37mhWpdfoeHdNuFN9MoHKZ/DNi32oYL NxaiMmo/FEITdYfl4VmL714uC3SzkleFjCotuNCVoy2qt8HSZeElm0v0VlAPgWOevySn vtPU7t2Q5WO3cW1qJVV6KYV8Lb81QGQ9aqPdv7TSAGbYgNsDLygT5U3mlq0nKpserxT3 0bYBB8IgFTHsn+B1DrFhgLiBd78bcQ9wi+ElKZVBnaCHmyly/JTnAz5f4JgqnQUps3r0 mWhunsrqViEwQ9+YN3ox70Penf9KdpP4TvoxUz4G9X77rLf9nwZemOQO3EObu/qMg/Mu dnNw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=fLBljgp6; arc=pass (i=1 spf=pass spfdomain=flex--irogers.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-89280-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89280-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id l19-20020a170906079300b00a449820cfdcsi795547ejc.262.2024.03.01.17.01.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 17:01:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-89280-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=fLBljgp6; arc=pass (i=1 spf=pass spfdomain=flex--irogers.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-89280-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89280-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 76E961F238D4 for ; Sat, 2 Mar 2024 01:01:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2FA6D16439; Sat, 2 Mar 2024 01:00:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="fLBljgp6" Received: from mail-pg1-f202.google.com (mail-pg1-f202.google.com [209.85.215.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0E85312E59 for ; Sat, 2 Mar 2024 01:00:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709341215; cv=none; b=KW28C1TOCHZasN7Gbtjh6A/d4TeQOxZ1PpmYXZjk8fjVBrjvndLIJ8kstX6DmMVzURFgZ1DIcT8DOmMdkg3qvyTHkUAu8n16d7rbZrITbeFBwxk2r5nTGGod7RGV9c4fD2+vg2xomNn0jk0qhVcJ9P6FwtyPXAxczXd91wrumK8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709341215; c=relaxed/simple; bh=oswX3i20yiaJHjTAeWqAXOG6a2/1Ta4qOMh9xoJeXu4=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=UDsmmMc73ep9RtYOtU5bBXifMzixrgNYLag82meLaeYGN7rDnJdflxDuhDk7F1YbuEKBYQKIfPcTIF7SgVvkLGury6JVEOd6i8YB9uKmyeCEssgccw0V7/VfhcYEtqjLM9a78BRh0EliTdivAkLuynlFHaLZkKmVnClJEnHQ7G4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=fLBljgp6; arc=none smtp.client-ip=209.85.215.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Received: by mail-pg1-f202.google.com with SMTP id 41be03b00d2f7-5dc91de351fso2164616a12.0 for ; Fri, 01 Mar 2024 17:00:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709341213; x=1709946013; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=F9W2L65moWfkRODZWtj1+8FpZZOCQB/UnzNIcvAZEKE=; b=fLBljgp6qk+iMOADua+20FQ06KrTCkM2VMIShD7IXVBK+bpRtIr0OyKJPlIpwpxfIh Ba2kIFN5C1TQ2qxDixFo1A+hb6VE+oSMK/fDuo3LUmnmMFaK91P/myloqeGodGFqkf3r 8KtNLrR9tSKYUHEx2CIGwGUD+aLEGDWOgywm8kZECGCHdi//yZUOs0w8aq/vO3MEsJbk HDu1/7Wp/2o/b86qloTRUOuIWp7aXvaog6dkGIWdt9x5O7x8tThjCKpmD/tnfHHVuAXE ZnLeKOLbJi7kMozJmAgyeytX6mfOOOf0c82+ytbcph+87E5/FZ/hOgDtL2+R/M4aJKZB sWqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709341213; x=1709946013; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=F9W2L65moWfkRODZWtj1+8FpZZOCQB/UnzNIcvAZEKE=; b=rSrHNG7mt3t6QuywFKImGLaxvJM6e31lnTu8n6SzloJu25s8TCE2nidHuMEDQJIEip xwztREB4jgKm8qhC335NwslPHCTUPMCw+VF+eE/QFRtYYZEedJXKk/im9e4wMarrQ8Td 16+FWJMI8iOGYtlFtflUi4irGsNn9Cne/p5ORbWXBcHaEi+zP81LPzxlJTBxK+JEvgTr wF55WVMoir/acL3qZnm2LoziY1TSkHDiVCIrHX95eEHD9XnGLTgkaO/9pNleSfdg/nyF 0rV7aVPqx95lMguGMwmopnseHuQO46pTHi0ev9d94F+e343djX6ex/sOV+59/rFZB3qL 2PeQ== X-Forwarded-Encrypted: i=1; AJvYcCXZ1xHwLjhQQ3EOPqSIyfMp85zDGvaYZIq29czP0dJx5Iecuk0Pcc0UnK8HX8yB87+kGJIqrAxLzdW5rwW80BTkiaOd4WdI6X1FYljS X-Gm-Message-State: AOJu0Yw6+xj78Qdk9z0UkQIMDyM8zouofDp4gpBJ6aUi7bR1Qoi5DHKi jD/GV7zPE44FvfnaUXPCuK+YFs9rnR1KSqUTd6uXdIwXf5c7AouwFSoPhirQMTr8+BwywMosWrx TwGWSUg== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:aba7:66c5:3365:7114]) (user=irogers job=sendgmr) by 2002:a63:d94a:0:b0:5dc:cee7:9b1b with SMTP id e10-20020a63d94a000000b005dccee79b1bmr7224pgj.5.1709341212230; Fri, 01 Mar 2024 17:00:12 -0800 (PST) Date: Fri, 1 Mar 2024 16:59:44 -0800 In-Reply-To: <20240302005950.2847058-1-irogers@google.com> Message-Id: <20240302005950.2847058-7-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240302005950.2847058-1-irogers@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v2 06/12] perf jevents: Term list fix in event parsing From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , John Garry , Kan Liang , Jing Zhang , Thomas Richter , James Clark , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Andi Kleen , Kajol Jain , Sandipan Das , Ravi Bangoria , Perry Taylor , Samantha Alt , Caleb Biggers , Weilin Wang , Edward Baker , Stephane Eranian X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792374273009331937 X-GMAIL-MSGID: 1792374273009331937 Fix events seemingly broken apart at a comma. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/metric.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/perf/pmu-events/metric.py b/tools/perf/pmu-events/metric.py index 31eea2f45152..0f4e67e5cfea 100644 --- a/tools/perf/pmu-events/metric.py +++ b/tools/perf/pmu-events/metric.py @@ -568,6 +568,12 @@ def ParsePerfJson(orig: str) -> Expression: r'Event(r"\1")', py) # If it started with a # it should have been a literal, rather than an event name py = re.sub(r'#Event\(r"([^"]*)"\)', r'Literal("#\1")', py) + # Fix events wrongly broken at a ',' + while True: + prev_py = py + py = re.sub(r'Event\(r"([^"]*)"\),Event\(r"([^"]*)"\)', r'Event(r"\1,\2")', py) + if py == prev_py: + break # Convert accidentally converted hex constants ("0Event(r"xDEADBEEF)"") back to a constant, # but keep it wrapped in Event(), otherwise Python drops the 0x prefix and it gets interpreted as # a double by the Bison parser @@ -586,7 +592,6 @@ def ParsePerfJson(orig: str) -> Expression: parsed = ast.fix_missing_locations(parsed) return _Constify(eval(compile(parsed, orig, 'eval'))) - def RewriteMetricsInTermsOfOthers(metrics: List[Tuple[str, str, Expression]] )-> Dict[Tuple[str, str], Expression]: """Shorten metrics by rewriting in terms of others. From patchwork Sat Mar 2 00:59:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 209160 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp248441dyc; Fri, 1 Mar 2024 17:01:58 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV+qe7fp9BuybUH2BLEgtQvxQWG49FMrAbratHcu4wVk2fR0uZDTlsVw3hq+lafGMDXyUCW/FhDgl1MLRnjDJC/sJg4Uw== X-Google-Smtp-Source: AGHT+IG9TINv1PQSt0S01xH5B4FlN0xRBVekdnmcujMK7GpnkKHN19WihL16g/VX8s75NCwxzZA8 X-Received: by 2002:a17:906:dfc4:b0:a44:c29c:67e4 with SMTP id jt4-20020a170906dfc400b00a44c29c67e4mr792030ejc.70.1709341318255; Fri, 01 Mar 2024 17:01:58 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709341318; cv=pass; d=google.com; s=arc-20160816; b=DDjiA68MTaK/nTZmJU58NugAwHf2lUcJAEdzXmdfL8mYmQZlhKJVikgxigNtPyeYr9 w6gIoZYQeXh5JQ8xGfVEQ1YH++jbN8MSlFYLiJ1ivxd9u9F27aylAKD/XDhkbCYrm5O3 EVP2YekLkCZd8ZPaBhw0ZBU+66D/P0JPx0b6F/wn5eSZcayXyWlsuVJFtwb8d7mXQOv3 LIC6MVaszbjaZ3jtR/3RY8/Jwh0JCoxhOiNJ0OvIDEdBrk+FyvTclRXevC/HTdmGZcqR AfE8hIpUTttDnsx3Oq8SYeM1CTmDHtl3tk9M9E+2EvTfrPeKWNzfTl4kV0NUZ9DaHaXa cLlA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:from:subject:references:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:in-reply-to:date :dkim-signature; bh=/C1Fptl7F9oJgqV/SnZtPnw4T5ATAHSmXZQvuFpHbZA=; fh=GZQBeunE0+aJePW4qYG6U4AUJN90Cjx23KL/iMgmAzg=; b=XFwUGVYUz5eN7TEEZ6nqqcYX48Ms6qdVK95ZJo9lq3UzIFVU3ox8PJiTwA1aECS+AP bpqvcI/NiGNtR7F72vc9j/HMpgg1Tnvv+sidhD1lO6fVxJAcqcTi4u/ndbaDLglu86v1 zyWw36FYOwn6UDWUkMsXz9/7akYdEl8TMZ0mWt+svmV0SO1imp9VFUF1K11+Hwnu/2H6 JoYJOkLijTdeZ7TFG5zu+frTonZrzzV6iOdEXHZbusXt1fgJv2l7NunrnkFtrdpB4eeK eBkSuLIplygA8xZeZRlX8mMhm5M8/l23ghckjhTvO742+VzsanSK+D+H45QlC8mllQ5j Wepw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=qI0xfJRj; arc=pass (i=1 spf=pass spfdomain=flex--irogers.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-89281-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89281-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id qx6-20020a170906fcc600b00a43db2e1acbsi1891193ejb.351.2024.03.01.17.01.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 17:01:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-89281-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=qI0xfJRj; arc=pass (i=1 spf=pass spfdomain=flex--irogers.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-89281-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89281-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id DC7C01F23C42 for ; Sat, 2 Mar 2024 01:01:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E2A8E10E3; Sat, 2 Mar 2024 01:00:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="qI0xfJRj" Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8B493F9D3 for ; Sat, 2 Mar 2024 01:00:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709341217; cv=none; b=ntCn4NnCAO7SRjxPgIKaHNJCdeqad5nb0h3CW+4cPLQcLjQz54XZ+Nkld37g/b/v6UT8IbT1Ls/i0OMmEDiEppMM/wOOUX1AtOELzKML8CJoQBnoPFqpR4QZbvyO2KDKPOO2Ox2XYiw8fuAoUUMAH3yGp3rkcUCEweyRn63tJR4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709341217; c=relaxed/simple; bh=ZXVWxGkn7pnCvmd8l6DV72SPICzKi/Gva//TpBe7PFE=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=ZnO/0o83EW72tsbaATHd3gCryuW2TygE9X9hmf2RGBM65FuxknEoG7K4fqdoQ01H6fMYsPSwBDFiXWx3UITKKsMu5pObZ7+JdDmj1MOx6feBK9JUrZuUto3tZUki3hq/BYirrFmZWbMLATZgLzqlAeKly5qpYiPP1EYR7kp/V4Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=qI0xfJRj; arc=none smtp.client-ip=209.85.128.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6098d88e994so11526647b3.0 for ; Fri, 01 Mar 2024 17:00:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709341214; x=1709946014; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=/C1Fptl7F9oJgqV/SnZtPnw4T5ATAHSmXZQvuFpHbZA=; b=qI0xfJRjpEdE3s+OWFK/wud9k0lVmfMm3Y19P85FmaYk2SVEokv8w2UtiFTB0o479D gyRES8/ofoCKLPMJkk6sR9qQConnJNRRkLTOBs59Y2MsUQ1StCcM5RpJKkl7S70jyPro DcZUhNWiMF47sQDGMFeXWnTHSesrnIKonsJecsfa97D84lPCmZJgs5X0jVLAv33koySJ jUg087JU2ftUyI3R4y2lRfeHJkULZARZvFz3Zaa6wiPv8ppAceeQBSmhPAx8hb2Z6Zej ZXC8ikBoy+eks3S/cM5fxOmp78Deo0ZMPReQFXWQmeOIECpoOmH8jsEf6VUX0EAgIln7 DS8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709341214; x=1709946014; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=/C1Fptl7F9oJgqV/SnZtPnw4T5ATAHSmXZQvuFpHbZA=; b=H9kbs794hu/cH/KP/VgBzPJpKGzVlrnTSHQ/2hRs9PdekpEk/MvrOq0IvDRFsK9D7r 7JQ/T+2gmka7pVOObl9uwAxgD4cCK2jB74xlQIKT1pvAelx/dxA2GU9oP9AIt3+UxEWI UkB1R+IDCS0vWcmF8T6oJx6MB2kUlD5RTEgH4/gYOMaRWpvn3xVPGo+3GKu8D6pkp+LU h+ToTy7u66UtBoYY0SfM2LXIRYNyTxQ1cshdlXt7ZdU6aUwPgRisMFUFgn0mhBcsGGCr 7wHJBxgNMzoJU7KVUVHJfjORl1KJck+b7kxi1e9ky8u+EKrYoEpUrCcv4B9EjHgTwBGf ToTg== X-Forwarded-Encrypted: i=1; AJvYcCVuX31xCLSmwdgX0KA5WzjAQQVSma1R65j2n3fB4z429f+7nAZEJzxdd26Di1xlfklgh1xRrV/eX3wO1JnQGYbT6aiH7sVaBT05ZmP+ X-Gm-Message-State: AOJu0Yy7uvmklWiTRUQ0aRW9Ksr8qcvZBoo3FUUb3KYKcv3qiMoxRpEf 11yauFhHda4TLF2JNSww642H/bP6aDH9H2qB5qopIkqry1gbX30+KZ0sFqwyd8y5ypVDN93l57l s1GYZmw== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:aba7:66c5:3365:7114]) (user=irogers job=sendgmr) by 2002:a05:6902:210b:b0:dcc:50ca:e153 with SMTP id dk11-20020a056902210b00b00dcc50cae153mr766214ybb.7.1709341214783; Fri, 01 Mar 2024 17:00:14 -0800 (PST) Date: Fri, 1 Mar 2024 16:59:45 -0800 In-Reply-To: <20240302005950.2847058-1-irogers@google.com> Message-Id: <20240302005950.2847058-8-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240302005950.2847058-1-irogers@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v2 07/12] perf jevents: Add threshold expressions to Metric From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , John Garry , Kan Liang , Jing Zhang , Thomas Richter , James Clark , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Andi Kleen , Kajol Jain , Sandipan Das , Ravi Bangoria , Perry Taylor , Samantha Alt , Caleb Biggers , Weilin Wang , Edward Baker , Stephane Eranian X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792374282114521386 X-GMAIL-MSGID: 1792374282114521386 Allow threshold expressions for metrics to be generated. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/metric.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/perf/pmu-events/metric.py b/tools/perf/pmu-events/metric.py index 0f4e67e5cfea..e81fed2e29b5 100644 --- a/tools/perf/pmu-events/metric.py +++ b/tools/perf/pmu-events/metric.py @@ -430,13 +430,15 @@ class Metric: expr: Expression scale_unit: str constraint: MetricConstraint + threshold: Optional[Expression] def __init__(self, name: str, description: str, expr: Expression, scale_unit: str, - constraint: MetricConstraint = MetricConstraint.GROUPED_EVENTS): + constraint: MetricConstraint = MetricConstraint.GROUPED_EVENTS, + threshold: Optional[Expression] = None): self.name = name self.description = description self.expr = expr.Simplify() @@ -447,6 +449,7 @@ class Metric: else: self.scale_unit = f'1{scale_unit}' self.constraint = constraint + self.threshold = threshold self.groups = set() def __lt__(self, other): @@ -473,6 +476,8 @@ class Metric: } if self.constraint != MetricConstraint.GROUPED_EVENTS: result['MetricConstraint'] = self.constraint.name + if self.threshold: + result['MetricThreshold'] = self.threshold.ToPerfJson() return result From patchwork Sat Mar 2 00:59:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 209163 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp249110dyc; Fri, 1 Mar 2024 17:03:10 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW1DvEywKNGahf9HREHSe6e0Yeg5PnxX5OQDGoai60t/7tbFi25sdvVtofgXCylps86tEQYVpTTIXLqv/puD+vIfBxMFA== X-Google-Smtp-Source: AGHT+IFwLr42RfBqfare4is1q9oq2XpIKgOvSJm+yi8lRZ7A/oAcAQwgJSJpwvHyJ1FvAJkaUUR2 X-Received: by 2002:a05:6a21:78a7:b0:1a1:3ecb:52fe with SMTP id bf39-20020a056a2178a700b001a13ecb52femr2706743pzc.0.1709341390138; Fri, 01 Mar 2024 17:03:10 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709341390; cv=pass; d=google.com; s=arc-20160816; b=G9ag9BTRSQBQEO03B9yLc5HTkpuX45+Deex2rdQ2SfnS0xBjLUC8RFMg2figkssCn1 wGntGhMCnHKviOjK0pMvko28PH49UsBi6FD6fMfFOGzq3pvNM3j38E4z2McwvZ6BHoJT BTOpwTaekfGb+FKkBzbjA6HnrHh4kK0CinPhmDDWZBpUc4eabQlqVMBePBSS4MTJEFee GqVP/Rpm3doGadXGDhdwNQbv4bzFJcsJM/taJImAAwSDu4fZ9tbXxT3K6E+OGhd0ZDVO RmtHcvIri7MbzmXF/8tIUHLGdo1958ZCaTu9asz5CxIL4V/+r+5W4emUk2IRodQPIF/k cveA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:from:subject:references:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:in-reply-to:date :dkim-signature; bh=CEuSAf1lkMchEU55uC9f020RZIQvzTohuVPV0uKWKVI=; fh=RSdAe3QNzwn92fTF1+6a92H4RXopTT2x2OApq0bgktI=; b=RgrxKc26GpdLhcDCVyrXo2pibBrMh5Q59B5+lgMOstjl4I6I1yqXFbWgPcdN0xsQuw tR1hd5XNgBmp4HmSFqq13KHD65f+HxSPIX92AscoNaQcyzoH4mzuIn6i70uigosj+ADD cma1hiIKr566mFsJB+j4IMxu4a39gpsgbIclAzf9aY8dfTbw6t3K73jg88vTKIaqLdMl A98ad5I1LFE/BETPaVZs8ZKLle6xyIjvBVNgtAsTi7puspJlJ3fci53hRq5sLrNHbvPH ALAsri36MF8lRBJzg81rvPgnOUcDKhpCTQPia4t1EMLFeDETS+4l/tZFyOzPA46EGq16 nwoA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=n32Z0gpv; arc=pass (i=1 spf=pass spfdomain=flex--irogers.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-89282-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89282-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id y2-20020a17090a6c8200b0029acaa59f3dsi4611070pjj.2.2024.03.01.17.03.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 17:03:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-89282-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=n32Z0gpv; arc=pass (i=1 spf=pass spfdomain=flex--irogers.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-89282-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89282-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 94A61286C0C for ; Sat, 2 Mar 2024 01:02:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9F7C317752; Sat, 2 Mar 2024 01:00:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="n32Z0gpv" Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 257EC1642B for ; Sat, 2 Mar 2024 01:00:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709341219; cv=none; b=MjOcb3NpPqjizzC2Iy18jYHcdd0GDl5jq8/BkXHz6gp5F0dFyl/IXLlv7r+z0y6CzLlWR678GgeHhbgxir0+4h1hYT72T9wBRbeKNh/4K1H8Ssk2XId+nJXVgIDOLA/hSrNBOjkcVkHeispOXLZcgXb3eXS9awQxIHfBbXHId/g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709341219; c=relaxed/simple; bh=KBRLOPIttIVmUTXmYYpZ5y5zAjJINB3dv9EpY8rLPGk=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=YASz+6JoF3GJArkfzzgTqfpDlGWMDlc9jtqQIFfcI/22KR2Nl3erBXG4Ku/x3kG8x+USJiPR4Ngqb28cBv7uExRUY2CwqBhbNgKG/t55FTXsindbvXtlX3N3JPZfjTy3GLbJsk+Mww/zf509Ing0lecV/K2UR5q31NYWCvOPc6A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=n32Z0gpv; arc=none smtp.client-ip=209.85.128.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6097409275bso35137997b3.0 for ; Fri, 01 Mar 2024 17:00:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709341217; x=1709946017; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=CEuSAf1lkMchEU55uC9f020RZIQvzTohuVPV0uKWKVI=; b=n32Z0gpvPPT2RMv9UttL3rcM6xcZ96lOJy5YZuWKSQHy7QhaQHqkjw3ne6BbBrYStd YtJ8sC42cq8Pe7TCQnnTFbSOrM4o0z8/LRE/nU1Cdg6jLH8QeUpyAqOXfP9+UDVlHrGC E+wjLAnJqE/sbWvlFa9u+tKguGkeVwWhQYqnQqSKDGWcv35Z/B5HcaWyRo6Jyzu1sJUK P2Adce1O3+MnJqH2dBvDF/WgzC69bnG9plbqwcMz5r0AcTMIuPxK+SuU+qdAdq24hlKV ELsBjUvlJbBD7IRh7YSs2GKXM3Kp8+TBZ4/zJ9kCdDSwvaD/GoOWzNVgRl6sWnSrRDJ5 tMjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709341217; x=1709946017; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=CEuSAf1lkMchEU55uC9f020RZIQvzTohuVPV0uKWKVI=; b=pOWklZWyQRX8BX5t4D7TQsCCDDV82MS0MJmP71GQGkrVMIOEdygyr+UqWnSZROf2u+ Vcdj0NHiA5q0NncyiFycPaRENin7mLiBvawWm/hhKroBgH0iZAmiEttHdtVxXIanogIs 2PvmWAsMWL4HSGzrJ31lyhl8X2TWVBvkAnLjB62htxuEyXRFHg+CYRprcoshkdKwIqFv CrHNF82hpD/dZs2EMaSv33oiuipvEXsGUtjZcV04IMyboDafCkrwXuOe8r8Uz5EOJ/RH x/MyEictPyIOl/NDdJHRR7r4uW1ywB8LJcxCwqhin0JhYN+Hq+B1Wo/eNiu3AsIJJYDO CSOg== X-Forwarded-Encrypted: i=1; AJvYcCUxgqbtZ9F5R9tFxXlqqRxIVY0IjXezj3980M4B3C+cvkcpfALZbgAwMfzNCcoodLFw0h3zk41y3ixHS/pighXvv6MmeqykOn8ES6fG X-Gm-Message-State: AOJu0YxeLd0x/j66hopsqaSIUk+7BTRgIRd1gTVfSbO5b8eEXXVcblld 9m4jz9fudjMqUTkElKEyv/hiUcQvm7OsAP6WckPkafBDUQrwIF8l2cCTIdGNzm5aIqQsuCiTaKv R1bze0w== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:aba7:66c5:3365:7114]) (user=irogers job=sendgmr) by 2002:a05:690c:fc3:b0:608:ced0:eb2e with SMTP id dg3-20020a05690c0fc300b00608ced0eb2emr638850ywb.0.1709341217224; Fri, 01 Mar 2024 17:00:17 -0800 (PST) Date: Fri, 1 Mar 2024 16:59:46 -0800 In-Reply-To: <20240302005950.2847058-1-irogers@google.com> Message-Id: <20240302005950.2847058-9-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240302005950.2847058-1-irogers@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v2 08/12] perf jevents: Move json encoding to its own functions From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , John Garry , Kan Liang , Jing Zhang , Thomas Richter , James Clark , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Andi Kleen , Kajol Jain , Sandipan Das , Ravi Bangoria , Perry Taylor , Samantha Alt , Caleb Biggers , Weilin Wang , Edward Baker , Stephane Eranian X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792374357242217635 X-GMAIL-MSGID: 1792374357242217635 Have dedicate encode functions rather than having them embedded in MetricGroup. This is to provide some uniformity in the Metric ToXXX routines. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/metric.py | 34 +++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/tools/perf/pmu-events/metric.py b/tools/perf/pmu-events/metric.py index e81fed2e29b5..b39189182608 100644 --- a/tools/perf/pmu-events/metric.py +++ b/tools/perf/pmu-events/metric.py @@ -484,15 +484,6 @@ class Metric: def ToMetricGroupDescriptions(self, root: bool = True) -> Dict[str, str]: return {} -class _MetricJsonEncoder(json.JSONEncoder): - """Special handling for Metric objects.""" - - def default(self, o): - if isinstance(o, Metric): - return o.ToPerfJson() - return json.JSONEncoder.default(self, o) - - class MetricGroup: """A group of metrics. @@ -523,8 +514,11 @@ class MetricGroup: return result - def ToPerfJson(self) -> str: - return json.dumps(sorted(self.Flatten()), indent=2, cls=_MetricJsonEncoder) + def ToPerfJson(self) -> List[Dict[str, str]]: + result = [] + for x in sorted(self.Flatten()): + result.append(x.ToPerfJson()) + return result def ToMetricGroupDescriptions(self, root: bool = True) -> Dict[str, str]: result = {self.name: self.description} if self.description else {} @@ -533,7 +527,23 @@ class MetricGroup: return result def __str__(self) -> str: - return self.ToPerfJson() + return str(self.ToPerfJson()) + + +def JsonEncodeMetric(x: MetricGroup): + class MetricJsonEncoder(json.JSONEncoder): + """Special handling for Metric objects.""" + + def default(self, o): + if isinstance(o, Metric) or isinstance(o, MetricGroup): + return o.ToPerfJson() + return json.JSONEncoder.default(self, o) + + return json.dumps(x, indent=2, cls=MetricJsonEncoder) + + +def JsonEncodeMetricGroupDescriptions(x: MetricGroup): + return json.dumps(x.ToMetricGroupDescriptions(), indent=2) class _RewriteIfExpToSelect(ast.NodeTransformer): From patchwork Sat Mar 2 00:59:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 209164 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp249202dyc; Fri, 1 Mar 2024 17:03:18 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW20rJYWe0RDe78lQ4LDfMsaTrLybEm6weJNYDHQCCO/GZ7vCPKeAcy9e4Hn67cssWccgtTUOK0Ebw0cyh2oAfU8F3oAw== X-Google-Smtp-Source: AGHT+IETRmZVyVvHFOabc6oEROfZJvKSqBD54NTqmav1h/iTosRYDffQyGl+WlSe1ofymmCko2Ad X-Received: by 2002:a17:902:eb87:b0:1dc:d50d:f669 with SMTP id q7-20020a170902eb8700b001dcd50df669mr4276981plg.12.1709341398247; Fri, 01 Mar 2024 17:03:18 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709341398; cv=pass; d=google.com; s=arc-20160816; b=xc7Te2PTkOYBUB22uj5wrbNc3Cf+2YvImTka7CMzTjJbfuoCENbX1tlUb3+egNlU+7 7H82EQ7AvgV7vJEfFZ46zqQ9oUIU3R8TFSGHCFAA0tN1ep2aLSiHfbP43pexEF4oVVKa OC6YtMGJ8P8QMUpvlU53Y9pgZiQ56Bog99s09Amtz1rfjEtvnE0ah2gEiyw/cIlQGML5 fvyhAJgczTqV29SuTWifHMF5YHtXbSJ0KGY/yy2e3KI7gSYpvMCIMZEZ49IO10RCYPVJ bnp8Vh/oEDh016N1l5JDr8hotYUJEz2YOweFT4n7mUFlXphQDd7Fh/C8vuSMlJQ5UxlI LOlg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:from:subject:references:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:in-reply-to:date :dkim-signature; bh=yRxIvbPDDMCjNnVdacSzvCtMsT39EeStBSRtXaTCLVU=; fh=wDOWqsEdGMAYy6h4ijUixIF1s5VHaXvwlBvU9AqZkJE=; b=JYNiN4BGUyv6wifA9OQVAxqldKApVO1QhiQy349Q4bEDZQVKa57GDgHJgGo1MIz4ec xw3rUvxPK3YzeQLQ1q9I6JHZASm3qNXIzPt2D/FC5jQgHC0XxQA784YuYaGuHlnHrjzL 73WtrYlDTkxouupYzlnQCJedg6qtHOXIQK3k9jvkRc2oiw0B3EwGLX/1Njnt2iWLpZ7c rqNYFVK9kIu/Y11+wpZsWov2yxb/6WZys2mqDVGG+bnb1lvKe0RzPzLfJ3oj1sSx+HvC 0FJo4ZJ78DCM+5lYcm9I99rShjjLQXybNkB71Lr0MdBOYlgVJ8dYAdsuyoDkBlp3HVdJ 06tQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="Xhr/ucg1"; arc=pass (i=1 spf=pass spfdomain=flex--irogers.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-89283-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89283-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id i4-20020a170902cf0400b001dcd0d28d46si4813711plg.50.2024.03.01.17.03.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 17:03:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-89283-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="Xhr/ucg1"; arc=pass (i=1 spf=pass spfdomain=flex--irogers.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-89283-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89283-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id EC30C286F04 for ; Sat, 2 Mar 2024 01:02:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A18DD5660; Sat, 2 Mar 2024 01:00:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Xhr/ucg1" Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7DBCE1C16 for ; Sat, 2 Mar 2024 01:00:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709341221; cv=none; b=cwHjq8EH/HST8jvajOq+vgEbqV/IjkxnCb7y/vyynqCpE0PZoIqt7rtP2P5IB7WIxuU5czakHu2tloTJzdDgE3a08hdl4DGWApt4b936tKMQDbKrZMjepf04bepDCHEbcuMrFz19JIvhK+N+d0lSzNoTV8qe+1iNOeJ1FSN2rGo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709341221; c=relaxed/simple; bh=r7EPMWXB50WRmPs6Ybs2X/h0mr+Q2k6sSSuIvq/Jh3g=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=p1S6SGKIR32+vIdkBqyJRps4wwVGAhSgb9nIM0A1fTgvbj88rhE4mrvqZGklwhCgaWePB3js/URwVMUCN6TueokGb9fSAivVKqOGwcGgut4KTYfvQNELFJZvpgn8bmcHwthzm8jYfKoQbN/Ww/skohU1XKIHiVb/1ah/LMGjOv4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=Xhr/ucg1; arc=none smtp.client-ip=209.85.219.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-dc743cc50a6so3629929276.2 for ; Fri, 01 Mar 2024 17:00:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709341219; x=1709946019; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=yRxIvbPDDMCjNnVdacSzvCtMsT39EeStBSRtXaTCLVU=; b=Xhr/ucg1WzqHMRl4tmdOibBGQNwk518oDN4TEROUxHVsglY/zSmmMxbvN5Eu13nsax JUOJCZy7YSPIAb4hw6emVeJd/LJKx6Gwg93F4CCaTm3BmIWYbxSXTPavLJqutZ4BhkzR s9Fnliw+3uLd0tOZRQuJaYWuApofzAO5+fAVGMBS8MzHbb/eWEtY8VjFG76ocPc+ufoy taEJtRT4I/4UBA5d+Mf2Qsr0aptw9T7vxHzqCvEztVjOlhKkBfaeRHqNX7JwI4wvHTIa mPacVLdJXCwzw/gI9ZVbLy25OZgJzbRZXYciYCMt6FaXFpx0JSfkKB2aeO9MjI2r5bwX vWTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709341219; x=1709946019; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=yRxIvbPDDMCjNnVdacSzvCtMsT39EeStBSRtXaTCLVU=; b=ah0FVJNtoh50XKZ1wriuDyfu4k9w0y9htUSgBN986nRN9u0ybPZErEhqSZVlRCYiQt qDcjrKT9Y5C+z+PHQam/jglDXm31pnJKPngCZYOojozUOhYPnyKo6FcX6iaOS+aMi+OU 7HJfRwWv7ss1TRg3IR8mlyl5yOp+Bnh+SMz6SZMNGhJZv4HWoDHYk9qnksS8i45x5j8L 4gL5Wu35vZ4tRbUS7OOh/1BOTG6tmqawVxCh+XvsoesEIfRAT4U50YZJDpnk6Gztuk3h i090UeHKMotrCaDwylmxJfeQ/cSIaWfQDe22NKpgpECVnmwXrhZJ4jGLtzcGbHfxyEwl IKUA== X-Forwarded-Encrypted: i=1; AJvYcCVHVUPwnXCvVdIw6A3hjfMqajrwOeJPKs1pMmqBjv3i3eSJFbh91+VryYQMwl/QVMu4qlUm2GpfZxVLpdZoriOn/mSR8B/jkVjN/Ksu X-Gm-Message-State: AOJu0Yy6nr6mErTCT1+Zi8bCjk8pO3O2S7aZ8HWE4SCDdrJsdwHEhp62 h4J/8RBy0Il4qwP5kpJfH1TkIlCW6fPfCsd54sJ/AAvCez6WrBi8uYybrfzet6Vq60a1gfztSy7 xCG0kDA== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:aba7:66c5:3365:7114]) (user=irogers job=sendgmr) by 2002:a05:6902:18d3:b0:dc7:865b:22c6 with SMTP id ck19-20020a05690218d300b00dc7865b22c6mr117870ybb.8.1709341219679; Fri, 01 Mar 2024 17:00:19 -0800 (PST) Date: Fri, 1 Mar 2024 16:59:47 -0800 In-Reply-To: <20240302005950.2847058-1-irogers@google.com> Message-Id: <20240302005950.2847058-10-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240302005950.2847058-1-irogers@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v2 09/12] perf jevents: Drop duplicate pending metrics From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , John Garry , Kan Liang , Jing Zhang , Thomas Richter , James Clark , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Andi Kleen , Kajol Jain , Sandipan Das , Ravi Bangoria , Perry Taylor , Samantha Alt , Caleb Biggers , Weilin Wang , Edward Baker , Stephane Eranian X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792374365929661833 X-GMAIL-MSGID: 1792374365929661833 Drop adding a pending metric if there is an existing one. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/jevents.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/pmu-events/jevents.py b/tools/perf/pmu-events/jevents.py index 65ab03ce5064..55205a260a16 100755 --- a/tools/perf/pmu-events/jevents.py +++ b/tools/perf/pmu-events/jevents.py @@ -468,7 +468,7 @@ def add_events_table_entries(item: os.DirEntry, topic: str) -> None: for e in read_json_events(item.path, topic): if e.name: _pending_events.append(e) - if e.metric_name: + if e.metric_name and not any(e.metric_name == x.metric_name for x in _pending_metrics): _pending_metrics.append(e) From patchwork Sat Mar 2 00:59:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 209165 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp249282dyc; Fri, 1 Mar 2024 17:03:29 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVOI3P7wt+FJzdBYwQrk8j/59qlO3/RD37JEXPzrOLQSlbJVxRRIUhVNKn34Epg4rNXmajfZTLMZMMu+av1zPNtXqzBRg== X-Google-Smtp-Source: AGHT+IGWfBruzhTv2t8GuDBoXnSLxK4qwffImw63iz9f42xl3SrhGUjw5lWtPOQRgB/5iTTYCluP X-Received: by 2002:a17:90a:d497:b0:299:1cce:f3c3 with SMTP id s23-20020a17090ad49700b002991ccef3c3mr4620414pju.7.1709341408874; Fri, 01 Mar 2024 17:03:28 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709341408; cv=pass; d=google.com; s=arc-20160816; b=ov4ZQtis0lQbRY/izc/RY8tKkKe1aV6WLKHKxl7cHvoNTYgyJ6oki/pOqKdZZULJCj SjDRHxU7pV+eJi57J8BimvECV/NnXdHYTXgbD1yMbB0JWh7+s9sLEYPRzuSt9jC77oQv W4mlY8DGupg7Trdj2kkg0ZYN684mreUP8OdcsPeQh/EyfNQ5IO71g9agosz+uiPOvCy1 KXgDWb7+UvIR15oU+iWDvbnwpPL1M8PBLO/aFNMBT00fRRAdmOHF3HsLfgO6tQ2AfQUG AvqWxYeHB1ew4fy3KY3+WWJGs/4JBxNmyuyg048BYygkcfFQMgo+wmWwlQ/bz/UpjHxn YLJg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:from:subject:references:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:in-reply-to:date :dkim-signature; bh=gGG+6HzWesnJ1eAogyUwc6CZn4obQaKW0ElKvKW4EMk=; fh=4RW0vBTBYNajgfnBpbHPcAtyVkkJviebcNgMI+Y35Vk=; b=kG4GdZsdGFvnI1R6Dk0gqETDQtSRUm/KGOcgXsaPVGOXaHlYx86HQfDXJp9wSMVZd9 RSZNrQPt02ichHcglIwYF9QGpg9rnZz3RU+S/Gmzw9K8RUoMGSfjU3KNtrB/a63174AC /G1wvvjOaAYXYABzsw8Z659tYLVhHgFpapfRko0DHFMbEmjQNJ1CYN5dHEr2ITpjROCJ wxQEJ/p09JWGUHVP4OA7EwIRcEXZJaFc+7DZq9ZGoI9kRLFBNXrC2Srla5w1dJ4h0f71 KpTUrMKHRPSM+W/lQaaD6NXm+ksoyQ338f+B5iNOQO4fpMhcIyvWANgp2tuSDlr73epM 1q0g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=vAYyEJkI; arc=pass (i=1 spf=pass spfdomain=flex--irogers.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-89284-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89284-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id y2-20020a17090a6c8200b0029acaa59f3dsi4611070pjj.2.2024.03.01.17.03.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 17:03:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-89284-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=vAYyEJkI; arc=pass (i=1 spf=pass spfdomain=flex--irogers.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-89284-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89284-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 6A96C287FA5 for ; Sat, 2 Mar 2024 01:02:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5EEDD6AB9; Sat, 2 Mar 2024 01:00:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="vAYyEJkI" Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0E91C1775C for ; Sat, 2 Mar 2024 01:00:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709341224; cv=none; b=rbKvJ9dpjJUPfgbgbvSb49HY3dSCGm0NguksL3e2RcW0wy0hgoXevEjcxNwjg80Nn8IVY1aMPjIOZOiJ33dv2eZYk+RErrY18lmofqllhdJuakwsO11bbDhckUgM9VFUDYinbDNVUv1IQ5bRCU576twbNL/AssVtpJLqnt88968= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709341224; c=relaxed/simple; bh=gNv29+h0IhWRsa2qydUVk3E45fI6zH8amlK1YqhsJZ8=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=rXtODrd++4AL7DNBSmU4qB5J80EHDotoMdkjP/1swO7C7NQ67Ncf50Bl1GtoLnazk0UYzy9Yb5TTvajBVLUE5GgGtWEQfH0mVukwT8pu117Mzj+0apSettiedC4mwtYDY2D9y0qWpQYm9lRKtn6Ld3Qlcch5GH9mvsOcAhXxhD8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=vAYyEJkI; arc=none smtp.client-ip=209.85.219.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-dbf618042daso4152456276.0 for ; Fri, 01 Mar 2024 17:00:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709341222; x=1709946022; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=gGG+6HzWesnJ1eAogyUwc6CZn4obQaKW0ElKvKW4EMk=; b=vAYyEJkIzKm3wM3sYfkjG86tfhIHfz0zDBxf4hrKBdXdaF8Q3BLphix7jN503LOtUr oRSN1f7cw2v3j3PIL5O6XBCvoVRNLZTGHGsPwq5PKq8MLlRe1xjNgO+FI4iPH0KcEHVX 7ry9JV9SZ1wD/AkGaLxQKEATB9tQ8XA77wKH2YZ8VlTPXLTwwzuFncDvHqCqmjhnmbUT GhEGxGZbkKZ0fTd0BI7xLtTyBqXO/Eg6yKbVCAVFtSOPy+LVlbwt2OEDEHLVvOOQwGNG JeqgjYEwmaBarD2jEuVr74SS6VQk6MYNXnm2V3WwMM/WclQeIaxhNEEV0UXo92nXi77z t2Ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709341222; x=1709946022; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=gGG+6HzWesnJ1eAogyUwc6CZn4obQaKW0ElKvKW4EMk=; b=YiULfYhVO8WGZjYJJ+BqaJe5Yfl/dL4RQ8je5u4FOoDAs85FDRkMMStmPhwbUkYYfo JSEa+E95e94kgJRqE4CBHBzUiMr3DExd+Iii2wOUcuu5p5MWbh0aBNCRnnWpyrR+NjZf be2fmQQBA9CZAVgE1rSWrA0YWRQkmXTBFztaw5EzVTY5JNd/N2MA+lHs3BxgDRju3gwG 8Lu0ku4/BSReAvzyXFOFvW5doOPsAM2+EuglaJlTwCeKyD8Szd2aekX7Kc3J3iqM9LRt fitvVdhDKeLU7NCbTMNc4j5BqO/ZDoyNed5Bhb+C58HnV7VtlanYld2r2042VprRf4zU Z63A== X-Forwarded-Encrypted: i=1; AJvYcCUIAFoCftNe4yamqxfudYmzIK+IUPd9V91dBDdZzkVaihA3wkllkmhVSK2kNBIIQFjD86iPWEI+TVUvxKHHgg/7SkR37yOfNMyH+3XG X-Gm-Message-State: AOJu0Ywx76Osleoey9pIQNb5pofKs1Xro5AIygK14IvAb2o7cv2mSGmX GtQSJ2cjqSWeT7ktSiD6sztsTFVCY2Vvy1AnVbmHcG3BpgEONuDB5ZoU32z+hcis5hmkxWp3W/G y5+TK+g== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:aba7:66c5:3365:7114]) (user=irogers job=sendgmr) by 2002:a05:690c:fce:b0:609:e1f:5a42 with SMTP id dg14-20020a05690c0fce00b006090e1f5a42mr640571ywb.2.1709341222105; Fri, 01 Mar 2024 17:00:22 -0800 (PST) Date: Fri, 1 Mar 2024 16:59:48 -0800 In-Reply-To: <20240302005950.2847058-1-irogers@google.com> Message-Id: <20240302005950.2847058-11-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240302005950.2847058-1-irogers@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v2 10/12] perf jevents: Skip optional metrics in metric group list From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , John Garry , Kan Liang , Jing Zhang , Thomas Richter , James Clark , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Andi Kleen , Kajol Jain , Sandipan Das , Ravi Bangoria , Perry Taylor , Samantha Alt , Caleb Biggers , Weilin Wang , Edward Baker , Stephane Eranian X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792374377430131737 X-GMAIL-MSGID: 1792374377430131737 For metric groups, skip metrics in the list that are None. This allows functions to better optionally return metrics. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/metric.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/perf/pmu-events/metric.py b/tools/perf/pmu-events/metric.py index b39189182608..dd8fd06940e6 100644 --- a/tools/perf/pmu-events/metric.py +++ b/tools/perf/pmu-events/metric.py @@ -493,13 +493,15 @@ class MetricGroup: """ def __init__(self, name: str, - metric_list: List[Union[Metric, 'MetricGroup']], + metric_list: List[Union[Optional[Metric], Optional['MetricGroup']]], description: Optional[str] = None): self.name = name - self.metric_list = metric_list + self.metric_list = [] self.description = description for metric in metric_list: - metric.AddToMetricGroup(self) + if metric: + self.metric_list.append(metric) + metric.AddToMetricGroup(self) def AddToMetricGroup(self, group): """Callback used when a MetricGroup is added into another.""" From patchwork Sat Mar 2 00:59:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 209161 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp249024dyc; Fri, 1 Mar 2024 17:03:00 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWtktLNhe7l17HKqFPa+r6eJmAo5KM8mQMZDY9YBUhMUgi7O7b1OzL1gW/sa+p9ItmN9lj5zl6lT2QWoIGjJJYrUtUeQg== X-Google-Smtp-Source: AGHT+IGCO9tCWanHiV/E0wVS82P0u82IdeFhnjnGQNqqkTrmitamXU6o8F5oYUv85Yhb24/gkp6a X-Received: by 2002:a05:620a:462c:b0:788:1556:58e6 with SMTP id br44-20020a05620a462c00b00788155658e6mr1482981qkb.41.1709341380728; Fri, 01 Mar 2024 17:03:00 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709341380; cv=pass; d=google.com; s=arc-20160816; b=zNtrfKTeMDwklPJdDFycF9fJpJZmfXV448J3WXMuiBpBXyy3ArbitJDuDkHjw70234 10+9PDf6443Qgv3zsoWDcP+WJl6hofgakuKqxTl5AeSEyog+NKHfRsU0XR6e1qwKW5vm ki7npSUiwb537weqVXmkPYhMH8ljCB9jw/r+7bSyN72BzDEhFwdWZbP7aqkW2ByiGLSU DBBIwnZjxBcNuozT8vqaKhoBOXR6E6n0sVwJ2I07N5bbjL/ti3S/jnbawRmIfborEUyH yVrGoAk+2O2EjWFlqE+U8Qwdsm76zJDeLmYF0YPhGdIYOpAL+VuPsYAANVNp7OVKceKe 0BCg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:from:subject:references:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:in-reply-to:date :dkim-signature; bh=Nx4MlmIt8t3TyA1tk4UL1nVGkD2g6IUGJuLnswRehIc=; fh=mnRbU3rMToMQhmWdExV6aqQhio249WImyNt6BZZCcas=; b=dAIdI0E4hFz7W39r89ExeKsNsAqm7D/h1nJpRGxYEbz/Mk9eTY6F67ORZmcoqe8TkX mscDIBL30KUD8SNMxy72tsss0xlGPUUZWI9amCGjcHyjigGz8HE2/1atDWMkIzLhABN2 vbiQWbWkitJW5D9jrqbxhWILfSn7go4elCOdFG9nVTMmtrlbfd2NH+kRaNiKfrYDvlVL cnqBTTR4ntFWJwSKt/YmJgPdClGM7XlsvXwLoxzqLhZZJjy1OkdCw9xbLfBamRIteaBW MhZC2hu8BnIhHqt8LON0wwrvOb+nw1eS+xpIg90dEo62zSFXqFvOvC5rl6cjvH8cxHCo rqcg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=4P4ohSiZ; arc=pass (i=1 spf=pass spfdomain=flex--irogers.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-89285-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89285-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id o10-20020a05620a110a00b00787722a2a36si4684492qkk.183.2024.03.01.17.03.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 17:03:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-89285-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=4P4ohSiZ; arc=pass (i=1 spf=pass spfdomain=flex--irogers.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-89285-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89285-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 729B21C2203A for ; Sat, 2 Mar 2024 01:03:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 49B1C17BC7; Sat, 2 Mar 2024 01:00:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="4P4ohSiZ" Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 483EC17BAA for ; Sat, 2 Mar 2024 01:00:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709341227; cv=none; b=CSx3sjNfgqaSQVuhGRcPvnWdALQfvrMVmaiOadLU49t1tVpNlyVtI/cnpWfJGoiXzt3MytWmz3Qd7TyA32iSpa3Dk2s7SKyInhcd/OzR2LC1pJCy+HdPAiHWi4WN+0u7sTE0W+hqNdAZR1dGkI45K/+6WwGsEYcjq3O5+A9lTsE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709341227; c=relaxed/simple; bh=CHrAJbvJO9BTJsj3EUS8jinTu8Wtt+S0RfDD6NVmeDM=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=M1L12piGCbZHfTgUkeuuOKKTp/q2hXvRcSXvXQoT9Gzt1ZatM9QcfwYdxgjo5q9QZJ/mHG30rIk5ccv+xgxsP4mHsvcqr20fg2s8Gf/tNOTJ8z+RkWeXTRsO+PJgljEpshjrGbV6M5HqUlNC4hMr/R/VB4lvHrZP0GOL1fodHhs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=4P4ohSiZ; arc=none smtp.client-ip=209.85.219.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-dcdc3db67f0so4352407276.1 for ; Fri, 01 Mar 2024 17:00:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709341224; x=1709946024; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=Nx4MlmIt8t3TyA1tk4UL1nVGkD2g6IUGJuLnswRehIc=; b=4P4ohSiZimBTWzpbIdDWLq1maUG/UOijRiCSLUJr1ha3rZATtkU2ZuRxQampCAsZVn adPk28HLACiImZ+juf2WN9IzJesDiZW2b6NBwIRRRn6b2L5yCRhle23j6eML8kw4zujJ bWtXE/ihEv1tZFLIGKuaNQ+ygwHyCeM0XefxQfugGIbILke3YIKhD8Lib1UW/3M6DOzY TtW96waX4wehE8woZUknml++lC9TbvwQ1edoWdOcV5kcCKq3GYjgpMCjMrSHhIrOMNnX 1Qxc44sMusxiEAev6v9+cFv9LOLpq+CfID1zy+bpdhORAAgub49Cqj+AT9Y/iaG73314 pjWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709341224; x=1709946024; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Nx4MlmIt8t3TyA1tk4UL1nVGkD2g6IUGJuLnswRehIc=; b=WqY2HGYGOkT9boFqhsM1vxutN/sR8B2SEiM5dBVouork27E9+CwmMuzh/mAJVwOBxv OflsF/c7B7/II62eDr+LY8213KfEwvBVHMCxBAsbu5kP8RD9RA+44MWzqwa9Fna+YZX3 0DNCrMWoWwfNOjx3qp4C1FBi1gcmi3TpO0YMSqv5kNpUCzIMeLl+D3NGain96zcuJ69Q ZbnFqgWyF+CKqLB/KQsSHZh/lns1X87x6LafAc1y3rgNKrO/+9ASRrJ6V1FqIjcpOIMe PnQRJ/Ffyg0FwRwnfjwsiHuHT8j8KByiwrAsUPBeTeVwqGXaO08JFj7tyErOV2BJ+6ae HrHg== X-Forwarded-Encrypted: i=1; AJvYcCVebtiO6/hPsmEg40xiABff8BV2prV1OksVfHidoCn94jNOk7g1YgmOOQJ5NUDsbfs/f8miXdg3Q19Dhjt8RN615sfvsJv7gZMPxNE3 X-Gm-Message-State: AOJu0YzoY5nRnDx9UbNXcj9FWLBlZZr0CQp0ogq2pMVT9QQtjD38R1lq 6GcQJ+CxCjuAZP0BV8tmm2E/SmmamDz+A1pP54ryEsUCttW5mj2NSn4bqjVl9/Dy8ikScFyV9Q+ IboHT/Q== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:aba7:66c5:3365:7114]) (user=irogers job=sendgmr) by 2002:a5b:b4d:0:b0:dcc:2267:796e with SMTP id b13-20020a5b0b4d000000b00dcc2267796emr1216113ybr.2.1709341224564; Fri, 01 Mar 2024 17:00:24 -0800 (PST) Date: Fri, 1 Mar 2024 16:59:49 -0800 In-Reply-To: <20240302005950.2847058-1-irogers@google.com> Message-Id: <20240302005950.2847058-12-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240302005950.2847058-1-irogers@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v2 11/12] perf jevents: Build support for generating metrics from python From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , John Garry , Kan Liang , Jing Zhang , Thomas Richter , James Clark , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Andi Kleen , Kajol Jain , Sandipan Das , Ravi Bangoria , Perry Taylor , Samantha Alt , Caleb Biggers , Weilin Wang , Edward Baker , Stephane Eranian X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792374347611366498 X-GMAIL-MSGID: 1792374347611366498 Generate extra-metrics.json and extra-metricgroups.json from python architecture specific scripts. The metrics themselves will be added in later patches. If a build takes place in tools/perf/ then extra-metrics.json and extra-metricgroups.json are generated in that directory and so added to .gitignore. If there is an OUTPUT directory then the tools/perf/pmu-events/arch files are copied to it so the generated extra-metrics.json and extra-metricgroups.json can be added/generated there. Signed-off-by: Ian Rogers --- tools/perf/.gitignore | 2 + tools/perf/Makefile.perf | 17 ++++++-- tools/perf/pmu-events/Build | 60 ++++++++++++++++++++++++-- tools/perf/pmu-events/amd_metrics.py | 17 ++++++++ tools/perf/pmu-events/arm64_metrics.py | 18 ++++++++ tools/perf/pmu-events/intel_metrics.py | 17 ++++++++ 6 files changed, 124 insertions(+), 7 deletions(-) create mode 100755 tools/perf/pmu-events/amd_metrics.py create mode 100755 tools/perf/pmu-events/arm64_metrics.py create mode 100755 tools/perf/pmu-events/intel_metrics.py diff --git a/tools/perf/.gitignore b/tools/perf/.gitignore index f5b81d439387..c9a8da5bfc56 100644 --- a/tools/perf/.gitignore +++ b/tools/perf/.gitignore @@ -39,6 +39,8 @@ trace/beauty/generated/ pmu-events/pmu-events.c pmu-events/jevents pmu-events/metric_test.log +pmu-events/arch/**/extra-metrics.json +pmu-events/arch/**/extra-metricgroups.json tests/shell/*.shellcheck_log tests/shell/coresight/*.shellcheck_log tests/shell/lib/*.shellcheck_log diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index 04d89d2ed209..4fbb0a173476 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf @@ -1177,7 +1177,20 @@ endif # CONFIG_PERF_BPF_SKEL bpf-skel-clean: $(call QUIET_CLEAN, bpf-skel) $(RM) -r $(SKEL_TMP_OUT) $(SKELETONS) $(SKEL_OUT)/vmlinux.h -clean:: $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clean $(LIBSYMBOL)-clean $(LIBPERF)-clean arm64-sysreg-defs-clean fixdep-clean python-clean bpf-skel-clean tests-coresight-targets-clean +pmu-events-clean: +ifeq ($(OUTPUT),) + $(call QUIET_CLEAN, pmu-events) $(RM) \ + pmu-events/pmu-events.c \ + pmu-events/metric_test.log + $(Q)find pmu-events/arch -name 'extra-metrics.json' -delete -o \ + -name 'extra-metricgroups.json' -delete +else + $(call QUIET_CLEAN, pmu-events) $(RM) -r $(OUTPUT)pmu-events/arch \ + $(OUTPUT)pmu-events/pmu-events.c \ + $(OUTPUT)pmu-events/metric_test.log +endif + +clean:: $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clean $(LIBSYMBOL)-clean $(LIBPERF)-clean arm64-sysreg-defs-clean fixdep-clean python-clean bpf-skel-clean tests-coresight-targets-clean pmu-events-clean $(call QUIET_CLEAN, core-objs) $(RM) $(LIBPERF_A) $(OUTPUT)perf-archive $(OUTPUT)perf-iostat $(LANG_BINDINGS) $(Q)find $(or $(OUTPUT),.) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete -o -name '*.shellcheck_log' -delete $(Q)$(RM) $(OUTPUT).config-detected @@ -1185,8 +1198,6 @@ clean:: $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clean $(LIBSYMBOL)-clean $( $(call QUIET_CLEAN, core-gen) $(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo $(OUTPUT)common-cmds.h TAGS tags cscope* $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)FEATURE-DUMP $(OUTPUT)util/*-bison* $(OUTPUT)util/*-flex* \ $(OUTPUT)util/intel-pt-decoder/inat-tables.c \ $(OUTPUT)tests/llvm-src-{base,kbuild,prologue,relocation}.c \ - $(OUTPUT)pmu-events/pmu-events.c \ - $(OUTPUT)pmu-events/metric_test.log \ $(OUTPUT)$(fadvise_advice_array) \ $(OUTPUT)$(fsconfig_arrays) \ $(OUTPUT)$(fsmount_arrays) \ diff --git a/tools/perf/pmu-events/Build b/tools/perf/pmu-events/Build index 1d18bb89402e..9af15e3498f1 100644 --- a/tools/perf/pmu-events/Build +++ b/tools/perf/pmu-events/Build @@ -1,7 +1,6 @@ pmu-events-y += pmu-events.o JDIR = pmu-events/arch/$(SRCARCH) -JSON = $(shell [ -d $(JDIR) ] && \ - find $(JDIR) -name '*.json' -o -name 'mapfile.csv') +JSON = $(shell find pmu-events/arch -name *.json -o -name *.csv) JDIR_TEST = pmu-events/arch/test JSON_TEST = $(shell [ -d $(JDIR_TEST) ] && \ find $(JDIR_TEST) -name '*.json') @@ -27,13 +26,66 @@ $(PMU_EVENTS_C): $(EMPTY_PMU_EVENTS_C) $(call rule_mkdir) $(Q)$(call echo-cmd,gen)cp $< $@ else +# Extract the model from a extra-metrics.json or extra-metricgroups.json path +model_name = $(shell echo $(1)|sed -e 's@.\+/\(.*\)/extra-metric.*\.json@\1@') +vendor_name = $(shell echo $(1)|sed -e 's@.\+/\(.*\)/[^/]*/extra-metric.*\.json@\1@') + +# Copy checked-in json for generation. +$(OUTPUT)pmu-events/arch/%: pmu-events/arch/% + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)cp $< $@ + +# Generate AMD Json +ZENS = $(shell ls -d pmu-events/arch/x86/amdzen*) +ZEN_METRICS = $(foreach x,$(ZENS),$(OUTPUT)$(x)/extra-metrics.json) +ZEN_METRICGROUPS = $(foreach x,$(ZENS),$(OUTPUT)$(x)/extra-metricgroups.json) + +$(ZEN_METRICS): pmu-events/amd_metrics.py + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(PYTHON) $< $(call model_name,$@) > $@ + +$(ZEN_METRICGROUPS): pmu-events/amd_metrics.py + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(PYTHON) $< -metricgroups $(call model_name,$@) > $@ + +# Generate ARM Json +ARMS = $(shell ls -d pmu-events/arch/arm64/arm/*) +ARM_METRICS = $(foreach x,$(ARMS),$(OUTPUT)$(x)/extra-metrics.json) +ARM_METRICGROUPS = $(foreach x,$(ARMS),$(OUTPUT)$(x)/extra-metricgroups.json) + +$(ARM_METRICS): pmu-events/arm64_metrics.py + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(PYTHON) $< $(call vendor_name,$@) $(call model_name,$@) > $@ + +$(ARM_METRICGROUPS): pmu-events/arm64_metrics.py + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(PYTHON) $< -metricgroups $(call vendor_name,$@) $(call model_name,$@) > $@ + +# Generate Intel Json +INTELS = $(shell ls -d pmu-events/arch/x86/*|grep -v amdzen|grep -v mapfile.csv) +INTEL_METRICS = $(foreach x,$(INTELS),$(OUTPUT)$(x)/extra-metrics.json) +INTEL_METRICGROUPS = $(foreach x,$(INTELS),$(OUTPUT)$(x)/extra-metricgroups.json) + +$(INTEL_METRICS): pmu-events/intel_metrics.py + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(PYTHON) $< $(call model_name,$@) > $@ + +$(INTEL_METRICGROUPS): pmu-events/intel_metrics.py + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(PYTHON) $< -metricgroups $(call model_name,$@) > $@ + +GEN_JSON = $(patsubst %,$(OUTPUT)%,$(JSON)) \ + $(ZEN_METRICS) $(ZEN_METRICGROUPS) \ + $(ARM_METRICS) $(ARM_METRICGROUPS) \ + $(INTEL_METRICS) $(INTEL_METRICGROUPS) + $(METRIC_TEST_LOG): $(METRIC_TEST_PY) $(METRIC_PY) $(call rule_mkdir) $(Q)$(call echo-cmd,test)$(PYTHON) $< 2> $@ || (cat $@ && false) -$(PMU_EVENTS_C): $(JSON) $(JSON_TEST) $(JEVENTS_PY) $(METRIC_PY) $(METRIC_TEST_LOG) +$(PMU_EVENTS_C): $(GEN_JSON) $(JSON_TEST) $(JEVENTS_PY) $(METRIC_PY) $(METRIC_TEST_LOG) $(call rule_mkdir) - $(Q)$(call echo-cmd,gen)$(PYTHON) $(JEVENTS_PY) $(JEVENTS_ARCH) $(JEVENTS_MODEL) pmu-events/arch $@ + $(Q)$(call echo-cmd,gen)$(PYTHON) $(JEVENTS_PY) $(JEVENTS_ARCH) $(JEVENTS_MODEL) $(OUTPUT)pmu-events/arch $@ endif # pmu-events.c file is generated in the OUTPUT directory so it needs a diff --git a/tools/perf/pmu-events/amd_metrics.py b/tools/perf/pmu-events/amd_metrics.py new file mode 100755 index 000000000000..cb850ab1ed13 --- /dev/null +++ b/tools/perf/pmu-events/amd_metrics.py @@ -0,0 +1,17 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) +from metric import (JsonEncodeMetric, JsonEncodeMetricGroupDescriptions, MetricGroup) +import argparse +import json + +parser = argparse.ArgumentParser(description="AMD perf json generator") +parser.add_argument("-metricgroups", help="Generate metricgroups data", action='store_true') +parser.add_argument("model", help="e.g. amdzen[123]") +args = parser.parse_args() + +all_metrics = MetricGroup("",[]) + +if args.metricgroups: + print(JsonEncodeMetricGroupDescriptions(all_metrics)) +else: + print(JsonEncodeMetric(all_metrics)) diff --git a/tools/perf/pmu-events/arm64_metrics.py b/tools/perf/pmu-events/arm64_metrics.py new file mode 100755 index 000000000000..a54fa8aae2fa --- /dev/null +++ b/tools/perf/pmu-events/arm64_metrics.py @@ -0,0 +1,18 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) +from metric import (JsonEncodeMetric, JsonEncodeMetricGroupDescriptions, MetricGroup) +import argparse +import json + +parser = argparse.ArgumentParser(description="ARM perf json generator") +parser.add_argument("-metricgroups", help="Generate metricgroups data", action='store_true') +parser.add_argument("vendor", help="e.g. arm") +parser.add_argument("model", help="e.g. neoverse-n1") +args = parser.parse_args() + +all_metrics = MetricGroup("",[]) + +if args.metricgroups: + print(JsonEncodeMetricGroupDescriptions(all_metrics)) +else: + print(JsonEncodeMetric(all_metrics)) diff --git a/tools/perf/pmu-events/intel_metrics.py b/tools/perf/pmu-events/intel_metrics.py new file mode 100755 index 000000000000..8b67b9613ab5 --- /dev/null +++ b/tools/perf/pmu-events/intel_metrics.py @@ -0,0 +1,17 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) +from metric import (JsonEncodeMetric, JsonEncodeMetricGroupDescriptions, MetricGroup) +import argparse +import json + +parser = argparse.ArgumentParser(description="Intel perf json generator") +parser.add_argument("-metricgroups", help="Generate metricgroups data", action='store_true') +parser.add_argument("model", help="e.g. skylakex") +args = parser.parse_args() + +all_metrics = MetricGroup("",[]) + +if args.metricgroups: + print(JsonEncodeMetricGroupDescriptions(all_metrics)) +else: + print(JsonEncodeMetric(all_metrics)) From patchwork Sat Mar 2 00:59:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 209162 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp249088dyc; Fri, 1 Mar 2024 17:03:07 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXqrObAyVf3jhN+Rh9UyNHiUJGZ+PmpqeXXgTzUmiMwbdow828zJLBAT1IKiTePIZHMGhMUZaUOwNtU+O/2hR56twHPjw== X-Google-Smtp-Source: AGHT+IFvfRc894RnUSQRaFkMkfND/9PxFTalto4vQ4jyxapqOAQil4sobB2IDaKAHi9T6Fnh2QXP X-Received: by 2002:a17:906:fb10:b0:a44:adc9:dadb with SMTP id lz16-20020a170906fb1000b00a44adc9dadbmr1935518ejb.13.1709341387563; Fri, 01 Mar 2024 17:03:07 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709341387; cv=pass; d=google.com; s=arc-20160816; b=ircZ7KoKgnn7k2KHaD1fXxR5zZPoF2bmBrqjBlGBh1JtLLWVkhPw1WgWwVuy7Z4Y6s bq4vK2NNMCstDTtLs8aTEW2IY7Cy7JX2Vq8/hqKiE862bNS0fNOWOdVDZFUCJM0B+zeM NsUnsfyJKKTY7NdH7FC7Lq/VLQB4aXeTP02eqHSbLw0xce++prhbe2Q8kfsP8X5BuWYL A8xEJVDTyrU9FOMJenTV8vLUrSKePB4mmOwlN5VEAtNExueREBZqJBvT9JzRKafB/KfG FZyCxXmA3owi0tzTeg5aYhUb/lRmPOW53YktxLyGAG/QNBjy9El5rN8k3aq/5ytUXHj8 bwlg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:from:subject:references:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:in-reply-to:date :dkim-signature; bh=+cp2KMY/NOxQl4V1qbGfl9TN4FcOPFLbnLz8O/u+Jtg=; fh=1Da0eeTDOCwhNZ2e4LE+w3nSxAfT0r2G6Xuv3vpLssk=; b=SEDLBP3MAKVwwZKKPVXmx0buThlFK5PSYkQfc8TsS7NSSxlSSMlf8lFiYcI2hAR0GO 3p020mvYb47oRNsI7MAhEqurNtEjNX92eH6VTPBzPu549XbuCOBmP28kKbprYL/3/II1 0O/IRAMgoXr+nEQNBIQFMKLBiV3fdDJoh3Mo070qHEEkWQHdtYXDGN/qnwJxLceNxsvQ Msk4RwDpuiMNnCJp7KWbdKPlMPl2CSqtBH9Zo7eZwJ/ipcp7TCIO5upLJHsAqmXDL8tP zZRS2W0iefhKQfCxV23CjAnPmH4jDAz+r7COM3ZrJ32+BBtNrHEeVQdg88Ci6SQqwd80 z4Fw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="EQ/82Ny+"; arc=pass (i=1 spf=pass spfdomain=flex--irogers.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-89286-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89286-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id h10-20020a17090634ca00b00a43d361aa87si1853746ejb.277.2024.03.01.17.03.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 17:03:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-89286-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="EQ/82Ny+"; arc=pass (i=1 spf=pass spfdomain=flex--irogers.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-89286-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89286-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 0AD921F23BEF for ; Sat, 2 Mar 2024 01:03:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 838D118E1D; Sat, 2 Mar 2024 01:00:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="EQ/82Ny+" Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EF12B17C70 for ; Sat, 2 Mar 2024 01:00:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709341229; cv=none; b=OpYVKyM85WhkEi8fH8R/c2Ut+WGjb206w9cXnsCG7nk+Gy8iSdMSMdpzQKOdm8IXjD6erbHh0Jb8lRmzGNon37pmTF4rsTnxy62II71uYev5nDxv8M4skVPybz50hwZYnWUvmlUySP/FvTck2Btai0rqfrG22CNMcBWqGR9Vk2M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709341229; c=relaxed/simple; bh=v3K5piv8aZamXDtQ+9SunlvVej87nRnO4NjntMDRkno=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=oUgPdRSgIez1JIBGlbkXFBipOixsS7ZfozdP1LsZxsJvR8GHi1Cgvlp0SdtQ/IdqWkrSx4fdpDByTORO4sX89+7Z5+4qnNtU5pJKc/HH6JWIldB2x8MzAhLwZo39vYM4y1aTGGjJ9wNrcABPrsjdB1UAgl8bxmcTHYnOQIfPD8Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=EQ/82Ny+; arc=none smtp.client-ip=209.85.128.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-5ee22efe5eeso47128357b3.3 for ; Fri, 01 Mar 2024 17:00:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709341227; x=1709946027; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=+cp2KMY/NOxQl4V1qbGfl9TN4FcOPFLbnLz8O/u+Jtg=; b=EQ/82Ny+LYJWppUEIvicfKy55HUOFjptkX9MYvlUivTxdbOwkiAwJiTdrivK559sdG 1mCddcxwFWUGEuJI8JLpd7KRmUfyl393jdOSelmaQmnflXVTW5daQutiufhAb1XDHF5A G5WIpgGYcDic8J0igUQipyd2mRlDqiUXBSP/JeopqYB6tNbwW3Ryi3vIP+NDICxOa0bt NKVEJK3tIvE+zTB3FB16HySj4QqxhcWM2nVptpKqn1fnXcs5zyHlUSHJMaMbVwOqFqsh Y60B8H4UIhQAV2xx/rH2jxNo+MPBbCSJXAHfGr9ZjC6e7qjcPDyUOxBxb0QeyQ02BRs0 GC7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709341227; x=1709946027; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=+cp2KMY/NOxQl4V1qbGfl9TN4FcOPFLbnLz8O/u+Jtg=; b=NZa7W7RrwwrJHlsabE1H0X/epfcOkxxpswrLxk4c14KVxV+7WUlg2sRvVdjzpUX2DU AcIO/5CHgFGMA4ZwI5ayYLUqmWxnIIWBEEPwdo39mMx4Q5/NZWICH/tfZ3pfD5iyIUQn 3xDyyRUUCh4W/xf5IJXOPDoThVvU4fdEdQKQvDn5dsU4mmEU2qUP2nX8BZc+Ws24YJwU 6fLv2gwoqjKmNHYkl+zx/2fuyft+6rYZIhmvbu7V06a25LujYFaS0z62K9Sjrml1UFYN yXWxwryBpOj2JTF3J1wXJpbJUNBoyMlWDT25uEqAVGtPCkkAy5GtQ683WpzBSEfoCDnV L2+w== X-Forwarded-Encrypted: i=1; AJvYcCW4WZEez9dCAae8U59xJp1CbuXkijpu3SPlB/XsEPyJUpLvXRh2G3nklk6l5/9j6WC8rNpqsQyOkVQ9ctUnF17SvUoeKW2RLq/aD6la X-Gm-Message-State: AOJu0YyUniS7VrqCX2pFHfuv7ALYjlVR63S07lJOa+aL6HnqPZ3+PVRF bcgF4DW5cMeMZ76NcJx7EP/BbnASAZRvJ/HkiSC8+g9+TtxePzpGjvpQigCIZUvcgjOTDuPkzhA 6/qGLKw== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:aba7:66c5:3365:7114]) (user=irogers job=sendgmr) by 2002:a05:690c:c86:b0:608:ed2f:e8f1 with SMTP id cm6-20020a05690c0c8600b00608ed2fe8f1mr626514ywb.8.1709341227083; Fri, 01 Mar 2024 17:00:27 -0800 (PST) Date: Fri, 1 Mar 2024 16:59:50 -0800 In-Reply-To: <20240302005950.2847058-1-irogers@google.com> Message-Id: <20240302005950.2847058-13-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240302005950.2847058-1-irogers@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v2 12/12] perf jevents: Add load event json to verify and allow fallbacks From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , John Garry , Kan Liang , Jing Zhang , Thomas Richter , James Clark , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Andi Kleen , Kajol Jain , Sandipan Das , Ravi Bangoria , Perry Taylor , Samantha Alt , Caleb Biggers , Weilin Wang , Edward Baker , Stephane Eranian X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792374354862656395 X-GMAIL-MSGID: 1792374354862656395 Add a LoadEvents function that loads all event json files in a directory. In the Event constructor ensure all events are defined in the event json except for legacy events like "cycles". If the initial event isn't found then legacy_event1 is used, and if that isn't found legacy_event2 is used. This allows a single Event to have multiple event names as models will often rename the same event over time. If the event doesn't exist an exception is raised. So that references to metrics can be added, add the MetricRef class. This doesn't validate as an event name and so provides an escape hatch for metrics to refer to each other. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/amd_metrics.py | 7 ++- tools/perf/pmu-events/arm64_metrics.py | 7 ++- tools/perf/pmu-events/intel_metrics.py | 7 ++- tools/perf/pmu-events/metric.py | 77 +++++++++++++++++++++++++- 4 files changed, 92 insertions(+), 6 deletions(-) diff --git a/tools/perf/pmu-events/amd_metrics.py b/tools/perf/pmu-events/amd_metrics.py index cb850ab1ed13..227f9b98c016 100755 --- a/tools/perf/pmu-events/amd_metrics.py +++ b/tools/perf/pmu-events/amd_metrics.py @@ -1,14 +1,19 @@ #!/usr/bin/env python3 # SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) -from metric import (JsonEncodeMetric, JsonEncodeMetricGroupDescriptions, MetricGroup) +from metric import (JsonEncodeMetric, JsonEncodeMetricGroupDescriptions, LoadEvents, + MetricGroup) import argparse import json +import os parser = argparse.ArgumentParser(description="AMD perf json generator") parser.add_argument("-metricgroups", help="Generate metricgroups data", action='store_true') parser.add_argument("model", help="e.g. amdzen[123]") args = parser.parse_args() +directory = f"{os.path.dirname(os.path.realpath(__file__))}/arch/x86/{args.model}/" +LoadEvents(directory) + all_metrics = MetricGroup("",[]) if args.metricgroups: diff --git a/tools/perf/pmu-events/arm64_metrics.py b/tools/perf/pmu-events/arm64_metrics.py index a54fa8aae2fa..7cd0ebc0bd80 100755 --- a/tools/perf/pmu-events/arm64_metrics.py +++ b/tools/perf/pmu-events/arm64_metrics.py @@ -1,8 +1,10 @@ #!/usr/bin/env python3 # SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) -from metric import (JsonEncodeMetric, JsonEncodeMetricGroupDescriptions, MetricGroup) +from metric import (JsonEncodeMetric, JsonEncodeMetricGroupDescriptions, LoadEvents, + MetricGroup) import argparse import json +import os parser = argparse.ArgumentParser(description="ARM perf json generator") parser.add_argument("-metricgroups", help="Generate metricgroups data", action='store_true') @@ -10,6 +12,9 @@ parser.add_argument("vendor", help="e.g. arm") parser.add_argument("model", help="e.g. neoverse-n1") args = parser.parse_args() +directory = f"{os.path.dirname(os.path.realpath(__file__))}/arch/arm64/{args.vendor}/{args.model}/" +LoadEvents(directory) + all_metrics = MetricGroup("",[]) if args.metricgroups: diff --git a/tools/perf/pmu-events/intel_metrics.py b/tools/perf/pmu-events/intel_metrics.py index 8b67b9613ab5..4fbb31c9eccd 100755 --- a/tools/perf/pmu-events/intel_metrics.py +++ b/tools/perf/pmu-events/intel_metrics.py @@ -1,14 +1,19 @@ #!/usr/bin/env python3 # SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) -from metric import (JsonEncodeMetric, JsonEncodeMetricGroupDescriptions, MetricGroup) +from metric import (JsonEncodeMetric, JsonEncodeMetricGroupDescriptions, LoadEvents, + MetricGroup) import argparse import json +import os parser = argparse.ArgumentParser(description="Intel perf json generator") parser.add_argument("-metricgroups", help="Generate metricgroups data", action='store_true') parser.add_argument("model", help="e.g. skylakex") args = parser.parse_args() +directory = f"{os.path.dirname(os.path.realpath(__file__))}/arch/x86/{args.model}/" +LoadEvents(directory) + all_metrics = MetricGroup("",[]) if args.metricgroups: diff --git a/tools/perf/pmu-events/metric.py b/tools/perf/pmu-events/metric.py index dd8fd06940e6..03312cd6d491 100644 --- a/tools/perf/pmu-events/metric.py +++ b/tools/perf/pmu-events/metric.py @@ -3,10 +3,50 @@ import ast import decimal import json +import os import re from enum import Enum from typing import Dict, List, Optional, Set, Tuple, Union +all_events = set() + +def LoadEvents(directory: str) -> None: + """Populate a global set of all known events for the purpose of validating Event names""" + global all_events + all_events = { + "context\-switches", + "cycles", + "duration_time", + "instructions", + "l2_itlb_misses", + } + for file in os.listdir(os.fsencode(directory)): + filename = os.fsdecode(file) + if filename.endswith(".json"): + for x in json.load(open(f"{directory}/{filename}")): + if "EventName" in x: + all_events.add(x["EventName"]) + elif "ArchStdEvent" in x: + all_events.add(x["ArchStdEvent"]) + + +def CheckEvent(name: str) -> bool: + """Check the event name exists in the set of all loaded events""" + global all_events + if len(all_events) == 0: + # No events loaded so assume any event is good. + return True + + if ':' in name: + # Remove trailing modifier. + name = name[:name.find(':')] + elif '/' in name: + # Name could begin with a PMU or an event, for now assume it is good. + return True + + return name in all_events + + class MetricConstraint(Enum): GROUPED_EVENTS = 0 NO_GROUP_EVENTS = 1 @@ -317,9 +357,18 @@ def _FixEscapes(s: str) -> str: class Event(Expression): """An event in an expression.""" - def __init__(self, name: str, legacy_name: str = ''): - self.name = _FixEscapes(name) - self.legacy_name = _FixEscapes(legacy_name) + def __init__(self, *args: str): + error = "" + for name in args: + if CheckEvent(name): + self.name = _FixEscapes(name) + return + if error: + error += " or " + name + else: + error = name + global all_events + raise Exception(f"No event {error} in:\n{all_events}") def ToPerfJson(self): result = re.sub('/', '@', self.name) @@ -338,6 +387,28 @@ class Event(Expression): return self +class MetricRef(Expression): + """A metric reference in an expression.""" + + def __init__(self, name: str): + self.name = _FixEscapes(name) + + def ToPerfJson(self): + return self.name + + def ToPython(self): + return f'MetricRef(r"{self.name}")' + + def Simplify(self) -> Expression: + return self + + def Equals(self, other: Expression) -> bool: + return isinstance(other, MetricRef) and self.name == other.name + + def Substitute(self, name: str, expression: Expression) -> Expression: + return self + + class Constant(Expression): """A constant within the expression tree."""