From patchwork Sun Nov 12 23:40:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Song Liu X-Patchwork-Id: 837300 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=fb.com header.i=@fb.com header.b="JHF2Fnor"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3yZqyY302Nz9s84 for ; Mon, 13 Nov 2017 10:40:37 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751241AbdKLXkV (ORCPT ); Sun, 12 Nov 2017 18:40:21 -0500 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:55632 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750985AbdKLXkS (ORCPT ); Sun, 12 Nov 2017 18:40:18 -0500 Received: from pps.filterd (m0109333.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id vACNdufP004539 for ; Sun, 12 Nov 2017 15:40:18 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=facebook; bh=IekIUK8eSSD6taTWUQBBmqdPMQWASTqZ400I4asGOAU=; b=JHF2FnorlBsG68wPRbO6pSHIZdmPjWHFqxWSo9TrH+ng0AEult4mz9/CA6lW61Ui5iM/ 4eU/il5Xvgy6z7YHtD3ElketTIucqwvkxakZ631F8TiVjb6ggwaENT+Jb+ILtrHaRl5T xhPXK3lmKAyzrVfgzERsnmRfWyU2zJo0Gro= Received: from mail.thefacebook.com ([199.201.64.23]) by mx0a-00082601.pphosted.com with ESMTP id 2e6xyar30e-6 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Sun, 12 Nov 2017 15:40:18 -0800 Received: from mx-out.facebook.com (192.168.52.123) by PRN-CHUB08.TheFacebook.com (192.168.16.18) with Microsoft SMTP Server id 14.3.361.1; Sun, 12 Nov 2017 15:40:17 -0800 Received: by devbig102.frc2.facebook.com (Postfix, from userid 4523) id 2FE51428249D; Sun, 12 Nov 2017 15:40:16 -0800 (PST) Smtp-Origin-Hostprefix: devbig From: Song Liu Smtp-Origin-Hostname: devbig102.frc2.facebook.com To: , , , , , , CC: , Song Liu Smtp-Origin-Cluster: frc2c02 Subject: [RFC] perf_event_open.2: add new type PERF_TYPE_PROBE Date: Sun, 12 Nov 2017 15:40:09 -0800 Message-ID: <20171112234014.2983360-4-songliubraving@fb.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20171112234014.2983360-1-songliubraving@fb.com> References: <20171112234014.2983360-1-songliubraving@fb.com> X-FB-Internal: Safe MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-11-12_10:, , signatures=0 X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org A new type PERF_TYPE_PROBE is being added to perf_event_attr. This patch adds information about this type. Note: the following two flags are also added to the man page. They are from perf_event.h in latest kernel repo. However, they are not related to PERF_TYPE_PROBE. Therefore, their usage are not included in this patch. write_backward : 1 namespaces : 1 Signed-off-by: Song Liu --- man2/perf_event_open.2 | 82 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 80 insertions(+), 2 deletions(-) diff --git a/man2/perf_event_open.2 b/man2/perf_event_open.2 index 03dc748..a37b78b 100644 --- a/man2/perf_event_open.2 +++ b/man2/perf_event_open.2 @@ -205,7 +205,12 @@ for the event being created. struct perf_event_attr { __u32 type; /* Type of event */ __u32 size; /* Size of attribute structure */ - __u64 config; /* Type-specific configuration */ + + /* Type-specific configuration */ + union { + __u64 config; + __u64 probe_desc; /* ptr to struct probe_desc */ + }; union { __u64 sample_period; /* Period of sampling */ @@ -244,8 +249,13 @@ struct perf_event_attr { due to exec */ use_clockid : 1, /* use clockid for time fields */ context_switch : 1, /* context switch data */ + write_backward : 1, /* Write ring buffer from end to beginning */ + namespaces : 1, /* include namespaces data */ - __reserved_1 : 37; + /* For PERF_TYPE_PROBE */ + is_uprobe : 1, /* 0 for kprobe, 1 for uprobe */ + is_return : 1, /* 0 for [k,u]probe, 1 for [k,u]retprobe */ + __reserved_1 : 33; union { __u32 wakeup_events; /* wakeup every n events */ @@ -336,6 +346,13 @@ field. For instance, .I /sys/bus/event_source/devices/cpu/type contains the value for the core CPU PMU, which is usually 4. +.TP +.BR PERF_TYPE_PROBE " (since Linux 4.TBD)" +This indicates a kprobe or uprobe should be created and +attached to the file descriptor. +See fields +.IR probe_desc ", " is_uprobe ", and " is_return +for more details. .RE .TP .I "size" @@ -627,6 +644,67 @@ then leave .I config set to zero. Its parameters are set in other places. +.PP +If +.I type +is +.BR PERF_TYPE_PROBE , +.I probe_desc +is used instead of +.IR config . +.RE +.TP +.I probe_desc +The +.I probe_desc +field is used with +.I type +of +.BR PERF_TYPE_PROBE , +to save a pointer to struct probe_desc: +.PP +.in +8n +.EX +struct probe_desc { + union { + __aligned_u64 func; + __aligned_u64 path; + }; + union { + __aligned_u64 addr; + __u64 offset; + }; +}; +.EE +Different fields of struct probe_desc are used to describe kprobes +and uprobes. For kprobes: use +.I func +and +.IR offset , +or use +.I addr +and leave +.I func +as NULL. For uprobe: use +.I path +and +.IR offset . +.RE +.TP +.IR is_uprobe ", " is_return +These two bits are used with +.I type +of +.BR PERF_TYPE_PROBE , +to specify type of the probe: +.PP +.in +8n +.EX +is_uprobe == 0, is_return == 0: kprobe +is_uprobe == 0, is_return == 1: kretprobe +is_uprobe == 1, is_return == 0: uprobe +is_uprobe == 1, is_return == 1: uretprobe +.EE .RE .TP .IR sample_period ", " sample_freq