Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1713309pxf; Fri, 12 Mar 2021 17:45:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJxZ+v8Opp497qBLRKtQLeqeHWSRTLh7ITTt8oORSJ1WkLzNo9qTSH/Zv7UJRNPTmvghqccr X-Received: by 2002:a17:906:f10c:: with SMTP id gv12mr11718371ejb.53.1615599912240; Fri, 12 Mar 2021 17:45:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615599912; cv=none; d=google.com; s=arc-20160816; b=X0eT9d3aDAAy7x3qw5C+9hUQDGuwPA0NqThKCujkuIkwTzeus4FFnJbqfHYhoGKTT8 TYaL9JjYwkbWC+uwPvpjilsMGu//J2J3Ov8fdx90lJoOxE9BWV7km4wp4PaF4Ec5/d3s nH0YZABj6on4UFohPixrs624IhJu5TWWZstLWKtpi2lmW3bzbOPbgAsH24drTNbD54Dm Oo3U0ZS1ivbMvIEibfZuHbcPv/M5wOIbm23GVyDhIEw/nVuRHMztEQj/pHQjlUSpwFuM LF2yZbwnQc2cOwZ6HmMeFeTTZYipztJB8pKs0kwXL5Yn/vxisbtd8Ydgx/ndy35HPfkN aRyg== 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=DbE3xDkQ8HktwIoRcbeaiX7gfulPHK+RCelzbpG3B1Q=; b=oL2QphshW2CURUcKVJB+XoQstyyLySWeOHM+9oHCnoecAMBSN/rd7qgJcablQ2QDee AqewlUyTedM/hn86cfvPCai8McQpyqhIsJIchsyoWy4/I4bkDiQ/AKbtsZT97mbUm9+V Xkg2eblaE6C6903XiW28vVX3v8gf88wjEHoj82ygWfdjFcj5+WZYHoVZx6YFCj30Vl5R mlExap1gCkLYkJnloi7YYw8XgH5IJYgmcE7eyNU1bA/4stFmDbHVZ8+eGwB01sDjokon nGoyJ7g4T82Ph/v/L3KxtU8Yp+alHt01zxKnFw9HLtovXc8XphXlPSgqXy2cmbncJgsa EhXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="ercgs/Vo"; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dp18si5658444ejc.432.2021.03.12.17.44.50; Fri, 12 Mar 2021 17:45:12 -0800 (PST) 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=@gmail.com header.s=20161025 header.b="ercgs/Vo"; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232559AbhCMBcH (ORCPT + 99 others); Fri, 12 Mar 2021 20:32:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231679AbhCMBb0 (ORCPT ); Fri, 12 Mar 2021 20:31:26 -0500 Received: from mail-yb1-xb33.google.com (mail-yb1-xb33.google.com [IPv6:2607:f8b0:4864:20::b33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 426A3C061574; Fri, 12 Mar 2021 17:31:26 -0800 (PST) Received: by mail-yb1-xb33.google.com with SMTP id x19so27298338ybe.0; Fri, 12 Mar 2021 17:31:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=DbE3xDkQ8HktwIoRcbeaiX7gfulPHK+RCelzbpG3B1Q=; b=ercgs/VoGb+1NneYMOPK67RWCyGd9m3SluCwWbruOrP1Tj+l9ZP9SXWDSnxu9GlwZF E//861xmFlN9+hM4D75juWHdYqvfkDr/aInUfIVZ3/7xzk94fGrXoMwvOxU7nh2Iu3fx wP8Nvv5u6b5S/wPi9N/HpvsQF5QSRhWYdI0uFhBVelkstJQnRdFOMVTy7cHxGQ5cEUAE sT6kg93RUuc3c/dsda4eM2i+xOGaXW9ErpWqxHDksPGF2Q2eHpqQodA4NNkwm99JkL6i 9aw4KkIFfUwaXxvkyWnxdaZcYtGG4A2KA1vzK2EGVDQMaApjWXGrKs7TqgEJTeBeE/iy cz1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=DbE3xDkQ8HktwIoRcbeaiX7gfulPHK+RCelzbpG3B1Q=; b=bNMVJK+0+57vliMqT0dlV4FhMsOTJ3HpM9H2EPNMnJSDmhWl8FP2/31kZkk561UiFe IqIZmSgorFQdoZeT++eIltkB1TlpOr7lw42qOFArRXMosnZr5gwm/8HwMNEdQsTHx+Vr Oas9dkNSBy1KF4I7kB3Gnj6w0FEkPruWAYRqtO3EKm/NyS0D6lEEZGOR7Qmo/w0ts5gX vxhCidGme6ia9hskjYCY5V0GZ0lr1RmACv9MGSFlxZICKDz16QO7L08bp2ATjSmt6NlG IMDiOj6N854J96rGa2dWi0ljtfUYR9Kp/fllv0TbSsgzw03fKzNTJkqoPferLGRWtaSW dxeA== X-Gm-Message-State: AOAM533mos0nAvQrKV+jFcK74Fmmbsxn1x0bW4yAU/2wYdHOW2ev4t4w mtOaXy+kEGxrTBrMfL0yxGhfocUTGYmicok3j2M= X-Received: by 2002:a25:cc13:: with SMTP id l19mr22707860ybf.260.1615599085306; Fri, 12 Mar 2021 17:31:25 -0800 (PST) MIME-Version: 1.0 References: <20210312214316.132993-1-sultan@kerneltoast.com> In-Reply-To: <20210312214316.132993-1-sultan@kerneltoast.com> From: Andrii Nakryiko Date: Fri, 12 Mar 2021 17:31:14 -0800 Message-ID: Subject: Re: [PATCH] libbpf: Use the correct fd when attaching to perf events To: Sultan Alsawaf Cc: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Networking , bpf , open list Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 12, 2021 at 1:43 PM Sultan Alsawaf wrote: > > From: Sultan Alsawaf > > We should be using the program fd here, not the perf event fd. Why? Can you elaborate on what issue you ran into with the current code? > > Fixes: 63f2f5ee856ba ("libbpf: add ability to attach/detach BPF program to perf event") > Signed-off-by: Sultan Alsawaf > --- > tools/lib/bpf/libbpf.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c > index d43cc3f29dae..3d20d57d4af5 100644 > --- a/tools/lib/bpf/libbpf.c > +++ b/tools/lib/bpf/libbpf.c > @@ -9538,7 +9538,7 @@ struct bpf_link *bpf_program__attach_perf_event(struct bpf_program *prog, > if (!link) > return ERR_PTR(-ENOMEM); > link->detach = &bpf_link__detach_perf_event; > - link->fd = pfd; > + link->fd = prog_fd; > > if (ioctl(pfd, PERF_EVENT_IOC_SET_BPF, prog_fd) < 0) { > err = -errno; > -- > 2.30.2 >