From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28125 invoked by alias); 9 Sep 2013 21:00:35 -0000 Mailing-List: contact systemtap-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: systemtap-owner@sourceware.org Received: (qmail 28112 invoked by uid 89); 9 Sep 2013 21:00:35 -0000 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 09 Sep 2013 21:00:35 +0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-5.1 required=5.0 tests=AWL,BAYES_00,KHOP_THREADED,RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r89L0Vdr018912 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 9 Sep 2013 17:00:32 -0400 Received: from t510.usersys.redhat.com (dhcp-10-15-1-11.hsv.redhat.com [10.15.1.11]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r89L0VJF001662 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 9 Sep 2013 17:00:31 -0400 Message-ID: <522E36EF.3080904@redhat.com> Date: Mon, 09 Sep 2013 21:00:00 -0000 From: David Smith User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130805 Thunderbird/17.0.8 MIME-Version: 1.0 To: "Paddie O'Brien" CC: systemtap@sourceware.org Subject: Re: Page faults References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2013-q3/txt/msg00286.txt.bz2 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)