Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp7153280ybi; Mon, 8 Jul 2019 15:43:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqw7xICOy1Gu2uOrSUukPb2CvP3zihsqf117Ji1YqAoRnEC233szIBlQ3lgN+rthoVKzTOMn X-Received: by 2002:a17:90a:24e4:: with SMTP id i91mr29707683pje.9.1562625813226; Mon, 08 Jul 2019 15:43:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562625813; cv=none; d=google.com; s=arc-20160816; b=Q7c4N88N1moA1LQwVAREk/Yj+rC3SPYNQ3ivw+eDhrN/z6kMca2viBUFCGw6k7yCrq jTD73bAm7ziH7hzNfUlGkZaclFxAU3EIKoBW5y9tX/s+RZHfKdBlBXYbVJo3pWtUsgDI It6qnMX8DYbAi1AoMM95MLXFUm95w5ilNzJokhqbNhScJo6kSh1XhIFu96ZHzBFzB9nD bNlm+5RoPv4/2IoX001zL4m21N9hbJqV7jbF0yfHyB+3B15jKrpcQp2CaUQWl0YNKJwI KLAAFU9IGaUpT2jPbndJ3kCfwo0Czrn2QL5IoIlBzqCzLhm8BGErji2+gube6HeYOs6L ybRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=IxnXRwFEVsBRcHWVY1AUPNtwkkxS39pGXrbWoyZ4Lsw=; b=WEO9WabWJRE/c+bgbZDW0ao8ufhrNMfXF/DPqD9pOVQ7Pc7hDI822mAIvmOuC5xWPM kT3dt6NmzH+BOWf2h48jzcvyrOxNWI/Zb+WZW+/kKhJkTOf/J5IggvBS73HlBG30WHKH +/2MSPUqZy565Q/5sIIZZfaqk3vXL9/fszG8WKvAQjcB2s8+rIYqFpjJzrArEmEazszz oi/n6yX3oGtc2jPm/SoM27kVRle49x1O4tPtgODx13Dhdf7N9uTdtjcNY2pZoFcnWeWF kFwyL3KfX0NkzyPvfBx9+3RjFUFs7gBtGnoA64cw3df9oyYG0Iw8JOT2CcD7BGjnkb4e f2nA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b="Fp/JXrr1"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id k191si20251464pgd.25.2019.07.08.15.43.16; Mon, 08 Jul 2019 15:43:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b="Fp/JXrr1"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S2391540AbfGHQjb (ORCPT + 99 others); Mon, 8 Jul 2019 12:39:31 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:49986 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725836AbfGHQja (ORCPT ); Mon, 8 Jul 2019 12:39:30 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x68GXjUi132033; Mon, 8 Jul 2019 16:38:23 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=corp-2018-07-02; bh=IxnXRwFEVsBRcHWVY1AUPNtwkkxS39pGXrbWoyZ4Lsw=; b=Fp/JXrr1F/US89eAFmDqwrjS5ytA2Bk6p9MCtg0f8xvvLnuii2vH0qVLYDh2iG1Pgsvp Fhxa+zbXiqx4pVSX/XEfKdW/QnzSIGKWigQCN9GJzeZNb6UN47/xRrPf0Pv3E5uQH5QN DGAd/lg2Fi1JkHfP6mH737oN8ApJAkF97iZae7Or4Ofc//AViLIGwoY6mm5g67XIqxk3 dupyan40rxoQuHvCz6S9fL1fTbIqEmA2uxnFGktXJbZIC9Z+Wof/QKAQyVcQdKcHxSL2 9jT+IUMbvpNJ8yotyKnJN3Nty5H8nInzmilFW1bylL95WAwJjttP2LbHIk94sc9KUECN BA== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2120.oracle.com with ESMTP id 2tjm9qffyr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 08 Jul 2019 16:38:23 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x68Gbb8P034884; Mon, 8 Jul 2019 16:38:22 GMT Received: from pps.reinject (localhost [127.0.0.1]) by aserp3030.oracle.com with ESMTP id 2tjhpck953-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 08 Jul 2019 16:38:22 +0000 Received: from aserp3030.oracle.com (aserp3030.oracle.com [127.0.0.1]) by pps.reinject (8.16.0.27/8.16.0.27) with SMTP id x68GcMFp036252; Mon, 8 Jul 2019 16:38:22 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3030.oracle.com with ESMTP id 2tjhpck94t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 08 Jul 2019 16:38:22 +0000 Received: from abhmp0007.oracle.com (abhmp0007.oracle.com [141.146.116.13]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x68GcFBL000636; Mon, 8 Jul 2019 16:38:15 GMT Received: from localhost (/10.159.211.102) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 08 Jul 2019 09:38:14 -0700 Date: Mon, 8 Jul 2019 12:38:11 -0400 From: Kris Van Hees To: Peter Zijlstra Cc: Kris Van Hees , netdev@vger.kernel.org, bpf@vger.kernel.org, dtrace-devel@oss.oracle.com, linux-kernel@vger.kernel.org, rostedt@goodmis.org, mhiramat@kernel.org, acme@kernel.org, ast@kernel.org, daniel@iogearbox.net, Chris Mason Subject: Re: [PATCH 1/1] tools/dtrace: initial implementation of DTrace Message-ID: <20190708163811.GB20847@oracle.com> References: <201907040313.x643D8Pg025951@userv0121.oracle.com> <201907040314.x643EUoA017906@aserv0122.oracle.com> <20190704130509.GO3402@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190704130509.GO3402@hirez.programming.kicks-ass.net> User-Agent: Mutt/1.5.23 (2014-03-12) X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9312 signatures=668688 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1907080206 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 04, 2019 at 03:05:09PM +0200, Peter Zijlstra wrote: > On Wed, Jul 03, 2019 at 08:14:30PM -0700, Kris Van Hees wrote: > > +int dt_bpf_attach(int event_id, int bpf_fd) > > +{ > > + int event_fd; > > + int rc; > > + struct perf_event_attr attr = {}; > > + > > + attr.type = PERF_TYPE_TRACEPOINT; > > + attr.sample_type = PERF_SAMPLE_RAW; > > + attr.sample_period = 1; > > + attr.wakeup_events = 1; > > + attr.config = event_id; > > + > > + /* Register the event (based on its id), and obtain a fd. */ > > + event_fd = perf_event_open(&attr, -1, 0, -1, 0); > > + if (event_fd < 0) { > > + perror("sys_perf_event_open"); > > + return -1; > > + } > > + > > + /* Enable the probe. */ > > + rc = ioctl(event_fd, PERF_EVENT_IOC_ENABLE, 0); > > AFAICT you didn't use attr.disabled = 1, so this IOC_ENABLE is > completely superfluous. Oh yes, good point (and the same applies to the dt_buffer.c code where I set up the events that own each buffer - no point in doing an explicit enable there eiteher). Thanks for catching this! > > + if (rc < 0) { > > + perror("PERF_EVENT_IOC_ENABLE"); > > + return -1; > > + } > > + > > + /* Associate the BPF program with the event. */ > > + rc = ioctl(event_fd, PERF_EVENT_IOC_SET_BPF, bpf_fd); > > + if (rc < 0) { > > + perror("PERF_EVENT_IOC_SET_BPF"); > > + return -1; > > + } > > + > > + return 0; > > +}