From patchwork Wed Nov 28 22:01:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 152355 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1632846ljp; Wed, 28 Nov 2018 14:01:34 -0800 (PST) X-Google-Smtp-Source: AJdET5fdaN5NXI5+f8Nin/phpJOKJ/tJDDbDSscJO9PBx4r70+Ql0GUO9OkzS/zemJQRQzDp5udr X-Received: by 2002:a62:14d1:: with SMTP id 200mr39724915pfu.103.1543442494401; Wed, 28 Nov 2018 14:01:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543442494; cv=none; d=google.com; s=arc-20160816; b=MUz0KBB9nnrbIVShJZ+kSv6pBLkkRs1UR1PqHMfKINwTWePUnjPh48pYR8hjoawiFh sIihapg/mCjV90t9l9ioFFUZWj3wF5JiBueyD26Tw4cOlfUCdQ+sbmK8hP+57DXQGEum 2YBAaLPYkOp0Pme53QyXiUvsC24UQdwRNzlTiIPfjSH3vQy0NJUt6tws+ZiJoADHClcI MJZsKKmilhO6WRuPzya8ZXq9qKMfXkHi6GdGr9+KFVQbjcqj8EEqMaXfCMMnBdNX3y4S mTRJY7OoA1myPtYb1LygnIUCOCOo+L33f31hKcxu63Vbjhe3aIhbgGhx/7/FJJbYhAcF 0wqQ== 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:message-id:date :subject:cc:to:from:dkim-signature; bh=rRFTiKpTPNMFVfmzVrsI37RlXOAn7jocrARDPWf4AIU=; b=k59LIpA1N2oMlDocCPT75Wb9yeF/e94XYcjkqtcPCEwrAii27AMGtbAq3FNPXYDwVN R2QJ5Dr94TS0V8IYXNfBiKJ8OK0jJU8sfCmiodFLfP3pPeUNhO4Gm3MFVAlX+WO+hkmT ZV4ROdOSRtEf5mgAuubU9N8xikeTPyCuERxI4xn8qZuadmgzclkFqi8szfVaM+8u/CnA Omf9HofyAlDnuDTq6bm8F4JtWvtvNBPL2I2VdM/Q4mJTpAurbEdx/DpI6yxGZpkLTauu 58QHhh4XzzobNTDuL7IuYYMpmCxnvthdI8WmhhhS3ZuD8Y8TJXbDti4Swag0oOyawFuL egng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="iWfL/vzJ"; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s19si8230002plp.151.2018.11.28.14.01.34; Wed, 28 Nov 2018 14:01:34 -0800 (PST) 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=@linaro.org header.s=google header.b="iWfL/vzJ"; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726751AbeK2JEg (ORCPT + 32 others); Thu, 29 Nov 2018 04:04:36 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:37041 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726702AbeK2JEf (ORCPT ); Thu, 29 Nov 2018 04:04:35 -0500 Received: by mail-pl1-f193.google.com with SMTP id b5so18059936plr.4 for ; Wed, 28 Nov 2018 14:01:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=rRFTiKpTPNMFVfmzVrsI37RlXOAn7jocrARDPWf4AIU=; b=iWfL/vzJqLH03KRjkz2aSQpdRp0VFGKWA4Txo78bHC7lxCTCElxAS3ptgxvjANWUI0 /4HbjaX0eZsQKtNpeDr3amrDJURrnCHtt6FgFeH1rGQo5h8uShBpLu01fBkxF/oHl+B/ 4gaGPOD4VTA35b6G/FqMFWCYXiycV35FIVACI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=rRFTiKpTPNMFVfmzVrsI37RlXOAn7jocrARDPWf4AIU=; b=a1E595x9zYKOxKFMZTECSS7xa85y/Mfh/vlb+IBXJE1Oec6bmcTObLDPQiL22casf2 yLU4giC/uR7hoVxdrULBUhFyl023BNi3QHC2JMaJCoyKcX4+HHWE77bgIeh6Kca5/V9X KwqnXKwR7b3PvaiLPZeohVIBPcMeQ3Hz/OXSkGc2Gfk+woE+DklTJX4P/QyZ1imCnq/F YVwVZvScfAOKQaBSgJINrI8i6ndLcS2w8QOYYzcdojatD6ialEtJfTI7DQ9eIWeFV+ui ch5NgvD8FYOBigABZJIMdYQ3QXTBFahOZtSaCYlhajbEFiv3lVwKQNPNCyiE60fsRby9 TXXA== X-Gm-Message-State: AA+aEWZrQH06VAWBUyvWfb91ymNBIfk8QryKK4rnmq3n5h6k/9uqwAd8 ST2srZSMpauPW2+KdkTbkk0hsw== X-Received: by 2002:a17:902:7c82:: with SMTP id y2mr38089963pll.33.1543442490423; Wed, 28 Nov 2018 14:01:30 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id 12sm8698051pgd.35.2018.11.28.14.01.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 28 Nov 2018 14:01:29 -0800 (PST) From: Mathieu Poirier To: acme@kernel.org, peterz@infradead.org, mingo@redhat.com Cc: tglx@linutronix.de, alexander.shishkin@linux.intel.com, schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com, will.deacon@arm.com, mark.rutland@arm.com, jolsa@redhat.com, namhyung@kernel.org, adrian.hunter@intel.com, ast@kernel.org, gregkh@linuxfoundation.org, hpa@zytor.com, suzuki.poulosi@arm.com, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v4 6/6] perf tools: Use ioctl function to send sink configuration to kernel Date: Wed, 28 Nov 2018 15:01:18 -0700 Message-Id: <1543442478-31465-7-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1543442478-31465-1-git-send-email-mathieu.poirier@linaro.org> References: <1543442478-31465-1-git-send-email-mathieu.poirier@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The communication of sink information for a trace session doesn't work when more than one CPU is involved in the scenario due to the static nature of sysFS. As such communicate the sink information to each event by using the driver's sink configuration information and an ioctl command. Signed-off-by: Mathieu Poirier --- tools/perf/arch/arm/util/cs-etm.c | 49 +++++++++++++++++++++++++++++++++++++-- tools/perf/util/evsel.c | 7 ++++++ tools/perf/util/evsel.h | 1 + 3 files changed, 55 insertions(+), 2 deletions(-) -- 2.7.4 diff --git a/tools/perf/arch/arm/util/cs-etm.c b/tools/perf/arch/arm/util/cs-etm.c index d8081c2e6d44..4f0563b99a07 100644 --- a/tools/perf/arch/arm/util/cs-etm.c +++ b/tools/perf/arch/arm/util/cs-etm.c @@ -619,6 +619,26 @@ static FILE *cs_device__open_file(const char *name) } +static int cs_etm_check_drv_config_term(const char *name) +{ + struct stat st; + char path[PATH_MAX]; + const char *sysfs; + + /* CS devices are all found under sysFS */ + sysfs = sysfs__mountpoint(); + if (!sysfs) + return -EINVAL; + + snprintf(path, PATH_MAX, + "%s" CS_BUS_DEVICE_PATH "%s", sysfs, name); + + if (stat(path, &st) < 0) + return -EINVAL; + + return 0; +} + static int __printf(2, 3) cs_device__print_file(const char *name, const char *fmt, ...) { va_list args; @@ -635,7 +655,7 @@ static int __printf(2, 3) cs_device__print_file(const char *name, const char *fm return ret; } -static int cs_etm_set_drv_config_term(struct perf_evsel_config_term *term) +static int cs_etm_set_drv_config_term_sysfs(struct perf_evsel_config_term *term) { int ret; char enable_sink[ENABLE_SINK_MAX]; @@ -650,6 +670,21 @@ static int cs_etm_set_drv_config_term(struct perf_evsel_config_term *term) return 0; } +static int cs_etm_set_drv_config_term_ioctl(struct perf_evsel *evsel, + struct perf_evsel_config_term *term) +{ + int ret; + const char *drv_cfg = term->val.drv_cfg; + + /* First check the input */ + ret = cs_etm_check_drv_config_term(drv_cfg); + if (ret) + return ret; + + /* All good, apply configuration */ + return perf_evsel__apply_drv_config(evsel, drv_cfg); +} + int cs_etm_set_drv_config(struct perf_evsel *evsel, struct perf_evsel_config_term **err_term) { @@ -660,7 +695,17 @@ int cs_etm_set_drv_config(struct perf_evsel *evsel, if (term->type != PERF_EVSEL__CONFIG_TERM_DRV_CFG) continue; - err = cs_etm_set_drv_config_term(term); + /* First try the new interface, i.e ioctl() */ + err = cs_etm_set_drv_config_term_ioctl(evsel, term); + if (!err) + continue; + + /* + * Something went wrong, we are probably working with an older + * kernel. As such use the sysFS interface, which will only + * work for per-thread scenarios. + */ + err = cs_etm_set_drv_config_term_sysfs(term); if (err) { *err_term = term; break; diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 6d187059a373..a0374dab843f 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -1195,6 +1195,13 @@ static int perf_evsel__append_filter(struct perf_evsel *evsel, return -1; } +int perf_evsel__apply_drv_config(struct perf_evsel *evsel, const char *config) +{ + return perf_evsel__run_ioctl(evsel, + PERF_EVENT_IOC_SET_DRV_CONFIG, + (void *)config); +} + int perf_evsel__append_tp_filter(struct perf_evsel *evsel, const char *filter) { return perf_evsel__append_filter(evsel, "(%s) && (%s)", filter); diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h index 3147ca76c6fc..30083b0ae62c 100644 --- a/tools/perf/util/evsel.h +++ b/tools/perf/util/evsel.h @@ -276,6 +276,7 @@ int perf_evsel__append_tp_filter(struct perf_evsel *evsel, const char *filter); int perf_evsel__append_addr_filter(struct perf_evsel *evsel, const char *filter); int perf_evsel__apply_filter(struct perf_evsel *evsel, const char *filter); +int perf_evsel__apply_drv_config(struct perf_evsel *evsel, const char *config); int perf_evsel__enable(struct perf_evsel *evsel); int perf_evsel__disable(struct perf_evsel *evsel);