All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Ahern <dsa@cumulusnetworks.com>
To: David Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH net-next] net: FIB tracepoints
Date: Thu, 27 Aug 2015 22:27:38 -0700	[thread overview]
Message-ID: <55DFF14A.90203@cumulusnetworks.com> (raw)
In-Reply-To: <20150827.221643.2144480812551172735.davem@davemloft.net>

On 8/27/15 10:16 PM, David Miller wrote:
> From: David Ahern <dsa@cumulusnetworks.com>
> Date: Thu, 27 Aug 2015 22:07:30 -0700
>
>> On 8/27/15 10:05 PM, David Miller wrote:
>>> From: David Ahern <dsa@cumulusnetworks.com>
>>> Date: Thu, 27 Aug 2015 21:59:32 -0700
>>>
>>>> +		__array(	__u8,	src,	4	)
>>>> +		__array(	__u8,	dst,	4	)
>>>    ...
>>>> +		__array(	__u8,	src,	4	)
>>>
>>> Maybe there is something I don't understand about tracing, but why not
>>> use __u32?  If endianness types are the issue, just force cast it as
>>> needed.
>>>
>>> Using a memcpy() on a 4-byte array is kinda excessive.
>>>
>>
>> Silly trick need to use %pI4. ie., printing the addresses as strings
>> vs. hex.
>
> %pI4 doesn't care what kind of pointer you give it, &__entry->src will
> work just fine if you used __u32.
>


$ git diff
diff --git a/include/trace/events/fib.h b/include/trace/events/fib.h
index 1fd7cfeb36ff..07687b93a4f0 100644
--- a/include/trace/events/fib.h
+++ b/include/trace/events/fib.h
@@ -22,7 +22,7 @@ TRACE_EVENT(fib_table_lookup,
                 __field(        __u8,   tos             )
                 __field(        __u8,   scope           )
                 __field(        __u8,   flags           )
-               __array(        __u8,   src,    4       )
+               __field(        __u32,  src     )
                 __array(        __u8,   dst,    4       )
         ),

@@ -33,13 +33,13 @@ TRACE_EVENT(fib_table_lookup,
                 __entry->tos = flp->flowi4_tos;
                 __entry->scope = flp->flowi4_scope;
                 __entry->flags = flp->flowi4_flags;
-               memcpy(&__entry->src,  &flp->saddr, 4);
+               __entry->src = flp->saddr;
                 memcpy(&__entry->dst,  &flp->daddr, 4);
         ),

         TP_printk("table %d oif %d iif %d src %pI4 dst %pI4 tos %d 
scope %d flags %x",
                   __entry->tb_id, __entry->oif, __entry->iif,
-                 __entry->src, __entry->dst, __entry->tos, __entry->scope,
+                 &__entry->src, __entry->dst, __entry->tos, __entry->scope,
                   __entry->flags)
  );

and compiles fine but run time:

$ perf record -e fib:* -a
   Warning: [fib:fib_table_lookup] bad op token &
^C[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.089 MB perf.data (148 samples) ]

$ perf script
  Warning: [fib:fib_table_lookup] bad op token &
...
          swapper     0 [000]    49.533997: fib:fib_table_lookup: 
[FAILED TO PARSE] tb_id=254 oif=0 iif=3 tos=0 scope=0 flags=0 
src=16843096 dst=ARRA
...


ie., it does matter. src was declared a u32 and trying to pass &src to 
the printk fails. Been down this road a lot.

David

  reply	other threads:[~2015-08-28  5:27 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-28  4:59 [PATCH net-next] net: FIB tracepoints David Ahern
2015-08-28  5:05 ` David Miller
2015-08-28  5:07   ` David Ahern
2015-08-28  5:12     ` David Ahern
2015-08-28  5:17       ` David Miller
2015-08-28  5:32         ` David Ahern
2015-08-28  5:48           ` David Miller
2015-08-28  5:16     ` David Miller
2015-08-28  5:27       ` David Ahern [this message]
2015-08-28  5:47         ` David Miller

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=55DFF14A.90203@cumulusnetworks.com \
    --to=dsa@cumulusnetworks.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.