mm/slub: avoid double string traverse in kmem_cache_flags()
Subsystems (2)
PATCH 1/1 mm/slub: avoid double string traverse in kmem_cache_flags()
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 <[email protected]>
--- mm/slub.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
mm/slub.c +1 -3
@@ -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)
Signature · 1 line
2.17.1
Quoted 2 lines · Yury Norov
If ',' is not found,
kmem_cache_flags()callsstrlen()to find the end of line. We can do it in a single pass usingstrchrnul().
Ping?
Quoted 22 lines
Signed-off-by Yury Norov <[email protected]>--- mm/slub.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)mm/slub.c +1
-3@@ -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)Signature · 1 line
2.17.1
Quoted 13 lines · Yury Norov
If ',' is not found,
kmem_cache_flags()callsstrlen()to find the end of line. We can do it in a single pass usingstrchrnul().Signed-off-by Yury Norov <[email protected]>--- mm/slub.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)mm/slub.c +0
-0
mm/slub.c slab_flags_t kmem_cache_flags(unsigned int object_size, · line 1323
Quoted 10 lines
mm/slub.c +1
-3@@ -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 <[email protected]>
Signature · 1 line
Aaron Tomlin