linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Mathieu Poirier <mathieu.poirier@linaro.org>
To: Mike Leach <mike.leach@linaro.org>
Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org,
	suzuki.poulose@arm.com, leo.yan@linaro.org
Subject: Re: [RFC PATCH 3/8] coresight: syscfg: Example CoreSight configuration loadable module
Date: Tue, 18 May 2021 09:52:13 -0600	[thread overview]
Message-ID: <20210518155213.GB776252@xps15> (raw)
In-Reply-To: <20210512211752.4103-4-mike.leach@linaro.org>

Good day Mike,

On Wed, May 12, 2021 at 10:17:47PM +0100, Mike Leach wrote:
> An example of creating a loadable module to add CoreSight configurations
> into a system.
> 
> In the Kernel samples/coresight directory.
> 
> Signed-off-by: Mike Leach <mike.leach@linaro.org>
> ---
>  MAINTAINERS                              |  1 +
>  samples/Kconfig                          |  9 +++
>  samples/Makefile                         |  1 +
>  samples/coresight/Makefile               |  4 ++
>  samples/coresight/coresight-cfg-sample.c | 73 ++++++++++++++++++++++++
>  5 files changed, 88 insertions(+)
>  create mode 100644 samples/coresight/Makefile
>  create mode 100644 samples/coresight/coresight-cfg-sample.c
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index bd7aff0c120f..9ff5f5e7dd06 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -1789,6 +1789,7 @@ F:	Documentation/trace/coresight/*
>  F:	drivers/hwtracing/coresight/*
>  F:	include/dt-bindings/arm/coresight-cti-dt.h
>  F:	include/linux/coresight*
> +F:	samples/coresight/*
>  F:	tools/perf/arch/arm/util/auxtrace.c
>  F:	tools/perf/arch/arm/util/cs-etm.c
>  F:	tools/perf/arch/arm/util/cs-etm.h
> diff --git a/samples/Kconfig b/samples/Kconfig
> index b5a1a7aa7e23..0cd618e15571 100644
> --- a/samples/Kconfig
> +++ b/samples/Kconfig
> @@ -223,4 +223,13 @@ config SAMPLE_WATCH_QUEUE
>  	  Build example userspace program to use the new mount_notify(),
>  	  sb_notify() syscalls and the KEYCTL_WATCH_KEY keyctl() function.
>  
> +config SAMPLE_CORESIGHT_SYSCFG
> +	tristate "Build example loadable module for CoreSight config"
> +	depends on CORESIGHT && m
> +	help
> +	  Build an example loadable module that adds new CoreSight features
> +	  and configuration using the CoreSight system configuration API.
> +	  This demonstrates how a user may create their own CoreSight
> +	  configurations and easily load them into the system at runtime.
> +
>  endif # SAMPLES
> diff --git a/samples/Makefile b/samples/Makefile
> index 087e0988ccc5..6c96297001a8 100644
> --- a/samples/Makefile
> +++ b/samples/Makefile
> @@ -30,3 +30,4 @@ obj-$(CONFIG_SAMPLE_INTEL_MEI)		+= mei/
>  subdir-$(CONFIG_SAMPLE_WATCHDOG)	+= watchdog
>  subdir-$(CONFIG_SAMPLE_WATCH_QUEUE)	+= watch_queue
>  obj-$(CONFIG_DEBUG_KMEMLEAK_TEST)	+= kmemleak/
> +obj-$(CONFIG_SAMPLE_CORESIGHT_SYSCFG)	+= coresight/
> diff --git a/samples/coresight/Makefile b/samples/coresight/Makefile
> new file mode 100644
> index 000000000000..09126aabf43d
> --- /dev/null
> +++ b/samples/coresight/Makefile
> @@ -0,0 +1,4 @@
> +# SPDX-License-Identifier: GPL-2.0-only
> +
> +obj-$(CONFIG_SAMPLE_CORESIGHT_SYSCFG) += coresight-cfg-sample.o
> +ccflags-y += -I$(src)/../../drivers/hwtracing/coresight

On my side this really doesn't work and it's baffling.  I double checked the
path that gets generated with V=1 and it is correct.  I ended up replacing
$(src) with $(srctree), which gave me a full path rather than a relative path,
to get things going.  Please see if that works on your side.

I looked at other Makefiles and $(srctree) is predominant.  As such I suggest to
go with that to avoid further headaches. 


> diff --git a/samples/coresight/coresight-cfg-sample.c b/samples/coresight/coresight-cfg-sample.c
> new file mode 100644
> index 000000000000..865c188fae34
> --- /dev/null
> +++ b/samples/coresight/coresight-cfg-sample.c
> @@ -0,0 +1,73 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright(C) 2020 Linaro Limited. All rights reserved.
> + * Author: Mike Leach <mike.leach@linaro.org>
> + */
> +
> +#include "coresight-config.h"
> +#include "coresight-syscfg.h"
> +
> +/* create an alternate autofdo configuration */
> +
> +/* we will provide 4 sets of preset parameter values */
> +#define AFDO2_NR_PRESETS	4
> +/* the total number of parameters in used features - strobing has 2 */
> +#define AFDO2_NR_PARAM_SUM	2
> +
> +static const char *afdo2_ref_names[] = {
> +	"strobing",
> +};
> +
> +/*
> + * set of presets leaves strobing window constant while varying period to allow
> + * experimentation with mark / space ratios for various workloads
> + */
> +static u64 afdo2_presets[AFDO2_NR_PRESETS][AFDO2_NR_PARAM_SUM] = {
> +	{ 1000, 100 },
> +	{ 1000, 1000 },
> +	{ 1000, 5000 },
> +	{ 1000, 10000 },
> +};
> +
> +struct cscfg_config_desc afdo2 = {
> +	.name = "autofdo2",
> +	.description = "Setup ETMs with strobing for autofdo\n"
> +	"Supplied presets allow experimentation with mark-space ratio for various loads\n",
> +	.nr_feat_refs = ARRAY_SIZE(afdo2_ref_names),
> +	.feat_ref_names = afdo2_ref_names,
> +	.nr_presets = AFDO2_NR_PRESETS,
> +	.nr_total_params = AFDO2_NR_PARAM_SUM,
> +	.presets = &afdo2_presets[0][0],
> +};
> +
> +static struct cscfg_feature_desc *sample_feats[] = {
> +	0

NULL

> +};
> +
> +static struct cscfg_config_desc *sample_cfgs[] = {
> +	&afdo2,
> +	0

NULL

The end result is the same but it is a matter of time before it gets flagged by
a bot.

With the above:

Reviewed-by: Mathieu Poirier <mathieu.poirier@linaro.org>

> +};
> +
> +static struct cscfg_load_owner_info mod_owner = {
> +	.type = CSCFG_OWNER_MODULE,
> +	.owner_handle = THIS_MODULE,
> +};
> +
> +/* module init and exit - just load and unload configs */
> +static int __init cscfg_sample_init(void)
> +{
> +	return cscfg_load_config_sets(sample_cfgs, sample_feats, &mod_owner);
> +}
> +
> +static void __exit cscfg_sample_exit(void)
> +{
> +	cscfg_unload_config_sets(&mod_owner);
> +}
> +
> +module_init(cscfg_sample_init);
> +module_exit(cscfg_sample_exit);
> +
> +MODULE_LICENSE("GPL v2");
> +MODULE_AUTHOR("Mike Leach <mike.leach@linaro.org>");
> +MODULE_DESCRIPTION("CoreSight Syscfg Example");
> -- 
> 2.17.1
> 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2021-05-18 15:53 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-12 21:17 [RFC PATCH 0/8] coresight: syscfg: dynamic load, resource management Mike Leach
2021-05-12 21:17 ` [RFC PATCH 1/8] coresight: syscfg: Update API to allow dynamic load and unload Mike Leach
2021-05-17 17:15   ` Mathieu Poirier
2021-05-17 17:27     ` Mathieu Poirier
2021-05-19 13:28       ` Mike Leach
2021-05-12 21:17 ` [RFC PATCH 2/8] coresight: syscfg: Update load API for config loadable modules Mike Leach
2021-05-17 17:38   ` Mathieu Poirier
2021-05-12 21:17 ` [RFC PATCH 3/8] coresight: syscfg: Example CoreSight configuration loadable module Mike Leach
2021-05-18 15:52   ` Mathieu Poirier [this message]
2021-05-18 16:38     ` Mike Leach
2021-05-18 21:15       ` Mathieu Poirier
2021-05-12 21:17 ` [RFC PATCH 4/8] coresight: configfs: Allow configfs to activate configuration Mike Leach
2021-05-18 19:36   ` Mathieu Poirier
2021-05-19  9:47     ` Mike Leach
2021-05-12 21:17 ` [RFC PATCH 5/8] coresight: syscfg: Add API to check and validate device resources Mike Leach
2021-05-21 17:56   ` Mathieu Poirier
2021-07-08 16:30     ` Mike Leach
2021-05-12 21:17 ` [RFC PATCH 6/8] coresight: etm4x: syscfg: Add resource management to etm4x Mike Leach
2021-05-26 17:51   ` Mathieu Poirier
2021-05-27 17:41   ` Mathieu Poirier
2021-05-28 16:17   ` Mathieu Poirier
2021-07-09  9:32     ` Mike Leach
2021-05-12 21:17 ` [RFC PATCH 7/8] coresight: etm4x: Update perf event resource handling Mike Leach
2021-05-12 21:17 ` [RFC PATCH 8/8] coresight: etm4x: Update configuration example Mike Leach
2021-05-13 15:56 ` [RFC PATCH 0/8] coresight: syscfg: dynamic load, resource management Mathieu Poirier
2021-05-13 16:53   ` Mike Leach
2021-05-14  1:35     ` Leo Yan
2021-05-18 18:31 ` Suzuki K Poulose
2021-05-19  9:43   ` Mike Leach
2021-05-19 15:37     ` Mathieu Poirier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210518155213.GB776252@xps15 \
    --to=mathieu.poirier@linaro.org \
    --cc=coresight@lists.linaro.org \
    --cc=leo.yan@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=mike.leach@linaro.org \
    --cc=suzuki.poulose@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).