From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lb0-f172.google.com (mail-lb0-f172.google.com [209.85.217.172]) by kanga.kvack.org (Postfix) with ESMTP id 55DB96B0255 for ; Fri, 11 Dec 2015 10:22:33 -0500 (EST) Received: by lbbcs9 with SMTP id cs9so72130757lbb.1 for ; Fri, 11 Dec 2015 07:22:32 -0800 (PST) Received: from mail-lb0-x235.google.com (mail-lb0-x235.google.com. [2a00:1450:4010:c04::235]) by mx.google.com with ESMTPS id zm8si10705079lbb.100.2015.12.11.07.22.31 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Dec 2015 07:22:31 -0800 (PST) Received: by lbbcs9 with SMTP id cs9so72130383lbb.1 for ; Fri, 11 Dec 2015 07:22:31 -0800 (PST) MIME-Version: 1.0 In-Reply-To: References: Date: Fri, 11 Dec 2015 15:22:31 +0000 Message-ID: Subject: Re: Page Cache Monitoring ( Hit/Miss ) From: Allan McAleavy Content-Type: multipart/alternative; boundary=001a11349980597d030526a0e4c3 Sender: owner-linux-mm@kvack.org List-ID: To: linux-mm@kvack.org --001a11349980597d030526a0e4c3 Content-Type: text/plain; charset=UTF-8 We add a page to the page cache using add_to_page_cache_lru based on the following assumptions READ MISS - So add an entry no_cached_page - so we need to create one from do_generic_file_read - during a file read operation page_cache_read - calls add_to_page_cache_lru CREATE A PAGE struct page *__page_cache_alloc(gfp_t gfp) page has flags which identify if dirty or free Writes add_to_page_cache writepage / writepages set_page_dirty_buffers do_generic_mapping_read - ASYNC read of pages in readahed? __block_write_full_page READ find_get_pages mark_page_accessed() for measuring cache accesses mark_buffer_dirty() for measuring cache writes add_to_page_cache_lru() for measuring page additions account_page_dirtied() for measuring page dirties (mark_page_accessed - mark_buffer_dirty) & misses = (add_to_page_cache_lru - account_page_dirtied), from this I then work out the hit ratio etc. Is there any other key functions I should be tracing? add_to_page_cache_lru lru_cache_add swap.c filemap.c vmscan.c Functions used lru_cache_add_active_or_unevictable add_to_page_cache_lru putback_lru_page So best use lru_cache_add for additions. account_page_dirtied() for measuring page dirties set_page_dirty - calls above __set_page_dirty_nobuffers - calls above also mark_buffer_dirty() for measuring cache writes - this calls __set_page_dirty ( are we getting twice the calls here? ) mark_page_accessed - calls SetPageActive On Thu, Dec 10, 2015 at 9:42 AM, Allan McAleavy wrote: > Hi Folks, > > I am working on a rewrite of Brendan Greggs original cachestat (ftrace) > script into bcc. What I was looking for was a steer in the right direction > for what functions to trace. At present I trace the following. > > add_to_page_cache_lru > account_page_dirtied > mark_page_accessed > mark_buffer_dirty > > Where total = (mark_page_accessed - mark_buffer_dirty) & misses = > (add_to_page_cache_lru - account_page_dirtied), from this I then work out > the hit ratio etc. Is there any other key functions I should be tracing? > > Thanks > --001a11349980597d030526a0e4c3 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
We add a page to the page cache using add_to_page_cac= he_lru based on the following assumptions

READ MIS= S - So add an entry=C2=A0
no_cached_page - so we need to create o= ne from=C2=A0
do_generic_file_read - during a file read operation=
page_cache_read - calls add_to_page_cache_lru=C2=A0
CREATE A PAGE
struct page *__page_cache_alloc(gfp_t = gfp)

page has flags which identify if dirty or fre= e

Writes
add_to_page_cache
wri= tepage / writepages=C2=A0
set_page_dirty_buffers
do_gen= eric_mapping_read =C2=A0- ASYNC read of pages in readahed?
__bloc= k_write_full_page

READ
find_get_pages


mark_page_accessed() for measuring ca= che accesses
mark_buffer_dirty() for measuring cache writes
=
add_to_page_cache_lru() for measuring page additions
account= _page_dirtied() for measuring page dirties


=C2=A0(mark_page_accessed - mark_buffer_dirty) & misses =3D (ad= d_to_page_cache_lru - account_page_dirtied),=C2=A0
=C2=A0from thi= s I then work out the hit ratio etc. Is there any other key functions I sho= uld be tracing?

add_to_page_cache_lru
lr= u_cache_add =C2=A0
swap.c
filemap.c
vmscan.c<= /div>

Functions used=C2=A0
lru_cache_add_activ= e_or_unevictable
add_to_page_cache_lru
putback_lru_page=

So best use lru_cache_add for additions.

account_page_dirtied() for measuring page dirties
set_page_dirty - calls above
__set_page_dirty_nobuffers - calls= above also=C2=A0

mark_buffer_dirty() for measurin= g cache writes - this calls __set_page_dirty ( are we getting twice the cal= ls here? )=C2=A0
mark_page_accessed - calls SetPageActive=C2=A0
--001a11349980597d030526a0e4c3-- -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org