Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp4865615ybi; Mon, 3 Jun 2019 19:26:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqykHdcULfSGKdJVdGUvyEOxtQeynCUOjin83CbIqmfxrc3gJ4x2luOav1Oq3CjNNhtgNqM/ X-Received: by 2002:a63:5443:: with SMTP id e3mr32211412pgm.265.1559615208828; Mon, 03 Jun 2019 19:26:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559615208; cv=none; d=google.com; s=arc-20160816; b=dfINJi1rt8cXuZpG9SKzRF8cFAwAR+6Dr3t7hDvs4yHrmY5b3h1iZ4LVM5LAwTVDjK Kztv/nEF/lHdxK0v8jBkrsIvrOZ1hwx1VBBDYIc+6ttErxPkuXIAhY+uP8EGRmrTI4JX 3m8hmHVS2pgPHBIaLlFaQqi9WBt2edIuMLPAvsHO3kyGSgYbhqinuVtuIjW/DouL8d9z WdeTmY77czHNTArNvMHjBZr4fAkzb58ymVyuBfwZzj6H4myfWoGXpMiqbOMffyArUfBT Do58Ol+pVC3j3XMA16BEmhIhG1w3DVF9CLJzXRrxZBdscOsyoPkwFu2gR5nqUqai6dwe 0g9w== 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=953Fmpxoe5BRE2aGgKiDo3eHcoukuq1R5gHORzJAqj0=; b=Y57roir9Aa/aOdeOCIozFAGI3KxRdZoIKPo0vtTzTOI/rBepE7BGV8PEGHUXKkII6x brJe189G+FEB1K8ezFaswhSrUH52iNei1QwzbZO5u32gr8fNLgfkG++ncPlhJc3ScWyK JZ+WDKFX9V3TXmAAjmvuYidr7X3BrPbQuzAOZcyI2f/FhhVQm/j88sWHR8GungEBRUgV 6sRLNaYn4we/BVRrIOi8hVCwt7dfY/wmFN0k+dtdTkWCn4CDv2E+QP7IjbzW3nM5U70T 9FWn4ee85f1HIJoKrJS9wIGxn4c8vqVgwpX+WaX5jI6kw9gXxczEcYNuNPXUCWnxJtf2 wpwQ== 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 bc10si14148100plb.43.2019.06.03.19.26.33; Mon, 03 Jun 2019 19:26:48 -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 S1726700AbfFDCZQ (ORCPT + 99 others); Mon, 3 Jun 2019 22:25:16 -0400 Received: from smtp2200-217.mail.aliyun.com ([121.197.200.217]:50973 "EHLO smtp2200-217.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726369AbfFDCZM (ORCPT ); Mon, 3 Jun 2019 22:25:12 -0400 X-Alimail-AntiSpam: AC=CONTINUE;BC=0.09231208|-1;CH=green;DM=CONTINUE|CONTINUE|true|0.412593-0.0549792-0.532428;FP=4993171859445338579|2|2|3|0|-1|-1|-1;HT=e02c03275;MF=han_mao@c-sky.com;NM=1;PH=DS;RN=4;RT=4;SR=0;TI=SMTPD_---.Eh6wegv_1559615110; Received: from localhost(mailfrom:han_mao@c-sky.com fp:SMTPD_---.Eh6wegv_1559615110) by smtp.aliyun-inc.com(10.147.41.120); Tue, 04 Jun 2019 10:25:10 +0800 From: Mao Han To: linux-kernel@vger.kernel.org Cc: Mao Han , linux-csky@vger.kernel.org, Guo Ren Subject: [PATCH V4 6/6] csky: Fix perf record in kernel/user space Date: Tue, 4 Jun 2019 10:24:00 +0800 Message-Id: <3a6a5379b4f692773d82ff5ad18a7b22ceaf5a80.1559614824.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 dc84dc7..e3308ab 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