Index Home About Blog
From: Linus Torvalds <torvalds@linux-foundation.org>
Newsgroups: fa.linux.kernel
Subject: Re: [PATCH 4/5 v2] x86 boot: show pfn addresses in hex not decimal
Date: Wed, 25 Jun 2008 02:59:54 UTC
Message-ID: <fa.EGkEwXvtl7iZZFO9hGkd5fMAMNA@ifi.uio.no>

On Tue, 24 Jun 2008, H. Peter Anvin wrote:
>
> What we really should have is %p produce this format.  For some odd reason,
> right now %p produces numbers without the 0x prefix.

Actually, I'd like to make %p produce the format that you right now have
to jump through insane hoops for: symbolic addresses.

Right now you have to do something insane like

	print_symbol(KERN_WARNING "address: %s\n", ptr);

to print a symbolic version, and it sucks because it's actually just able
to print symbols, you cannot mix any other types in there.

I think it would be much easier to use if "%p" just did the symbolic
version (if it's relevant) automatically. If you _just_ want the hex
representation, you can already always just use %#lx and a cast.

(Of course, then for things that we can't make into symbolic names, we'd
have to fall back to just the hex representation, and whether that one
then includes the 0x or not I don't have strong opinions on.)

And yes, to avoid messing with current users, maybe we should only do that
with %#p (which I don't think anybody uses right now, although I suspect
it actually adds the '0x' you'd like). The '#' thing is, of course, all
about 'alternate forms'. But I worry that gcc warns about undefined
formatting behavior.

			Linus


From: Linus Torvalds <torvalds@linux-foundation.org>
Newsgroups: fa.linux.kernel
Subject: Re: [PATCH 4/5 v2] x86 boot: show pfn addresses in hex not decimal
Date: Wed, 25 Jun 2008 03:01:36 UTC
Message-ID: <fa.8iahk1LzBAQmBpEa9ddyQQ3IYpg@ifi.uio.no>

On Tue, 24 Jun 2008, Linus Torvalds wrote:
>
> And yes, to avoid messing with current users, maybe we should only do that
> with %#p (which I don't think anybody uses right now, although I suspect
> it actually adds the '0x' you'd like). The '#' thing is, of course, all
> about 'alternate forms'. But I worry that gcc warns about undefined
> formatting behavior.

Indeed it does, I just checked. Very irritating.

		Linus


From: Linus Torvalds <torvalds@linux-foundation.org>
Newsgroups: fa.linux.kernel
Subject: Re: [PATCH 4/5 v2] x86 boot: show pfn addresses in hex not decimal
Date: Wed, 25 Jun 2008 04:05:07 UTC
Message-ID: <fa.LTYaHFUaPXo+x+kjwrwUDhaMCtA@ifi.uio.no>

On Tue, 24 Jun 2008, Paul Jackson wrote:
>
> I'd be inclined instead to use "%P" for symbolic addrs.

That doesn't work - gcc warns about it.

That turns out to be a problem with %#p too.

It's really irritating how we cannot extend on the printk strings without
either having to throw out gcc warnings altogether. gcc has no extension
mechanism to the built-in rules ;/

The format warnings are too useful to drop entirely. I guess sparse could
be taught to do them, and then we could drop the gcc support for them. But
that would still limit coverage a _lot_.

		Linus


From: Linus Torvalds <torvalds@linux-foundation.org>
Newsgroups: fa.linux.kernel
Subject: Re: [PATCH 4/5 v2] x86 boot: show pfn addresses in hex not decimal
Date: Wed, 25 Jun 2008 15:21:32 UTC
Message-ID: <fa.sfhl2R9y4VUlIN4pkAqCQhazkeg@ifi.uio.no>

On Wed, 25 Jun 2008, Johannes Berg wrote:
>
> In networking, we've gone through various incarnations of print_mac()
> which is similar to the sym() macro Paul proposed, and it turned out to
> be undesirable because of the way it interacts with static inlines that
> only optionally contain code at all, the print_mac() function call is
> still emitted by the compiler. People experimented with marking it
> __pure but that had other problems.

You don't even have to go that esoteric.

Just printing things like "sector_t" or "u64" is painful, because the
exact type depends on config options and/or architecture.

> It would be nice to be able to say
>
> u8 *eaddr;
>
> printk(... %M ..., eaddr);

For special things, I do think we should extend the format more, and
forget about single-character names. It would be lovely to do them as
%[mac], %[u64], %[symbol] or similar. Because once you don't rely on gcc
checking the string, you can do it.

The problem is that right now we absolutely _do_ rely on gcc checking the
string, and as such we're forced to use standard patterns, and standard
patterns _only_. And that means that %M isn't an option, but also that if
we want symbolic names we'd have to use %p, and not some extension.

But once you drop the 'standard patterns' requirement, I do think you
should drop it _entirely_, and not just extend it with some pissant
single-character unreadable mess.

				Linus

Index Home About Blog