-
-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
llfio::map(section, reserve) doesn't work on windows #121
Comments
Windows doesn't allow resizing of a section with open maps. You might note that |
So there's a window where there's nothing mapped if you do the following?
From looking at the code I thought that it only unmapped things if you reduce the size of the section. To extend it it seems to use |
Yes, you're right we only tear down the maps if shrinking: https://github.com/ned14/llfio/blob/develop/include/llfio/v2.0/detail/impl/windows/mapped_file_handle.ipp#L146 Sorry my memory is fading as LLFIO generally just works and I don't need to care about implementation any more. Looking at the source code comments, maps cannot exceed section size, but section size can exceed file size, if the section was created with the right flags. There is another use case here which might be confusing. Section handles can be backed by an explicit file, or by the swap file. Maps behave differently depending on which, and indeed which flags the file was opened with. When the documentation says "Create a memory mapped view of a backing storage, optionally reserving additional address space for later growth." and you're supplying a section handle configured by you to use, you're kinda into "I know what I'm doing" territory. It's on you to configure the section handle to be appropriately configured. The other reason I left this open to success or fail is Microsoft originally promised me they'd fix section handles being so weird to work with in a future kernel release, and to date they have not. What I probably could do is improve the documentation for that specific function to clarify that you cannot reserve more than the section handle's size? |
Hmm. I read here in my own docs:
Which suggests that section handles cannot exceed the length of their backing file either. Reading the |
Yea, I'm fine if it's just a documentation issue. Whatever
I, on the other hand was hoping to delegate understanding all this platform specific wierdness to you :) Thanks. |
Out of interest, is your backing file zero sized? Linux and Windows won't map a zero sized file (BSD is fine with it).
Yeah, there's a tension there all right. The most common case of a straight mapped file handle with an ample address space reservation for efficiency should "just work", except where it doesn't, but the API design should encourage the avoidance of all those places where it doesn't so 99.9% of users won't ever see problems. But there are also use cases where you've got some quite customised file mapping going on. Generally speaking, if you get it working on Windows it'll "just work" on POSIX, so I tried to leave open the door for such customised file mapping use cases. TBH on 64 bit there is rarely a need to customise mappings much, it's a big need on 32 bit but not on 64 bit. There is also a bit of legacy design cruft in there. Originally mapped file handle couldn't do offsets nor partial maps, so the ability to get into map handle and section handle was important. Now that mapped file handle can do offsets and partial maps, a lot of the need for map handle and section handle have gone away. And indeed the proposal up before WG21 just has mapped file handle now. |
I'm not using a specific backing file, just a temp_inode. The library seems to handle making a zero length file and only mapping it once it's truncated to some size correctly. The actual difference seems to be map_handle.ipp:752:
where
|
That does seem to be a bug then. Thanks for reporting it! |
The documentation suggests that the second argument allows you to reserve memory. I was expecting to be able to use a larger value than the section size, so I could later grow the section without changing the address. However, on windows you get error 0xC000001F because you can't create a mapping larger than the section, apparently. mapped_file_handle seems to manage to do it though.
The text was updated successfully, but these errors were encountered: