linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Steffen Rumler <Steffen.Rumler@siemens.com>
To: linuxppc <linuxppc-embedded@ozlabs.org>
Subject: Dump Page Cache state for out of memory
Date: Wed, 19 Jan 2005 11:45:13 +0100	[thread overview]
Message-ID: <41EE3A39.7080703@siemens.com> (raw)

Hi,

I'm using the following code in order to
dump the state concerning the Page Cache
related to filesystem I/O, from out_of_memory().

Steffen

--

oo_kill.c:

...
typedef struct {
     unsigned long locked;    /* number locked pages */
     unsigned long clean;     /* number clean pages */
     unsigned long dirty;     /* number dirty pages */
     struct super_block *sb;  /* related superblock */
} dump_page_cache_entry_t;

static dump_page_cache_entry_t dump_page_cache_arr[16];

static dump_page_cache_entry_t *
get_dump_cache_entry (struct super_block *sb)
{
     int i;

     for(i=0; i < 16; i++){
         if(dump_page_cache_arr[i].sb == sb)  return &dump_page_cache_arr[i];
         if(dump_page_cache_arr[i].sb == NULL){
             dump_page_cache_arr[i].sb = sb;
             return &dump_page_cache_arr[i];
         }
     }
     return &dump_page_cache_arr[15];
}

/*  dump page cache state
  */

static void dump_page_cache (void)
{
     int i;
     struct page **p = page_hash_table;
     struct page  *q;
     unsigned long flags;
     unsigned long total  = 0;
     dump_page_cache_entry_t *ep;
     struct super_block *sb;

     for(i=0; i<PAGE_HASH_SIZE; i++){

         for(q=*p;q;q=q->next_hash){

             total++;
             if(q->mapping  && q->mapping->host && (sb=q->mapping->host->i_sb)){

                 flags = q->flags;
                 ep = get_dump_cache_entry(sb);

                 if((flags & (1 << PG_locked))){
                     ep->locked++;
                 }else{
                     if((flags & (1 << PG_dirty))){
                         if(flags & (1 << PG_uptodate)){
                             ep->dirty++;
                         }
                     }else{
                         ep->clean++;
                     }
                 }
             }
         }
         p++;
     }

     printk(KERN_EMERG "%s (%d) %s(): Page Cache Status:\n", __FILE__, __LINE__, __func__);
     for(i=0; i<16; i++){

         dump_page_cache_entry_t *ce = &dump_page_cache_arr[i];

         if(ce->sb){

             printk(KERN_EMERG "%14s  clean: %-10d  locked: %-10d  dirty: %d\n",
                     ce->sb->s_type ? ce->sb->s_type->name : "???",
                     ce->clean, ce->locked, ce->dirty);
         }else{
             break;
         }
     }
     printk("%14s %d\n", "total", total);
}

...

void out_of_memory(void)
{
    ...
    dump_page_cache();
    ...
}

                 reply	other threads:[~2005-01-19 10:45 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=41EE3A39.7080703@siemens.com \
    --to=steffen.rumler@siemens.com \
    --cc=linuxppc-embedded@ozlabs.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 NNTP newsgroup(s).