* [PATCH -next] EDAC: Fix debugfs_simple_attr.cocci warnings
@ 2018-10-05 10:52 YueHaibing
2018-10-05 20:38 ` Borislav Petkov
0 siblings, 1 reply; 2+ messages in thread
From: YueHaibing @ 2018-10-05 10:52 UTC (permalink / raw)
To: Tony Luck, Borislav Petkov, Mauro Carvalho Chehab
Cc: YueHaibing, linux-edac, kernel-janitors
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>
---
drivers/edac/skx_edac.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/edac/skx_edac.c b/drivers/edac/skx_edac.c
index e840412..a9a32b3 100644
--- a/drivers/edac/skx_edac.c
+++ b/drivers/edac/skx_edac.c
@@ -913,12 +913,13 @@ static int debugfs_u64_set(void *data, u64 val)
return 0;
}
-DEFINE_SIMPLE_ATTRIBUTE(fops_u64_wo, NULL, debugfs_u64_set, "%llu\n");
+DEFINE_DEBUGFS_ATTRIBUTE(fops_u64_wo, NULL, debugfs_u64_set, "%llu\n");
static struct dentry *mydebugfs_create(const char *name, umode_t mode,
struct dentry *parent, u64 *value)
{
- return debugfs_create_file(name, mode, parent, value, &fops_u64_wo);
+ return debugfs_create_file_unsafe(name, mode, parent, value,
+ &fops_u64_wo);
}
static void setup_skx_debug(void)
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH -next] EDAC: Fix debugfs_simple_attr.cocci warnings
2018-10-05 10:52 [PATCH -next] EDAC: Fix debugfs_simple_attr.cocci warnings YueHaibing
@ 2018-10-05 20:38 ` Borislav Petkov
0 siblings, 0 replies; 2+ messages in thread
From: Borislav Petkov @ 2018-10-05 20:38 UTC (permalink / raw)
To: YueHaibing; +Cc: Tony Luck, Mauro Carvalho Chehab, linux-edac, kernel-janitors
On Fri, Oct 05, 2018 at 10:52:40AM +0000, YueHaibing wrote:
> 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
What significant overhead? This commit message needs to explain what is
wrong with the use of DEFINE_DEBUGFS_ATTRIBUTE first.
> DEFINE_DEBUGFS_ATTRIBUTE + debugfs_create_file_unsafe().
Reading the comment over this function:
* It is your responsibility to protect your struct file_operation
* methods against file removals by means of debugfs_use_file_start()
* and debugfs_use_file_finish(). ->open() is still protected by
* debugfs though.
doesn't sound like something I'd want to additionally pay attention to.
--
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-10-05 20:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-10-05 10:52 [PATCH -next] EDAC: Fix debugfs_simple_attr.cocci warnings YueHaibing
2018-10-05 20:38 ` Borislav Petkov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox