public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
From: "Paddie O'Brien" <paddieobrien@gmail.com>
To: David Smith <dsmith@redhat.com>
Cc: systemtap@sourceware.org
Subject: Re: Page faults
Date: Tue, 10 Sep 2013 16:14:00 -0000	[thread overview]
Message-ID: <CAOK12DbaDN6kY6Ng-V9oGcPAzoh7eDoDSZ6gz+wkKkUZO=kHsA@mail.gmail.com> (raw)
In-Reply-To: <522E36EF.3080904@redhat.com>

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)

  reply	other threads:[~2013-09-10 16:14 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-09 20:36 Paddie O'Brien
2013-09-09 21:00 ` David Smith
2013-09-10 16:14   ` Paddie O'Brien [this message]
2013-09-10 18:12     ` David Smith
2013-09-10 20:12     ` Frank Ch. Eigler
2013-09-10 21:38       ` Paddie O'Brien

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='CAOK12DbaDN6kY6Ng-V9oGcPAzoh7eDoDSZ6gz+wkKkUZO=kHsA@mail.gmail.com' \
    --to=paddieobrien@gmail.com \
    --cc=dsmith@redhat.com \
    --cc=systemtap@sourceware.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).