From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4EFBF2D3EC1 for ; Wed, 26 Nov 2025 08:29:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764145779; cv=none; b=VKVmORCN4HcfoWrjz6dTGqeSG3iYcsn2+aCVYRmn2I5ohUcoKf9xYFX2pUg/xmrSvpSx++u2bq5nnkmxK7AbJObB6aLQrUYeMwPc2RysYNc33VQ6U68C2ltE0AFHrnj9y7eHSUavWDJTwU9dmj0zIkq0TwCatQMvz7sZhxpSM+0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764145779; c=relaxed/simple; bh=Fj/H8GtoC7Lv7YBEqyRgHiGtF6bA+y+/0v3L6P5/oBY=; h=From:Date:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=hl7/1zWoiPmcukvk4BFs7IGDTcOsWyTWVsPOUCCpBOWgLvLxHoJXv5TuY8D7bla16fuDibPHigavTYOYEgLjiw6xeEuzILGn3j1htwa2efBZk3e52cuLCXQptPzAP/1ht/g6uDZaOObv5++BRMl+PuX5QptuGXT1EesbiARtWbg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=eyZ00Fo/; arc=none smtp.client-ip=209.85.128.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="eyZ00Fo/" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-4775895d69cso26614615e9.0 for ; Wed, 26 Nov 2025 00:29:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764145776; x=1764750576; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:date:from:from:to :cc:subject:date:message-id:reply-to; bh=7YBiD1eNXL57VH/myk+1e2UVUfOZ7Wljk4dl2rbdSRk=; b=eyZ00Fo/VZhIxv9EcAqdyZf6Ok+nDqrpY3WLSr75Qr+OcezyuLnLFB42chYvio+Rra u0oBpYh1IOaoTNt8VLE/e+ZwbMjUuh1nE6AxrVCejGYS3Afs98rVAfbz2mVoDP+6FB1B L08YhRmnQRLlllhNIom4cQzVzO1x8pWINfcehKzrd46+xYmHtZ+lqwrxLewrWTgPjhbY uG1D9FyoLEk0CzMEtNWNIjHalJMijFRPzR6uUH90O++XQkoxFDAZMRUnFadi5ZdNEXTd 41rzumCVhlfOHSr5RxQoH44wxeutypmeQ/7AztW1KvrTPBzQljzogdbIy6NtBV+9vHOB pzew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764145776; x=1764750576; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=7YBiD1eNXL57VH/myk+1e2UVUfOZ7Wljk4dl2rbdSRk=; b=u6VDKf7RJs6/lbyhUXHDfDN/377qZ/2oOeJWRKuSdTnF4IqdDlPZfUWZU/CRMVTv2Q rVFrh/J6a/W4j9h+lwgcsTbzEPS1y4eDADW/2u4K5stmB90OSyWZqANVpDCqmYWjAdrL ssa38Q06ucuGKygMCxqy1VI4/Mkc5tu52h9yf2+vQhirg7srRLN2ICVDtHdw2ItTTVGs IPqNYlb2Tsby+7fxxi/Xp3ziTMyTq+7GhJ82vUGXGkanw5OrrnByHnHLonKUN/b8dW7P uIb3TGxd94rOfPzUi/cIBoaHL5hNfcjC3ePhhdYJ8FdMSHP50eG4tifqBHA3bcrJRTrg Lzpw== X-Forwarded-Encrypted: i=1; AJvYcCXXU9vK+zMu3Niq1x4e+tZLFXMDLuXrTKdfb1S/dw0OfprmqvPq/TFBHx32YLjLagJ3/TYpb/pZ8xuK3jo=@vger.kernel.org X-Gm-Message-State: AOJu0YykRRGnCzSg+GueSbnvcA/Ouv3szoldJIZ3AbjKYM49uAV+Nc6V ep4Te8frmqbprmJAiVgyPLaHP8Xpj/7qYfdazFvybiSY0St/SPbIV54b X-Gm-Gg: ASbGncuOw4160Fo/VW1/YGEcY8vzGlTSOv1g3qnGoWK1x/xH0rjFf2/w6Noug8SiuQC BMk/srMXB7bP355Gp43+Qej4tnAD9oPDCt1DES25nDfU7PzlFymsuEg4p7gkDhiEVOXDu+H3gZN 8KQe4y4erMeVYbCWozqi0XIjFvWBFwv1ozuUzIPfoCtZDMWfNIM16+XEeovM+ZnhSFn5ulk6Vn3 Y2d7jA9nWZvXO94HAeb/EneoYgBBj/In/n//2qXRtIkrb/cbBO8VDexhywrX4RfGfHo7z1tOi2H 3YDcdWkwo4unBZhaeuoGNDsDDQb7QcCHs4uUxhvVAwQmPty+HsfZWjEPBB9jotXDxBuSFLUhrB4 DUfgYoNA4JW+c0UBcWTL8qoma3OlctTnb5qpq11wvbY7R6LHYdpB/Qu6NvwAi X-Google-Smtp-Source: AGHT+IGtL/u/j9YWsyVWNlFi4rIReU+8tAA0EpazadN9+phB7KRu8ZYycmV+h5JEOdRiOCEneJ6XkA== X-Received: by 2002:a05:600c:354e:b0:470:fe3c:a3b7 with SMTP id 5b1f17b1804b1-47904ac4380mr49638245e9.5.1764145775525; Wed, 26 Nov 2025 00:29:35 -0800 (PST) Received: from krava ([2a02:8308:a00c:e200::b44f]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4790adf0b2asm28932705e9.11.2025.11.26.00.29.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Nov 2025 00:29:35 -0800 (PST) From: Jiri Olsa X-Google-Original-From: Jiri Olsa Date: Wed, 26 Nov 2025 09:29:33 +0100 To: Andrii Nakryiko Cc: Andrii Nakryiko , bpf@vger.kernel.org, linux-kernel@vger.kernel.org, Song Liu , Yonghong Song , John Fastabend Subject: Re: [PATCH bpf-next 4/4] selftests/bpf: Add test for checking correct nop of optimized usdt Message-ID: References: <20251117083551.517393-1-jolsa@kernel.org> <20251117083551.517393-5-jolsa@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Mon, Nov 24, 2025 at 09:34:45AM -0800, Andrii Nakryiko wrote: > On Mon, Nov 17, 2025 at 12:36 AM Jiri Olsa wrote: > > > > Adding test that attaches bpf program on usdt probe in 2 scenarios; > > > > - attach program on top of usdt_1 which is standard nop probe > > incidentally followed by nop5. The usdt probe does not have > > extra data in elf note record, so we expect the probe to land > > on the first nop without being optimized. > > > > - attach program on top of usdt_2 which is probe defined on top > > of nop,nop5 combo. The extra data in the elf note record and > > presence of upeobe syscall ensures that the probe is placed > > on top of nop5 and optimized. > > > > Signed-off-by: Jiri Olsa > > --- > > tools/testing/selftests/bpf/.gitignore | 2 + > > tools/testing/selftests/bpf/Makefile | 7 +- > > tools/testing/selftests/bpf/prog_tests/usdt.c | 82 +++++++++++++++++++ > > tools/testing/selftests/bpf/progs/test_usdt.c | 9 ++ > > tools/testing/selftests/bpf/usdt_1.c | 14 ++++ > > tools/testing/selftests/bpf/usdt_2.c | 13 +++ > > 6 files changed, 126 insertions(+), 1 deletion(-) > > create mode 100644 tools/testing/selftests/bpf/usdt_1.c > > create mode 100644 tools/testing/selftests/bpf/usdt_2.c > > > > can you please add a simple uprobe benchmark so that we can compare > nop1 vs nop5 performance easily? See below, I'd actually force nop1 > for existing test with custom USDT_NOP override, and assume nop1+nop5 > as a default case for nop5 bench. yes, will add it > > > diff --git a/tools/testing/selftests/bpf/.gitignore b/tools/testing/selftests/bpf/.gitignore > > index be1ee7ba7ce0..89f480729a6b 100644 > > --- a/tools/testing/selftests/bpf/.gitignore > > +++ b/tools/testing/selftests/bpf/.gitignore > > @@ -45,3 +45,5 @@ xdp_synproxy > > xdp_hw_metadata > > xdp_features > > verification_cert.h > > +usdt_1 > > +usdt_2 > > diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile > > index 34ea23c63bd5..4a21657e45f7 100644 > > --- a/tools/testing/selftests/bpf/Makefile > > +++ b/tools/testing/selftests/bpf/Makefile > > @@ -733,6 +733,10 @@ $(VERIFICATION_CERT) $(PRIVATE_KEY): $(VERIFY_SIG_SETUP) > > $(VERIFY_SIG_HDR): $(VERIFICATION_CERT) > > $(Q)xxd -i -n test_progs_verification_cert $< > $@ > > > > +ifeq ($(SRCARCH),$(filter $(SRCARCH),x86)) > > +USDTX := usdt_1.c usdt_2.c > > +endif > > + > > why not compile it unconditionally, why complicating makefile if we > can do x86-64-specific logic in corresponding files? ok > > > # Define test_progs test runner. > > TRUNNER_TESTS_DIR := prog_tests > > TRUNNER_BPF_PROGS_DIR := progs > > @@ -754,7 +758,8 @@ TRUNNER_EXTRA_SOURCES := test_progs.c \ > > json_writer.c \ > > $(VERIFY_SIG_HDR) \ > > flow_dissector_load.h \ > > - ip_check_defrag_frags.h > > + ip_check_defrag_frags.h \ > > + $(USDTX) > > TRUNNER_LIB_SOURCES := find_bit.c > > TRUNNER_EXTRA_FILES := $(OUTPUT)/urandom_read \ > > $(OUTPUT)/liburandom_read.so \ > > diff --git a/tools/testing/selftests/bpf/prog_tests/usdt.c b/tools/testing/selftests/bpf/prog_tests/usdt.c > > index f4be5269fa90..a8ca2920c009 100644 > > --- a/tools/testing/selftests/bpf/prog_tests/usdt.c > > +++ b/tools/testing/selftests/bpf/prog_tests/usdt.c > > @@ -247,6 +247,86 @@ static void subtest_basic_usdt(bool optimized) > > #undef TRIGGER > > } > > > > +#ifdef __x86_64 > > +extern void usdt_1(void); > > +extern void usdt_2(void); > > + > > +/* nop, nop5 */ > > +static unsigned char nop15[6] = { 0x90, 0x0f, 0x1f, 0x44, 0x00, 0x00 }; > > nop15 is a very confusing name for this :) nop1_nop5_combo ? ok :) > > > + > > +static void *find_nop15(void *fn) > > +{ > > + int i; > > + > > + for (i = 0; i < 10; i++) { > > + if (!memcmp(nop15, fn + i, 5)) > > + return fn + i; > > + } > > + return NULL; > > +} > > + > > [...] > > > char _license[] SEC("license") = "GPL"; > > diff --git a/tools/testing/selftests/bpf/usdt_1.c b/tools/testing/selftests/bpf/usdt_1.c > > new file mode 100644 > > index 000000000000..0e00702b1701 > > --- /dev/null > > +++ b/tools/testing/selftests/bpf/usdt_1.c > > @@ -0,0 +1,14 @@ > > +// SPDX-License-Identifier: GPL-2.0 > > + > > +/* > > + * Include usdt.h with defined USDT_NOP macro will switch > > + * off the extra info in usdt probe. > > + */ > > +#define USDT_NOP .byte 0x90, 0x0f, 0x1f, 0x44, 0x00, 0x00 > > +#include "usdt.h" > > upstream usdt.h will use nop1+nop5 on x86-64 unconditionally, so I'd > invert this, and *force* one of the cases to a single nop1 with custom > USDT_NOP, wdyt? ok, it's basically what it's doing now, just with the extra nop5, but I agree that having just nop1 makes more sense thanks, jirka