On Tue, Jul 22, 2008 at 6:32 AM, Peter Teoh <htmldeveloper@xxxxxxxxx> wrote: >> Also, how can I know by looking at the kernel code if a function is >> preemptible or not ? >> > > Generally, when u see the function: cond_resched(), or many other > similar function (eg, schedule()), or any form of mutex usage (which > will call schedule()) then it mean that CPU can be reschedule to > execute other tasks - which means that the current tasks can be > blocked. > > So in particular for you: > > This happened in memory.c: > > cond_resched(); > while (!(page = follow_page(vma, start, foll_flags))) { > int ret; > ret = handle_mm_fault(mm, vma, start, > foll_flags & FOLL_WRITE); > if (ret & VM_FAULT_ERROR) { > if (ret & VM_FAULT_OOM) > return i ? i : -ENOMEM; > else if (ret > > where handle_mm_fault() will call handle_pte_fault(), so outside of > handle_mm_fault(), it is potentially possible to be blocked. > Peter, thanks for your detailed response. I looked for the piece of code you pasted above in memory.c (2.6.26) and I found it in "get_user_pages()" which in turn is called by many other functions in memory.c So I assume that when a major fault happens, somehow get_user_pages() gets called, is that correct ? Basically what I need is, when a page gets swapped in, I want to find out its corresponding process. i.e. which process needed to have that page swapped in. There seems to be no direct way to do that as far as I can see. Even the mm_struct doesn't have a mapping back to the task_struct though there is something defined in 2.6.26 using CONFIG_MM_OWNER, but I'm not sure if that is correct since it says it points to the "canonical user/owner of this mm". Here is the portion of mm_struct : 228 #ifdef CONFIG_MM_OWNER 229 /* 230 * "owner" points to a task that is regarded as the canonical 231 * user/owner of this mm. All of the following must be true in 232 * order for it to be changed: 233 * 234 * current == mm->owner 235 * current->mm != mm 236 * new_owner->mm == mm 237 * new_owner->alloc_lock is held 238 */ 239 struct task_struct *owner; 240 #endif Anyways, this is in 2.6.26 only. In a nutshell, I want to be able to identify the process that needs (caused) the swap in of a page from the swap space. How can I do it ? Thanks -arn -- To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx Please read the FAQ at http://kernelnewbies.org/FAQ