Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756299AbdLTSK6 (ORCPT ); Wed, 20 Dec 2017 13:10:58 -0500 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:36866 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1756138AbdLTSKv (ORCPT ); Wed, 20 Dec 2017 13:10:51 -0500 From: Song Liu To: Peter Zijlstra CC: Steven Rostedt , "mingo@redhat.com" , David Miller , "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "Daniel Borkmann" , Kernel Team Subject: Re: [PATCH v5 3/6] perf: implement pmu perf_kprobe Thread-Topic: [PATCH v5 3/6] perf: implement pmu perf_kprobe Thread-Index: AQHTbuP6FXlIEaishkKffEl7NkoqDKNMFakAgAADLwCAAITrAA== Date: Wed, 20 Dec 2017 18:10:11 +0000 Message-ID: References: <20171206224518.3598254-1-songliubraving@fb.com> <20171206224518.3598254-6-songliubraving@fb.com> <20171220100301.bvacqfua4hj2onzq@hirez.programming.kicks-ass.net> <20171220101426.cquh5uv4bgj4bk7y@hirez.programming.kicks-ass.net> In-Reply-To: <20171220101426.cquh5uv4bgj4bk7y@hirez.programming.kicks-ass.net> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: Apple Mail (2.3273) x-originating-ip: [2620:10d:c090:200::5:5303] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;CY4PR15MB1511;20:1Yhl2fgVCvobH+vF/eOcyPHpHX0PkDCwRqycn2WBjgcUzw//MwoBNiyn0TWExIcl9utz8p+thMEpwRfclqkIhFbrqQxuFgcrzbZnQL/59S5q1e6rGWJdrRjnTEy/FiRKByVA9PEh4ns6fdiwjf30eon2dI6GY0LUwYv31arpfMk= x-ms-exchange-antispam-srfa-diagnostics: SSOS; x-ms-office365-filtering-correlation-id: a27bfeea-59df-49f4-4256-08d547d4e924 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(5600026)(4604075)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(2017052603307)(7153060);SRVR:CY4PR15MB1511; x-ms-traffictypediagnostic: CY4PR15MB1511: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(6040470)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93001095)(3231023)(11241501184)(3002001)(6041268)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(6072148)(201708071742011);SRVR:CY4PR15MB1511;BCL:0;PCL:0;RULEID:(100000803101)(100110400095);SRVR:CY4PR15MB1511; x-forefront-prvs: 0527DFA348 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(39380400002)(396003)(39860400002)(376002)(346002)(366004)(24454002)(189003)(199004)(99286004)(2900100001)(33656002)(2906002)(4326008)(3660700001)(105586002)(93886005)(3280700002)(106356001)(36756003)(6916009)(53936002)(77096006)(2950100002)(6486002)(6436002)(6246003)(97736004)(76176011)(229853002)(14454004)(8936002)(25786009)(6506007)(53546011)(478600001)(50226002)(5660300001)(7736002)(6512007)(68736007)(86362001)(81166006)(82746002)(57306001)(316002)(6116002)(305945005)(83716003)(8676002)(54906003)(81156014)(102836004);DIR:OUT;SFP:1102;SCL:1;SRVR:CY4PR15MB1511;H:CY4PR15MB1512.namprd15.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-ID: MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: a27bfeea-59df-49f4-4256-08d547d4e924 X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Dec 2017 18:10:11.0712 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 8ae927fe-1255-47a7-a2af-5f3a069daaa2 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR15MB1511 X-OriginatorOrg: fb.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-12-20_07:,, signatures=0 X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by mail.home.local id vBKIBGQI005134 Content-Length: 2285 Lines: 75 > On Dec 20, 2017, at 2:14 AM, Peter Zijlstra wrote: > > On Wed, Dec 20, 2017 at 11:03:01AM +0100, Peter Zijlstra wrote: >> On Wed, Dec 06, 2017 at 02:45:15PM -0800, Song Liu wrote: >>> @@ -8537,7 +8620,7 @@ static int perf_event_set_filter(struct perf_event *event, void __user *arg) >>> char *filter_str; >>> int ret = -EINVAL; >>> >>> - if ((event->attr.type != PERF_TYPE_TRACEPOINT || >>> + if ((!perf_event_is_tracing(event) || >>> !IS_ENABLED(CONFIG_EVENT_TRACING)) && >>> !has_addr_filter(event)) >>> return -EINVAL; >> >> You actually missed an instance later in this same function... fixing >> that. > > > @@ -8518,23 +8601,19 @@ perf_event_set_addr_filter(struct perf_e > > static int perf_event_set_filter(struct perf_event *event, void __user *arg) > { > - char *filter_str; > int ret = -EINVAL; > - > - if ((event->attr.type != PERF_TYPE_TRACEPOINT || > - !IS_ENABLED(CONFIG_EVENT_TRACING)) && > - !has_addr_filter(event)) > - return -EINVAL; > + char *filter_str; > > filter_str = strndup_user(arg, PAGE_SIZE); > if (IS_ERR(filter_str)) > return PTR_ERR(filter_str); > > - if (IS_ENABLED(CONFIG_EVENT_TRACING) && > - event->attr.type == PERF_TYPE_TRACEPOINT) > - ret = ftrace_profile_set_filter(event, event->attr.config, > - filter_str); > - else if (has_addr_filter(event)) > +#ifdef CONFIG_EVENT_TRACING > + if (perf_event_is_tracing(event)) > + ret = ftrace_profile_set_filter(event, event->attr.config, filter_str); > + else > +#endif > + if (has_addr_filter(event)) > ret = perf_event_set_addr_filter(event, filter_str); > > kfree(filter_str); > > > > Is that right? Yeah, this is right and neat. Thanks a lot for your help on this. I think there is one more thing to change: diff --git i/kernel/events/core.c w/kernel/events/core.c index a906f30..516ff9b 100644 --- i/kernel/events/core.c +++ w/kernel/events/core.c @@ -8226,7 +8226,7 @@ static int perf_event_set_bpf_prog(struct perf_event *event, u32 prog_fd) static void perf_event_free_bpf_prog(struct perf_event *event) { - if (event->attr.type != PERF_TYPE_TRACEPOINT) { + if (!perf_event_is_tracing(event)) { perf_event_free_bpf_handler(event); return; } Thanks, Song