* Page faults
@ 2013-09-09 20:36 Paddie O'Brien
2013-09-09 21:00 ` David Smith
0 siblings, 1 reply; 6+ messages in thread
From: Paddie O'Brien @ 2013-09-09 20:36 UTC (permalink / raw)
To: systemtap
[-- Attachment #1: Type: text/plain, Size: 610 bytes --]
Hi,
I run the attached to print out the offsets of faulting pages. Both
probes should (I think) print the same number but instead I get this:
hello: filemap_fault
Page: 1678263179
hello: find_get_page
Page: 15
hello: filemap_fault
Page: 1678263179
hello: find_get_page
Page: 1
hello: filemap_fault
Page: 1678263179
hello: find_get_page
Page: 10
etc. etc.
Both functions are from mm/filemap.c. filemap_fault does this:
pgoff_t offset = vmf->offset;
find_get_page(mapping, offset);
Basically, printing the offset in find_get_page works but printing
vmf->offset in filemap_fault doesn't.
Why?
Thanks,
P
[-- Attachment #2: pages.stp --]
[-- Type: application/octet-stream, Size: 330 bytes --]
#!/usr/bin/stap
probe kernel.function("filemap_fault")
{
if (execname() != "hello") next;
printf("%s: filemap_fault\n", execname());
printf("Page: %lu\n", $vmf->pgoff);
}
probe kernel.function("find_get_page")
{
if (execname() != "hello") next;
printf("%s: find_get_page\n", execname());
printf("Page: %lu\n", $offset);
}
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Page faults
2013-09-09 20:36 Page faults Paddie O'Brien
@ 2013-09-09 21:00 ` David Smith
2013-09-10 16:14 ` Paddie O'Brien
0 siblings, 1 reply; 6+ messages in thread
From: David Smith @ 2013-09-09 21:00 UTC (permalink / raw)
To: Paddie O'Brien; +Cc: systemtap
On 09/09/2013 03:36 PM, Paddie O'Brien wrote:
> Hi,
>
> I run the attached to print out the offsets of faulting pages. Both
> probes should (I think) print the same number but instead I get this:
>
> hello: filemap_fault
> Page: 1678263179
> hello: find_get_page
> Page: 15
>
> hello: filemap_fault
> Page: 1678263179
> hello: find_get_page
> Page: 1
>
> hello: filemap_fault
> Page: 1678263179
> hello: find_get_page
> Page: 10
>
> etc. etc.
>
> Both functions are from mm/filemap.c. filemap_fault does this:
>
> pgoff_t offset = vmf->offset;
> find_get_page(mapping, offset);
>
> Basically, printing the offset in find_get_page works but printing
> vmf->offset in filemap_fault doesn't.
>
> Why?
Here's your script:
====
probe kernel.function("filemap_fault")
{
if (execname() != "hello") next;
printf("%s: filemap_fault\n", execname());
printf("Page: %lu\n", $vmf->pgoff);
}
probe kernel.function("find_get_page")
{
if (execname() != "hello") next;
printf("%s: find_get_page\n", execname());
printf("Page: %lu\n", $offset);
}
=====
Here's filemap_fault() (at least my version of it):
====
int filemap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
{
int error;
struct file *file = vma->vm_file;
struct address_space *mapping = file->f_mapping;
struct file_ra_state *ra = &file->f_ra;
struct inode *inode = mapping->host;
pgoff_t offset = vmf->pgoff;
struct page *page;
pgoff_t size;
int ret = 0;
size = (i_size_read(inode) + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
if (offset >= size)
return VM_FAULT_SIGBUS;
/*
* Do we have something in the page cache already?
*/
page = find_get_page(mapping, offset);
====
Based on that, filemap_fault() can return before calling
find_get_page(), so your calls may not be matching up like you think
they do.
You might try something like this (untested), and see what happens:
=====
global handled
probe kernel.function("filemap_fault")
{
if (execname() != "hello") next;
printf("%s: filemap_fault\n", execname());
printf("Page: %lu\n", $vmf->pgoff);
handled[tid()] = 1
}
probe kernel.function("filemap_fault").return
{
delete handled[tid()]
}
probe kernel.function("find_get_page")
{
if (handled[tid()] != 1) next;
printf("%s: find_get_page\n", execname());
printf("Page: %lu\n", $offset);
}
=====
--
David Smith
dsmith@redhat.com
Red Hat
http://www.redhat.com
256.217.0141 (direct)
256.837.0057 (fax)
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Page faults
2013-09-09 21:00 ` David Smith
@ 2013-09-10 16:14 ` Paddie O'Brien
2013-09-10 18:12 ` David Smith
2013-09-10 20:12 ` Frank Ch. Eigler
0 siblings, 2 replies; 6+ messages in thread
From: Paddie O'Brien @ 2013-09-10 16:14 UTC (permalink / raw)
To: David Smith; +Cc: systemtap
Thanks David. I tried your approach but I get the same result.
The script sometimes crashes unless I include --skip-badvars.
Could my problem be caused by a misconfigured systemtap installation?
Thanks,
P
On 9 September 2013 22:00, David Smith <dsmith@redhat.com> wrote:
> On 09/09/2013 03:36 PM, Paddie O'Brien wrote:
>> Hi,
>>
>> I run the attached to print out the offsets of faulting pages. Both
>> probes should (I think) print the same number but instead I get this:
>>
>> hello: filemap_fault
>> Page: 1678263179
>> hello: find_get_page
>> Page: 15
>>
>> hello: filemap_fault
>> Page: 1678263179
>> hello: find_get_page
>> Page: 1
>>
>> hello: filemap_fault
>> Page: 1678263179
>> hello: find_get_page
>> Page: 10
>>
>> etc. etc.
>>
>> Both functions are from mm/filemap.c. filemap_fault does this:
>>
>> pgoff_t offset = vmf->offset;
>> find_get_page(mapping, offset);
>>
>> Basically, printing the offset in find_get_page works but printing
>> vmf->offset in filemap_fault doesn't.
>>
>> Why?
>
> Here's your script:
>
> ====
> probe kernel.function("filemap_fault")
> {
> if (execname() != "hello") next;
> printf("%s: filemap_fault\n", execname());
> printf("Page: %lu\n", $vmf->pgoff);
> }
>
> probe kernel.function("find_get_page")
> {
> if (execname() != "hello") next;
> printf("%s: find_get_page\n", execname());
> printf("Page: %lu\n", $offset);
> }
> =====
>
> Here's filemap_fault() (at least my version of it):
>
> ====
> int filemap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
> {
> int error;
> struct file *file = vma->vm_file;
> struct address_space *mapping = file->f_mapping;
> struct file_ra_state *ra = &file->f_ra;
> struct inode *inode = mapping->host;
> pgoff_t offset = vmf->pgoff;
> struct page *page;
> pgoff_t size;
> int ret = 0;
>
> size = (i_size_read(inode) + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
> if (offset >= size)
> return VM_FAULT_SIGBUS;
>
> /*
> * Do we have something in the page cache already?
> */
> page = find_get_page(mapping, offset);
> ====
>
> Based on that, filemap_fault() can return before calling
> find_get_page(), so your calls may not be matching up like you think
> they do.
>
> You might try something like this (untested), and see what happens:
>
> =====
> global handled
>
> probe kernel.function("filemap_fault")
> {
> if (execname() != "hello") next;
> printf("%s: filemap_fault\n", execname());
> printf("Page: %lu\n", $vmf->pgoff);
> handled[tid()] = 1
> }
> probe kernel.function("filemap_fault").return
> {
> delete handled[tid()]
> }
>
> probe kernel.function("find_get_page")
> {
> if (handled[tid()] != 1) next;
> printf("%s: find_get_page\n", execname());
> printf("Page: %lu\n", $offset);
> }
> =====
>
> --
> David Smith
> dsmith@redhat.com
> Red Hat
> http://www.redhat.com
> 256.217.0141 (direct)
> 256.837.0057 (fax)
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Page faults
2013-09-10 16:14 ` Paddie O'Brien
@ 2013-09-10 18:12 ` David Smith
2013-09-10 20:12 ` Frank Ch. Eigler
1 sibling, 0 replies; 6+ messages in thread
From: David Smith @ 2013-09-10 18:12 UTC (permalink / raw)
To: Paddie O'Brien; +Cc: systemtap
On 09/10/2013 11:14 AM, Paddie O'Brien wrote:
> Thanks David. I tried your approach but I get the same result.
>
> The script sometimes crashes unless I include --skip-badvars.
>
> Could my problem be caused by a misconfigured systemtap installation?
>
> Thanks,
> P
Hmm, interesting. I tweaked the script a bit to use the 'target()'
function, which returns the pid of the target (from either '-c command'
or '-x pid').
====
global handled
probe kernel.function("filemap_fault")
{
if (pid() != target()) next;
printf("%s: filemap_fault\n", execname());
printf("Page: %lu\n", $vmf->pgoff);
handled[tid()] = 1
}
probe kernel.function("filemap_fault").return
{
if (pid() != target()) next;
delete handled[tid()]
}
probe kernel.function("find_get_page")
{
if (handled[tid()] != 1) next;
printf("%s: find_get_page\n", execname());
printf("Page: %lu\n\n", $offset);
}
====
When I run "stap -c page_faults.stp -c ls", all the page numbers match up.
Since I didn't have to use '--skip-badvars', my next guess would be that
you've got an older systemtap.
I'm running HEAD systemtap (~2.3) on 3.11.0-0.rc5.git3.1.fc20.x86_64.
What version of systemtap and what kernel are you running?
--
David Smith
dsmith@redhat.com
Red Hat
http://www.redhat.com
256.217.0141 (direct)
256.837.0057 (fax)
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Page faults
2013-09-10 16:14 ` Paddie O'Brien
2013-09-10 18:12 ` David Smith
@ 2013-09-10 20:12 ` Frank Ch. Eigler
2013-09-10 21:38 ` Paddie O'Brien
1 sibling, 1 reply; 6+ messages in thread
From: Frank Ch. Eigler @ 2013-09-10 20:12 UTC (permalink / raw)
To: Paddie O'Brien; +Cc: David Smith, systemtap
paddieobrien wrote:
> The script sometimes crashes unless I include --skip-badvars.
> Could my problem be caused by a misconfigured systemtap installation?
The exact error message could help. It's possible that there is a
build problem (e.g., debuginfo errors), or runtime bugs, or kernel
unexpected behavior. You may be able to use constructs such as
try {
foo = $var->field
} catch {
next
}
or "stap --suppress-handler-errors".
- FChE
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Page faults
2013-09-10 20:12 ` Frank Ch. Eigler
@ 2013-09-10 21:38 ` Paddie O'Brien
0 siblings, 0 replies; 6+ messages in thread
From: Paddie O'Brien @ 2013-09-10 21:38 UTC (permalink / raw)
To: Frank Ch. Eigler; +Cc: David Smith, systemtap
stap -V says version 1.7 and the kernel is 3.2.0-4-686-pae
I'll try upgrading...
On 10 September 2013 21:12, Frank Ch. Eigler <fche@redhat.com> wrote:
>
> paddieobrien wrote:
>
>> The script sometimes crashes unless I include --skip-badvars.
>> Could my problem be caused by a misconfigured systemtap installation?
>
> The exact error message could help. It's possible that there is a
> build problem (e.g., debuginfo errors), or runtime bugs, or kernel
> unexpected behavior. You may be able to use constructs such as
>
> try {
> foo = $var->field
> } catch {
> next
> }
>
> or "stap --suppress-handler-errors".
>
> - FChE
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-09-10 21:38 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-09-09 20:36 Page faults Paddie O'Brien
2013-09-09 21:00 ` David Smith
2013-09-10 16:14 ` Paddie O'Brien
2013-09-10 18:12 ` David Smith
2013-09-10 20:12 ` Frank Ch. Eigler
2013-09-10 21:38 ` Paddie O'Brien
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).