All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] pfn_t: force '~' to be parsed as an unary operator
@ 2018-10-21 14:59 ` Sebastien Boisvert
  0 siblings, 0 replies; 5+ messages in thread
From: Sebastien Boisvert @ 2018-10-21 14:59 UTC (permalink / raw)
  Cc: Sebastien Boisvert, Dan Williams, Steven Rostedt (VMware),
	Arnaldo Carvalho de Melo, Tzvetomir Stoyanov (VMware),
	Namhyung Kim, Ross Zwisler, Elenie Godzaridis, linux-perf-users,
	linux-kernel

Tracing the event "fs_dax:dax_pmd_insert_mapping" with perf produces this
warning:
      [fs_dax:dax_pmd_insert_mapping] unknown op '~'

It is printed in process_op (tools/lib/traceevent/event-parse.c) because '~'
is parsed as a binary operator.

perf reads the format of fs_dax:dax_pmd_insert_mapping ("print fmt") from
/sys/kernel/debug/tracing/events/fs_dax/dax_pmd_insert_mapping/format .

The format contains:

~(((u64) ~(~(((1UL) << 12)-1)))
         ^
         \ interpreted as a binary operator by process_op().

This part is generated in the declaration of the event class
dax_pmd_insert_mapping_class in include/trace/events/fs_dax.h :

		__print_flags_u64(__entry->pfn_val & PFN_FLAGS_MASK, "|",
			PFN_FLAGS_TRACE),

This patch adds a pair of parentheses in the declaration of PFN_FLAGS_MASK to
make sure that '~' is parsed as a unary operator by perf.

The part of the format that was problematic is now:

~(((u64) (~(~(((1UL) << 12)-1))))

Now, all the '~' are parsed as unary operators.

Cc: Dan Williams <dan.j.williams@intel.com>
Cc: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: "Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Ross Zwisler <zwisler@kernel.org>
Cc: Elenie Godzaridis <arangradient@gmail.com>
Cc: linux-perf-users@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Sebastien Boisvert <sebhtml@videotron.qc.ca>
---
 include/linux/pfn_t.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/pfn_t.h b/include/linux/pfn_t.h
index 21713dc14ce2..673546ba7342 100644
--- a/include/linux/pfn_t.h
+++ b/include/linux/pfn_t.h
@@ -10,7 +10,7 @@
  * PFN_DEV - pfn is not covered by system memmap by default
  * PFN_MAP - pfn has a dynamic page mapping established by a device driver
  */
-#define PFN_FLAGS_MASK (((u64) ~PAGE_MASK) << (BITS_PER_LONG_LONG - PAGE_SHIFT))
+#define PFN_FLAGS_MASK (((u64) (~PAGE_MASK)) << (BITS_PER_LONG_LONG - PAGE_SHIFT))
 #define PFN_SG_CHAIN (1ULL << (BITS_PER_LONG_LONG - 1))
 #define PFN_SG_LAST (1ULL << (BITS_PER_LONG_LONG - 2))
 #define PFN_DEV (1ULL << (BITS_PER_LONG_LONG - 3))
-- 
2.17.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] pfn_t: force '~' to be parsed as an unary operator
@ 2018-10-21 14:59 ` Sebastien Boisvert
  0 siblings, 0 replies; 5+ messages in thread
From: Sebastien Boisvert @ 2018-10-21 14:59 UTC (permalink / raw)
  Cc: Sebastien Boisvert, Dan Williams, Steven Rostedt (VMware),
	Arnaldo Carvalho de Melo, Tzvetomir Stoyanov (VMware),
	Namhyung Kim, Ross Zwisler, Elenie Godzaridis, linux-perf-users,
	linux-kernel

Tracing the event "fs_dax:dax_pmd_insert_mapping" with perf produces this
warning:
      [fs_dax:dax_pmd_insert_mapping] unknown op '~'

It is printed in process_op (tools/lib/traceevent/event-parse.c) because '~'
is parsed as a binary operator.

perf reads the format of fs_dax:dax_pmd_insert_mapping ("print fmt") from
/sys/kernel/debug/tracing/events/fs_dax/dax_pmd_insert_mapping/format .

The format contains:

