Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1595776pxf; Fri, 12 Mar 2021 13:45:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJxJ8b8IkGJ3+91s3j9MAs2dUDRTyDNhN9CpIeJnh2/RjxovjfS1uPjerXpMIO6P5reEGMKe X-Received: by 2002:a05:6402:4301:: with SMTP id m1mr17200149edc.210.1615585523404; Fri, 12 Mar 2021 13:45:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615585523; cv=none; d=google.com; s=arc-20160816; b=RBOtHmxjlIrqsZbsmG1oafKOsmyyF8ePR/PAxL1CgwH3DSkZAItp3kfAEQmmIJZi1r WvI2uSdfJUukUnBecTCB+AnoLAfCeoe7i/Ai5QcIr6iOULWutD5CRazyMtOR2vZFVX5a 7ythEiGq58SNjZtqk8wxqmnAE6w9olJC28J0w6NvCtdgzQ7obidUaKxDfUoN45U8B+FZ 6sGQ8u5hiD9Mzkp/rhZ9L0VOvrT6sN3OnfuNOyVRHVVftCxtD2UjiiQQX3MYMHQH2SQF HQUW0b+M0myvQGZjEpLT5rhAG+bqaRhGcPoHDHbWWJCDHhdMf/pix4I20kI3UuV5nVqg njtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:content-transfer-encoding:mime-version :message-id:date:subject:cc:from:sender:dkim-signature; bh=THf+Q27rCE5bAqT61RxqjUfzIMw5JhYn8NNtx0p14fg=; b=MAiRiR07MDlsTch3JQuFcCQqZRpDLopfjLhEgYz1IKuwWi8hQeSAH1UVrkJVkQJCtN wgh3pIWfvf6RS3pqQ85SSqkRnIUEqa8mStv691gwSCf2b0NIV4/NSbI3ynUEk8v8rRoL Ac4JnBMPZTscxxAaRB7ryVJtwDAtOnsP/TNkAWbWP7XKTeV+Rc2ulNFrr/q4XQwzoPz6 OK9RW7oumtTu/OE79Ilt9ZTZWVODnXdO1qufFRtPMDHff8hsPi/NG38y8wk1rXfeEfG9 DeoPnX9DR7LjKINwjpJ3jtqY6JPtYvwY5UbtF1oz7+Cot22BWQD1HsZcqA/M8pNvItVf tH/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=WiHXeodK; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g9si5202853ejh.247.2021.03.12.13.45.00; Fri, 12 Mar 2021 13:45:23 -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=fail header.i=@gmail.com header.s=20161025 header.b=WiHXeodK; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235283AbhCLVoE (ORCPT + 99 others); Fri, 12 Mar 2021 16:44:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234219AbhCLVnx (ORCPT ); Fri, 12 Mar 2021 16:43:53 -0500 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E70F6C061574; Fri, 12 Mar 2021 13:43:52 -0800 (PST) Received: by mail-pj1-x1034.google.com with SMTP id t18so5784201pjs.3; Fri, 12 Mar 2021 13:43:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=THf+Q27rCE5bAqT61RxqjUfzIMw5JhYn8NNtx0p14fg=; b=WiHXeodK/wol85oDmp7yWl+34nzWFLLznfcL4ts+vBP6cg2Py3p4BieaEbNbDTe6om xkRVMLslLYumR2uzSl78EdTI8MsgzfYtMNPrOXE/SWeFNA4zcrufbk5yk3ZK/uytmFfk wq4sgh5mkTgrYox0bpP+WB3IvJKnTO+AzctCuG9GzUbfdrwBgd3K+wLtZ4sWMjvZssa6 /xsIvLMuWh9TUa4OGYX6GQJx4UB3I2NJ1Ksajt1xjKmPTSMcldIl7IDIz+ZkwoVqhXAn 2X0O6w79P2l3F5KxyrbWoZWrXcfpRYIz7RJFUIEcJXwdBoBi0g4ZaHeHowiy4re1GO8H PvEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; bh=THf+Q27rCE5bAqT61RxqjUfzIMw5JhYn8NNtx0p14fg=; b=LxY92C9cir5N9cLtm+aNVVwOCG+BFmbq1BrtwxzWi6qKQJ/uPvhR2KfZmMS+rwNOKA M+gfZ2b8sQotAz9padBDfrdF0Y8KW0VW+nAZl88xcMgRT/StMnkwUHMpeCvOG/g9GQFB tTLZvcHrA6f4V9yahRGbQulf7/JRiaCO4NK+l5SJEEUYsfcpczHa0ndaJX5lZ9eEoH7N uPE3Frq2sDXr+6Gbq5dDmrwb+nRtSZIm1tp9hkgwrYrba07RAlPzIZMQUTFiYPc5lX42 7H41s8/srGUD6JwJseb1QOHxf2qFthicU88LYHHNXl39xtpPsB2SeFnNXSMkTeZdbHGl jfcA== X-Gm-Message-State: AOAM531mhg0c9fEJVWiMytH+YdVnoOcD+9NiKkl3EyQgxQtaRz9cUu3f GQBXI4oUufJJ4czJeWPOseVT0XkJPWZLRw== X-Received: by 2002:a17:902:bd96:b029:e6:3d73:f90e with SMTP id q22-20020a170902bd96b02900e63d73f90emr480048pls.63.1615585432536; Fri, 12 Mar 2021 13:43:52 -0800 (PST) Received: from sultan-box.localdomain (static-198-54-131-119.cust.tzulo.com. [198.54.131.119]) by smtp.gmail.com with ESMTPSA id e63sm6276094pfe.208.2021.03.12.13.43.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Mar 2021 13:43:52 -0800 (PST) Sender: Sultan Alsawaf From: Sultan Alsawaf X-Google-Original-From: Sultan Alsawaf Cc: Sultan Alsawaf , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] libbpf: Use the correct fd when attaching to perf events Date: Fri, 12 Mar 2021 13:43:15 -0800 Message-Id: <20210312214316.132993-1-sultan@kerneltoast.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sultan Alsawaf We should be using the program fd here, not the perf event fd. 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