Skip to content
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

lib/ukfile: Add backing buffer shared memory API #1411

Open
wants to merge 1 commit into
base: staging
Choose a base branch
from

Conversation

andreittr
Copy link
Contributor

Description of changes

This change expands the ukfile API to provide direct shared memory access to file backing buffers, useful for implementing memory mappings (mmap) or single-copy file-to-file transfers (sendfile).
In broad strokes, consumers would use it as such:

  1. single-copy file-to-file (sendfile):
  • lock source file
  • iomem(BORROW)
  • write into dest file the iovec received from above
  • unlock source file
  1. shared memory mapping (file mmaps):
  • mmap() does iomem(ACQUIRE); this ensures
    (1) backing buffer is mapped by the file for the respective area and
    (2) addresses returned by iomem(RETRIEVE) are stable until RELEASE
  • munmap() does iomem(RELEASE)
  • sometime between mmap and paging in the memory, do iomem(RETRIEVE) to get specific memory ranges
  1. memory gifting (i.e., make the file take some memory and use it as its own)
  • call iomem(GIFT) with memory you own and want the file to take over
  • like a reverse mmap: the file takes your memory as its backing buffer, rather than the other way around
  • does not have a POSIX/Linux equivalent

A boilerplate no-op implementation is provided, and existing ukfiles are patched to use it.
No actual implementations or consumers of this API are included. Rather, the intent of this PR is to review the API and ensure it is properly documented in isolation.

Prerequisite checklist

  • Read the contribution guidelines regarding submitting new changes to the project;
  • Tested your changes against relevant architectures and platforms;
  • Ran the checkpatch.uk on your commit series before opening this PR;
  • Updated relevant documentation.

Base target

  • Architecture(s): [e.g. x86_64 or N/A]
  • Platform(s): [e.g. kvm, xen or N/A]
  • Application(s): [e.g. app-python3 or N/A]

Additional configuration

N/A

This change expands the ukfile API to provide direct shared memory
access to file backing buffers, useful for implementing memory mappings
(mmap) or single-copy file-to-file transfers (sendfile).

A boilerplate no-op implementation is provided, and existing ukfiles are
patched to use it. No actual implementations of this API are included in
this commit.

Signed-off-by: Andrei Tatar <andrei@unikraft.io>
@andreittr andreittr requested a review from a team as a code owner May 6, 2024 12:41
@github-actions github-actions bot added area/lib Internal Unikraft Microlibrary lang/c Issues or PRs to do with C/C++ labels May 6, 2024
@razvand razvand requested review from Krechals, andreistan26 and eduardvintila and removed request for a team May 21, 2024 20:27
@razvand razvand added this to the v0.18.0 (Helene) milestone May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/lib Internal Unikraft Microlibrary lang/c Issues or PRs to do with C/C++
Projects
Status: 🏗 In Progress
Development

Successfully merging this pull request may close these issues.

None yet

3 participants