lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAM9d7ciWzaqP2i=Agx9JxGCw4C3gQ=UUW+cMwWvAPjecd6C2=Q@mail.gmail.com>
Date:   Mon, 7 Dec 2020 22:23:59 +0900
From:   Namhyung Kim <namhyung@...nel.org>
To:     Ian Rogers <irogers@...gle.com>
Cc:     Peter Zijlstra <peterz@...radead.org>,
        Ingo Molnar <mingo@...hat.com>,
        Arnaldo Carvalho de Melo <acme@...nel.org>,
        Mark Rutland <mark.rutland@....com>,
        Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        Jiri Olsa <jolsa@...hat.com>,
        linux-kernel <linux-kernel@...r.kernel.org>,
        Andi Kleen <ak@...ux.intel.com>,
        Jin Yao <yao.jin@...ux.intel.com>,
        John Garry <john.garry@...wei.com>,
        Paul Clarke <pc@...ibm.com>, kajoljain <kjain@...ux.ibm.com>,
        Stephane Eranian <eranian@...gle.com>,
        Sandeep Dasgupta <sdasgup@...gle.com>
Subject: Re: [PATCH v5 4/5] perf metric: Add utilities to work on ids map.

On Wed, Dec 2, 2020 at 4:40 PM Ian Rogers <irogers@...gle.com> wrote:
>
> Add utilities to new/free an ids hashmap, as well as to union. Add
> testing of the union. Unioning hashmaps will be used when parsing the
> metric, if a value is known then the hashmap is unnecessary, otherwise
> we need to union together all the event ids to compute their values for
> reporting.
>
> Signed-off-by: Ian Rogers <irogers@...gle.com>
> ---
[SNIP]

What about adding a comment that it should not access ids1 and ids2
after this function since they can be released?

> +struct hashmap *ids__union(struct hashmap *ids1, struct hashmap *ids2)
> +{
> +       size_t bkt;
> +       struct hashmap_entry *cur;
> +       int ret;
> +       struct expr_id_data *old_data = NULL;
> +       char *old_key = NULL;
> +
> +       if (!ids1)
> +               return ids2;
> +
> +       if (!ids2)
> +               return ids1;
> +
> +       if (hashmap__size(ids1) <  hashmap__size(ids2)) {
> +               struct hashmap *tmp = ids1;
> +
> +               ids1 = ids2;
> +               ids2 = tmp;
> +       }
> +       hashmap__for_each_entry(ids2, cur, bkt) {
> +               ret = hashmap__set(ids1, cur->key, cur->value,
> +                               (const void **)&old_key, (void **)&old_data);
> +               free(old_key);
> +               free(old_data);
> +
> +               if (ret)
> +                       break;
> +       }
> +       hashmap__free(ids2);
> +       return ids1;
> +}

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