[-next] powerpc/powernv: Fix debugfs_simple_attr.cocci warnings
diff mbox series

Message ID 1538736631-99728-1-git-send-email-yuehaibing@huawei.com
State Changes Requested
Headers show
Series
  • [-next] powerpc/powernv: Fix debugfs_simple_attr.cocci warnings
Related show

Checks

Context Check Description
snowpatch_ozlabs/build-ppc32 success Test build-ppc32 on branch next
snowpatch_ozlabs/build-ppc64e success Test build-ppc64e on branch next
snowpatch_ozlabs/build-ppc64be success Test build-ppc64be on branch next
snowpatch_ozlabs/build-ppc64le success Test build-ppc64le on branch next
snowpatch_ozlabs/checkpatch success Test checkpatch on branch next
snowpatch_ozlabs/apply_patch success next/apply_patch Successfully applied

Commit Message

YueHaibing Oct. 5, 2018, 10:50 a.m. UTC
Use DEFINE_DEBUGFS_ATTRIBUTE rather than DEFINE_SIMPLE_ATTRIBUTE
for debugfs files.

Semantic patch information:
Rationale: DEFINE_SIMPLE_ATTRIBUTE + debugfs_create_file()
imposes some significant overhead as compared to
DEFINE_DEBUGFS_ATTRIBUTE + debugfs_create_file_unsafe().

Generated by: scripts/coccinelle/api/debugfs/debugfs_simple_attr.cocci

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
 arch/powerpc/platforms/powernv/memtrace.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Michael Ellerman Oct. 8, 2018, 8:27 a.m. UTC | #1
YueHaibing <yuehaibing@huawei.com> writes:
> Use DEFINE_DEBUGFS_ATTRIBUTE rather than DEFINE_SIMPLE_ATTRIBUTE
> for debugfs files.
>
> Semantic patch information:
> Rationale: DEFINE_SIMPLE_ATTRIBUTE + debugfs_create_file()
> imposes some significant overhead as compared to
> DEFINE_DEBUGFS_ATTRIBUTE + debugfs_create_file_unsafe().

Sorry this isn't detailed enough for me to actually understand the
pros/cons of this patch.

Perhaps I'm expected to know it, but I don't.

I had a look at what each macro produces and it wasn't obvious to me
what the benefit is.

cheers

> Generated by: scripts/coccinelle/api/debugfs/debugfs_simple_attr.cocci
>
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
> ---
>  arch/powerpc/platforms/powernv/memtrace.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/arch/powerpc/platforms/powernv/memtrace.c b/arch/powerpc/platforms/powernv/memtrace.c
> index 84d038e..0cb6548 100644
> --- a/arch/powerpc/platforms/powernv/memtrace.c
> +++ b/arch/powerpc/platforms/powernv/memtrace.c
> @@ -311,8 +311,8 @@ static int memtrace_enable_get(void *data, u64 *val)
>  	return 0;
>  }
>  
> -DEFINE_SIMPLE_ATTRIBUTE(memtrace_init_fops, memtrace_enable_get,
> -					memtrace_enable_set, "0x%016llx\n");
> +DEFINE_DEBUGFS_ATTRIBUTE(memtrace_init_fops, memtrace_enable_get,
> +			 memtrace_enable_set, "0x%016llx\n");
>  
>  static int memtrace_init(void)
>  {
> @@ -321,8 +321,8 @@ static int memtrace_init(void)
>  	if (!memtrace_debugfs_dir)
>  		return -1;
>  
> -	debugfs_create_file("enable", 0600, memtrace_debugfs_dir,
> -			    NULL, &memtrace_init_fops);
> +	debugfs_create_file_unsafe("enable", 0600, memtrace_debugfs_dir, NULL,
> +				   &memtrace_init_fops);
>  
>  	return 0;
>  }

Patch
diff mbox series

diff --git a/arch/powerpc/platforms/powernv/memtrace.c b/arch/powerpc/platforms/powernv/memtrace.c
index 84d038e..0cb6548 100644
--- a/arch/powerpc/platforms/powernv/memtrace.c
+++ b/arch/powerpc/platforms/powernv/memtrace.c
@@ -311,8 +311,8 @@  static int memtrace_enable_get(void *data, u64 *val)
 	return 0;
 }
 
-DEFINE_SIMPLE_ATTRIBUTE(memtrace_init_fops, memtrace_enable_get,
-					memtrace_enable_set, "0x%016llx\n");
+DEFINE_DEBUGFS_ATTRIBUTE(memtrace_init_fops, memtrace_enable_get,
+			 memtrace_enable_set, "0x%016llx\n");
 
 static int memtrace_init(void)
 {
@@ -321,8 +321,8 @@  static int memtrace_init(void)
 	if (!memtrace_debugfs_dir)
 		return -1;
 
-	debugfs_create_file("enable", 0600, memtrace_debugfs_dir,
-			    NULL, &memtrace_init_fops);
+	debugfs_create_file_unsafe("enable", 0600, memtrace_debugfs_dir, NULL,
+				   &memtrace_init_fops);
 
 	return 0;
 }