Thread (6 messages) 6 messages, 2 authors, 2019-05-29

Re: [PATCH 1/7] General notification queue with user mmap()'able ring buffer [ver #13]

From: Miklos Szeredi <miklos@szeredi.hu>
Date: 2019-05-29 07:55:54
Also in: linux-fsdevel, lkml

On Tue, May 28, 2019 at 5:10 PM David Howells [off-list ref] wrote:
Implement a misc device that implements a general notification queue as a
ring buffer that can be mmap()'d from userspace.

The way this is done is:

 (1) An application opens the device and indicates the size of the ring
     buffer that it wants to reserve in pages (this can only be set once):

        fd = open("/dev/watch_queue", O_RDWR);
        ioctl(fd, IOC_WATCH_QUEUE_NR_PAGES, nr_of_pages);

 (2) The application should then map the pages that the device has
     reserved.  Each instance of the device created by open() allocates
     separate pages so that maps of different fds don't interfere with one
     another.  Multiple mmap() calls on the same fd, however, will all work
     together.

        page_size = sysconf(_SC_PAGESIZE);
        mapping_size = nr_of_pages * page_size;
        char *buf = mmap(NULL, mapping_size, PROT_READ|PROT_WRITE,
                         MAP_SHARED, fd, 0);
Would it make sense to use relayfs for the implementation of the
mapped ring buffer?

Thanks,
Miklos
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help