linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Aaron Tomlin <atomlin@redhat.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: cl@linux.com, penberg@kernel.org, rientjes@google.com,
	iamjoonsoo.kim@lge.com, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] slub: extend slub debug to handle multiple slabs
Date: Fri, 28 Sep 2018 11:05:55 +0100	[thread overview]
Message-ID: <20180928100555.bvv75beo3c57g6vw@atomlin.usersys.com> (raw)
In-Reply-To: <20180921163412.de1b331a639a8031aaf85d4f@linux-foundation.org>

On Fri 2018-09-21 16:34 -0700, Andrew Morton wrote:
> On Thu, 20 Sep 2018 21:00:16 +0100 Aaron Tomlin <atomlin@redhat.com> wrote:
> > --- a/mm/slub.c
> > +++ b/mm/slub.c
> > @@ -1283,9 +1283,37 @@ slab_flags_t kmem_cache_flags(unsigned int object_size,
> >  	/*
> >  	 * Enable debugging if selected on the kernel commandline.
> >  	 */
> 
> The above comment is in a strange place.  Can we please move it to
> above the function definition in the usual fashion?  And make it
> better, if anything seems to be missing.

OK.

> > -	if (slub_debug && (!slub_debug_slabs || (name &&
> > -		!strncmp(slub_debug_slabs, name, strlen(slub_debug_slabs)))))
> > -		flags |= slub_debug;
> > +
> > +	char *end, *n, *glob;
> 
> `end' and `glob' could be local to the loop which uses them, which I
> find a bit nicer.

OK.

> `n' is a rotten identifier.  Can't we think of something which
> communicates meaning?

OK.

> > +	int len = strlen(name);
> > +
> > +	/* If slub_debug = 0, it folds into the if conditional. */
> > +	if (!slub_debug_slabs)
> > +		return flags | slub_debug;
> 
> If we take the above return, the call to strlen() was wasted cycles. 
> Presumably gcc is smart enough to prevent that, but why risk it.

OK.

> > +	n = slub_debug_slabs;
> > +	while (*n) {
> > +		int cmplen;
> > +
> > +		end = strchr(n, ',');
> > +		if (!end)
> > +			end = n + strlen(n);
> > +
> > +		glob = strnchr(n, end - n, '*');
> > +		if (glob)
> > +			cmplen = glob - n;
> > +		else
> > +			cmplen = max(len, (int)(end - n));
> 
> max_t() exists for this.  Or maybe make `len' size_t, but I expect that
> will still warn - that subtraction returns a ptrdiff_t, yes?

I think max_t(size_t, ...) should be appropriate?

I'll address the above and in the next version.


> > +
> > +		if (!strncmp(name, n, cmplen)) {
> > +			flags |= slub_debug;
> > +			break;
> > +		}
> > +
> > +		if (!*end)
> > +			break;
> > +		n = end + 1;
> > +	}
> The code in this loop hurts my brain a bit. I hope it's correct ;)

It works :)



-- 
Aaron Tomlin

      reply	other threads:[~2018-09-28 10:05 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-20 20:00 Aaron Tomlin
2018-09-21 23:34 ` Andrew Morton
2018-09-28 10:05   ` Aaron Tomlin [this message]

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=20180928100555.bvv75beo3c57g6vw@atomlin.usersys.com \
    --to=atomlin@redhat.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 \
    /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