~(((u64) ~(~(((1UL) << 12)-1)))
         ^
         \ interpreted as a binary operator by process_op().

This part is generated in the declaration of the event class
dax_pmd_insert_mapping_class in include/trace/events/fs_dax.h :

		__print_flags_u64(__entry->pfn_val & PFN_FLAGS_MASK, "|",
			PFN_FLAGS_TRACE),

This patch adds a pair of parentheses in the declaration of PFN_FLAGS_MASK to
make sure that '~' is parsed as a unary operator by perf.

The part of the format that was problematic is now:

~(((u64) (~(~(((1UL) << 12)-1))))

Now, all the '~' are parsed as unary operators.

Cc: Dan Williams <dan.j.williams@intel.com>
Cc: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: "Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Ross Zwisler <zwisler@kernel.org>
Cc: Elenie Godzaridis <arangradient@gmail.com>
Cc: linux-perf-users@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Sebastien Boisvert <sebhtml@videotron.qc.ca>
---
 include/linux/pfn_t.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/pfn_t.h b/include/linux/pfn_t.h
index 21713dc14ce2..673546ba7342 100644
--- a/include/linux/pfn_t.h
+++ b/include/linux/pfn_t.h
@@ -10,7 +10,7 @@
  * PFN_DEV - pfn is not covered by system memmap by default
  * PFN_MAP - pfn has a dynamic page mapping established by a device driver
  */
-#define PFN_FLAGS_MASK (((u64) ~PAGE_MASK) << (BITS_PER_LONG_LONG - PAGE_SHIFT))
+#define PFN_FLAGS_MASK (((u64) (~PAGE_MASK)) << (BITS_PER_LONG_LONG - PAGE_SHIFT))
 #define PFN_SG_CHAIN (1ULL << (BITS_PER_LONG_LONG - 1))
 #define PFN_SG_LAST (1ULL << (BITS_PER_LONG_LONG - 2))
 #define PFN_DEV (1ULL << (BITS_PER_LONG_LONG - 3))
-- 
2.17.1

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] pfn_t: force '~' to be parsed as an unary operator
  2018-10-21 14:59 ` Sebastien Boisvert
  (?)
@ 2018-10-22 17:13 ` Dan Williams
  2018-10-24 22:43   ` Andrew Morton
       [not found]   ` <FRrzgp7InaOtKFRs0geay1@videotron.ca>
  -1 siblings, 2 replies; 5+ messages in thread
From: Dan Williams @ 2018-10-22 17:13 UTC (permalink / raw)
  To: sebhtml
  Cc: Steven Rostedt, acme, tz.stoyanov, Namhyung Kim, zwisler,
	arangradient, linux-perf-users, Linux Kernel Mailing List,
	Andrew Morton

[ added Andrew ]

Patch here: https://lore.kernel.org/patchwork/patch/1002234/

On Sun, Oct 21, 2018 at 8:00 AM Sebastien Boisvert
<sebhtml@videotron.qc.ca> wrote:
>
> Tracing the event "fs_dax:dax_pmd_insert_mapping" with perf produces this
> warning:
>       [fs_dax:dax_pmd_insert_mapping] unknown op '~'
>
> It is printed in process_op (tools/lib/traceevent/event-parse.c) because '~'
> is parsed as a binary operator.
>
> perf reads the format of fs_dax:dax_pmd_insert_mapping ("print fmt") from
> /sys/kernel/debug/tracing/events/fs_dax/dax_pmd_insert_mapping/format .
>
> The format contains:
>
> ~(((u64) ~(~(((1UL) << 12)-1)))
>          ^
>          \ interpreted as a binary operator by process_op().
>
> This part is generated in the declaration of the event class
> dax_pmd_insert_mapping_class in include/trace/events/fs_dax.h :
>
>                 __print_flags_u64(__entry->pfn_val & PFN_FLAGS_MASK, "|",
>                         PFN_FLAGS_TRACE),
>
> This patch adds a pair of parentheses in the declaration of PFN_FLAGS_MASK to
> make sure that '~' is parsed as a unary operator by perf.
>
> The part of the format that was problematic is now:
>
> ~(((u64) (~(~(((1UL) << 12)-1))))
>
> Now, all the '~' are parsed as unary operators.
>
> Cc: Dan Williams <dan.j.williams@intel.com>


Acked-by: Dan Williams <dan.j.williams@intel.com>


> Cc: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
> Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
> Cc: "Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com>
> Cc: Namhyung Kim <namhyung@kernel.org>
> Cc: Ross Zwisler <zwisler@kernel.org>
> Cc: Elenie Godzaridis <arangradient@gmail.com>
> Cc: linux-perf-users@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> Signed-off-by: Sebastien Boisvert <sebhtml@videotron.qc.ca>
> ---
>  include/linux/pfn_t.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/linux/pfn_t.h b/include/linux/pfn_t.h
> index 21713dc14ce2..673546ba7342 100644
> --- a/include/linux/pfn_t.h
> +++ b/include/linux/pfn_t.h
> @@ -10,7 +10,7 @@
>   * PFN_DEV - pfn is not covered by system memmap by default
>   * PFN_MAP - pfn has a dynamic page mapping established by a device driver
>   */
> -#define PFN_FLAGS_MASK (((u64) ~PAGE_MASK) << (BITS_PER_LONG_LONG - PAGE_SHIFT))
> +#define PFN_FLAGS_MASK (((u64) (~PAGE_MASK)) << (BITS_PER_LONG_LONG - PAGE_SHIFT))
>  #define PFN_SG_CHAIN (1ULL << (BITS_PER_LONG_LONG - 1))
>  #define PFN_SG_LAST (1ULL << (BITS_PER_LONG_LONG - 2))
>  #define PFN_DEV (1ULL << (BITS_PER_LONG_LONG - 3))
> --
> 2.17.1
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] pfn_t: force '~' to be parsed as an unary operator
  2018-10-22 17:13 ` Dan Williams
@ 2018-10-24 22:43   ` Andrew Morton
       [not found]   ` <FRrzgp7InaOtKFRs0geay1@videotron.ca>
  1 sibling, 0 replies; 5+ messages in thread
From: Andrew Morton @ 2018-10-24 22:43 UTC (permalink / raw)
  To: Dan Williams
  Cc: sebhtml, Steven Rostedt, acme, tz.stoyanov, Namhyung Kim,
	zwisler, arangradient, linux-perf-users,
	Linux Kernel Mailing List

On Mon, 22 Oct 2018 10:13:48 -0700 Dan Williams <dan.j.williams@intel.com> wrote:

> [ added Andrew ]
> 
> Patch here: https://lore.kernel.org/patchwork/patch/1002234/
> 
> On Sun, Oct 21, 2018 at 8:00 AM Sebastien Boisvert
> <sebhtml@videotron.qc.ca> wrote:
> >
> > Tracing the event "fs_dax:dax_pmd_insert_mapping" with perf produces this
> > warning:
> >       [fs_dax:dax_pmd_insert_mapping] unknown op '~'
> >
> > It is printed in process_op (tools/lib/traceevent/event-parse.c) because '~'
> > is parsed as a binary operator.
> >
> > perf reads the format of fs_dax:dax_pmd_insert_mapping ("print fmt") from
> > /sys/kernel/debug/tracing/events/fs_dax/dax_pmd_insert_mapping/format .
> >
> > The format contains:
> >
> > ~(((u64) ~(~(((1UL) << 12)-1)))
> >          ^
> >          \ interpreted as a binary operator by process_op().
> >
> > This part is generated in the declaration of the event class
> > dax_pmd_insert_mapping_class in include/trace/events/fs_dax.h :
> >
> >                 __print_flags_u64(__entry->pfn_val & PFN_FLAGS_MASK, "|",
> >                         PFN_FLAGS_TRACE),
> >
> > This patch adds a pair of parentheses in the declaration of PFN_FLAGS_MASK to
> > make sure that '~' is parsed as a unary operator by perf.
> >
> > The part of the format that was problematic is now:
> >
> > ~(((u64) (~(~(((1UL) << 12)-1))))
> >
> > Now, all the '~' are parsed as unary operators.
> >
> > Cc: Dan Williams <dan.j.williams@intel.com>
> 
> 
> Acked-by: Dan Williams <dan.j.williams@intel.com>
> 

I grabbed it, and added cc:stable.

But aren't we fixing this in the wrong place?  That's a valid
expression and if this isn't addressed in perf then we may hit a
similar issue elsewhere...


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] pfn_t: force '~' to be parsed as an unary operator
       [not found]   ` <FRrzgp7InaOtKFRs0geay1@videotron.ca>
@ 2018-10-24 23:52     ` sebhtml
  0 siblings, 0 replies; 5+ messages in thread
From: sebhtml @ 2018-10-24 23:52 UTC (permalink / raw)
  To: Andrew Morton, Dan Williams
  Cc: Steven Rostedt, acme, tz.stoyanov, Namhyung Kim, zwisler,
	arangradient, linux-perf-users, Linux Kernel Mailing List

On 2018-10-24 6:43 p.m., Andrew Morton wrote:
> 
> I grabbed it, and added cc:stable.
> 
> But aren't we fixing this in the wrong place?  That's a valid
> expression and if this isn't addressed in perf then we may hit a
> similar issue elsewhere...
> 

Right.

Based on:
     git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 01aa9d518eae8a4d75cd3049defc6ed0b6d0a658

In perf, the warning
       [fs_dax:dax_pmd_insert_mapping] unknown op '~'
comes from tools/lib/traceevent/event-parse.c at line 2045:
                 do_warning_event(event, "unknown op '%s'", token);

This is in this function:

static enum tep_event_type
process_op(struct tep_event_format *event, struct tep_print_arg *arg, char **tok);

The code path to reach the good '~' case needs:
         if (arg->type == TEP_PRINT_OP && !arg->op.left) {

I assume that here arg->op.left is not NULL because of (u64) on the left.

~(((u64) ~(~(((1UL) << 12)-1)))
          ^

However, I fail to see where '~' is parsed as a binary operator though.

Any pointer would be welcome.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-10-25  0:08 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-21 14:59 [PATCH] pfn_t: force '~' to be parsed as an unary operator Sebastien Boisvert
2018-10-21 14:59 ` Sebastien Boisvert
2018-10-22 17:13 ` Dan Williams
2018-10-24 22:43   ` Andrew Morton
     [not found]   ` <FRrzgp7InaOtKFRs0geay1@videotron.ca>
2018-10-24 23:52     ` sebhtml

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.