Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1734329pxf; Fri, 12 Mar 2021 18:32:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJx0rgvl0hj3vlk0x2O90kx9KHBJgZ9J0VLnWNlTZg1WeSswyBU8fLbtB23hKI5DiW+VQxab X-Received: by 2002:a17:906:11d1:: with SMTP id o17mr11905417eja.517.1615602768307; Fri, 12 Mar 2021 18:32:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615602768; cv=none; d=google.com; s=arc-20160816; b=TS34BSj46dzMCC0qzfqg8voJaXXSuIBvxSwTkg/YS3h84a49ToruMTRcB+WDZf8kO1 yXUfMtDHl4RmBMZfYq5A/hJGe2a9Aw2XSa+bYIYjVyDy9B8rWx6cfvKUzS6yEubufHam P1hjOtIFbOfDjMrn4z9kITACXCtp55E5wZFsa3Oq7ilYwiD3kbJY9HQDtO53CbUq5azk gTsS8NhZj/c4YI6hEb/rX/hhvET17vAXiDuiz8Iu4vJ7XYDUWVuTiNAVImQbYORRoIrt a8SBO0YU0HU/LZ+BWh/2NWstkX2eROtc+nHD58DmJZIUFSzKo5dHJckss3M8EmtlCDFf dRvA== 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; bh=bL9MisVqCy9+mMTkkT9Ym/rs2nuRRYH0hpQS2/1i2Qc=; b=PJZoiRqsRoSI7AiZypTIY1xkXm6PtDmLxf4TifNb0x7X587xRJl1XgokmapJ33bO1O RtQS9NGLomc+Ufr5hW5TdZWttC6SndMUYN/AizlEnCUPV4QFDm/a9ZjQsOr68YaRxhsZ s6gjFfQGWJY8FtSR1PhvB/LFWhBICKAuk9H/iBIC3c9xvxRfdwhcHIgc0y733Q2kFmND py0QkC1dhX1kx4rDdEbT65MN+/OzGJ6aGGb4qYTYjMmfl2gSmz12pdc0n3/Cvp3MGIkw L+ZHb/bGiozTU1is4n75YPkb7VbwHldZ3oFhnas9+/elKwd7MDnrGrxYIGpyPRQY9LfC wY8Q== ARC-Authentication-Results: i=1; mx.google.com; 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 r12si5916936ejz.5.2021.03.12.18.32.26; Fri, 12 Mar 2021 18:32:48 -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; 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 S233115AbhCMCWi (ORCPT + 99 others); Fri, 12 Mar 2021 21:22:38 -0500 Received: from mail-pf1-f169.google.com ([209.85.210.169]:39042 "EHLO mail-pf1-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233414AbhCMCWU (ORCPT ); Fri, 12 Mar 2021 21:22:20 -0500 Received: by mail-pf1-f169.google.com with SMTP id 18so3084179pfo.6; Fri, 12 Mar 2021 18:22:20 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=bL9MisVqCy9+mMTkkT9Ym/rs2nuRRYH0hpQS2/1i2Qc=; b=YAdYbG6fff0/jGTaEsRmaJxkFUQWpdEk9BoNC2qDSFyxVxYBYbbdIAkXfpKnqHTgG7 Ut8yRQiLkeqEJdWIE+D9/es4MO4I94Hro2bR+Ry3uK/Y5r605ALCnLYmCYw8IUN5Z6N0 8FHpCRd6szDB8VMY2pq+3xnlISt9lMM7lcJBdH40X7NPMVHsjp/K5agTAS17iK62D4SG qe+jJYPRFLiugO2bTY//C080wuKDyiLHEbGeZ0VOlcyApuu3shfoknndB9HJjd8Qj2z/ si21JfrXebVy+zfpwXzHzcuSAwK+WKZ27ar/HeD20VOqp9XWZccdVREYQKDRj3tLh1sF UJ1w== X-Gm-Message-State: AOAM532ZC/dezKIjU3S/Gz1Dip8YfNcgXa/ySf0FAVhLBeaum4BfqyIr Ol/8Q77McjLhfGHAQdtFFaBXqZLRWGJokA== X-Received: by 2002:a65:4243:: with SMTP id d3mr14766300pgq.180.1615602140435; Fri, 12 Mar 2021 18:22:20 -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 m5sm6768990pfd.96.2021.03.12.18.22.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Mar 2021 18:22:20 -0800 (PST) Date: Fri, 12 Mar 2021 18:22:17 -0800 From: Sultan Alsawaf To: Andrii Nakryiko Cc: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Networking , bpf , open list Subject: Re: [PATCH] libbpf: Use the correct fd when attaching to perf events Message-ID: References: <20210312214316.132993-1-sultan@kerneltoast.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 12, 2021 at 05:31:14PM -0800, Andrii Nakryiko wrote: > 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? bpf_link__pin() would fail with -EINVAL when using tracepoints, kprobes, or uprobes. The failure would happen inside the kernel, in bpf_link_get_from_fd() right here: if (f.file->f_op != &bpf_link_fops) { fdput(f); return ERR_PTR(-EINVAL); } Since bpf wasn't looking for the perf event fd, I swapped it for the program fd and bpf_link__pin() worked. Sultan