Originally posted by indepe
View Post
Announcement
Collapse
No announcement yet.
Wine Developers Are Working On A New Linux Kernel Sync API To Succeed ESYNC/FSYNC
Collapse
X
-
-
Originally posted by oiaohm View Post
This is you being wrong. Wine is a Compatibility Layer. So wine tries to avoid emulation of the Windows kernel where ever possible, Its is required to avoid emulating Windows kernel where possible to avoid the performance over head.
Wine developers are wanting the compatible locking in the Linux kernel so it does not have to be emulated instead just straight up substituted.
Wine is not emulation is old name of Wine because instead of emulating windows kernel where possible its substitution with what the host OS kernel provides.
A longer time ago I have taken a look at the esync source code, and it is doing the same kind of things that I am talking about. Except I am proposing other (existing) technologies instead of using eventfd.
- Likes 1
Leave a comment:
-
Originally posted by indepe View Post
When the locking happens inside the Windows kernel, it is still atomic locking, it just happens hidden by the Windows kernel, under the Windows kernel's control.
But in WINE the emulation of a Windows kernel call happens in Linux user space (except if that userspace function in turn calls the Linux kernel).
So you have 3 layers: 1) Windows application, 2) WINE emulation layer, 3) Linux kernel.
The WINE emulation layer is inside the Windows kernel (so to speak), but in LINUX user space.
So in this discussion when we talk about userspace, we mean the WINE layer which is inside the emulated Windows kernel.
That means you cannot use userspace atomic operations in the Windows application for events, but you can use LINUX userspace atomic operations in the WINE layer emulating the inside of the WIndows kernel.
Wine developers are wanting the compatible locking in the Linux kernel so it does not have to be emulated instead just straight up substituted.
Wine is not emulation is old name of Wine because instead of emulating windows kernel where possible its substitution with what the host OS kernel provides.
- Likes 1
Leave a comment:
-
Originally posted by Weasel View PostEvents are absolutely atomic on Windows. Obviously all events have a state else they wouldn't be events (you'd only have PulseEvent). Actually all synchronization objects have state. And yes you absolutely can modify this state atomically, especially with the kernel syscalls (which is what it is under Windows). EVENT_MODIFY_STATE is just an access right, it has nothing to do with atomic or not, just "permissions".
Originally posted by Weasel View PostResetEvent is a basic function that simply sets the state of an event to non-signaled. It's absolutely atomic. To be fair, you can do it even in userspace atomically, by using the "xchg" instruction, which would ALSO give you the event's former state, atomically. It might be implemented that way, who knows?
Weasel they design is before the xchg instruction existed because the code starts on alpha not x86 in Event area. xchg is a more modern instruction than that section of the Windows code base.
Originally posted by Weasel View PostRegardless, the whole point of any synchronization API is to synchronize things, and being atomic is a hard requirement. Otherwise, the API is deeply flawed (like PulseEvent is).
Yes the whole point of any synchronisation API should be to synchronise things but this is windows we are talking about with its Event system and other old synchronise API/ABI they are broken in places applications are designed to function with the way the windows synchronise systems fail to-do what you expect.
- Likes 1
Leave a comment:
-
Originally posted by oiaohm View PostYour general atomic locking is not your old school privilege/kernel controlled/pre atomic locking. The big things here is the old pre atomic locking include methods to take back the lock by force that requires extra information on who has the lock to be tracked by privilege party being the kernel. Yes I know its a idea to say we will avoid syscalls to take out a lock but these old pre atomic are designed to use syscalls and the difference in privilege between kernel and user-mode and have security privileges on the locking to be processed as part of the locking solution. These beasts are different.
Yes saying this stuff can be implemented with atomic locking in userspace means you don't understand the problem at all. These are locking structures with privileges designed to be kernel processed that were not designed to use atomic to avoid syscalls. Attempting to avoid syscall makes implementing them hell.
But in WINE the emulation of a Windows kernel call happens in Linux user space (except if that userspace function in turn calls the Linux kernel).
So you have 3 layers: 1) Windows application, 2) WINE emulation layer, 3) Linux kernel.
The WINE emulation layer is inside the Windows kernel (so to speak), but in LINUX user space.
So in this discussion when we talk about userspace, we mean the WINE layer which is inside the emulated Windows kernel.
That means you cannot use userspace atomic operations in the Windows application for events, but you can use LINUX userspace atomic operations in the WINE layer emulating the inside of the WIndows kernel.
Hope that helps.Last edited by indepe; 22 January 2021, 09:54 PM.
Leave a comment:
-
Originally posted by oiaohm View PostI really should not have to be doing this you are meant to be a Windows programmer apparently you don't know your stuff.
https://docs.microsoft.com/en-us/win...ltiple-objects
Notice here wait for multiple is not Mutex but instead event. Happens that the event in windows is not atomic design.
https://docs.microsoft.com/en-us/win...-access-rights
The give away is right on this page. EVENT_MODIFY_STATE is the give away. The fact state is meant to be able to change while running.
ResetEvent is a basic function that simply sets the state of an event to non-signaled. It's absolutely atomic. To be fair, you can do it even in userspace atomically, by using the "xchg" instruction, which would ALSO give you the event's former state, atomically. It might be implemented that way, who knows?
Regardless, the whole point of any synchronization API is to synchronize things, and being atomic is a hard requirement. Otherwise, the API is deeply flawed (like PulseEvent is).
Leave a comment:
-
Originally posted by Weasel View PostWTF is a pre atomic method? Give actual examples.
The following example uses the CreateEvent function to create two event objects and the CreateThread function to create a thread.
Notice here wait for multiple is not Mutex but instead event. Happens that the event in windows is not atomic design.
The Windows security model enables you to control access to event, mutex, semaphore, and waitable timer objects. Timer queues, interlocked variables, and critical section objects are not securable. For more information, see Access-Control Model.
The give away is right on this page. EVENT_MODIFY_STATE is the give away. The fact state is meant to be able to change while running.
Do notice on this page that Mutex there is a space left in the API/ABI for a Mutex to be a muggable lock like a EVENT is with the but that does not mean its not muggable.
There is also another bit of fun on the security page.
SYNCHRONIZE (0x00100000L) The right to use the object for synchronization. This enables a thread to wait until the object is in the signaled state.
Your general atomic locking is not your old school privilege/kernel controlled/pre atomic locking. The big things here is the old pre atomic locking include methods to take back the lock by force that requires extra information on who has the lock to be tracked by privilege party being the kernel. Yes I know its a idea to say we will avoid syscalls to take out a lock but these old pre atomic are designed to use syscalls and the difference in privilege between kernel and user-mode and have security privileges on the locking to be processed as part of the locking solution. These beasts are different.
Yes saying this stuff can be implemented with atomic locking in userspace means you don't understand the problem at all. These are locking structures with privileges designed to be kernel processed that were not designed to use atomic to avoid syscalls. Attempting to avoid syscall makes implementing them hell.
- Likes 1
Leave a comment:
-
Originally posted by Weasel View PostOk, I understand what you're trying to say now. You want to implement the whole thing in userspace, just with locks to protect the code from races.
Originally posted by Weasel View PostTbh, it sounds pretty nice in practice, but I'm guessing this approach suffers from contention or some other thing they measured. I don't know—they seem to be specifically looking for "kernel options". BTW esync currently emulates some of these things pretty badly, not just in terms of performance, but having race conditions. That's why some weird games don't even work with esync on.
Originally posted by Weasel View PostAnyway you gave me some ideas to try for my "lockless" (as in, syscalls, not atomic locks) design of an app I have.
Leave a comment:
-
Originally posted by indepe View PostSo maybe PulseEvent poses special problems that are hidden from plain view. For example, why do you think there need to be 2 syscalls unless the whole thing is a single syscall?
In the absence of knowing about any Windows specifics, I would think of something like:
Code:{ acquire_lock_of_event(e); thread t = thread_waiting_for_event(e); clear_waitlist_of_event(e); reset_event(e); release_lock_of_event(e); if (t != NULL) { wake_thread( t ); } }
(EDIT: This is of course a simplification. For example instead of the "thread t", it would be something like "wait_entry_for_thread".)
(EDIT 2: Note that the potential syscall in wake_thread is outside the lock.)
Tbh, it sounds pretty nice in practice, but I'm guessing this approach suffers from contention or some other thing they measured. I don't know—they seem to be specifically looking for "kernel options". BTW esync currently emulates some of these things pretty badly, not just in terms of performance, but having race conditions. That's why some weird games don't even work with esync on.
Anyway you gave me some ideas to try for my "lockless" (as in, syscalls, not atomic locks) design of an app I have.
Leave a comment:
-
Originally posted by oiaohm View PostNo that would not work. Because you have pre atomic methods and other code in modern day windows applications that are atomic methods. Anyone porting code to DEC Alpha back in Windows 4.0 days use to run into that problem as well where you code areas that were using atomic methods that was fine on i386 x86 or better was now totally screwed.
Pre atomic methods for doing locking can be used on a CPU that support atomic methods but atomic methods cannot be used to replace them in all cases.
Leave a comment:
Leave a comment: