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: 10703443 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 288F215A8 for ; Wed, 28 Nov 2018 22:02:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 191222DEF9 for ; Wed, 28 Nov 2018 22:02:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0D6C72DF04; Wed, 28 Nov 2018 22:02:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9AD892DEF9 for ; Wed, 28 Nov 2018 22:02:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=QyU3t9IcuLp7CCHDiU0SZ9zJNdZGUKAEAmNaV69Y8+U=; b=mbErIaM5787CyeIexdKnh30l/k lP3sInWfQbWs/0wjjoPGjKsmDQNyc3IlpYlO30za/RNRD4Gbb87cnl0MVNr+k7uwXMaFau6q//Wg/ OqfV4mry82VFH9tDHF53F4lRh4QURzh1sWJ22j34bmW7kgKCVJxH5hQEbiO5RSNdZ/8txuYqp6LGZ BxEzDYdGNSQ5fDmve8PARW8UOZi/l4M9Vn1RbUJ2yMNBkuEraJhYMPi5abgrAqPWdmSW7kUPtD3km IIGpxAH+LaXVYiq2g38D9HEh3h9/YCTxit1fv4OxNEWecbft2HrowV+G1xWSQkDStJnO11Qu4To9Y pVnQ7nKQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gS7ut-00014b-Vf; Wed, 28 Nov 2018 22:02:44 +0000 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gS7ts-0008Ib-TE for linux-arm-kernel@lists.infradead.org; Wed, 28 Nov 2018 22:01:48 +0000 Received: by mail-pl1-x641.google.com with SMTP id u18so5473903plq.7 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=tOzGIxY1tBCVP4G6QynvfReOl5L5afkiJZkBq9jSBQ0Gyu7+qB7n0/TeIIMnNCK3IG IzbjRELuiZKVb1zW3jVneTB1ntJxehurMbGOlYsabygT9v/hsoGdV/6g008ZxMu5AdTs iKYxpOMi5i92UjpiKPP6H1iuG9MuyhHdHbTeUEf4/4Zx78dNS76RNxS+ZnKx10zvT/BS DlelMb1ZFHo5iKpTqHZ+1XJkOLQu9lmnL76rog4qfSYDjbe+s6dN9BnlO04ojcxRjB0d jcJd4i1FtE2Rdh05Y9iWuw3pWd6Z6e35E29Q4M7UnW068sB5pEQ+FS9kejazaD3w1rYw +djw== X-Gm-Message-State: AA+aEWYXcK9zIjGxVkHZ2KbKvKAO7D2Jv06kq5aG3ntx9ZOQpSHvCzFg xvVlx8UJdOED5RDJHcAGUINwEA== X-Google-Smtp-Source: AFSGD/VtZc2q+OMUOyBnH3TubVVJnHnUtm3odnJyulU8S8ItFb+ZTnHETA51KwyQd/75SxVV4l+H+Q== 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181128_140141_706412_A5F1FA5B X-CRM114-Status: GOOD ( 14.92 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, linux-s390@vger.kernel.org, alexander.shishkin@linux.intel.com, will.deacon@arm.com, hpa@zytor.com, heiko.carstens@de.ibm.com, adrian.hunter@intel.com, ast@kernel.org, suzuki.poulosi@arm.com, linux-arm-kernel@lists.infradead.org, gregkh@linuxfoundation.org, schwidefsky@de.ibm.com, namhyung@kernel.org, tglx@linutronix.de, jolsa@redhat.com, linux-kernel@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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);