If I already hold the mmap semaphore (reading) for an mm_struct and I would like to write some data to a member of the page struct should I up_read the semaphore and attempt to acquire a down_write on the mm_struct or should I use a seperate lock (it’s a structure member that I created, it’s a list). Also if I already hold a down_read semaphore and I call another method that down_reads the same semaphore this should not deadlock from my understanding correct?
Share
The solution I found is that down_read’s are not going to cause a deadlock. Instead I use a spinlock to maintain exclusive rights to modify the list and also change the flags of the page. This allows me to avoid issues with multiple faults on the same page and also allows me to see that if I currently hold the lock then the page fault handler can just return because I will handle that fault already.