From: Mauricio Lin <mauriciolin@gmail.com>
To: linux-kernel@vger.kernel.org
Subject: Segmentation fault to detect resident memory size
Date: Fri, 29 Oct 2004 19:30:59 -0200 [thread overview]
Message-ID: <3f250c71041029143074a8221e@mail.gmail.com> (raw)
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.
reply other threads:[~2004-10-29 21:37 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3f250c71041029143074a8221e@mail.gmail.com \
--to=mauriciolin@gmail.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox