mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* All pages belonging to a process
@ 2009-08-25  6:36 Anupama Chandwani
  2009-08-25 12:44 ` Jiri Kosina
  0 siblings, 1 reply; 4+ messages in thread
From: Anupama Chandwani @ 2009-08-25  6:36 UTC (permalink / raw)
  To: linux kernel mailing list

Hi,

I need to have a debug print for all pages belonging to a process, for
which i have the following code:

if (task->mm && task->mm->mmap)
{
      /* For all vma-s of a process */
      for (vma = task->mm->mmap; vma!=NULL; vma = vma->next)
      {
               pgd = pgd_offset(mm, address);
               if (!pgd_present(*pgd))
                    continue;

               pud = pud_offset(pgd, address);
               if (!pud_present(*pud))
                    continue;

               pmd = pmd_offset(pud, address);
               if (!pmd_present(*pmd))
                    continue;

              pte = pte_offset_map_lock (task->mm->vm_mm, pmd, address, &ptl);

              print pte_pfn(*pte) and other debug info;

              pte_unmap_unlock(pte, ptl);
      }
}

The code hangs. I do not get anything in dmesg.
Any pointers by observing the code?

--
Cheers,
Anupama Chandwani

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: All pages belonging to a process
  2009-08-25  6:36 All pages belonging to a process Anupama Chandwani
@ 2009-08-25 12:44 ` Jiri Kosina
  2009-08-26 20:28   ` Anupama Chandwani
  0 siblings, 1 reply; 4+ messages in thread
From: Jiri Kosina @ 2009-08-25 12:44 UTC (permalink / raw)
  To: Anupama Chandwani; +Cc: linux kernel mailing list

[-- Attachment #1: Type: TEXT/PLAIN, Size: 873 bytes --]

On Tue, 25 Aug 2009, Anupama Chandwani wrote:

>       /* For all vma-s of a process */
>       for (vma = task->mm->mmap; vma!=NULL; vma = vma->next)

you mean vma->vm_next?

>       {
>                pgd = pgd_offset(mm, address);
>                if (!pgd_present(*pgd))
>                     continue;
> 
>                pud = pud_offset(pgd, address);
>                if (!pud_present(*pud))
>                     continue;
> 
>                pmd = pmd_offset(pud, address);
>                if (!pmd_present(*pmd))
>                     continue;
> 
>               pte = pte_offset_map_lock (task->mm->vm_mm, pmd, address, &ptl);
> 
>               print pte_pfn(*pte) and other debug info;
> 
>               pte_unmap_unlock(pte, ptl);
>       }
> }
> 
> The code hangs. I do not get anything in dmesg.

Do you have mmap_sem locked?

-- 
Jiri Kosina
SUSE Labs

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: All pages belonging to a process
  2009-08-25 12:44 ` Jiri Kosina
@ 2009-08-26 20:28   ` Anupama Chandwani
  2009-08-26 20:45     ` Anupama Chandwani
  0 siblings, 1 reply; 4+ messages in thread
From: Anupama Chandwani @ 2009-08-26 20:28 UTC (permalink / raw)
  To: Jiri Kosina; +Cc: linux kernel mailing list

Hi Jiri,

>>       /* For all vma-s of a process */
>>       for (vma = task->mm->mmap; vma!=NULL; vma = vma->next)
>
> you mean vma->vm_next?

Sorry for the typo, it is vma = vma->vm_next

>
>>       {
>>                pgd = pgd_offset(mm, address);
>>                if (!pgd_present(*pgd))
>>                     continue;
>>
>>                pud = pud_offset(pgd, address);
>>                if (!pud_present(*pud))
>>                     continue;
>>
>>                pmd = pmd_offset(pud, address);
>>                if (!pmd_present(*pmd))
>>                     continue;
>>
>>               pte = pte_offset_map_lock (task->mm->vm_mm, pmd, address, &ptl);
>>
>>               print pte_pfn(*pte) and other debug info;
>>
>>               pte_unmap_unlock(pte, ptl);
>>       }
>> }
>>
>> The code hangs. I do not get anything in dmesg.
>
> Do you have mmap_sem locked?

I didnt, but that didnt solve the problem.

>
> --
> Jiri Kosina
> SUSE Labs
>



-- 
Cheers,
Anupama Chandwani

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: All pages belonging to a process
  2009-08-26 20:28   ` Anupama Chandwani
@ 2009-08-26 20:45     ` Anupama Chandwani
  0 siblings, 0 replies; 4+ messages in thread
From: Anupama Chandwani @ 2009-08-26 20:45 UTC (permalink / raw)
  To: Jiri Kosina; +Cc: linux kernel mailing list

>>
>> Do you have mmap_sem locked?
>
> I didnt, but that didnt solve the problem.
>

The problem was when the "pte" was not present, due to no page for the
corresponding pte.
After handling that condition, it works fine.

Thanks Jiri for your help.


-- 
Cheers,
Anupama Chandwani

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-08-26 20:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-25  6:36 All pages belonging to a process Anupama Chandwani
2009-08-25 12:44 ` Jiri Kosina
2009-08-26 20:28   ` Anupama Chandwani
2009-08-26 20:45     ` Anupama Chandwani

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®