Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1042512ybt; Fri, 10 Jul 2020 20:54:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJypDsyvzWQuf0d8zwILrRzxeKIPwJJyORAE9x9vpoe40ZhizroYsn/hpjyBMgiT/e7x7yhI X-Received: by 2002:a17:906:eb4b:: with SMTP id mc11mr62926046ejb.5.1594439647847; Fri, 10 Jul 2020 20:54:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594439647; cv=none; d=google.com; s=arc-20160816; b=sNyQu3VU06gb5HhLuegWw5mFH87FcQLJ5TrVK5SMebr4+u65ApwiplaaW2q8ikzk+T QDWMDdHv/loYXbyaKtVMWmVaGCR3kqUSfhDIlhcRx4VLJ/bb09wgcqlrGEk70q6twWBQ kLc/HOIzTM7135caF/XUDvPdmux/OOBKXbzTPAknnHkA+YTK2LzkUk2tdzmhhtZGwZ4h Lvjl1sKUblPq7fdifu7+FU4w1J/UD4ILivIgcdD4y56fy1BM9dher8G3ShI/OO8U3h+f FpJx0vUqzPoNsCqMJ/jc/6pDINRe38q3YIA58yuj5FSf9DgPhZtbZJGfyEkG6B222PoO c4sA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=Z6AWxd/5FGxxwuquMSsRnXjurO0TQ1vFQCnKi381IDk=; b=Jp/rsE62VhlddFCU9bIGn+cLts9tTDkKhmsV0/msZx6XVu0HZ0Fkzr1zN1uufG5g0G uZGK8mK3zl+q5LNAUiApEZDbfaOnqv0dlrYM9OlGJUiziTZcvDzi+RZesu9K0ZuVHJ3Q 07WaLSMKndJ/FMJTHy3lvGaGNHVcvSYtR7gS1qgYxXJxLk1vz9qSWDdp+Jtzxg98teSr vDM6TGx2OPWHho6Gk8jV4ctDDPystF4Fhyz3J8NZhMJ/ruTANpWWc7Fm/T754ZBU/Hbx jBBCfhbnFCYTaRd05S+mmwNIVA7SB2H1FDFeoNAo8CuWJiw0USAMZEftpthsAd3sKvxe P/JQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=C6VcTj4x; 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 u17si5685507edd.139.2020.07.10.20.53.32; Fri, 10 Jul 2020 20:54:07 -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=@gmail.com header.s=20161025 header.b=C6VcTj4x; 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 S1727858AbgGKDxP (ORCPT + 99 others); Fri, 10 Jul 2020 23:53:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726671AbgGKDxP (ORCPT ); Fri, 10 Jul 2020 23:53:15 -0400 Received: from mail-qt1-x841.google.com (mail-qt1-x841.google.com [IPv6:2607:f8b0:4864:20::841]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 626AEC08C5DD; Fri, 10 Jul 2020 20:53:15 -0700 (PDT) Received: by mail-qt1-x841.google.com with SMTP id j10so6075893qtq.11; Fri, 10 Jul 2020 20:53:15 -0700 (PDT) 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=Z6AWxd/5FGxxwuquMSsRnXjurO0TQ1vFQCnKi381IDk=; b=C6VcTj4xMiKCEMQoy5rLWrZmdNXOcvN+ZJWsPgA9F3KDPpSTwuPddnzlcvjzaKviDr 36i/TPtGiY1XVQCDCjvcjth6U2AL3ZxXYLYsQZSQ1recPIH7ulfuNjErU6j0rezNvOWM 5+GEBf+5tYDU3h9DQX5dC0ozoCRszTSkW6hoU2r+HeYbu8/JGVfZKxFFrzYOhJ6YQyxh USF0vCFLTGo0LFcP91ac6lr7NIv1CICrork6aBlnlYwSIp5sVTUVSTJhhX7E9fh3v1xg Yo8NotMYcQRJbM7zYazEa97OHP5uKQuXNsjTpCjrSg7KurH5U6wsmi1wdBCGJtSlD3q8 xTHA== 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=Z6AWxd/5FGxxwuquMSsRnXjurO0TQ1vFQCnKi381IDk=; b=uBA/1EffQo+rn7sr0ClHhi+bJurc/YBs+MIul7ZpkhMDn0IZwHxm73+rc46ZRhKMiF vJfJf1/pS1ibZMrbd3ajNpH/t4NnXYiB2DrvSeItYbM69mH17RNk9wiedb6xSBOWIpOq ixDrAKs8yE2HT7+8QvcL0lXm/gFwQZ2DqfNn5KhZ/vDt07kertgGXxThWFkNDXD7f+lX C50rTVP+lsJjJ9qhtt0MYS7RYotaDDd9fOsoqvh7bUxo1Dqf/iJdN4xn7OfUHUJjTRlj FwXrORCSShB9du2pGC0btyMjDvM4lcefjQacYZaim/ps+8WVTavlIUxKoP9+NwzIMcV1 bONg== X-Gm-Message-State: AOAM530oXK5seH8HX5Bw7ox6hWSrm4Wmw5m0lfDBItC3payNoQVHhcE+ p2palbTGGpqHg44MbufZDmdc5Vmo/MnyKypbCVw= X-Received: by 2002:ac8:1991:: with SMTP id u17mr71393499qtj.93.1594439594578; Fri, 10 Jul 2020 20:53:14 -0700 (PDT) MIME-Version: 1.0 References: <20200711012639.3429622-1-songliubraving@fb.com> <20200711012639.3429622-2-songliubraving@fb.com> In-Reply-To: <20200711012639.3429622-2-songliubraving@fb.com> From: Andrii Nakryiko Date: Fri, 10 Jul 2020 20:53:03 -0700 Message-ID: Subject: Re: [PATCH bpf-next 1/5] bpf: block bpf_get_[stack|stackid] on perf_event with PEBS entries To: Song Liu Cc: open list , bpf , Networking , Alexei Starovoitov , Daniel Borkmann , Kernel Team , john fastabend , KP Singh , Jesper Dangaard Brouer , Peter Ziljstra Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jul 10, 2020 at 6:30 PM Song Liu wrote: > > Calling get_perf_callchain() on perf_events from PEBS entries may cause > unwinder errors. To fix this issue, the callchain is fetched early. Such > perf_events are marked with __PERF_SAMPLE_CALLCHAIN_EARLY. > > Similarly, calling bpf_get_[stack|stackid] on perf_events from PEBS may > also cause unwinder errors. To fix this, block bpf_get_[stack|stackid] on > these perf_events. Unfortunately, bpf verifier cannot tell whether the > program will be attached to perf_event with PEBS entries. Therefore, > block such programs during ioctl(PERF_EVENT_IOC_SET_BPF). > > Signed-off-by: Song Liu > --- Perhaps it's a stupid question, but why bpf_get_stack/bpf_get_stackid can't figure out automatically that they are called from __PERF_SAMPLE_CALLCHAIN_EARLY perf event and use different callchain, if necessary? It is quite suboptimal from a user experience point of view to require two different BPF helpers depending on PEBS or non-PEBS perf events. [...]