From: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
To: David Rientjes <rientjes@google.com>
Cc: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>,
Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
Andrew Morton <akpm@linux-foundation.org>,
Christoph Lameter <cl@linux.com>,
Pekka Enberg <penberg@kernel.org>,
Joonsoo Kim <iamjoonsoo.kim@lge.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/3] tools/vm/slabinfo: update struct slabinfo members' types
Date: Thu, 12 Nov 2015 15:17:01 +0900 [thread overview]
Message-ID: <20151112061701.GA498@swordfish> (raw)
In-Reply-To: <alpine.DEB.2.10.1511112105200.9296@chino.kir.corp.google.com>
On (11/11/15 21:07), David Rientjes wrote:
[..]
> > > > /* Object size */
> > > > - unsigned long long min_objsize = max, max_objsize = 0, avg_objsize;
> > > > + unsigned int min_objsize = UINT_MAX, max_objsize = 0, avg_objsize;
> > > >
> > > > /* Number of partial slabs in a slabcache */
> > > > unsigned long long min_partial = max, max_partial = 0,
> > >
> > > avg_objsize should not be unsigned int.
> >
> > Hm. the assumption is that `avg_objsize' cannot be larger
> > than `max_objsize', which is
> > `int object_size;' in `struct kmem_cache' from slab_def.h
> > and
> > `unsigned int object_size;' in `struct kmem_cache' from slab.h.
> >
> >
> > avg_objsize = total_used / total_objects;
> >
>
I'm not sure I clearly understand the problems you're pointing
me to.
> This has nothing to do with object_size in the kernel.
what we have in slabinfo as slab_size(), ->object_size, etc.
comming from slub's sysfs attrs:
chdir("/sys/kernel/slab")
while readdir
...
slab->object_size = get_obj("object_size");
slab->slab_size = get_obj("slab_size");
...
and attr show handlers are:
...
static ssize_t slab_size_show(struct kmem_cache *s, char *buf)
{
return sprintf(buf, "%d\n", s->size);
}
SLAB_ATTR_RO(slab_size);
static ssize_t object_size_show(struct kmem_cache *s, char *buf)
{
return sprintf(buf, "%d\n", s->object_size);
}
SLAB_ATTR_RO(object_size);
...
so those are sprintf("%d") of `struct kmem_cache'-s `int'
values.
> total_used and total_objects are unsigned long long.
yes, that's correct.
but `total_used / total_objects' cannot be larger that the size
of the largest object, which is represented in the kernel and
returned to user space as `int'. it must fit into `unsigned int'.
> If you need to convert max_objsize to be unsigned long long as
> well, that would be better.
... in case if someday `struct kmem_cache' will be updated to keep
`unsigned long' sized objects and sysfs attrs will do sprintf("%lu")?
IOW, if slabs will keep objects bigger that 4gig?
-ss
--
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>
WARNING: multiple messages have this Message-ID (diff)
From: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
To: David Rientjes <rientjes@google.com>
Cc: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>,
Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
Andrew Morton <akpm@linux-foundation.org>,
Christoph Lameter <cl@linux.com>,
Pekka Enberg <penberg@kernel.org>,
Joonsoo Kim <iamjoonsoo.kim@lge.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/3] tools/vm/slabinfo: update struct slabinfo members' types
Date: Thu, 12 Nov 2015 15:17:01 +0900 [thread overview]
Message-ID: <20151112061701.GA498@swordfish> (raw)
In-Reply-To: <alpine.DEB.2.10.1511112105200.9296@chino.kir.corp.google.com>
On (11/11/15 21:07), David Rientjes wrote:
[..]
> > > > /* Object size */
> > > > - unsigned long long min_objsize = max, max_objsize = 0, avg_objsize;
> > > > + unsigned int min_objsize = UINT_MAX, max_objsize = 0, avg_objsize;
> > > >
> > > > /* Number of partial slabs in a slabcache */
> > > > unsigned long long min_partial = max, max_partial = 0,
> > >
> > > avg_objsize should not be unsigned int.
> >
> > Hm. the assumption is that `avg_objsize' cannot be larger
> > than `max_objsize', which is
> > `int object_size;' in `struct kmem_cache' from slab_def.h
> > and
> > `unsigned int object_size;' in `struct kmem_cache' from slab.h.
> >
> >
> > avg_objsize = total_used / total_objects;
> >
>
I'm not sure I clearly understand the problems you're pointing
me to.
> This has nothing to do with object_size in the kernel.
what we have in slabinfo as slab_size(), ->object_size, etc.
comming from slub's sysfs attrs:
chdir("/sys/kernel/slab")
while readdir
...
slab->object_size = get_obj("object_size");
slab->slab_size = get_obj("slab_size");
...
and attr show handlers are:
...
static ssize_t slab_size_show(struct kmem_cache *s, char *buf)
{
return sprintf(buf, "%d\n", s->size);
}
SLAB_ATTR_RO(slab_size);
static ssize_t object_size_show(struct kmem_cache *s, char *buf)
{
return sprintf(buf, "%d\n", s->object_size);
}
SLAB_ATTR_RO(object_size);
...
so those are sprintf("%d") of `struct kmem_cache'-s `int'
values.
> total_used and total_objects are unsigned long long.
yes, that's correct.
but `total_used / total_objects' cannot be larger that the size
of the largest object, which is represented in the kernel and
returned to user space as `int'. it must fit into `unsigned int'.
> If you need to convert max_objsize to be unsigned long long as
> well, that would be better.
... in case if someday `struct kmem_cache' will be updated to keep
`unsigned long' sized objects and sysfs attrs will do sprintf("%lu")?
IOW, if slabs will keep objects bigger that 4gig?
-ss
next prev parent reply other threads:[~2015-11-12 6:16 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-10 13:32 [PATCH 0/3] tools/vm: trivial fixes Sergey Senozhatsky
2015-11-10 13:32 ` Sergey Senozhatsky
2015-11-10 13:32 ` [PATCH 1/3] tools/vm: fix Makefile multi-targets Sergey Senozhatsky
2015-11-10 13:32 ` Sergey Senozhatsky
2015-11-10 15:29 ` Christoph Lameter
2015-11-10 15:29 ` Christoph Lameter
2015-11-11 12:28 ` Sergey Senozhatsky
2015-11-11 12:28 ` Sergey Senozhatsky
2015-11-11 20:34 ` David Rientjes
2015-11-11 20:34 ` David Rientjes
2015-11-12 0:58 ` Sergey Senozhatsky
2015-11-12 0:58 ` Sergey Senozhatsky
2015-11-10 13:32 ` [PATCH 2/3] tools/vm/page-types: suppress gcc warnings Sergey Senozhatsky
2015-11-10 13:32 ` Sergey Senozhatsky
2015-11-11 20:44 ` David Rientjes
2015-11-11 20:44 ` David Rientjes
2015-11-12 0:54 ` Sergey Senozhatsky
2015-11-12 0:54 ` Sergey Senozhatsky
2015-11-12 5:46 ` David Rientjes
2015-11-12 5:46 ` David Rientjes
2015-11-10 13:32 ` [PATCH 3/3] tools/vm/slabinfo: update struct slabinfo members' types Sergey Senozhatsky
2015-11-10 13:32 ` Sergey Senozhatsky
2015-11-10 15:28 ` Christoph Lameter
2015-11-10 15:28 ` Christoph Lameter
2015-11-11 20:55 ` David Rientjes
2015-11-11 20:55 ` David Rientjes
2015-11-12 1:13 ` Sergey Senozhatsky
2015-11-12 1:13 ` Sergey Senozhatsky
2015-11-12 5:07 ` David Rientjes
2015-11-12 5:07 ` David Rientjes
2015-11-12 6:17 ` Sergey Senozhatsky [this message]
2015-11-12 6:17 ` Sergey Senozhatsky
2015-11-12 9:59 ` David Rientjes
2015-11-12 9:59 ` David Rientjes
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=20151112061701.GA498@swordfish \
--to=sergey.senozhatsky.work@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=cl@linux.com \
--cc=iamjoonsoo.kim@lge.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=penberg@kernel.org \
--cc=rientjes@google.com \
--cc=sergey.senozhatsky@gmail.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.