Requirement: kernel and userspace share huge memory through mmap. userspace is producer and kernel is consumer.
I have written a kernel module which creates a device and implements the mmap syscall and allocates kernel buffer. Userspace opens the device and calls mmap and writes something. Kernel reads it through timer thread every 5 sec and it works fine.
Issue is how do I synchronize this mmap'ed area.
Solutions I thought of:
1) After writing to mmap area , userspace sends netlink notification which marks global flag saying data is ready and kernel is ready to read now.
2) After writing to mmap area , userspace issues ioctl which marks global flag saying data is ready and kernel is ready to read now.
Are there any better approaches?