[Bug bpf/23858] New: sorted iteration on bpf arrays can't sort values

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

[Bug bpf/23858] New: sorted iteration on bpf arrays can't sort values

fweimer at redhat dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=23858

            Bug ID: 23858
           Summary: sorted iteration on bpf arrays can't sort values
           Product: systemtap
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: bpf
          Assignee: systemtap at sourceware dot org
          Reporter: fche at redhat dot com
  Target Milestone: ---

% stap -e 'global a probe oneshot { a[0]=5; a[3]=3; a[5]=0;
  foreach (b in a+) printf("%d %d\n", b, a[b]) }'
5 0
3 3
0 5

% stap --bpf -e 'global a probe oneshot { a[0]=5; a[3]=3; a[5]=0;
  foreach (b in a+) printf("%d %d\n", b, a[b]) }'
0 5
3 3
5 0

--
You are receiving this mail because:
You are the assignee for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug bpf/23858] sorted iteration on bpf arrays can't sort values

fweimer at redhat dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=23858

Serhei Makarov <me at serhei dot io> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |me at serhei dot io

--- Comment #1 from Serhei Makarov <me at serhei dot io> ---
Also need to check correct value sorting for strings after PR23875.

--
You are receiving this mail because:
You are the assignee for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug bpf/23858] sorted iteration on bpf arrays can't sort values

fweimer at redhat dot com
In reply to this post by fweimer at redhat dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=23858

--- Comment #2 from Serhei Makarov <me at serhei dot io> ---
More involved example:

global a
global s

probe oneshot {
  printf("BEGIN")
  a[0]=5; a[3]=3; a[5]=0
  s["avocado"]=5; s["blueberry"]=3; s["caramel apple"]=0
  foreach (b in a+) printf("%d",a[b])
  foreach (b in a-) printf("%d",a[b])
  foreach (k in s+) printf("%d",s[k])
  foreach (k in s-) printf("%d",s[k])
  printf("END\n")
}

BPF and LKM SystemTap sort it in opposite order, but I'm not sure which is
right. See
https://sourceware.org/systemtap/langref/6_Statement_types.html#SECTION00076000000000000000

"If you add a single plus (+) or minus (-) operator after the VAR or the ARRAY
identifier, the iteration order will be sorted by the ascending or descending
index or value."

--
You are receiving this mail because:
You are the assignee for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug bpf/23858] sorted iteration on bpf arrays can't sort values

fweimer at redhat dot com
In reply to this post by fweimer at redhat dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=23858

--- Comment #3 from Serhei Makarov <me at serhei dot io> ---
Sorry, was just confused.

To sort by key, use foreach (b+ in a). That works correctly.
To sort by value, use foreach (b in a+). That needs to be fixed.

--
You are receiving this mail because:
You are the assignee for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug bpf/23858] sorted iteration on bpf arrays can't sort values

fweimer at redhat dot com
In reply to this post by fweimer at redhat dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=23858

--- Comment #4 from Serhei Makarov <me at serhei dot io> ---
Should also fix statistics aggregate sorting to use s->sort_aggr while I'm at
it.

--
You are receiving this mail because:
You are the assignee for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug bpf/23858] sorted iteration on bpf arrays can't sort values

fweimer at redhat dot com
In reply to this post by fweimer at redhat dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=23858

Serhei Makarov <me at serhei dot io> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|systemtap at sourceware dot org    |me at serhei dot io

--
You are receiving this mail because:
You are the assignee for the bug.