Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp828357pxb; Wed, 22 Sep 2021 14:00:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJylXH1HhvJYmbqwqrdHmUpWtfu2fFiGUqibbZFBMWB7OJKAvyBfgUoXHzdDVZCD+Y28GRlf X-Received: by 2002:a05:6638:339e:: with SMTP id h30mr938551jav.148.1632344441876; Wed, 22 Sep 2021 14:00:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632344441; cv=none; d=google.com; s=arc-20160816; b=TzzEBj7wmhDv18/+jW3Z2uAIJOJSPI+81OTsMqVtG5a5TWURIuvc+YLPjlTRJ9y3Fn 3nOmScAVbOMpRRfcy+JmFwdDT4Nar4fQM/kAQSTtUv2tPqsd3OvuPtjnJbgWxc01jqDD h1NRaQR1HV052AjbQ9rIsL5Z2JqHZ6yxfApf3Q+G2MOSW779k3w0b6/GuHHQGpdQpzEn fUqua/w4P2+lUtrrDfG6FM92SM9czaYSEm5/HLQ5WETUC+ES/kJLM5n8u672BELPkeL7 mDpGknmV66OBtr2ECXIdBvwDYC1bMrYPE2Sad19Ug4o9RWpGSYV6C3TyguJgPzH4elqg 5cSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=gO65tY85mzxNSiMQSTLAVCO3OAT6edKTBG18pm5kxVg=; b=cymJwOZsU9PZX3Q2l8pzPvwr/M7hAf96Eoe932h6LG9W2ZGZ7TdfqfjzTEOhV45cPK xBxVj5S41xD6hXDctUkwRMSZhSSH/84YWYDEdEkKpSrM2hj+3yf7e/LrN+EMLAGCi7r7 3WRg3ayjRSCuj/3Hyb9jCCiKzBhxpRGYOAwhbdkkkDVsoUmFOo54/7k0/7YRLM8WJeI7 O6JVFBMelSjVvK/kPGoBTZ5FD42svIugypDKn1mg7PgcgmuNOW0j0dDg7uIF4dZKxk/5 Zb5OC7U63M2viTRrFFp7G4QozonBR6ktWEcMFS/nKIN4iWlhU7U83tUo3PqNtUbR2Wkb RGCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=cH127BAt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q11si3577181ilg.114.2021.09.22.14.00.28; Wed, 22 Sep 2021 14:00:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=cH127BAt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237915AbhIVVBL (ORCPT + 99 others); Wed, 22 Sep 2021 17:01:11 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:51441 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237819AbhIVVBK (ORCPT ); Wed, 22 Sep 2021 17:01:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632344379; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=gO65tY85mzxNSiMQSTLAVCO3OAT6edKTBG18pm5kxVg=; b=cH127BAtNK9teC7oRRQ+6HyCooTZtke5/R/sR+c6kIbW6Ou5Szo5g42e1R4UyF0M6Vwbkr ddzCHUrP6gOJuNQFi1C94HJytypqNHxfPG5ekn9wKJyTmxyGGhWm/o7NjvF44Hr56bd+5N lPBdXhPMmDbsDDPCAkhBr8YuWv0LRCU= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-229-PfybcMdIPkue6UI3p7Wdqg-1; Wed, 22 Sep 2021 16:59:37 -0400 X-MC-Unique: PfybcMdIPkue6UI3p7Wdqg-1 Received: by mail-wr1-f70.google.com with SMTP id j16-20020adfa550000000b0016012acc443so3286391wrb.14 for ; Wed, 22 Sep 2021 13:59:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=gO65tY85mzxNSiMQSTLAVCO3OAT6edKTBG18pm5kxVg=; b=sckHb3aPzQPqCFBuPwGQGLoy8tfiETlntwu00YRAd1P9K+lAluWNnLRnrsLb5NuT+C QOUqyy0R/4es5nkMVABZajq2hsaQJVKvbn4QL/HnGcAPXQCj8GyXnJEtzbjqWRQx0RYm MYIeGzuoGb9j2Vf0aIz8rpcj8oy14tQ0LbgPsxHrJ1xbGnYfMV8StQIzd5gIKhqun/WI C6wjlDNho5sjOwvNVDz1LIpO0kHC1TcHvQ0dCxatMiEhdmetPlachrhOALXt1pON91hi 2B3etges7xPr1M+5GKkp1HlYEmPsR0NyUCls9G1MdZ5x0niGtWJJBzpfxeyZmGbS1uMp GvDA== X-Gm-Message-State: AOAM530O833Fn6Skfk3UpM5c703QtYtkKepW/hMOj1c6rXzhqLMvIxan cFKWb+nK2oBNv3eYehg6Y3H9QFcemj/VH0QkslZUhrigBFXFqWizazAmVTE7/I6FZn2ZsrmT6wC XQkBih9mXXoxRTMnv9CANwN3G X-Received: by 2002:a5d:47ce:: with SMTP id o14mr1173112wrc.30.1632344376669; Wed, 22 Sep 2021 13:59:36 -0700 (PDT) X-Received: by 2002:a5d:47ce:: with SMTP id o14mr1173088wrc.30.1632344376488; Wed, 22 Sep 2021 13:59:36 -0700 (PDT) Received: from krava ([83.240.63.48]) by smtp.gmail.com with ESMTPSA id c135sm7335517wme.6.2021.09.22.13.59.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Sep 2021 13:59:36 -0700 (PDT) Date: Wed, 22 Sep 2021 22:59:32 +0200 From: Jiri Olsa To: Ian Rogers Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Namhyung Kim , linux-kernel@vger.kernel.org, Andi Kleen , Jin Yao , John Garry , Paul Clarke , kajoljain , linux-perf-users@vger.kernel.org, Stephane Eranian , Sandeep Dasgupta Subject: Re: [PATCH v8 5/8] perf metric: Add utilities to work on ids map. Message-ID: References: <20210918063513.2356923-1-irogers@google.com> <20210918063513.2356923-6-irogers@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210918063513.2356923-6-irogers@google.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 17, 2021 at 11:35:10PM -0700, Ian Rogers wrote: SNIP > > +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; should we return NULL in here? jirka > + } > + hashmap__free(ids2); > + return ids1; > +} > + > +/* Caller must make sure id is allocated */ > +int expr__add_id(struct expr_parse_ctx *ctx, const char *id) > +{ > + return ids__insert(ctx->ids, id, ctx->parent); > +} > + SNIP