Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp974437pxb; Wed, 1 Sep 2021 14:11:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzOjahcYDVApekIFQQQFOxc63h5Q6nD3pgPujjkcqWKUoLTQlLTzKrxusL05b3VuS8CgZkf X-Received: by 2002:a02:cc59:: with SMTP id i25mr1346188jaq.125.1630530664876; Wed, 01 Sep 2021 14:11:04 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1630530664; cv=pass; d=google.com; s=arc-20160816; b=SiJa618VGvnB9ZxJdHgAXP7y+anFTQvxs2vdK3f7B8SNWX2F8JO1hURNO2XRHOG8a7 6gbMDDrmcWBZ7y0bws5rzwywftb2slltqcuUPLq/Kk4kU8XPsk5kK3gdAf6GmC+9DJ2G C2lnGqdgR1PNCDR/zOxLXXpwbm6Dl196JtCjxsHE/t6OD5Sm17od6SFF2aEae7X+fFSY QjZzdtGyA9xyL76YjXinHTA9Wyb/igJjuDNFgh+pzVCvIwbO/rMeRN3PYhrjOuRmuaSI LA0pJjeGf6+GikGSosI4Qdz310vUE5JX0IeQDsg3tx9W8Lfo/9GGFoxafLxGmCw/49k9 xeSQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :message-id:date:subject:cc:to:from:dkim-signature:dkim-signature :dkim-signature; bh=Ux34rEi+oVVlTMiJ9LMJkt3ssy1Fz/sBcVLy0Xx3yLw=; b=N3cF3Yk1ZNpASrSrFTKVRpLVwhbCeNQw2YieRTRXUM+FaHcUQpckqlCJDf4D9qld0o B+3aUpp89bph0QeMB3XaluNJrvF+hGFvWuQu/wLXRw/UVRRKha4TXHvgtsH8h9XMPuna F4sV3KLsLDm5js6lDckrtv6+6788sxtIq2oE7ajL+cAMP1Ld7+g/UAq51tx0noC4+gn7 hLz4d0jCV4guUzd/VCArS/duVnWW57cii594dV3rT+IwPGBF+jMbrTnOfRRsSykNvEeN PtO+y4dPGJM6Z56sLVNSV4JylB7vgBsIm4O9cx0BHfCjXZ0f8e5GNpDwMFVz66od8rh3 XXlg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2021-07-09 header.b=B0jph2yG; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=owDGvKIV; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=OIpKumI8; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i9si631941ilc.6.2021.09.01.14.10.52; Wed, 01 Sep 2021 14:11:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2021-07-09 header.b=B0jph2yG; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=owDGvKIV; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=OIpKumI8; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344070AbhIAVJ2 (ORCPT + 99 others); Wed, 1 Sep 2021 17:09:28 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:43980 "EHLO mx0a-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343826AbhIAVJ0 (ORCPT ); Wed, 1 Sep 2021 17:09:26 -0400 Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 181I45tf008937; Wed, 1 Sep 2021 21:08:20 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=Ux34rEi+oVVlTMiJ9LMJkt3ssy1Fz/sBcVLy0Xx3yLw=; b=B0jph2yG87PMEjljQnFdc11DZ3jBd/bca9YrC7Yy8i61WAlM6utrknM1L5U3xAc7bSdf mOO086nLe2Nt/3jBetNzneUxNAKOZWCR5wVxZ4IGblm0GbrhoV5anZsMgLfLopF9xvXl bkj799YLl9j3J+FgDpw8tmwGxozJNi52XlS3ekOUENLD1bSdQsjwhcR8cuxTmeIXBvg+ asDF8F1GAsTE6m/kNYHFphNo59Co+BzuPPU4nQKjn/Yio8cz4Z+Fpo/Yx5QTWHYR5r6l 8PbLLckR4ARVhbxSEZNKOOBQIBUExQQVAwMdCxVDgeN6cZkj/uD8udH9kE2B74Ph8avL hw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=Ux34rEi+oVVlTMiJ9LMJkt3ssy1Fz/sBcVLy0Xx3yLw=; b=owDGvKIVJz1IWsSzNB6ICOYCGO1Y2cWbgn1Bc3LQq8OX0BLScMgP0zW2UK8BABwStNUE ESj4U0cw6fPpx8rWbIGRSu2SxYkF45rPT4njLuiflFTgnLvcmrN9JJT5CTejNgLIpPBi hb4NLtq4hyudzUXXx7ZZXcUeua/u7ib5sW0YlkS/w5dusmEmAlVhbtmGi4fBQpg8garP IersZhwa8a0yp/prfIBBsm7EcyNeTKsmqNwU34EqwhHlH4JPLU1byd41q493XbWkJe6f YA88ulbORpD8DSsa0V+BuINToY3bQ9FkYLr29Hm3i5zg5rjU4CVo0sHUJTXQa6ztxZoj ow== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3atdw0gjj9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 01 Sep 2021 21:08:20 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 181L6PdK027409; Wed, 1 Sep 2021 21:08:19 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2048.outbound.protection.outlook.com [104.47.66.48]) by userp3030.oracle.com with ESMTP id 3ate04rppy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 01 Sep 2021 21:08:19 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OpqnNbIXBtGXjFnZpKKG6hQx/AgNv0v2mDfvAbDkXGPle94QnS/bWou7drJKRsapAL5QAA8P3hM4FX6xhKVGYH7NsYDr3njM6l67jUPJ0IOzbF5TUXT7hU4RndZA6FG5avpYyEcajiCdGPCAtbhvezopj3wDAYHaFG2TH/VfRxb2AQBTNdnQeohFFlBktT1zOVRnL7Jxoyyk+62ZYfusyGwTzY7OuR70O3hzaXI0Ij6VujElEHBqlvj+QiQNwz++eUtO0UOpQuZGlAM7wPsGAzA5HUUCicoowX8kbHCBk7HjygBtTTjBwQBoRCkpkx0Ob/JjU4ciBh1uyIBUj1ah1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=Ux34rEi+oVVlTMiJ9LMJkt3ssy1Fz/sBcVLy0Xx3yLw=; b=QTifDvmbkQC3kJtcDxZjiKIDsSgzpoTz7LRPfYvLGpQqqHj/fbNIstnm/aTZO6IEDsUwnxB/3gM9DTL0rmIawrEd8/yqaGPTEJ+zllwT7YgVeDOzxal8uSsq9DCdSy3oAS7amkD4I/n4pOR060XkS0a/S0LBcLMt/rNKE0HrQu0BAjxBo/AKkn9AW/SjJyduuG3oB4tYOghaywH8+nepT+ZuxbNUaxofP2hWtDAPfQ3Z3Y/3aQzK/NI8axfI0dBfkMFQ0qxNTP/XHdPSosnBpkUzFHywloNyXC6WrW6qUiRV143iPNaVVLFLPUgZ1Xscjv+Is3Jz7qu5e0VcGFpKGQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Ux34rEi+oVVlTMiJ9LMJkt3ssy1Fz/sBcVLy0Xx3yLw=; b=OIpKumI8UwXJl3CswhY+9iOAehsV9Cv2em4E07obdECdXZnG5tVaaK7MThueqpVHMbPCERf8+gxj3mZ6dn0pQufd6XHZ1p2rV+SooMjhUBlQ62ELJ7MvANRCHTM0pFTD/K8cUWUFA1hRBxae4t79D1x0Q+h/mAiwTLcotSPaz+I= Authentication-Results: infradead.org; dkim=none (message not signed) header.d=none;infradead.org; dmarc=none action=none header.from=oracle.com; Received: from CH2PR10MB4166.namprd10.prod.outlook.com (2603:10b6:610:78::20) by CH0PR10MB5211.namprd10.prod.outlook.com (2603:10b6:610:df::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.17; Wed, 1 Sep 2021 21:08:15 +0000 Received: from CH2PR10MB4166.namprd10.prod.outlook.com ([fe80::2c22:7eb8:a2f0:e027]) by CH2PR10MB4166.namprd10.prod.outlook.com ([fe80::2c22:7eb8:a2f0:e027%7]) with mapi id 15.20.4457.025; Wed, 1 Sep 2021 21:08:15 +0000 From: Stephen Brennan To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim Cc: Stephen Brennan , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] perf script python: Allow reporting [un]throttle Date: Wed, 1 Sep 2021 14:08:15 -0700 Message-Id: <20210901210815.133251-1-stephen.s.brennan@oracle.com> X-Mailer: git-send-email 2.30.2 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SA9PR13CA0149.namprd13.prod.outlook.com (2603:10b6:806:27::34) To CH2PR10MB4166.namprd10.prod.outlook.com (2603:10b6:610:78::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost (148.87.23.10) by SA9PR13CA0149.namprd13.prod.outlook.com (2603:10b6:806:27::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.4 via Frontend Transport; Wed, 1 Sep 2021 21:08:15 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 16c82270-6a3e-42c3-829d-08d96d8c9d76 X-MS-TrafficTypeDiagnostic: CH0PR10MB5211: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?y+261XZeOQI6PZdUnZ6rMYiImfaKb2UFtk3P3t0ZVK/wytbmlztiTkMvnmeK?= =?us-ascii?Q?xa/18fZNtFqFb+sVFiX2O5b4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7LeYvh7etKkO7oQ4GnM4urY/AAxx0Z2FUM0MzpOUbdK31gN5PI0D6id/3?= =?us-ascii?Q?U6J5zCMOIe4TXNk42Z6cYExNGb7g6LA5U79aH+r9ksocbGk=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:5;SRV:;IPV:NLI;SFV:SPM;H:CH2PR10MB4166.namprd10.prod.outlook.com;PTR:;CAT:OSPM;SFS:(376002)(39860400002)(136003)(396003)(366004)(346002)(36756003)(26005)(6496006)(8676002)(956004)(38350700002)(38100700002)(186003)(110136005)(8936002)(83380400001)(6486002)(66556008)(66476007)(52116002)(66946007)(103116003)(2616005)(1076003)(2906002)(5660300002)(4326008)(86362001)(316002)(478600001)(23200700001);DIR:OUT;SFP:1501; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?9hLSBNGIkc/Q+a65IIWYcTimwkGcPB//q+9DeHg+RW4Wgg3+SE9U2L72CfpW?= =?us-ascii?Q?RIwW49ss0j+8GI8sqktRkdIRfwce9KMEwKaH3uqS6HdeK+atLbEDuVzWXBdM?= =?us-ascii?Q?pfEBidOlVxPjr+XJMHiF7Xb3kWir2x9StNtxywXkHBJ1pZsGUHem3nPf/U3Y?= =?us-ascii?Q?m9vMeD2EAiMGYwHEBPKQjR/JWEFFyOxHJcMa/J1Jl6MAxSkucMOIdGfxQgrM?= =?us-ascii?Q?DZO396e0yaBENraNwfsnHJkMi3x0GVbpBXGrM+BYEedtrmAw8wYMBXQ2AI+f?= =?us-ascii?Q?lj/dWT4N24xB2KJFLTCZApEwwH9gaLVRtgFMB/h8/iu7L4jfOTuuQb4k32qX?= =?us-ascii?Q?fpPsAo7/ib6WVbPfyM4w9H3CAjcmIqIN1OAFX6vahfT/8DkBsPXVmllzbyXl?= =?us-ascii?Q?fcIdZGxnLagntHDbniV52qnm/HUMYcsaurR6W5cZqsVzSOQn7W3RQ8jHQC5W?= =?us-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Org: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 16c82270-6a3e-42c3-829d-08d96d8c9d76 X-MS-Exchange-CrossTenant-AuthSource: CH2PR10MB4166.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Sep 2021 21:08:15.6116 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 5PBZXuM1cr3/8bWWNoPs/J7OLYnYkLB39A8HzYclc18rdwoFlvjONqLVw8cmMcyI2qQXCSST9eTQvzIXontS34DF/hx/U4Zn5SVeHvTNTGg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB5211 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10094 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 adultscore=0 mlxscore=0 phishscore=0 malwarescore=0 suspectscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2108310000 definitions=main-2109010123 X-Proofpoint-GUID: 9ICeD3x-A4cfRapEoXlKj8hAJWLDIAdB X-Proofpoint-ORIG-GUID: 9ICeD3x-A4cfRapEoXlKj8hAJWLDIAdB Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org perf_events may sometimes throttle an event due to creating too many samples during a given timer tick. As of now, the perf tool will not report on throttling, which means this is a silent error. Implement a callback for the throttle and unthrottle events within the Python scripting engine, which can allow scripts to detect and report when events may have been lost due to throttling. The simplest script to report throttle events is: def throttle(*args): print("throttle" + repr(args)) def unthrottle(*args): print("unthrottle" + repr(args)) Signed-off-by: Stephen Brennan --- tools/perf/builtin-script.c | 13 ++++++++ .../scripting-engines/trace-event-python.c | 32 +++++++++++++++++++ tools/perf/util/trace-event.h | 3 ++ 3 files changed, 48 insertions(+) diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 064da7f3618d..072869a35f85 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -2492,6 +2492,17 @@ process_lost_event(struct perf_tool *tool, sample->tid); } +static int +process_throttle_event(struct perf_tool *tool __maybe_unused, + union perf_event *event, + struct perf_sample *sample, + struct machine *machine) +{ + if (scripting_ops && scripting_ops->process_throttle) + scripting_ops->process_throttle(event, sample, machine); + return 0; +} + static int process_finished_round_event(struct perf_tool *tool __maybe_unused, union perf_event *event, @@ -3652,6 +3663,8 @@ int cmd_script(int argc, const char **argv) .stat_config = process_stat_config_event, .thread_map = process_thread_map_event, .cpu_map = process_cpu_map_event, + .throttle = process_throttle_event, + .unthrottle = process_throttle_event, .ordered_events = true, .ordering_requires_timestamps = true, }, diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c index 69129e2aa7a1..c0c010350bc2 100644 --- a/tools/perf/util/scripting-engines/trace-event-python.c +++ b/tools/perf/util/scripting-engines/trace-event-python.c @@ -1422,6 +1422,37 @@ static void python_process_event(union perf_event *event, } } +static void python_process_throttle(union perf_event *event, + struct perf_sample *sample, + struct machine *machine) +{ + const char *handler_name; + PyObject *handler, *t; + + if (event->header.type == PERF_RECORD_THROTTLE) + handler_name = "throttle"; + else + handler_name = "unthrottle"; + handler = get_handler(handler_name); + if (!handler) + return; + + t = tuple_new(6); + if (!t) + return; + + tuple_set_u64(t, 0, event->throttle.time); + tuple_set_u64(t, 1, event->throttle.id); + tuple_set_u64(t, 2, event->throttle.stream_id); + tuple_set_s32(t, 3, sample->cpu); + tuple_set_s32(t, 4, sample->pid); + tuple_set_s32(t, 5, sample->tid); + + call_object(handler, t, handler_name); + + Py_DECREF(t); +} + static void python_do_process_switch(union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -2079,5 +2110,6 @@ struct scripting_ops python_scripting_ops = { .process_auxtrace_error = python_process_auxtrace_error, .process_stat = python_process_stat, .process_stat_interval = python_process_stat_interval, + .process_throttle = python_process_throttle, .generate_script = python_generate_script, }; diff --git a/tools/perf/util/trace-event.h b/tools/perf/util/trace-event.h index 54aadeedf28c..640981105788 100644 --- a/tools/perf/util/trace-event.h +++ b/tools/perf/util/trace-event.h @@ -90,6 +90,9 @@ struct scripting_ops { void (*process_stat)(struct perf_stat_config *config, struct evsel *evsel, u64 tstamp); void (*process_stat_interval)(u64 tstamp); + void (*process_throttle)(union perf_event *event, + struct perf_sample *sample, + struct machine *machine); int (*generate_script) (struct tep_handle *pevent, const char *outfile); }; -- 2.30.2