linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Eric Dumazet <dada1@cosmosbay.com>
To: Pekka Enberg <penberg@cs.helsinki.fi>
Cc: Pavel Emelianov <xemul@sw.ru>, Andrew Morton <akpm@osdl.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	devel@openvz.org, Kirill Korotaev <dev@openvz.org>,
	linux-mm@kvack.org
Subject: Re: [PATCH] Show slab memory usage on OOM and SysRq-M
Date: Tue, 17 Apr 2007 17:12:13 +0200	[thread overview]
Message-ID: <20070417171213.e3cbc260.dada1@cosmosbay.com> (raw)
In-Reply-To: <84144f020704170622h2b16f0f6m47ffdbb3b5686758@mail.gmail.com>

On Tue, 17 Apr 2007 16:22:48 +0300
"Pekka Enberg" <penberg@cs.helsinki.fi> wrote:

> Hi,
> 
> On 4/17/07, Pavel Emelianov <xemul@sw.ru> wrote:
> > +static unsigned long get_cache_size(struct kmem_cache *cachep)
> > +{
> > +       unsigned long slabs;
> > +       struct kmem_list3 *l3;
> > +       struct list_head *lh;
> > +       int node;
> > +
> > +       slabs = 0;
> > +
> > +       for_each_online_node (node) {
> > +               l3 = cachep->nodelists[node];
> > +               if (l3 == NULL)
> > +                       continue;
> > +
> > +               spin_lock(&l3->list_lock);
> > +               list_for_each (lh, &l3->slabs_full)
> > +                       slabs++;
> > +               list_for_each (lh, &l3->slabs_partial)
> > +                       slabs++;
> > +               list_for_each (lh, &l3->slabs_free)
> > +                       slabs++;
> > +               spin_unlock(&l3->list_lock);
> > +       }
> > +
> > +       return slabs * ((PAGE_SIZE << cachep->gfporder) +
> > +               (OFF_SLAB(cachep) ? cachep->slabp_cache->buffer_size : 0));
> > +}
> 
> Considering you're doing this at out_of_memory() time, wouldn't it
> make more sense to add a ->nr_pages to struct kmem_cache and do the
> tracking in kmem_getpages/kmem_freepages?
> 

To avoid a deadlock ? yes...

This nr_pages should be in struct kmem_list3, not in struct kmem_cache, or else you defeat NUMA optimizations if touching a field in kmem_cache at kmem_getpages()/kmem_freepages() time.

       for_each_online_node (node) {
               l3 = cachep->nodelists[node];
               if (l3)
                   slabs += l3->nr_pages; /* dont lock l3->list_lock */
       }

--
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: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  parent reply	other threads:[~2007-04-17 15:12 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-17 12:55 Pavel Emelianov
2007-04-17 13:22 ` Pekka Enberg
2007-04-17 13:50   ` Pavel Emelianov
2007-04-17 14:02     ` Pekka J Enberg
2007-04-17 14:21       ` Pavel Emelianov
2007-04-17 15:12   ` Eric Dumazet [this message]
2007-04-18  6:17     ` Pekka J Enberg
2007-04-18 12:07       ` Eric Dumazet

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=20070417171213.e3cbc260.dada1@cosmosbay.com \
    --to=dada1@cosmosbay.com \
    --cc=akpm@osdl.org \
    --cc=dev@openvz.org \
    --cc=devel@openvz.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=penberg@cs.helsinki.fi \
    --cc=xemul@sw.ru \
    /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