News for hackers. Stuff that matters.
Re:Intro to Low-Level Graphics on Linux by zokier on Wednesday August 30, 2017 @04:47PM (#15135864)
Personally I find the heavy use of ioctls in modern Linux APIs bit distasteful. Sure, its pragmatic and easy, but it really feels abusing the UNIX mantra of "everything is a file" when the only operation you can do for that "file" is some specific ioctls. I first noticed this in the very nice KVM article that ran on LWN few years back, and now again here. I really wish there was some more structured way of talking to the kernel, but I can understand that introducing a ton of new syscalls probably is not practical.
Re:Intro to Low-Level Graphics on Linux by nhaehnle on Thursday August 31, 2017 @03:36AM (#15138760)
Nitpick: DRM files also support mmap(), which is how you map video memory into user space.

To your overall point though: do you think there's something better?

The operations required by user-mode drivers and APIs just don't map well to file operations. On the other hand, creating dedicated syscalls for graphics isn't very attractive either, because many of the ioctls are quite hardware-specific.

Using ioctls is a pragmatic solution, and I doubt you can really come up with something much better, though I'd be interested in being proven wrong.

Re:Intro to Low-Level Graphics on Linux by zokier on Thursday August 31, 2017 @08:15AM (#15139742)
I think something like bus1 might be neat, but admittedly I haven't thought that out very throughly. Of course bus1 is not even in mainline yet, and ioctl apis have been around for decades
Re:Intro to Low-Level Graphics on Linux by _pmf_ on Thursday August 31, 2017 @02:58AM (#15138649)
> I really wish there was some more structured way of talking to the kernel

There's netlink. It's "more structured", in that it has a lot more structures.

Modules of common subsystems already support the same ioctl structs where this makes sense. Any mechanism replacing ioctls would only change the way you call it, it cannot reduce the inherent differences between modules. Well, one could use D-Bus or some generic property / key-value system, but this would only be generic on the surface.

Re:Intro to Low-Level Graphics on Linux by usr1106 on Thursday August 31, 2017 @06:24PM (#15144488)
The "Everything is a file in Unix" principle really hasn't been true since 1983 when Berkeley sockets were introduced. Network interfaces are neither files nor sockets. There are plenty of Linux concepts, which are yet something else.

Just as a side node to your ioctl criticism, I don't say ioctls are great.

Re:Intro to Low-Level Graphics on Linux by vardump on Wednesday August 30, 2017 @06:57PM (#15136826)
> Personally I find the heavy use of ioctls in modern Linux APIs bit distasteful.

That's how things work in Windows as well. That's how userland talks to kernel mode drivers.

Well, except everything is an object.

Re:Intro to Low-Level Graphics on Linux by Const-me on Thursday August 31, 2017 @10:34AM (#15140593)
> That's how things work in Windows as well.

GPU drivers are different. Basically, Windows have Direct3D already in the kernel, exposing relatively large API surface for the userland half of the driver.

https://docs.microsoft.com/en-us/windows-hardware/drivers/di...

Re:Intro to Low-Level Graphics on Linux by hossbeast on Wednesday August 30, 2017 @11:31PM (#15137972)
Which has nothing to say about whether it's a good idea.
Re:Intro to Low-Level Graphics on Linux by revelation on Thursday August 31, 2017 @06:21AM (#15139324)
They have come up with plenty more ways to talk to the kernel.

Just look at the absolute abortion that is "netlink". Very deeply nested structures with self-referencing pointers and sizeofs everywhere. You are looking at 300 LoC for the most trivial operations unless you want to use a shitty (like extfs tools shitty) library.

I actually prefer the ioctl, it keeps the insanity in check of these structure astronauts that gave us netlink.

Re:Intro to Low-Level Graphics on Linux by simplicio on Thursday August 31, 2017 @10:29AM (#15140549)
Yea, I think ioctl is probably the most elegant solution. The fact that hardware has a wide-variation in properties, requests, etc. mean some part of the interface is going to be inelegant and case dependent. ioctl at least puts all that variation behind a single system call.
Re:Intro to Low-Level Graphics on Linux by TazeTSchnitzel on Wednesday August 30, 2017 @07:02PM (#15136854)
Did Plan 9 try to fix this?
Re:Intro to Low-Level Graphics on Linux by FullyFunctional on Thursday August 31, 2017 @01:40AM (#15138368)
This interesting article also reminded me of another HN story (comment really) [1] about Carmack's interest in providing Plan 9 with great interactive graphics. It's IMO a great pity they didn't consider his input more seriously.

[1] https://news.ycombinator.com/item?id=14523222

Re:Intro to Low-Level Graphics on Linux by secure on Thursday August 31, 2017 @01:18AM (#15138316)