* Memory managment locks
@ 2001-09-10 13:12 Martin Maletinsky
2001-09-16 1:51 ` Arnaldo Carvalho de Melo
0 siblings, 1 reply; 2+ messages in thread
From: Martin Maletinsky @ 2001-09-10 13:12 UTC (permalink / raw)
To: linux-mm
Hi,
I am writing a kernel thread, that should check if a process' page (specified by a virtual address and the pointer to a task structure) is present in physical memory, and
if this is the case pin it in memory (i.e. prevent it from being swapped out). I plan to pin the page by incrementing it's usage count (i.e. the count field of the
corresponding page descriptor) - this is the way map_user_kiobuf() pins pages in memory. I have some questions about semaphores and spinlocks to be used, when accessing a
process' mm structure and page tables:
(1) To parse a process' page tables I need to hold the page_table_lock in the process' mm_struct structure (according to A.Rubini's device driver book,
http://www.xml.com/ldd/chapter/book/ch13.html). I still need to keep the lock held while incrementing the page's usage count (according to various comments throughout the
kernel sources, page_table_lock prevents kswapd() from swapping out pages of the process). Question: Are there other spinlocks or semaphores to be held during the
operations I mentioned?
(2) When is the semaphore mmap_sem in the mm_struct structure to be held? When is the alloc_lock spinlock in the task_struct structure to be held?
(3) When multiple locks / semaphores have to be acquired, is there any rule concerning the order in which they should be acquired to prevent dead locks?
(4) Why isn't page_table_lock a read/write spinlock (is there any reason to prevent several threads from scanning a process' page table simultaneously)?
Thanks in advance for any help
Martin
--
Supercomputing System AG email: maletinsky@scs.ch
Martin Maletinsky phone: +41 (0)1 445 16 05
Technoparkstrasse 1 fax: +41 (0)1 445 16 10
CH-8005 Zurich
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Memory managment locks
2001-09-10 13:12 Memory managment locks Martin Maletinsky
@ 2001-09-16 1:51 ` Arnaldo Carvalho de Melo
0 siblings, 0 replies; 2+ messages in thread
From: Arnaldo Carvalho de Melo @ 2001-09-16 1:51 UTC (permalink / raw)
To: Martin Maletinsky; +Cc: linux-mm
Em Mon, Sep 10, 2001 at 03:12:29PM +0200, Martin Maletinsky escreveu:
> I am writing a kernel thread, that should check if a process' page
> (specified by a virtual address and the pointer to a task structure) is
> present in physical memory, and if this is the case pin it in memory
> (i.e. prevent it from being swapped out). I plan to pin the page by
> incrementing it's usage count (i.e. the count field of the corresponding
> page descriptor) - this is the way map_user_kiobuf() pins pages in
> memory. I have some questions about semaphores and spinlocks to be used,
> when accessing a process' mm structure and page tables:
have you looked at the linux-mm wiki at http://linux-mm.org/wiki, specially
this part: http://linux-mm.org/wiki/moin.cgi/MemoryLocking ?
hope this helps,
- Arnaldo
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2001-09-16 1:51 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-09-10 13:12 Memory managment locks Martin Maletinsky
2001-09-16 1:51 ` Arnaldo Carvalho de Melo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox