Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp3794316ybi; Sun, 2 Jun 2019 23:49:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqxl4sUecu4zAQXkuZ+Nz6tDI+sA+hOo/fqlndlTfmmsOga2lqfxKG+R90dhjewN2Ps+jUO/ X-Received: by 2002:a17:902:b204:: with SMTP id t4mr27997354plr.285.1559544583150; Sun, 02 Jun 2019 23:49:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559544583; cv=none; d=google.com; s=arc-20160816; b=CxorH10pn7PJX8u3H6zxa0qlEge/8qD6pRX2D8MCkc5zdGkecPay4zCfAyt6P87b3n te2wtN91CsCr3n0oZrkJpK31jZCQxZL95/bpl3bc4oZ0CVPsTQ7WZxdSCm3S58q5vz8e PQwn8/Ej2SCYncpGxylULVtXX82P8qwaHL9wrsL0H0q2/D0vyTuCk4ue0V8zxUff6qvk p/RVnZUAMKvvEHqSbFZY0zY+GAqt76By57hT0xgtoChYwHDVYZlKvgs/wpWi2akF1gUJ HacNcLu0jo1Tzw+3zEDXHmr26iplRvydI04gWIErhEEegeLWY8Hrv8VkmKrnNLKNg4uw TV5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from; bh=ZFWwxlLWpg3CBxhIEN0R3LmnMMObJPJ3CkbX9w33gKs=; b=EgrcJn3geB+KbxqvTaw2bnyVJ+CHQzSLMiN1nH9vSFVCWNPSJ9yjAX2X48293/vpJr omahM4+OIwMIfiJqBiAxTR0ydXz90isGN6j4Abf3iHsEDJllftfTstT8gS+lvdsqoTxI GZB3VhIFIEDGhuJSIN0Ho06BSos+kGU9/i2bawc8NjhkqDXabXMjbVyEnV0y/p1erEJ8 MOqxwH4mq/WLqoDei4Y3LuSF1Z69fqE7jEklbF1kLtfrNHRWbH6dnup7ootrnuCT1zQ/ dtO9nF85ssF6XK6ChrZacSzdeJitFOyO4ItEHHPQw1cz8RPfStzR34CNzHqdQfoTD8rk XtKQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p7si15491434pls.253.2019.06.02.23.49.27; Sun, 02 Jun 2019 23:49:43 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727246AbfFCGrv (ORCPT + 99 others); Mon, 3 Jun 2019 02:47:51 -0400 Received: from smtp2200-217.mail.aliyun.com ([121.197.200.217]:48155 "EHLO smtp2200-217.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727291AbfFCGru (ORCPT ); Mon, 3 Jun 2019 02:47:50 -0400 X-Alimail-AntiSpam: AC=CONTINUE;BC=0.09180124|-1;CH=green;DM=CONTINUE|CONTINUE|true|0.416466-0.0537556-0.529779;FP=0|0|0|0|0|-1|-1|-1;HT=e02c03311;MF=han_mao@c-sky.com;NM=1;PH=DS;RN=4;RT=4;SR=0;TI=SMTPD_---.EglZUbk_1559544455; Received: from localhost(mailfrom:han_mao@c-sky.com fp:SMTPD_---.EglZUbk_1559544455) by smtp.aliyun-inc.com(10.147.42.197); Mon, 03 Jun 2019 14:47:35 +0800 From: Mao Han To: linux-kernel@vger.kernel.org Cc: Mao Han , Guo Ren , linux-csky@vger.kernel.org Subject: [PATCH V3 6/6] csky: Fix perf record in kernel/user space Date: Mon, 3 Jun 2019 14:46:25 +0800 Message-Id: <79c0094b29f2315045a9a2544c9837bcf6f78fea.1559544301.git.han_mao@c-sky.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org csky_pmu_event_init is called several times during the perf record initialzation. After configure the event counter in either kernel space or user space, csky_pmu_event_init is called twice with no attr specified. Configuration will be overwritten with sampling in both kernel space and user space. --all-kernel/--all-user is useless without this patch applied. Signed-off-by: Mao Han CC: Guo Ren CC: linux-csky@vger.kernel.org --- arch/csky/kernel/perf_event.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/csky/kernel/perf_event.c b/arch/csky/kernel/perf_event.c index de95005..011fd9b 100644 --- a/arch/csky/kernel/perf_event.c +++ b/arch/csky/kernel/perf_event.c @@ -983,6 +983,12 @@ static int csky_pmu_event_init(struct perf_event *event) struct hw_perf_event *hwc = &event->hw; int ret; + if (event->attr.type != PERF_TYPE_HARDWARE && + event->attr.type != PERF_TYPE_HW_CACHE && + event->attr.type != PERF_TYPE_RAW) { + return -ENOENT; + } + if (event->attr.exclude_user) csky_pmu.hpcr = BIT(2); else if (event->attr.exclude_kernel) -- 2.7.4