LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] mm/slub: avoid double string traverse in kmem_cache_flags()
@ 2019-05-01  5:31 Yury Norov
  2019-05-07 21:04 ` Yury Norov
  2019-05-14 12:22 ` Aaron Tomlin
  0 siblings, 2 replies; 3+ messages in thread
From: Yury Norov @ 2019-05-01  5:31 UTC (permalink / raw)
  To: Aaron Tomlin, Christoph Lameter, Pekka Enberg, David Rientjes,
	Joonsoo Kim, Andrew Morton
  Cc: Yury Norov, linux-mm, linux-kernel, Yury Norov

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] mm/slub: avoid double string traverse in kmem_cache_flags()
  2019-05-01  5:31 [PATCH] mm/slub: avoid double string traverse in kmem_cache_flags() Yury Norov
@ 2019-05-07 21:04 ` Yury Norov
  2019-05-14 12:22 ` Aaron Tomlin
  1 sibling, 0 replies; 3+ messages in thread
From: Yury Norov @ 2019-05-07 21:04 UTC (permalink / raw)
  To: Aaron Tomlin, Christoph Lameter, Pekka Enberg, David Rientjes,
	Joonsoo Kim, Andrew Morton
  Cc: Yury Norov, linux-mm, linux-kernel

On Tue, Apr 30, 2019 at 10:31:11PM -0700, Yury Norov wrote:
> 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().

Ping?

> 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] mm/slub: avoid double string traverse in kmem_cache_flags()
  2019-05-01  5:31 [PATCH] mm/slub: avoid double string traverse in kmem_cache_flags() Yury Norov
  2019-05-07 21:04 ` Yury Norov
@ 2019-05-14 12:22 ` Aaron Tomlin
  1 sibling, 0 replies; 3+ messages in thread
From: Aaron Tomlin @ 2019-05-14 12:22 UTC (permalink / raw)
  To: Yury Norov
  Cc: Christoph Lameter, Pekka Enberg, David Rientjes, Joonsoo Kim,
	Andrew Morton, Yury Norov, linux-mm, linux-kernel

On Tue 2019-04-30 22:31 -0700, Yury Norov wrote:
> 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)

Fair enough.

Acked-by: Aaron Tomlin <atomlin@redhat.com>

-- 
Aaron Tomlin

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-05-14 12:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-01  5:31 [PATCH] mm/slub: avoid double string traverse in kmem_cache_flags() Yury Norov
2019-05-07 21:04 ` Yury Norov
2019-05-14 12:22 ` Aaron Tomlin

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).