diff mbox series

[RFC,01/15] slub: Create sysfs field /sys/slab/<cache>/ops

Message ID 20190308041426.16654-2-tobin@kernel.org (mailing list archive)
State New, archived
Headers show
Series mm: Implement Slab Movable Objects (SMO) | expand

Commit Message

Tobin C. Harding March 8, 2019, 4:14 a.m. UTC
Create an ops field in /sys/slab/*/ops to contain all the callback
operations defined for a slab cache. This will be used to display
the additional callbacks that will be defined soon to enable movable
objects.

Display the existing ctor callback in the ops fields contents.

Co-developed-by: Christoph Lameter <cl@linux.com>
Signed-off-by: Tobin C. Harding <tobin@kernel.org>
---
 mm/slub.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

Comments

Roman Gushchin March 11, 2019, 9:23 p.m. UTC | #1
On Fri, Mar 08, 2019 at 03:14:12PM +1100, Tobin C. Harding wrote:
> Create an ops field in /sys/slab/*/ops to contain all the callback
> operations defined for a slab cache. This will be used to display
> the additional callbacks that will be defined soon to enable movable
> objects.
> 
> Display the existing ctor callback in the ops fields contents.
> 
> Co-developed-by: Christoph Lameter <cl@linux.com>
> Signed-off-by: Tobin C. Harding <tobin@kernel.org>

Hi Tobin!

> ---
>  mm/slub.c | 13 +++++++++----
>  1 file changed, 9 insertions(+), 4 deletions(-)
> 
> diff --git a/mm/slub.c b/mm/slub.c
> index dc777761b6b7..69164aa7cbbf 100644
> --- a/mm/slub.c
> +++ b/mm/slub.c
> @@ -5009,13 +5009,18 @@ static ssize_t cpu_partial_store(struct kmem_cache *s, const char *buf,
>  }
>  SLAB_ATTR(cpu_partial);
>  
> -static ssize_t ctor_show(struct kmem_cache *s, char *buf)
> +static ssize_t ops_show(struct kmem_cache *s, char *buf)
>  {
> +	int x = 0;
> +
>  	if (!s->ctor)
>  		return 0;
        ^^^^^^^^^^^^^^^^^
You can drop this part, can't you?

Also, it's not clear (without looking into following patches) why do you
make this refactoring. So, please, add a note, or move this change into
the patch 3.

Thanks!
Tobin Harding March 12, 2019, 1:16 a.m. UTC | #2
On Mon, Mar 11, 2019 at 09:23:27PM +0000, Roman Gushchin wrote:
> On Fri, Mar 08, 2019 at 03:14:12PM +1100, Tobin C. Harding wrote:
> > Create an ops field in /sys/slab/*/ops to contain all the callback
> > operations defined for a slab cache. This will be used to display
> > the additional callbacks that will be defined soon to enable movable
> > objects.
> > 
> > Display the existing ctor callback in the ops fields contents.
> > 
> > Co-developed-by: Christoph Lameter <cl@linux.com>
> > Signed-off-by: Tobin C. Harding <tobin@kernel.org>
> 
> Hi Tobin!
> 
> > ---
> >  mm/slub.c | 13 +++++++++----
> >  1 file changed, 9 insertions(+), 4 deletions(-)
> > 
> > diff --git a/mm/slub.c b/mm/slub.c
> > index dc777761b6b7..69164aa7cbbf 100644
> > --- a/mm/slub.c
> > +++ b/mm/slub.c
> > @@ -5009,13 +5009,18 @@ static ssize_t cpu_partial_store(struct kmem_cache *s, const char *buf,
> >  }
> >  SLAB_ATTR(cpu_partial);
> >  
> > -static ssize_t ctor_show(struct kmem_cache *s, char *buf)
> > +static ssize_t ops_show(struct kmem_cache *s, char *buf)
> >  {
> > +	int x = 0;
> > +
> >  	if (!s->ctor)
> >  		return 0;
>         ^^^^^^^^^^^^^^^^^
> You can drop this part, can't you?
> 
> Also, it's not clear (without looking into following patches) why do you
> make this refactoring. So, please, add a note, or move this change into
> the patch 3.

No worries, thanks for looking at this.  Will amend the commit message
and drop the constructor check.

thanks,
Tobin
diff mbox series

Patch

diff --git a/mm/slub.c b/mm/slub.c
index dc777761b6b7..69164aa7cbbf 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -5009,13 +5009,18 @@  static ssize_t cpu_partial_store(struct kmem_cache *s, const char *buf,
 }
 SLAB_ATTR(cpu_partial);
 
-static ssize_t ctor_show(struct kmem_cache *s, char *buf)
+static ssize_t ops_show(struct kmem_cache *s, char *buf)
 {
+	int x = 0;
+
 	if (!s->ctor)
 		return 0;
-	return sprintf(buf, "%pS\n", s->ctor);
+
+	if (s->ctor)
+		x += sprintf(buf + x, "ctor : %pS\n", s->ctor);
+	return x;
 }
-SLAB_ATTR_RO(ctor);
+SLAB_ATTR_RO(ops);
 
 static ssize_t aliases_show(struct kmem_cache *s, char *buf)
 {
@@ -5428,7 +5433,7 @@  static struct attribute *slab_attrs[] = {
 	&objects_partial_attr.attr,
 	&partial_attr.attr,
 	&cpu_slabs_attr.attr,
-	&ctor_attr.attr,
+	&ops_attr.attr,
 	&aliases_attr.attr,
 	&align_attr.attr,
 	&hwcache_align_attr.attr,