Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp5257169ybi; Tue, 4 Jun 2019 03:59:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqygLyHVWZQ/8d5fp4AA6jsn3HL2+GijBBsMqJsEPzuHmou9frsmjATQ2uZFEsWQer1gKD2e X-Received: by 2002:a63:dc09:: with SMTP id s9mr35035031pgg.425.1559645961836; Tue, 04 Jun 2019 03:59:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559645961; cv=none; d=google.com; s=arc-20160816; b=gbysWFqBiDZAKQXEylQRUJXDZvjJcwM3Ceky1OitYLgwR4LkV3wB9GqLYNejBDW26j T0XeKJSdOTXw1FIafurLJJVJSZNEm4qe95XgGuGJzkjE2ONg9fi6ece8gJt7DPj/1qnF uwAwgEA3Wfr8ce9j2qo+dM7Mz7iaaC0vlw/ds8kp2QdRAMSPRYgcd9y7pAuC580cWtbe M1ZApdEpuvz5iqrvUCQ5E2cPATAURmGmBLvnTl7uUMS6jdHDMcFsNvfGBTtTJsRtvsev qupa8QWhXmLvbN6Gtg0OsPM/r/sqXsMjTgcl714nQUc1ejmeJI96MVijqROjEHV281el V0jg== 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=raN6Fytu1eJ0yvwKQWQixDkydkqfzjzH+u8hqxoAxig=; b=nYUHZZnB12+sLg8REw6cYEa2cgq29FPIfjfM/CjxHew1S/Ap852yg2rR6NR4BCQEUU 1481XcEb+UmXuzrBgTcawCoce4QCzAFBGwF3hUilJ32JB50wlgc7yj2wXDPZ6mK61Av2 xnr1d8qF1NSV2tc+mfpAH3XpRb/OIMNywqOCjfuMSLDGuTjyAwsGn4W6Y17U4nj4h575 s2JR2gA68C0fXUc6iPEuD3xn5rsyjwNNGEKMpiKqxMye4NRWUm8DYQZCRHCajNg4Vkd4 BQHni0Cu83ZIA0Dvc9GlzHczKWGqOBwTOeMRa0xYSl8qBkt01naizfWWvdD2TEvoSNNg 68nQ== 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 c184si20855220pga.99.2019.06.04.03.59.04; Tue, 04 Jun 2019 03:59:21 -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 S1727597AbfFDK4Y (ORCPT + 99 others); Tue, 4 Jun 2019 06:56:24 -0400 Received: from smtp2200-217.mail.aliyun.com ([121.197.200.217]:52391 "EHLO smtp2200-217.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726877AbfFDK4M (ORCPT ); Tue, 4 Jun 2019 06:56:12 -0400 X-Alimail-AntiSpam: AC=CONTINUE;BC=0.07489662|-1;CH=green;DM=CONTINUE|CONTINUE|true|0.122591-0.00828454-0.869125;FP=0|0|0|0|0|-1|-1|-1;HT=e02c03299;MF=han_mao@c-sky.com;NM=1;PH=DS;RN=4;RT=4;SR=0;TI=SMTPD_---.EhJB.ip_1559645769; Received: from localhost(mailfrom:han_mao@c-sky.com fp:SMTPD_---.EhJB.ip_1559645769) by smtp.aliyun-inc.com(10.147.40.2); Tue, 04 Jun 2019 18:56:09 +0800 From: Mao Han To: linux-kernel@vger.kernel.org Cc: Mao Han , linux-csky@vger.kernel.org, Guo Ren Subject: [PATCH V5 6/6] csky: Fix perf record in kernel/user space Date: Tue, 4 Jun 2019 18:54:49 +0800 Message-Id: <210ca538c85e6f1b9f1539fd9f69cc59d046dc11.1559644961.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 | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/arch/csky/kernel/perf_event.c b/arch/csky/kernel/perf_event.c index 499427e..13a254e 100644 --- a/arch/csky/kernel/perf_event.c +++ b/arch/csky/kernel/perf_event.c @@ -976,15 +976,6 @@ static int csky_pmu_event_init(struct perf_event *event) struct hw_perf_event *hwc = &event->hw; int ret; - if (event->attr.exclude_user) - csky_pmu.hpcr = BIT(2); - else if (event->attr.exclude_kernel) - csky_pmu.hpcr = BIT(3); - else - csky_pmu.hpcr = BIT(2) | BIT(3); - - csky_pmu.hpcr |= BIT(1) | BIT(0); - switch (event->attr.type) { case PERF_TYPE_HARDWARE: if (event->attr.config >= PERF_COUNT_HW_MAX) @@ -993,21 +984,32 @@ static int csky_pmu_event_init(struct perf_event *event) if (ret == HW_OP_UNSUPPORTED) return -ENOENT; hwc->idx = ret; - return 0; + break; case PERF_TYPE_HW_CACHE: ret = csky_pmu_cache_event(event->attr.config); if (ret == CACHE_OP_UNSUPPORTED) return -ENOENT; hwc->idx = ret; - return 0; + break; case PERF_TYPE_RAW: if (hw_raw_read_mapping[event->attr.config] == NULL) return -ENOENT; hwc->idx = event->attr.config; - return 0; + break; default: return -ENOENT; } + + if (event->attr.exclude_user) + csky_pmu.hpcr = BIT(2); + else if (event->attr.exclude_kernel) + csky_pmu.hpcr = BIT(3); + else + csky_pmu.hpcr = BIT(2) | BIT(3); + + csky_pmu.hpcr |= BIT(1) | BIT(0); + + return 0; } /* starts all counters */ -- 2.7.4