From: Yury Norov <yury.norov@gmail.com>
To: Aaron Tomlin <atomlin@redhat.com>,
Christoph Lameter <cl@linux.com>,
Pekka Enberg <penberg@kernel.org>,
David Rientjes <rientjes@google.com>,
Joonsoo Kim <iamjoonsoo.kim@lge.com>,
Andrew Morton <akpm@linux-foundation.org>
Cc: Yury Norov <ynorov@marvell.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Yury Norov <yury.norov@gmail.com>
Subject: [PATCH] mm/slub: avoid double string traverse in kmem_cache_flags()
Date: Tue, 30 Apr 2019 22:31:11 -0700 [thread overview]
Message-ID: <20190501053111.7950-1-ynorov@marvell.com> (raw)
If ',' is not found, kmem_cache_flags() calls strlen() to find the end
of line. We can do it in a single pass using strchrnul().
Signed-off-by: Yury Norov <ynorov@marvell.com>
---
mm/slub.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/mm/slub.c b/mm/slub.c
index 4922a0394757..85f90370a293 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -1317,9 +1317,7 @@ slab_flags_t kmem_cache_flags(unsigned int object_size,
char *end, *glob;
size_t cmplen;
- end = strchr(iter, ',');
- if (!end)
- end = iter + strlen(iter);
+ end = strchrnul(iter, ',');
glob = strnchr(iter, end - iter, '*');
if (glob)
--
2.17.1
next reply other threads:[~2019-05-01 5:31 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-01 5:31 Yury Norov [this message]
2019-05-07 21:04 ` [PATCH] mm/slub: avoid double string traverse in kmem_cache_flags() Yury Norov
2019-05-14 12:22 ` Aaron Tomlin
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=20190501053111.7950-1-ynorov@marvell.com \
--to=yury.norov@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=atomlin@redhat.com \
--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=ynorov@marvell.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;
as well as URLs for NNTP newsgroup(s).