From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BE7BAC433E6 for ; Tue, 16 Feb 2021 10:41:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7E5B164DAF for ; Tue, 16 Feb 2021 10:41:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229703AbhBPKlC (ORCPT ); Tue, 16 Feb 2021 05:41:02 -0500 Received: from foss.arm.com ([217.140.110.172]:60314 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230060AbhBPKkq (ORCPT ); Tue, 16 Feb 2021 05:40:46 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7F5831FB; Tue, 16 Feb 2021 02:40:00 -0800 (PST) Received: from [192.168.0.130] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3C9BE3F73B; Tue, 16 Feb 2021 02:39:57 -0800 (PST) Subject: Re: [PATCH V3 08/14] coresight: core: Add support for dedicated percpu sinks To: Mathieu Poirier , Suzuki K Poulose Cc: linux-arm-kernel@lists.infradead.org, coresight@lists.linaro.org, mike.leach@linaro.org, lcherian@marvell.com, linux-kernel@vger.kernel.org References: <1611737738-1493-1-git-send-email-anshuman.khandual@arm.com> <1611737738-1493-9-git-send-email-anshuman.khandual@arm.com> <20210204183446.GA1636242@xps15> From: Anshuman Khandual Message-ID: <72bd5139-a6e1-64c0-c111-818bc04a81b8@arm.com> Date: Tue, 16 Feb 2021 16:10:18 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20210204183446.GA1636242@xps15> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2/5/21 12:04 AM, Mathieu Poirier wrote: > On Thu, Jan 28, 2021 at 09:16:34AM +0000, Suzuki K Poulose wrote: >> On 1/27/21 8:55 AM, Anshuman Khandual wrote: >>> Add support for dedicated sinks that are bound to individual CPUs. (e.g, >>> TRBE). To allow quicker access to the sink for a given CPU bound source, >>> keep a percpu array of the sink devices. Also, add support for building >>> a path to the CPU local sink from the ETM. >>> >>> This adds a new percpu sink type CORESIGHT_DEV_SUBTYPE_SINK_PERCPU_SYSMEM. >>> This new sink type is exclusively available and can only work with percpu >>> source type device CORESIGHT_DEV_SUBTYPE_SOURCE_PERCPU_PROC. >>> >>> This defines a percpu structure that accommodates a single coresight_device >>> which can be used to store an initialized instance from a sink driver. As >>> these sinks are exclusively linked and dependent on corresponding percpu >>> sources devices, they should also be the default sink device during a perf >>> session. >>> >>> Outwards device connections are scanned while establishing paths between a >>> source and a sink device. But such connections are not present for certain >>> percpu source and sink devices which are exclusively linked and dependent. >>> Build the path directly and skip connection scanning for such devices. >>> >>> Cc: Mathieu Poirier >>> Cc: Mike Leach >>> Cc: Suzuki K Poulose >>> Signed-off-by: Anshuman Khandual >>> --- >>> Changes in V3: >>> >>> - Updated coresight_find_default_sink() >>> >>> drivers/hwtracing/coresight/coresight-core.c | 16 ++++++++++++++-- >>> include/linux/coresight.h | 12 ++++++++++++ >>> 2 files changed, 26 insertions(+), 2 deletions(-) >>> >>> diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtracing/coresight/coresight-core.c >>> index 0062c89..4795e28 100644 >>> --- a/drivers/hwtracing/coresight/coresight-core.c >>> +++ b/drivers/hwtracing/coresight/coresight-core.c >>> @@ -23,6 +23,7 @@ >>> #include "coresight-priv.h" >>> static DEFINE_MUTEX(coresight_mutex); >>> +DEFINE_PER_CPU(struct coresight_device *, csdev_sink); >>> /** >>> * struct coresight_node - elements of a path, from source to sink >>> @@ -784,6 +785,13 @@ static int _coresight_build_path(struct coresight_device *csdev, >>> if (csdev == sink) >>> goto out; >>> + if (coresight_is_percpu_source(csdev) && coresight_is_percpu_sink(sink) && >>> + sink == per_cpu(csdev_sink, source_ops(csdev)->cpu_id(csdev))) { >>> + _coresight_build_path(sink, sink, path); > > The return value for _coresight_build_path() needs to be checked. Otherwise a > failure to allocate a node for the sink will go unoticed and make for a very > hard problem to debug. How about this instead ? diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtracing/coresight/coresight-core.c index 4795e28..e93e669 100644 --- a/drivers/hwtracing/coresight/coresight-core.c +++ b/drivers/hwtracing/coresight/coresight-core.c @@ -787,9 +787,10 @@ static int _coresight_build_path(struct coresight_device *csdev, if (coresight_is_percpu_source(csdev) && coresight_is_percpu_sink(sink) && sink == per_cpu(csdev_sink, source_ops(csdev)->cpu_id(csdev))) { - _coresight_build_path(sink, sink, path); - found = true; - goto out; + if (_coresight_build_path(sink, sink, path) == 0) { + found = true; + goto out; + } } /* Not a sink - recursively explore each port found on this element */ > >>> + found = true; >>> + goto out; >>> + } >>> + >>> /* Not a sink - recursively explore each port found on this element */ >>> for (i = 0; i < csdev->pdata->nr_outport; i++) { >>> struct coresight_device *child_dev; >>> @@ -999,8 +1007,12 @@ coresight_find_default_sink(struct coresight_device *csdev) >>> int depth = 0; >>> /* look for a default sink if we have not found for this device */ >>> - if (!csdev->def_sink) >>> - csdev->def_sink = coresight_find_sink(csdev, &depth); >>> + if (!csdev->def_sink) { >>> + if (coresight_is_percpu_source(csdev)) >>> + csdev->def_sink = per_cpu(csdev_sink, source_ops(csdev)->cpu_id(csdev)); >>> + if (!csdev->def_sink) >>> + csdev->def_sink = coresight_find_sink(csdev, &depth); >>> + } >>> return csdev->def_sink; >>> } >>> diff --git a/include/linux/coresight.h b/include/linux/coresight.h >>> index 976ec26..bc3a5ca 100644 >>> --- a/include/linux/coresight.h >>> +++ b/include/linux/coresight.h >>> @@ -50,6 +50,7 @@ enum coresight_dev_subtype_sink { >>> CORESIGHT_DEV_SUBTYPE_SINK_PORT, >>> CORESIGHT_DEV_SUBTYPE_SINK_BUFFER, >>> CORESIGHT_DEV_SUBTYPE_SINK_SYSMEM, >>> + CORESIGHT_DEV_SUBTYPE_SINK_PERCPU_SYSMEM, > > Do we absolutely need to add a new sink type? It is only used in > _coresight_build_path() and that code could be: > > if (coresight_is_percpu_source(csdev)) { > sink == per_cpu(csdev_sink, source_ops(csdev)->cpu_id(csdev)); Do you mean if (sink == per_cpu(...)) above ? > if (sink && sink == csdev) { How could the sink fetched from the source csdev be the same ? I would still suggest keeping CORESIGHT_DEV_SUBTYPE_SINK_PERCPU_SYSMEM for logical separation between source and sink, which also improves clarity and readability. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A7F5DC433DB for ; Tue, 16 Feb 2021 10:42:10 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 37E7A64DFF for ; Tue, 16 Feb 2021 10:42:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 37E7A64DFF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=OZ+x82g/QJ7biEu7u5/bYw9GsGMOKDYARc8/M6a0azE=; b=p3BkotFJ1mTGx5OidQawW4Amg IpOxhUFmF+4vr+e4YSCROYSftYm9W+U7z+Y4MVBG9ZbcJO9efhckOFOv/eWZimKC+szGA+arIYnMi nOfQrrkGMAVvWCC13O26oUCQMmF6nVsY4P8GD1FGDaLfufAVx2SPRTfhBCtvEO4K8gLdjkTANlfeS m30tTdpFb4PEYJoVdy+tjiFrc+FFuKqv8diN28Sxj6SADbNb5QbAbdrcSUWXBM03wBqDL9OlziSAi 63Fnz0dYs3bIqxzv+eNDcB2EjVfyVlbf5IFo3JkWFAhej6n19dGcN2AjJJ+fR94imV5QJB+bOFtD3 OS0vzweUA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1lBxm1-0001EC-SJ; Tue, 16 Feb 2021 10:40:05 +0000 Received: from foss.arm.com ([217.140.110.172]) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1lBxlz-0001DV-29 for linux-arm-kernel@lists.infradead.org; Tue, 16 Feb 2021 10:40:04 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7F5831FB; Tue, 16 Feb 2021 02:40:00 -0800 (PST) Received: from [192.168.0.130] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3C9BE3F73B; Tue, 16 Feb 2021 02:39:57 -0800 (PST) Subject: Re: [PATCH V3 08/14] coresight: core: Add support for dedicated percpu sinks To: Mathieu Poirier , Suzuki K Poulose References: <1611737738-1493-1-git-send-email-anshuman.khandual@arm.com> <1611737738-1493-9-git-send-email-anshuman.khandual@arm.com> <20210204183446.GA1636242@xps15> From: Anshuman Khandual Message-ID: <72bd5139-a6e1-64c0-c111-818bc04a81b8@arm.com> Date: Tue, 16 Feb 2021 16:10:18 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20210204183446.GA1636242@xps15> Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210216_054003_292796_FC47DBAD X-CRM114-Status: GOOD ( 27.23 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, coresight@lists.linaro.org, lcherian@marvell.com, linux-arm-kernel@lists.infradead.org, mike.leach@linaro.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 2/5/21 12:04 AM, Mathieu Poirier wrote: > On Thu, Jan 28, 2021 at 09:16:34AM +0000, Suzuki K Poulose wrote: >> On 1/27/21 8:55 AM, Anshuman Khandual wrote: >>> Add support for dedicated sinks that are bound to individual CPUs. (e.g, >>> TRBE). To allow quicker access to the sink for a given CPU bound source, >>> keep a percpu array of the sink devices. Also, add support for building >>> a path to the CPU local sink from the ETM. >>> >>> This adds a new percpu sink type CORESIGHT_DEV_SUBTYPE_SINK_PERCPU_SYSMEM. >>> This new sink type is exclusively available and can only work with percpu >>> source type device CORESIGHT_DEV_SUBTYPE_SOURCE_PERCPU_PROC. >>> >>> This defines a percpu structure that accommodates a single coresight_device >>> which can be used to store an initialized instance from a sink driver. As >>> these sinks are exclusively linked and dependent on corresponding percpu >>> sources devices, they should also be the default sink device during a perf >>> session. >>> >>> Outwards device connections are scanned while establishing paths between a >>> source and a sink device. But such connections are not present for certain >>> percpu source and sink devices which are exclusively linked and dependent. >>> Build the path directly and skip connection scanning for such devices. >>> >>> Cc: Mathieu Poirier >>> Cc: Mike Leach >>> Cc: Suzuki K Poulose >>> Signed-off-by: Anshuman Khandual >>> --- >>> Changes in V3: >>> >>> - Updated coresight_find_default_sink() >>> >>> drivers/hwtracing/coresight/coresight-core.c | 16 ++++++++++++++-- >>> include/linux/coresight.h | 12 ++++++++++++ >>> 2 files changed, 26 insertions(+), 2 deletions(-) >>> >>> diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtracing/coresight/coresight-core.c >>> index 0062c89..4795e28 100644 >>> --- a/drivers/hwtracing/coresight/coresight-core.c >>> +++ b/drivers/hwtracing/coresight/coresight-core.c >>> @@ -23,6 +23,7 @@ >>> #include "coresight-priv.h" >>> static DEFINE_MUTEX(coresight_mutex); >>> +DEFINE_PER_CPU(struct coresight_device *, csdev_sink); >>> /** >>> * struct coresight_node - elements of a path, from source to sink >>> @@ -784,6 +785,13 @@ static int _coresight_build_path(struct coresight_device *csdev, >>> if (csdev == sink) >>> goto out; >>> + if (coresight_is_percpu_source(csdev) && coresight_is_percpu_sink(sink) && >>> + sink == per_cpu(csdev_sink, source_ops(csdev)->cpu_id(csdev))) { >>> + _coresight_build_path(sink, sink, path); > > The return value for _coresight_build_path() needs to be checked. Otherwise a > failure to allocate a node for the sink will go unoticed and make for a very > hard problem to debug. How about this instead ? diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtracing/coresight/coresight-core.c index 4795e28..e93e669 100644 --- a/drivers/hwtracing/coresight/coresight-core.c +++ b/drivers/hwtracing/coresight/coresight-core.c @@ -787,9 +787,10 @@ static int _coresight_build_path(struct coresight_device *csdev, if (coresight_is_percpu_source(csdev) && coresight_is_percpu_sink(sink) && sink == per_cpu(csdev_sink, source_ops(csdev)->cpu_id(csdev))) { - _coresight_build_path(sink, sink, path); - found = true; - goto out; + if (_coresight_build_path(sink, sink, path) == 0) { + found = true; + goto out; + } } /* Not a sink - recursively explore each port found on this element */ > >>> + found = true; >>> + goto out; >>> + } >>> + >>> /* Not a sink - recursively explore each port found on this element */ >>> for (i = 0; i < csdev->pdata->nr_outport; i++) { >>> struct coresight_device *child_dev; >>> @@ -999,8 +1007,12 @@ coresight_find_default_sink(struct coresight_device *csdev) >>> int depth = 0; >>> /* look for a default sink if we have not found for this device */ >>> - if (!csdev->def_sink) >>> - csdev->def_sink = coresight_find_sink(csdev, &depth); >>> + if (!csdev->def_sink) { >>> + if (coresight_is_percpu_source(csdev)) >>> + csdev->def_sink = per_cpu(csdev_sink, source_ops(csdev)->cpu_id(csdev)); >>> + if (!csdev->def_sink) >>> + csdev->def_sink = coresight_find_sink(csdev, &depth); >>> + } >>> return csdev->def_sink; >>> } >>> diff --git a/include/linux/coresight.h b/include/linux/coresight.h >>> index 976ec26..bc3a5ca 100644 >>> --- a/include/linux/coresight.h >>> +++ b/include/linux/coresight.h >>> @@ -50,6 +50,7 @@ enum coresight_dev_subtype_sink { >>> CORESIGHT_DEV_SUBTYPE_SINK_PORT, >>> CORESIGHT_DEV_SUBTYPE_SINK_BUFFER, >>> CORESIGHT_DEV_SUBTYPE_SINK_SYSMEM, >>> + CORESIGHT_DEV_SUBTYPE_SINK_PERCPU_SYSMEM, > > Do we absolutely need to add a new sink type? It is only used in > _coresight_build_path() and that code could be: > > if (coresight_is_percpu_source(csdev)) { > sink == per_cpu(csdev_sink, source_ops(csdev)->cpu_id(csdev)); Do you mean if (sink == per_cpu(...)) above ? > if (sink && sink == csdev) { How could the sink fetched from the source csdev be the same ? I would still suggest keeping CORESIGHT_DEV_SUBTYPE_SINK_PERCPU_SYSMEM for logical separation between source and sink, which also improves clarity and readability. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel