Skip to contentSkip to conversation

new system call mknod64

PATCH [email protected] 4 participants 4 messages Apr 21, 2003 – Apr 22, 2003

lore
Share & tools
lore
#0 lore raw

Nice to see this discussion.

Linus says

Quoted 4 lines

The question is only _where_ (not whether) we do the mapping. Right now we keep "dev_t" in the same format as we give back to user space, and thus we always map into that format internally. But we don't have to: we can have an internal format that is different from the one we show users.

and in fact the patches I have been giving out use kdev_t as internal format, where you can think of kdev_t as u64, or, if you prefer, as struct { u32 major, minor; }.

As I wrote a month or two ago, my favourite version is to have register_region work in the kdev_t space, rather than the dev_t space, since intervals in kdev_t space have a direct interpretation in terms of major, minor.

Andries

(Both versions do not differ very much;
as far as I am concerned the choice is not very important, but the kdev_t version is slightly cleaner.)

(As Al already remarked, device numbers do not play much of a role internally. I removed i_dev. We still have i_rdev.)

#1 lore raw
Followup to:  <[email protected]>
By author:    [email protected]
In newsgroup: linux.dev.kernel
Quoted 5 lines

and in fact the patches I have been giving out use kdev_t as internal format, where you can think of kdev_t as u64, or, if you prefer, as struct { u32 major, minor; }.

Any reason why we don't just *make it* a struct? (Well, besides that it'd somewhat suck on 64-bit architectures?)

-hpa

Signature · 3 lines
<[email protected]> at work, <[email protected]> in private!
"Unix gives you enough rope to shoot yourself in the foot."
Architectures needed: ia64 m68k mips64 ppc ppc64 s390 s390x sh v850 x86-64
#2 lore raw
Quoted 6 lines · H. Peter Anvin
Quoted 3 lines

and in fact the patches I have been giving out use kdev_t as internal format, where you can think of kdev_t as u64, or, if you prefer, as struct { u32 major, minor; }.

Any reason why we don't just *make it* a struct? (Well, besides that it'd somewhat suck on 64-bit architectures?)

It varies very much between architectures.

I just checked, and simple copies of this structure are absolutely atrocious in GCC 3.2 (I tried Alpha, Mips64 and Sparc64). The code was approx. 3 times longer to copy the 32:32 struct than to copy a 64 bit scalar.

On x86_64, the struct produces the same code as the scalar. The same is true on s390x.

If you change this to test 16:16, on i386 (or x86_64 with -m32), the struct still produces the same code as the scalar.

Looks like a part of GCC that might be easy to improve, given that it works quite well on some architectures already.

-- Jamie

#3 lore raw
Quoted 8 lines · Jamie Lokier

It varies very much between architectures.

I just checked, and simple copies of this structure are absolutely atrocious in GCC 3.2 (I tried Alpha, Mips64 and Sparc64). The code was approx. 3 times longer to copy the 32:32 struct than to copy a 64 bit scalar.

Last time I had access to gcc on sparc, copying a struct where the compiler guessed that non-aligned access may occure produced code that was guarenteed not to crash the program. This was tested in user mode, in 32 bit, but still...

Copying a struct with two 32 bit values does not prove to the compiler that it will be 64bit aligned. It is therefor reasonable for the compiler to assume it needs two 32 bit transfers, rather than one 64 bit transfer. Try adding "#pragme align 8", or whatever it is called, and seeing if this inefficiency goes away.

Quoted 4 lines

On x86_64, the struct produces the same code as the scalar. The same is true on s390x.

I don't know how x86_64 is doing, but x86 does not issue a bus error when unaligned value is being accessed. It is therefor reasonable for the compiler not to worry about it. If x86_64 is the same, the results you report seem like a reasonable feature of gcc, rather than a bug.

Shachar

Signature · 3 lines
Shachar Shemesh
Open Source integration consultant
Home page & resume - http://www.shemesh.biz/