Re: mmap synchronization question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi...

> Ive a user app and a device driver sharing memory via mmap. This
> block of memory contains info for a memory allocator. This is used by
> the user app to get memory or to decide to do another mmap. Now the
> kernel can basically return memory to the freelist, but doesnt want
> to be competing with the user app and corrupt the freelist. I obv
> dont want to make the kernel wait for the userapp(although i can
> guarantee that no deadlocks will ever occur). I would like to  signal
> the process , the address within its  process space that can be added
> to the freelist. Im a bit lost on the way to do this..Any pointers?

OK, from what I read above, sounds like you want to implement non 
blocking notification to user space so user space knows which block is 
freed, am I correct? The way I see it, there are two "actors" competing 
here: user and kernel space (kernel thread(s)?). So, as long as they 
are sharing the same free-list, I think you're enforced to implement 
locking mechanism, hence the need of signaling. 

How about this: let the kernel space manage the freelist completely? 
After all, (from what I read) it is the kernel space that actually uses 
the memory block, right? That way, only one side that actually touches 
the freelist. And about the synchronization, perhaps you can use signal 
(e.g using force_signal()) or do a read on /proc entry that in turns 
sleeps in a notifier. Doable?

Sorry...can't give any code snippets...

regards,

Mulyadi


--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux