linux-kbuild.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
To: Nick Alcock <nick.alcock@oracle.com>
Cc: Alexander Lobakin <aleksander.lobakin@intel.com>,
	Alessandro Carminati <alessandro.carminati@gmail.com>,
	Luis Chamberlain <mcgrof@kernel.org>,
	Masahiro Yamada <masahiroy@kernel.org>,
	Nathan Chancellor <nathan@kernel.org>,
	"Nick Desaulniers" <ndesaulniers@google.com>,
	Nicolas Schier <nicolas@fjasle.eu>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	Daniel Bristot de Oliveira <bristot@kernel.org>,
	Viktor Malik <vmalik@redhat.com>, <linux-kernel@vger.kernel.org>,
	<linux-kbuild@vger.kernel.org>,
	<linux-trace-kernel@vger.kernel.org>, <eugene.loh@oracle.com>,
	<kris.van.hees@oracle.com>, <live-patching@vger.kernel.org>
Subject: Re: [PATCH v2] scripts/link-vmlinux.sh: Add alias to duplicate symbols for kallsyms
Date: Fri, 21 Jul 2023 10:09:31 +0900	[thread overview]
Message-ID: <20230721100931.b366ecfbeb09cba01c73d47a@kernel.org> (raw)
In-Reply-To: <87wmyu7n5t.fsf@esperi.org.uk>

On Thu, 20 Jul 2023 14:00:46 +0100
Nick Alcock <nick.alcock@oracle.com> wrote:

> On 19 Jul 2023, Alexander Lobakin verbalised:
> 
> > From: Nick Alcock <nick.alcock@oracle.com>
> > Date: Wed, 19 Jul 2023 12:12:06 +0100
> >>> Yes, please coordinate with Nick and review each other's work, now we
> >>> have two separate efforts with different reasons but hopefully we'll
> >
> > Three efforts[0] :D Mine went unnoticed unfortunately, so I switched to
> > other projects then.
> 
> It's odd, nobody seems to have noticed these until recently and now
> suddenly people are crawling out of the woodwork wanting unique
> addresses :) maybe the ambiguous ones are just getting commonplace
> enough that they're biting people more often?

Usually, the ambiguous symbols are used as internal functions and
are easily changed by kernel update. Thus it is only used for debugging.
On the other hand, exposed symbols are considered as more stable (It's
not really that stable.) so users tend to use that.

BTW, note that `perf probe` and kprobe-events already supported that by
'_text+OFFSET' style to point those functions (`perf probe` convert the
given 'function@file-path' place to '_text+OFFSET' using DWARF and ELF).
BPF doesn't because it only supports "function name". (I'm not sure how
Dtrace support it)

If we really consider to improve BPF trace to trace such internal functions,
I think you should consider to reuse perf-probe's code to find actual
address and convert it to '_text+OFFSET' style to specify the probe point.

I think this still useful if user can identify the traced symbol from the
source code line, easily without DWARF analysis. And BPF also need to
support "SYMBOL+OFFSET" style probe points.

> 
> > My idea was to give relative path from the kernel root to the objfile,
> > as we have a good bunch of non-unique "filename + symbol name" pairs.
> 
> I considered that, but unfortunately that has two problems to a raging
> perfectionist like me:
> 
>  - the objfile probably won't exist except if you're actually doing
>    kernel development, since kernel build trees are big enough that a
>    lot of people delete them after building or ship kernels to other
>    machines: if someone else built your kernel (overwhelmingly common
>    among non-kernel-devs) the objfiles are sure to be absent. (But an
>    option to not truncate the names when you know they won't be absent
>    might be a good idea, though this pushes space requirements up by
>    hundreds of kilobytes so it should probably be off by default.)

As I said, these internal symbol tracing is usually only for debugging
the kernel. So I think this is not so problematic.

Thank you,

> 
>  - even giving a path to the kernel module on disk (much lower
>    resolution and vulnerable to ambiguity again) is unreliable because
>    there's absolutely no guarantee that any given process can see any of
>    them: they might be in a different fs namespace or the modules might
>    only be present in an initramfs (hell, I even know setups which
>    *compile* the modules needed for rootfs mounting in the initramfs!
>    Yes this is borderline insane, yes it happens). More commonly, they
>    might be compressed using any of a number of compressors, changing
>    the name, and the kernel has no idea which compressor might have been
>    used (not unless you want it to go and look, and, well, wandering
>    around over the fs hunting down .ko.* files from kernelspace to get
>    their names right is *not* my idea of a good time! It's hard enough
>    to get that right from userspace, honestly, even with kmod helping.)
> 
>    The most you could do would be to provide a key you could use with
>    kmod to dig the real modules out from userspace. Partial names are as
>    good as anything for that :)
> 
> So all the objfile names are, when it comes down to it, is names with no
> intrinsic meaning: even if they're filenames of some kind, tools can't
> rely on being able to access those files. (For my most common use case,
> using a tracer on an enterprise-built production kernel, they'd almost
> never be able to.)
> 
> So you might as well treat the objfile names as arbitrary string keys
> that might be a memory-jogger for humans, which means you can chop
> boring bits off them to save space :)


-- 
Masami Hiramatsu (Google) <mhiramat@kernel.org>

  parent reply	other threads:[~2023-07-21  1:09 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-14 15:03 [PATCH v2] scripts/link-vmlinux.sh: Add alias to duplicate symbols for kallsyms Alessandro Carminati
2023-07-17 14:52 ` Steven Rostedt
2023-07-17 16:50   ` Luis Chamberlain
2023-07-18  1:01     ` Masami Hiramatsu
2023-07-18 16:06   ` Alessandro Carminati
2023-07-18 16:55     ` Steven Rostedt
2023-07-21  9:21       ` Alessandro Carminati
2023-07-21 12:40         ` Alessandro Carminati
2023-07-24 10:30           ` Alexander Lobakin
2023-08-24 15:35           ` Francis Laniel
2023-08-25 10:15             ` Alessandro Carminati
2023-08-25 12:31               ` Masami Hiramatsu
2023-07-19 16:08     ` Masami Hiramatsu
2023-07-19 11:12   ` Nick Alcock
2023-07-19 15:12     ` Alexander Lobakin
2023-07-20 13:00       ` Nick Alcock
2023-07-20 17:00         ` Alexander Lobakin
2023-07-21  1:09         ` Masami Hiramatsu [this message]
2023-07-21  1:39           ` Kris Van Hees

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230721100931.b366ecfbeb09cba01c73d47a@kernel.org \
    --to=mhiramat@kernel.org \
    --cc=aleksander.lobakin@intel.com \
    --cc=alessandro.carminati@gmail.com \
    --cc=bristot@kernel.org \
    --cc=eugene.loh@oracle.com \
    --cc=kris.van.hees@oracle.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=live-patching@vger.kernel.org \
    --cc=masahiroy@kernel.org \
    --cc=mcgrof@kernel.org \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=nick.alcock@oracle.com \
    --cc=nicolas@fjasle.eu \
    --cc=vmalik@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).