Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1803594pxa; Sun, 2 Aug 2020 22:17:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwrEx++lbcE0ZUij3OxHO1h08rjSG2mnXd6Wwsuo2ORFg9Fxvh89ZPWm/kgb3ym0RLdXV3U X-Received: by 2002:a50:da44:: with SMTP id a4mr14570319edk.379.1596431835443; Sun, 02 Aug 2020 22:17:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596431835; cv=none; d=google.com; s=arc-20160816; b=pN5RRcRJSARrYr3j7lGQFb14n2xBh6Dyjih+IISgaqmN671e6gTsYRn4wT75uaGkpI fhOmuA2lGen8ocx56C5+rF9mE44hmRcGwoxbfHh8TxAG+XOO9PlRjEjvOX6HjHU1br0X 3iXjk8CelOLEzmQmdOlnuGI+xY5odxtbV9QsI/jSPqSrApF6xbg1/IICVEUSxTesK4Xx mLlFIcRINpzNKHK5tMkwRgSveTVPbynAjNnG+NNrYJwxcdL3h09Axm/16iRQKPX6xdeN p985jegiRBF2J+Uau6GoPWjETkUXaBuPPWnGWrnJ7r2r4CnbCLHXzcNO7kL6Q8LzRpqm bijA== 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=DBnDjn7vidDkpVU0WID8k/kuqtUn/mEBKE1Jn9YiCUg=; b=NfJN4a023CeeRHBPHxAGs8Lrc2lIL4OOtbQR0C/AP/lWiOXirU1sosU9Cd7rfpCSHY zrmDgPboBAYhzoXzf8a1oGm8d/3gt5/JAAOkUHgjxf32SSjnY0S3qs5qkPBIbL4hddZi 3w0j+BtDd86MgbYLA5VQ9hIerooEHHsTCH3DxX47Yb/9MKC8Bvgr/VC9diUh2rGgWV2U 01ZCIDdbVu3LqNrsw0TzD4hWrmEq/ez8FykAw8tyBVqg+N3V0SOTQTdVeOc5FK4zDwyV zEtfseOBGpe8hPYVwToMnC5zzK4bHWgl/kVc3zvFhT+SLbVvnYn3GIIiEmaOoP5gYs1Y /CMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=iTzcJA1R; 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 c21si9521595ejm.385.2020.08.02.22.16.53; Sun, 02 Aug 2020 22:17:15 -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=iTzcJA1R; 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 S1726394AbgHCFKo (ORCPT + 99 others); Mon, 3 Aug 2020 01:10:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725935AbgHCFKn (ORCPT ); Mon, 3 Aug 2020 01:10:43 -0400 Received: from mail-yb1-xb44.google.com (mail-yb1-xb44.google.com [IPv6:2607:f8b0:4864:20::b44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 448C1C06174A; Sun, 2 Aug 2020 22:10:43 -0700 (PDT) Received: by mail-yb1-xb44.google.com with SMTP id q3so62203ybp.7; Sun, 02 Aug 2020 22:10:43 -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=DBnDjn7vidDkpVU0WID8k/kuqtUn/mEBKE1Jn9YiCUg=; b=iTzcJA1Rs9SjWutqGbiB+/Y0adyCk2lZYULEWoM72kmyroik/YInYByz8zbeXPTc2d PUYBq7kt5w2/uAFTAPM18+T3g46xAnBmK+Sstq7z/wNM3p0Lt4x+9gzfPSc6ozLRUM2t RkM9McdeoAOskWcHTcfhFTVx4K4pVTHrkULcKpIIPUkVe8TZReL53NxCF3aXxfGa4M/0 jlHUQ8sz364daT82VFZulbY7KBPWoNC4U1+sBPYDQvnxJ5q6GrmcVWnEtLyXYUqB/nNZ 8HTkVSBir0Rv0JdVnEhgnVIFGGR0+M/SYBc1Dz4tKE/kEM/ppLHBCbPtOFDv2Gzovb2O mc6A== 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=DBnDjn7vidDkpVU0WID8k/kuqtUn/mEBKE1Jn9YiCUg=; b=b3Z4pdrfdizo/Npro1bRHTLZXTA6sv0Q7xc6N1Ube4bVsRJM1TalGXXIHShURgfmAt QOXVlpL9djl1ghr5TW/KnIbZ2MU9wvO85Gx2TIFVAg5DA6gpEdOhhfWfq/Jvw708VhcB a5s5Iyff04+WMkciTNTLI/NG1ZcGnsaeengDeV++aNMnTB1HW9CF14KLRq+CSP/4qKep G/ulzhuUkARy7xkH9CPBcjPGcH+FHEHbZAybsWAOQC08AKuJGN8iC569BotTrfhaeGe4 JO2U/WGUihQH2OvltIwNnq/CSW3JXasEijick39O3fONQmvK9J6gfzyjwCx10Zzq4P2m wcOg== X-Gm-Message-State: AOAM530pBb0MXtGACz7ZL1qAflB2eDDXi/rHUFjLKZ37AmgkE5O4XjQV kvt/lj3utzhMBPa9v9Z3WfvtNVmcbwBRDOQ3AIeEqw== X-Received: by 2002:a25:d84a:: with SMTP id p71mr24748708ybg.347.1596431442552; Sun, 02 Aug 2020 22:10:42 -0700 (PDT) MIME-Version: 1.0 References: <20200801084721.1812607-1-songliubraving@fb.com> <20200801084721.1812607-6-songliubraving@fb.com> In-Reply-To: From: Andrii Nakryiko Date: Sun, 2 Aug 2020 22:10:31 -0700 Message-ID: Subject: Re: [PATCH bpf-next 5/5] selftests/bpf: add benchmark for uprobe vs. user_prog To: Song Liu Cc: open list , bpf , Networking , Alexei Starovoitov , Daniel Borkmann , Kernel Team , john fastabend , KP Singh , Jesper Dangaard Brouer , Daniel Xu 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 Sun, Aug 2, 2020 at 9:47 PM Song Liu wrote: > > > > On Aug 2, 2020, at 6:51 PM, Andrii Nakryiko wrote: > > > > On Sat, Aug 1, 2020 at 1:50 AM Song Liu wrote: > >> > >> Add a benchmark to compare performance of > >> 1) uprobe; > >> 2) user program w/o args; > >> 3) user program w/ args; > >> 4) user program w/ args on random cpu. > >> > > > > Can you please add it to the existing benchmark runner instead, e.g., > > along the other bench_trigger benchmarks? No need to re-implement > > benchmark setup. And also that would also allow to compare existing > > ways of cheaply triggering a program vs this new _USER program? > > Will try. > > > > > If the performance is not significantly better than other ways, do you > > think it still makes sense to add a new BPF program type? I think > > triggering KPROBE/TRACEPOINT from bpf_prog_test_run() would be very > > nice, maybe it's possible to add that instead of a new program type? > > Either way, let's see comparison with other program triggering > > mechanisms first. > > Triggering KPROBE and TRACEPOINT from bpf_prog_test_run() will be useful. > But I don't think they can be used instead of user program, for a couple > reasons. First, KPROBE/TRACEPOINT may be triggered by other programs > running in the system, so user will have to filter those noise out in > each program. Second, it is not easy to specify CPU for KPROBE/TRACEPOINT, > while this feature could be useful in many cases, e.g. get stack trace > on a given CPU. > Right, it's not as convenient with KPROBE/TRACEPOINT as with the USER program you've added specifically with that feature in mind. But if you pin user-space thread on the needed CPU and trigger kprobe/tp, then you'll get what you want. As for the "noise", see how bench_trigger() deals with that: it records thread ID and filters everything not matching. You can do the same with CPU ID. It's not as automatic as with a special BPF program type, but still pretty simple, which is why I'm still deciding (for myself) whether USER program type is necessary :) > Thanks, > Song