From nobody Mon Jun 24 16:27:55 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4W7D0V0nhJz5PBsj; Mon, 24 Jun 2024 16:28:10 +0000 (UTC) (envelope-from rlibby@gmail.com) Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "WR4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4W7D0T4MtSz4Ndm; Mon, 24 Jun 2024 16:28:09 +0000 (UTC) (envelope-from rlibby@gmail.com) Authentication-Results: mx1.freebsd.org; none Received: by mail-lf1-x12b.google.com with SMTP id 2adb3069b0e04-52ce09b76e0so1540503e87.0; Mon, 24 Jun 2024 09:28:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719246487; x=1719851287; darn=freebsd.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=84ez4MPoL/Y4YYwzwyncej0NEKXZ/e2g5zXrQ9+DkYA=; b=jQw7tG8KznXy/8UxUo4WnCuky8NCcchgBr5ZqWuMp9yVJRXPSj0XvUsJRSTmmmX9As ntFWGWHKWXRuK55cx+LNOihsVrJFBFKnoQp/heKDqrUpZNdDOuYIT+0YKUTKFQcR0JLO ATh2v2MJo/6FnmKFeSFixglRQGMzA+6Ddrr3NX7JWX7U5oZIMcp6ZSzORKjosQf18NJB MkRVlofNNF+pxD6UimEC5pGHw/4svFKtfg6tvI2kP6ZlaGYOxslUF6Ub/H5bahzov8wK ae0HRLOyQb/UDWe5LdCLgKHP6CNwcCmYOGP7Ho5HPHi6kxKH9nCOP2QSnfAWChaVLDb6 0pBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719246487; x=1719851287; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=84ez4MPoL/Y4YYwzwyncej0NEKXZ/e2g5zXrQ9+DkYA=; b=sXs3NffFnmYzkcytmFSV/66mdJfbPNnQ9wFCI2PdszIxxngHdgMwUrnmorH7FycApG yp7CvLg0BlgyPNEy2ilMOXz6TaOrh5P1eMi9d6v8KDlCVgJWQQR/Nnyd4VLnguDwCcwo cqnhvaJncTcpkIUdu0BE4BxQ3RGRZ+ho/f8GD/ECiKNcmbPRroIa9tAusdaW1EL2XLK7 pawqT0wlQvQWj8/ondn1jDn4DBrSZ4L047KvXFef2AT2Qu5pF/GpHyQ9NzoHRG9mDABV ERupqqRs3WcCmclRvVnHcLKaptn5q73I4RjgnD39YdPabyj8bxqSRWcmEmKlXFsHJWE9 jakg== X-Forwarded-Encrypted: i=1; AJvYcCUp2LZrJ8y6hPyvpEN0zHYnT/cMonKuE9rFU4ZYZEOorQv4l4fVDYOHB0W1LFMORuogBPGQTK82/Z7VRnwdVU/QFs0v/9+I7cwVGqpnOTZLzgPb+rXEoye6DbG3dJEc2XkC+Q0JqrXv74+iHqNjur19lg== X-Gm-Message-State: AOJu0Yzn6Dt5GLmFUODatLF3FEewfDgiQGfKuF7uiquK2zlXnxjMz2QH x1YVTWI2pXA8JMu7jLxGwmC5QLrL692ja4mr4bYIpiTacfetFeD2A5eQHaBhY9Abu6y5pFKCKNB Lkj9mBOrn3hObbX3HU8QavLQLf45rwvQm X-Google-Smtp-Source: AGHT+IEs2qWKCrhZimIlDFczz0O93nYoGJXesr5OcWM+5c37B9ecfE0+Epxm/Q0OkI+FhXX6Ij3p3WbEEDA54YWWAAo= X-Received: by 2002:a05:6512:33cc:b0:52c:ebf6:9a7f with SMTP id 2adb3069b0e04-52cebf69b22mr414134e87.11.1719246486572; Mon, 24 Jun 2024 09:28:06 -0700 (PDT) List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 References: <202406192058.45JKwB77036327@gitrepo.freebsd.org> In-Reply-To: From: Ryan Libby Date: Mon, 24 Jun 2024 09:27:55 -0700 Message-ID: Subject: Re: git: ddf0ed09bd8f - main - sdt: Implement SDT probes using hot-patching To: Mark Johnston Cc: src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spamd-Bar: ---- X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:15169, ipnet:2a00:1450::/32, country:US] X-Rspamd-Queue-Id: 4W7D0T4MtSz4Ndm On Mon, Jun 24, 2024 at 9:06=E2=80=AFAM Mark Johnston w= rote: > > On Mon, Jun 24, 2024 at 08:36:55AM -0700, Ryan Libby wrote: > > On Wed, Jun 19, 2024 at 1:58=E2=80=AFPM Mark Johnston wrote: > > > > > > The branch main has been updated by markj: > > > > > > URL: https://cgit.FreeBSD.org/src/commit/?id=3Dddf0ed09bd8f83677407db= 36828aca2c10f419c9 > > > > > > commit ddf0ed09bd8f83677407db36828aca2c10f419c9 > > > Author: Mark Johnston > > > AuthorDate: 2024-06-19 20:57:09 +0000 > > > Commit: Mark Johnston > > > CommitDate: 2024-06-19 20:57:41 +0000 > > > > > > sdt: Implement SDT probes using hot-patching > > > > > > The idea here is to avoid a memory access and conditional branch = per > > > probe site. Instead, the probe is represented by an "unreachable= " > > > unconditional function call. asm goto is used to store the addre= ss of > > > the probe site (represented by a no-op sled) and the address of t= he > > > function call into a tracepoint record. Each SDT probe carries a= list > > > of tracepoints. > > > > Questions out of curiosity and maybe ignorance: > > > > How does this work with relocations? Something must be adjusting these > > addresses? > > The compiler handles this as part of the implementation of asm goto: > the inline assembly can reference jump targets with "%l" and > they're specified as operands to the asm goto statement. In the kernel > these references are resolved statically, and kernel modules will > contain relocations for the sdt_tracepoint_set section. > > > > +/* > > > + * Work around an apparent clang bug or limitation which prevents th= e use of the > > > + * "i" (immediate) constraint with the probe structure. > > > + */ > > > +#define _SDT_ASM_PROBE_CONSTRAINT "Ws" > > > +#define _SDT_ASM_PROBE_OPERAND "p" > > > > Is it because i386 kmods are built with -fPIC? > > I suspect that that's related, yeah. The compiler might be assuming > that some indirection is needed to compute the target address, but in > this case it's an address in the same function and presumably can safely > be assumed to be an immediate. > That makes sense for the "%l1", does it also apply to the "%c0"? Or does use of "%c" for the probe pointer require non-PIC? As in, don't the _probes_ get relocated, and don't we need to patch the pointers to the probes? > > By the way, it seems gcc13 (latest in ports) doesn't support the "Ws" > > constraint. It seems to have been added to gcc 14. I know i386 is tie= r > > 2 these days, and gcc is a second consideration anyway. Trying to test > > out a patch for i386 gcc, I found that it doesn't build currently and > > this is one of a few reasons. > > What happens if "i" is used with gcc? IIRC I had tried gcc+i386 when > testing the patch but the kernel failed to build for other reasons at > the time. It also errors out with constraint "%i" and modifier "%c". /usr/src/freebsd/sys/sys/sdt.h:216:9: error: 'asm' operand 0 probably does not match constraints [-Werror] ... /usr/src/freebsd/sys/sys/sdt.h:216:9: error: impossible constraint in 'asm' It works if I remove -fPIC, but I assume we're doing that for a reason... Ryan