public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Segmentation fault to detect resident memory size
@ 2004-10-29 21:30 Mauricio Lin
  0 siblings, 0 replies; only message in thread
From: Mauricio Lin @ 2004-10-29 21:30 UTC (permalink / raw)
  To: linux-kernel

Hi all,

I had implemented a new entry in proc directory called smaps for
kernel 2.6.1 and it is working.

I have tried to upgrade it to kernel 2.6.9 but a segmentation fault is
thrown on my shell when I cat the /proc/PID/smaps entry.

Below is the code. It is the same code I had implemented for kernel
2.6.1 but it is not working for kernel 2.6.9. I have done some
debugging and I notice if I comment the instructions after the second
"if statement" the segmentation fault problem is removed. But if I
write a simple printk after it a segmentation fault is invoked.  It is
very strange. I do not know what is going on. Does anyone can help me?


void resident_mem_size(struct mm_struct *mm, unsigned long start_address,
			unsigned long end_address, unsigned long *size) {
	pgd_t *my_pgd;
	pmd_t *my_pmd;
	pte_t *my_pte;
	unsigned long page;

	for (page = start_address; page < end_address; page += PAGE_SIZE) {
		my_pgd = pgd_offset(mm, page);
		if (pgd_none(*my_pgd) || pgd_bad(*my_pgd)) continue;
		my_pmd = pmd_offset(my_pgd, page);
		if (pmd_none(*my_pmd) || pmd_bad(*my_pmd)) continue;
		my_pte = pte_offset_map(my_pmd, page);
		if (pte_present(*my_pte)) {
			*size += PAGE_SIZE;
		}
	  }
}

Mauricio Lin.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2004-10-29 21:37 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-10-29 21:30 Segmentation fault to detect resident memory size Mauricio Lin

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