Subject: Re: [PATCH v2 05/06] 9p fid refcount: add a 9p_fid_ref tracepoint

From: Dominique Martinet <[email-masked]>
Date: Mon, 13 Jun 2022 16:00:52 +0900

Dominique Martinet wrote on Mon, Jun 13, 2022 at 08:46:34AM +0900:
> I've applied your suggestion to use DECLARE_TRACEPOINT + enable checks,
> it doesn't seem to have many users but it looks good to me.
>
> diff --git a/include/net/9p/client.h b/include/net/9p/client.h
> index 9fd38d674057..6f347983705d 100644
> --- a/include/net/9p/client.h
> +++ b/include/net/9p/client.h
> @@ -237,8 +238,17 @@ static inline int p9_req_try_get(struct p9_req_t *r)
>  
>  int p9_req_put(struct p9_req_t *r);
>  
> +/* We cannot have the real tracepoints in header files,
> + * use a wrapper function */
> +DECLARE_TRACEPOINT(9p_fid_ref);
> +void do_trace_9p_fid_get(struct p9_fid *fid);
> +void do_trace_9p_fid_put(struct p9_fid *fid);
> +
>  static inline struct p9_fid *p9_fid_get(struct p9_fid *fid)
>  {
> +	if (tracepoint_enabled(9p_fid_ref))

This here requires __tracepoint_9p_fid_ref exported...

> diff --git a/net/9p/client.c b/net/9p/client.c
> index f3eb280c7d9d..06d67a02d431 100644
> --- a/net/9p/client.c
> +++ b/net/9p/client.c
> @@ -928,6 +931,18 @@ static void p9_fid_destroy(struct p9_fid *fid)
>  	kfree(fid);
>  }
>  

So I've also added this here:

+/* We also need to export tracepoint symbols for tracepoint_enabled() */
+EXPORT_TRACEPOINT_SYMBOL(9p_fid_ref);
+

Which looks frequent enough to probably be the right thing to do?

(It's small enough that I won't bother repost a v3 unless something else
comes up)

> +void do_trace_9p_fid_get(struct p9_fid *fid)
> +{
> +	trace_9p_fid_ref(fid, P9_FID_REF_GET);
> +}
> +EXPORT_SYMBOL(do_trace_9p_fid_get);
> +
> +void do_trace_9p_fid_put(struct p9_fid *fid)
> +{
> +	trace_9p_fid_ref(fid, P9_FID_REF_PUT);
> +}
> +EXPORT_SYMBOL(do_trace_9p_fid_put);
> +
>  static int p9_client_version(struct p9_client *c)
>  {
>  	int err = 0;

-- 
Dominique