From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (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 CB99B19539F for ; Thu, 12 Feb 2026 14:08:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770905318; cv=none; b=bMyElK9+dgu+OIAuw6gvJSOeq1Rl6jmXOtFex9CR9bt4C1QIqtkZIMdEypLEnwhN0ATvsoqewWuvbNOPu21oQyS07M9NE37CbI9d7CiI3NAvNYrf5JSGGNzf8QeBt3FmIG6slVD5n1lBSd3lfOf45PwY+BuHEHPTa9JqW7WAg9c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770905318; c=relaxed/simple; bh=BABOwnLidNmL4sEecG9G+5OdAqQiNm1wEXRvcJvWxRM=; h=From:Date:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=d4jcZCap5BuUkBGr8LXIOjU1B55W05/9siFN4qbDmqBR1vpOpsd6cta6EWJsKGAGFkTqry1vtZ3FzpWFuSy3M4vTPdRsQm56BjHBaeWrTdLELNjNFlvAJtJCCx0+kmhNqnBWuGAR1S0FXQhjzrQlIVrUPgFcmaV7OTZHEpvPIec= 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=LsQM4+uj; arc=none smtp.client-ip=209.85.128.51 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="LsQM4+uj" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-4836f4cbe0bso1656365e9.3 for ; Thu, 12 Feb 2026 06:08:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770905315; x=1771510115; 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=eMEuxtwyIGE57M7rnPRpb5C9mv94nB7nm2gHJHVMXag=; b=LsQM4+ujZqDekArYLCGZUWLbkr0MWpAhm/nos/h/3h/6ZzZ+BO9B+UAu7+Qv2Ni8Y/ b3nNvuWizr1bZ3aR42747TPzSxgwJC5RKbxVchkkeL37lNPFr0mJ+47ygSLKGSK5xJRb 9PBm72cc1uak/0CurW0ItSjmvVefeDf+Q9aqmVf0JnDesLJOmUKFjx7qO7qkVZU1dagD Gx4Ho4NaikQYsofbKQcwBGif7gqUVCEQlhrOaJZ71/RRVpHt08+erJtVKgaZEjRzMwBI yD849qxSbeUyf1KB11dTJ0jr4rZYxWzyQl/xRm1PhGrw8fRTferTKRXa6tGyULtze9zb QI6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770905315; x=1771510115; 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=eMEuxtwyIGE57M7rnPRpb5C9mv94nB7nm2gHJHVMXag=; b=CEog6hRnYOU2DdevBW1q9DwHN0vI8+D367Cqcko7ldQ5oZZJNzN4BGHafwsMv3H7ek BQEmWF1LCE6WZ8bti/dezonPaqdN0P/2n4zI4pvCWFvPIcuuTKTqV0hpaeOd0vNp0aWK 1aeR9i0Yv+yyoTKsJUmTaVpak1I75UOHAWdpjC2qnnbhDUrpT13ptQ3zCQksblXANLu2 RiLZirNI/doNacRpyzVYrN9UPujy071haMN1h1UJn1BjblyIudp5XXsgJyKwI4AUFZlh cs3izdayEaCwmUlDBLgsSm/KGPCsxTuHAyfl9xtxPqYQrXykSjLBbr72kgHsWBxzlbw3 hZrQ== X-Forwarded-Encrypted: i=1; AJvYcCXQapsMO5xflmCK6Wf6FFHGlpfd656FXs5D/fM3UL3wKvKCLOsVCb07EuxU4iH34t4MbXsJDt8XQur1G6o=@vger.kernel.org X-Gm-Message-State: AOJu0YxU+WnHbrIQMBypKBEbSHWke+mE+K9S3Fyu+FWvqL1MN3kyUCzo bceMLCRSbzhwyuCO3atmqWrBKiET3iHWOd8aekebceIhW1Nlg/XupQvl X-Gm-Gg: AZuq6aLTjOWAnh6urib4bJf9Oy5HNczUzBurZwn854E1ETpTSLjAxDSPMUBu4LGXeBv K7rU2GT1TXKfdw3u7eHkNA6Q3S53G2Ny/G7ll019lmy2N5MSSp5NImbzhBjNp21qy32pP3djDPl mwRC1y8ca80FmjppBdrlbysbpswfBxI4Zu1tvdqBpUiRLKjcsT2QTfFlvzUWD072sOrERSqzsIR 10MTXf4riK5n1NS/bQ5Oj6+vV2Iel7fuxZDHFKt5lmN3GhHesy7oIAdUlXllJhCP8hrmVCbY+k7 195d3HI08N+Nt5bMLVpvpYPqYRVtU6cnXRG5UINUshdawX9IzocdkD02YSiPRAnv6ZvMn34UsH4 TzSyUAida/jFaiD5KZU6Hk6B31/9F6MOdqFENxGRlTQ8mR6l2/7em31tDT2DuGtyUeB6xEFcR X-Received: by 2002:a05:600c:1c26:b0:477:9a28:b0a4 with SMTP id 5b1f17b1804b1-48367085b66mr34639025e9.0.1770905314732; Thu, 12 Feb 2026 06:08:34 -0800 (PST) Received: from krava ([2a02:8308:a00c:e200::b44f]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4835a60ee40sm97756055e9.1.2026.02.12.06.08.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Feb 2026 06:08:33 -0800 (PST) From: Jiri Olsa X-Google-Original-From: Jiri Olsa Date: Thu, 12 Feb 2026 15:08:32 +0100 To: Andrii Nakryiko Cc: Andrii Nakryiko , bpf@vger.kernel.org, linux-kernel@vger.kernel.org, Song Liu , Yonghong Song , John Fastabend Subject: Re: [PATCHv3 bpf-next 3/5] libbpf: Add support to detect nop,nop5 instructions combo for usdt probe Message-ID: References: <20260211084858.750950-1-jolsa@kernel.org> <20260211084858.750950-4-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 Wed, Feb 11, 2026 at 01:45:12PM -0800, Andrii Nakryiko wrote: > On Wed, Feb 11, 2026 at 12:49 AM Jiri Olsa wrote: > > > > Adding support to detect nop,nop5 instructions combo for usdt probe > > by checking on probe's following nop5 instruction. > > > > When the nop,nop5 combo is detected together with uprobe syscall, > > we can place the probe on top of nop5 and get it optimized. > > > > [1] https://github.com/libbpf/usdt > > Signed-off-by: Jiri Olsa > > --- > > tools/lib/bpf/usdt.c | 55 ++++++++++++++++++++++++++++++++++++++++---- > > 1 file changed, 51 insertions(+), 4 deletions(-) > > > > diff --git a/tools/lib/bpf/usdt.c b/tools/lib/bpf/usdt.c > > index d1524f6f54ae..4e5f70bb4c31 100644 > > --- a/tools/lib/bpf/usdt.c > > +++ b/tools/lib/bpf/usdt.c > > @@ -262,6 +262,7 @@ struct usdt_manager { > > bool has_bpf_cookie; > > bool has_sema_refcnt; > > bool has_uprobe_multi; > > + bool has_uprobe_syscall; > > }; > > > > struct usdt_manager *usdt_manager_new(struct bpf_object *obj) > > @@ -301,6 +302,13 @@ struct usdt_manager *usdt_manager_new(struct bpf_object *obj) > > * usdt probes. > > */ > > man->has_uprobe_multi = kernel_supports(obj, FEAT_UPROBE_MULTI_LINK); > > + > > + /* > > + * Detect kernel support for uprobe() syscall, it's presence means we can > > + * take advantage of faster nop5 uprobe handling. > > + * Added in: 56101b69c919 ("uprobes/x86: Add uprobe syscall to speed up uprobe") > > + */ > > + man->has_uprobe_syscall = kernel_supports(obj, FEAT_UPROBE_SYSCALL); > > return man; > > } > > > > @@ -585,13 +593,42 @@ static int parse_usdt_note(GElf_Nhdr *nhdr, const char *data, size_t name_off, > > > > static int parse_usdt_spec(struct usdt_spec *spec, const struct usdt_note *note, __u64 usdt_cookie); > > > > -static int collect_usdt_targets(struct usdt_manager *man, Elf *elf, const char *path, pid_t pid, > > - const char *usdt_provider, const char *usdt_name, __u64 usdt_cookie, > > - struct usdt_target **out_targets, size_t *out_target_cnt) > > +#if defined(__x86_64__) > > +static bool has_nop_combo(int fd, long off) > > +{ > > + static unsigned char nop_combo[6] = { > > + 0x90, 0x0f, 0x1f, 0x44, 0x00, 0x00 /* nop,nop5 */ > > + }; > > + unsigned char buf[6] = {}; > > + > > + /* > > + * We are using file descriptor that backs Elf object, > > + * let's dup it to be on the safe side. > > + */ > > + fd = dup(fd); > > + if (fd < 0) > > + return false; > > + if (lseek(fd, off, SEEK_SET) == off) > > + read(fd, buf, 6); > > + close(fd); > > ugh, use pread() instead of all this ? I wouldn't bother with short > read handling, if we didn't get 6 bytes, so be it, no nop5. ok, that's simpler, will change thanks, jirka > > > + return memcmp(buf, nop_combo, 6) == 0; > > +} > > +#else > > +static bool has_nop_combo(int fd, long off) > > +{ > > + return false; > > +} > > +#endif > > + > > [...]