Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp767054pxb; Thu, 17 Feb 2022 14:24:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJzyRVk+xe+LLMIWzV6n9NpX8ZbjSXHl4+QCHNGkoDgjqJSpro8GITmfHcc52ms+C6Qw/UAq X-Received: by 2002:a63:b50b:0:b0:373:9242:6b98 with SMTP id y11-20020a63b50b000000b0037392426b98mr3928466pge.553.1645136679283; Thu, 17 Feb 2022 14:24:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645136679; cv=none; d=google.com; s=arc-20160816; b=d+9JJ6f4yG2tWsIScWY3Znb4tg06A5JjMqNaVETqrvTGO0zQrdRa3vMBJcfNRzZKuV haarz2xsef5yhIHiNwzp30Aa1wApQ1VJ02DhcTYQYq44dtV/U3E8pvML11rttxR3EMJI gmahfYqTB23Wkf82hZWxk9pp1h8eJncBtVLT6iDHUcD1lhVWr6bjSJbEIM2ySdOPemKW Ns/u1lG9IvPF379M/D8MS1eXGmtgAnwGUjIN1eAqdbFKO6WMKsDdM903hAli9AeSBEoa 0wXOhOWPyDEZbFLnyIZ1mNDqHam3pH9it/yXYWIopnGfu3xDM5plIzo64xO54MSHzBwO EFyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=YYu50T47m2X15x/aJyA+exabFEHDtWyNBqkWcs49TkU=; b=0HBvIBf5E73HuYAs0v1GaSDGUqYxyePhDoe/apoHMf2jLWRjqpgmvxb3s+N+MnZk7i XBpPCbVCrVS7HGEYi4pRyjEdI+XbWKWyeV9+49gPj4KnsqV1UkTsSX3cMUvoKQxTShe2 VyW1X4F7Xj7PoPnX/5kaXIfO+tKF0jL30jNpNLiPjmj1UlfaU1dQyTuQtcBE8Gxa15m8 JGgjbLcGxwpgFedaFm30G/pWS7wdL7FwNjNbpb7RUkeYch0Bx/eP2ugMc0yPCoAHT6Wl 0HxBXYow56/mPjMOZcel11rmrrmp5cMuiggLeH3D7YKVFUqmZ4bOyKmHWTGdGM1gOIjO 2tdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ev4QrgJP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g125si9243582pgc.814.2022.02.17.14.24.18; Thu, 17 Feb 2022 14:24:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ev4QrgJP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244464AbiBQVro (ORCPT + 99 others); Thu, 17 Feb 2022 16:47:44 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:34970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232099AbiBQVrn (ORCPT ); Thu, 17 Feb 2022 16:47:43 -0500 Received: from mail-io1-xd2e.google.com (mail-io1-xd2e.google.com [IPv6:2607:f8b0:4864:20::d2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9054C102423; Thu, 17 Feb 2022 13:47:28 -0800 (PST) Received: by mail-io1-xd2e.google.com with SMTP id c23so624849ioi.4; Thu, 17 Feb 2022 13:47:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=YYu50T47m2X15x/aJyA+exabFEHDtWyNBqkWcs49TkU=; b=ev4QrgJP8rMw+DRyRssNZyhsWtgCHd0RnHRTdh98a+lZvx7PZSRjSZOGd/SYWZoA3j 9k2wVHuezrkp7wr2A9zgdwYFDfN+uK9Vj08D4PrvbAyztMfHFwc1rL0PB7xvPanEoyxe t4D7GYrWNS4z8PoKUlj5nqK2QvoMOAKWfEAo1DL7hyIoPbmvQiPN3d/Gapm7GIQfYYug ote3EnGwgPhWWV1/sc/LmwJ0vWq8RwB5/4D5oen9vKWSwnIPHyvSMliw0WGn1OJZF0Oa H+BTaYlcVq68fmxJ1R+UXZh6gP75/RaO1G6USm6FbycX8L4skjZnXWXuJ5vXnLf1bYqX GwnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=YYu50T47m2X15x/aJyA+exabFEHDtWyNBqkWcs49TkU=; b=jjRxObVztPxG2x+oA9kImdSY/qZ5fa4X+ravrUm2LNXMyVJ6GHSC42lHBWGJoojXND nsRnEqllqvQ016+ma1RzZMsQyYBM1+CPxxDCVNhq4C+MCr+UjaKqVr8LomTS+qXbhDdF oXkFo4bV/Lss+M0JYytTqytMtAeEKwlE0U8i84dO0eaRa9j5CgLETEklT7VtylhcS40Z M42l8ANGpFUNufrPe5Xl2zAuyTPhwTKcdw4FI7WPVqiVdD6RT86NODvj/H7JqcH2t5FJ Um5YHBXGqY6Fe5ooOk1Kmj49LXovYUgXtJBvACCVFBGrX6kGyxEtiXudefOZ5VcQp62j WJ2w== X-Gm-Message-State: AOAM531ogTTmGyiKT/1WNTVonzZgVkzVpCJVd3rkNIkfIAccDUQ91SQz LNbXEk0mzAxcoXwBKc84VbM0x+2iy1DuJD/Z6BQ= X-Received: by 2002:a05:6638:22c3:b0:30a:2226:e601 with SMTP id j3-20020a05663822c300b0030a2226e601mr3291883jat.237.1645134448000; Thu, 17 Feb 2022 13:47:28 -0800 (PST) MIME-Version: 1.0 References: <20220217131916.50615-1-jolsa@kernel.org> <20220217131916.50615-2-jolsa@kernel.org> In-Reply-To: <20220217131916.50615-2-jolsa@kernel.org> From: Andrii Nakryiko Date: Thu, 17 Feb 2022 13:47:16 -0800 Message-ID: Subject: Re: [PATCH 1/3] perf tools: Remove bpf_program__set_priv/bpf_program__priv usage To: Jiri Olsa Cc: Arnaldo Carvalho de Melo , Andrii Nakryiko , lkml , Peter Zijlstra , Ingo Molnar , Mark Rutland , Namhyung Kim , Alexander Shishkin , Ian Rogers , "linux-perf-use." , bpf Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 17, 2022 at 5:19 AM Jiri Olsa wrote: > > Both bpf_program__set_priv/bpf_program__priv are deprecated > and will be eventually removed. > > Using hashmap to replace that functionality. > > Suggested-by: Andrii Nakryiko > Signed-off-by: Jiri Olsa > --- > tools/perf/util/bpf-loader.c | 91 +++++++++++++++++++++++++++++------- > 1 file changed, 75 insertions(+), 16 deletions(-) > [...] > + > +static int program_set_priv(struct bpf_program *prog, void *priv) > +{ > + void *old_priv; > + > + if (!bpf_program_hash) { > + bpf_program_hash = hashmap__new(ptr_hash, ptr_equal, NULL); > + if (!bpf_program_hash) should use IS_ERR here > + return -ENOMEM; > + } > + > + old_priv = program_priv(prog); > + if (old_priv) { > + clear_prog_priv(prog, old_priv); > + return hashmap__set(bpf_program_hash, prog, priv, NULL, NULL); > + } > + return hashmap__add(bpf_program_hash, prog, priv); > } [...]