-
-
Notifications
You must be signed in to change notification settings - Fork 604
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
mmap() on device #1216
Comments
Hi and welcome to OSv community, I have never tried to I am assuming the code in your app would look something like this: int devFd = open("/dev/path/to/my/device", O_RDWR);
void *myDevPtr = mmap(start, length, prot, flags, devFd, offset); The This may not be what you want because I am not sure how OSv will handle the case when the data in the populated region of the ivshmem device changes and I am assuming you want to see the change in the app. Maybe we can evict that region when something happens? I am assuming the host has a way to notify guests of data changes maybe via interrupts? I think that ideally, we would want to have this BTW. I am very interested to see the implementation of your driver and may be try things myself so I can guide you better. |
Hi @wkozaczuk, I pushed my work in progress here. At the moment I just wrote support for the To test my driver:
(BTW I submitted a PR to fix a problem related to BARs size computation, that was causing problems when allocating shm > 4M) |
Another possible use case (useful in my project) would be related to exposing virtio rings directly to the application. This concept is mentioned in the OSv paper (Sec. 3), but I could not find any follow up on the topic (did I miss something?). I think that an |
Try the memcache example app. It's a bit hacky but works
…On Fri, Feb 10, 2023, 8:41 PM Federico Parola ***@***.***> wrote:
Another possible use case (useful in my project) would be related to
exposing virtio rings directly to the application. This concept is
mentioned in the OSv paper
<https://www.usenix.org/system/files/conference/atc14/atc14-paper-kivity.pdf>
(Sec. 3), but I could not find any follow up on the topic (did I miss
something?). I think that an mmap() operation would be a good fit for this
task.
—
Reply to this email directly, view it on GitHub
<#1216 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AANHURMRNDMFIWJ3IO7YWL3WW2DVNANCNFSM6AAAAAAUTLNVYM>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
On Fri, Feb 10, 2023 at 9:24 PM Federico Parola ***@***.***> wrote:
Thanks @dorlaor <https://github.com/dorlaor>, is this
<https://github.com/vladzcloudius/osv-memcached> the memcahced version
you are mentioning?
Correct. There isn't a nice API between the layers but since the app
can use the UDP functions and buffer mgmt, the result can be the same.
The more people creates app this way, the easiest we can define an API
for them
… —
Reply to this email directly, view it on GitHub
<#1216 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AANHURPJVGZSV5DMQZJPCHLWW2IYVANCNFSM6AAAAAAUTLNVYM>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
I am guessing this code that implemented the |
After analyzing the relevant code I think we need to implement the functionality to support First, we cannot rely on the current implementation of To accommodate it, I propose we make the following changes to VFS and
This is obviously just a sketch of the changes but I wonder what others think about my proposal. @FedeParola I will try to prototype my changes and integrate them with your implementation of the |
BTW I am also adding the device spec for Inter-VM Shared Memory. As I understand it is QEMU specific device. Are there any efforts to standardize it as part of VirtIO? |
Hi @wkozaczuk, I have an additional question concerning the use of the POSIX system call API. What is the overhead with respect to direct function calls (e.g. the one performed in the memcached example)? Even if all the code in the unikernel runs at the same level, it seems to me that there's still a level of indirection (SYSCALL instruction, that probably just jumps to the syscall handling code without changing CPU ring + lookup in a table of system calls to retrieve the correct function). Is this correct or am I missing something? |
@FedeParola You are right that the direct |
I see, thanks for the clarification. |
We sort of did this already. We use in OSv musl as-is where it doesn't use system calls, but modified it when it does. For example (I just randomly picked a file), musl/src/stdio/remove.c calls the SYS_unlink system call (and a few others), but our version libc/stdio/remove.c was modified (in this case, almost without leaving a single line...) to call the unlink() function. |
And sometimes we use a preprocessor trick to make the compiler replace SYS_* with a local function call. See syscall_to_function.h and how it is applied. This way in some cases we still use unmodified musl code but compiled to use local functions. |
@FedeParola are you still interested in implementing this feature? It looks like I finally may have some time to work on it. I am also trying to figure out what in general to work on next. And I have my interests as well :-) So please let me know. |
Hi @wkozaczuk, at the moment the sketchy implementation I made is fine for my work, and unfortunately I don't have time to allocate to a proper implementation :( . Hopefully in the future, but I guess it is worth waiting for the new |
Hello,
I'm trying to add support for the QEMU ivshmem device [1], to share memory between the host and the guest. I wrote a small driver that checks the existence of the device, creates an item on the devfs, and retrieves the address of the shared memory region from the PCI BAR used by ivshmem. At this point I would like to make this memory available to an application, that first
open()
s the device knowing its path and then performs anmmap()
operation.Any advice on how to proceed on this second point? It seems to me that there is no support to apply mmap operations on devices.
Thanks in advance
[1] https://www.qemu.org/docs/master/system/devices/ivshmem.html
The text was updated successfully, but these errors were encountered: