lkml.org 
[lkml]   [2022]   [Jan]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 12/54] tools/perf: replace bitmap_weight with bitmap_empty where appropriate
    Date
    Some code in builtin-c2c.c calls bitmap_weight() to check if any bit of
    a given bitmap is set. It's better to use bitmap_empty() in that case
    because bitmap_empty() stops traversing the bitmap as soon as it finds
    first set bit, while bitmap_weight() counts all bits unconditionally.

    Signed-off-by: Yury Norov <yury.norov@gmail.com>
    ---
    tools/perf/builtin-c2c.c | 4 ++--
    1 file changed, 2 insertions(+), 2 deletions(-)

    diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c
    index 77dd4afacca4..14f787c67140 100644
    --- a/tools/perf/builtin-c2c.c
    +++ b/tools/perf/builtin-c2c.c
    @@ -1080,7 +1080,7 @@ node_entry(struct perf_hpp_fmt *fmt __maybe_unused, struct perf_hpp *hpp,
    bitmap_zero(set, c2c.cpus_cnt);
    bitmap_and(set, c2c_he->cpuset, c2c.nodes[node], c2c.cpus_cnt);

    - if (!bitmap_weight(set, c2c.cpus_cnt)) {
    + if (bitmap_empty(set, c2c.cpus_cnt)) {
    if (c2c.node_info == 1) {
    ret = scnprintf(hpp->buf, hpp->size, "%21s", " ");
    advance_hpp(hpp, ret);
    @@ -1944,7 +1944,7 @@ static int set_nodestr(struct c2c_hist_entry *c2c_he)
    if (c2c_he->nodestr)
    return 0;

    - if (bitmap_weight(c2c_he->nodeset, c2c.nodes_cnt)) {
    + if (!bitmap_empty(c2c_he->nodeset, c2c.nodes_cnt)) {
    len = bitmap_scnprintf(c2c_he->nodeset, c2c.nodes_cnt,
    buf, sizeof(buf));
    } else {
    --
    2.30.2
    \
     
     \ /
      Last update: 2022-01-23 19:41    [W:6.869 / U:0.000 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site