Skip to contentSkip to conversation

Revert "debugfs, coccinelle: check for obsolete DEFINE_SIMPLE_ATTRIBUTE() usage"

PATCH Superseded Sean Christopherson 3 participants 5 messages Jul 10, 2023 – Jul 12, 2023

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Revert "debugfs, coccinelle: check for obsolete DEFINE_SIMPLE_ATTRIBUTE() usage"

Remove coccinelle's recommendation to use DEFINE_SIMPLE_ATTRIBUTE() instead of DEFINE_SIMPLE_ATTRIBUTE(). Regardless of whether or not the "significant overhead" incurred by debugfs_create_file() is actually meaningful, warnings from the script have led to a rash of low-quality patches that have sowed confusion and consumed maintainer time for little to no benefit. There have been no less than four attempts to "fix" KVM, and a quick search on lore shows that KVM is not alone.

This reverts commit 5103068eaca290f890a30aae70085fac44cecaf6.

---
 .../api/debugfs/debugfs_simple_attr.cocci     | 68 -------------------
 1 file changed, 68 deletions(-)
 delete mode 100644 scripts/coccinelle/api/debugfs/debugfs_simple_attr.cocci
scripts/coccinelle/api/debugfs/debugfs_simple_attr.cocci deleted +0 -68
deleted file mode 100644
index 7c312310547c..000000000000
@@ -1,68 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/// Use DEFINE_DEBUGFS_ATTRIBUTE rather than DEFINE_SIMPLE_ATTRIBUTE
-/// for debugfs files.
-///
-//# Rationale: DEFINE_SIMPLE_ATTRIBUTE + debugfs_create_file()
-//# imposes some significant overhead as compared to
-//# DEFINE_DEBUGFS_ATTRIBUTE + debugfs_create_file_unsafe().
-//
-// Copyright (C): 2016 Nicolai Stange
-// Options: --no-includes
-//
-
-virtual context
-virtual patch
-virtual org
-virtual report
-
-@dsa@
-declarer name DEFINE_SIMPLE_ATTRIBUTE;
-identifier dsa_fops;
-expression dsa_get, dsa_set, dsa_fmt;
-position p;
-@@
-DEFINE_SIMPLE_ATTRIBUTE@p(dsa_fops, dsa_get, dsa_set, dsa_fmt);
-
-@dcf@
-expression name, mode, parent, data;
-identifier dsa.dsa_fops;
-@@
-debugfs_create_file(name, mode, parent, data, &dsa_fops)
-
-
-@context_dsa depends on context && dcf@
-declarer name DEFINE_DEBUGFS_ATTRIBUTE;
-identifier dsa.dsa_fops;
-expression dsa.dsa_get, dsa.dsa_set, dsa.dsa_fmt;
-@@
-* DEFINE_SIMPLE_ATTRIBUTE(dsa_fops, dsa_get, dsa_set, dsa_fmt);
-
-
-@patch_dcf depends on patch expression@
-expression name, mode, parent, data;
-identifier dsa.dsa_fops;
-@@
-- debugfs_create_file(name, mode, parent, data, &dsa_fops)
-+ debugfs_create_file_unsafe(name, mode, parent, data, &dsa_fops)
-
-@patch_dsa depends on patch_dcf && patch@
-identifier dsa.dsa_fops;
-expression dsa.dsa_get, dsa.dsa_set, dsa.dsa_fmt;
-@@
-- DEFINE_SIMPLE_ATTRIBUTE(dsa_fops, dsa_get, dsa_set, dsa_fmt);
-+ DEFINE_DEBUGFS_ATTRIBUTE(dsa_fops, dsa_get, dsa_set, dsa_fmt);
-
-
-@script:python depends on org && dcf@
-fops << dsa.dsa_fops;
-p << dsa.p;
-@@
-msg="%s should be defined with DEFINE_DEBUGFS_ATTRIBUTE" % (fops)
-coccilib.org.print_todo(p[0], msg)
-
-@script:python depends on report && dcf@
-fops << dsa.dsa_fops;
-p << dsa.p;
-@@
-msg="WARNING: %s should be defined with DEFINE_DEBUGFS_ATTRIBUTE" % (fops)
-coccilib.report.print_report(p[0], msg)

base-commit: 06c2afb862f9da8dc5efa4b6076a0e48c3fbaaa5

Signature · 1 line
2.41.0.255.g8b1d071c50-goog
Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines · Sean Christopherson

Remove coccinelle's recommendation to use DEFINE_SIMPLE_ATTRIBUTE() instead of DEFINE_SIMPLE_ATTRIBUTE(). Regardless of whether or not the "significant overhead" incurred by debugfs_create_file() is actually meaningful, warnings from the script have led to a rash of low-quality patches that have sowed confusion and consumed maintainer time for little to no benefit. There have been no less than four attempts to "fix" KVM, and a quick search on lore shows that KVM is not alone.

This reverts commit 5103068eaca290f890a30aae70085fac44cecaf6.

Quoted 9 lines
#2 lore raw
In reply to Sean Christopherson
Quoted 2 lines

Remove coccinelle's recommendation to use DEFINE_SIMPLE_ATTRIBUTE() instead of DEFINE_SIMPLE_ATTRIBUTE().

I find this wording inappropriate for a change request
because of an undesirable term duplication.
Would you like to refer to the identifier “DEFINE_DEBUGFS_ATTRIBUTE” here?

Quoted 6 lines

Regardless of whether or not the
"significant overhead" incurred by debugfs_create_file() is actually meaningful, warnings from the script have led to a rash of low-quality patches that have sowed confusion and consumed maintainer time for little to no benefit. There have been no less than four attempts to "fix" KVM, and a quick search on lore shows that KVM is not alone.

Will such information trigger any further clarification?

Regards,
Markus

#3 lore raw
Quoted 6 lines · Markus Elfring
Quoted 2 lines

Remove coccinelle's recommendation to use DEFINE_SIMPLE_ATTRIBUTE() instead of DEFINE_SIMPLE_ATTRIBUTE().

I find this wording inappropriate for a change request
because of an undesirable term duplication.
Would you like to refer to the identifier “DEFINE_DEBUGFS_ATTRIBUTE” here?

Doh, copy+paste fail on my part.

Quoted 8 lines
Quoted 6 lines

Regardless of whether or not the
"significant overhead" incurred by debugfs_create_file() is actually meaningful, warnings from the script have led to a rash of low-quality patches that have sowed confusion and consumed maintainer time for little to no benefit. There have been no less than four attempts to "fix" KVM, and a quick search on lore shows that KVM is not alone.

Will such information trigger any further clarification?

I don't quite follow the question. What information, and what clarification?

#4 lore raw
Quoted 10 lines
Quoted 8 lines
Quoted 6 lines

Regardless of whether or not the
"significant overhead" incurred by debugfs_create_file() is actually meaningful, warnings from the script have led to a rash of low-quality patches that have sowed confusion and consumed maintainer time for little to no benefit. There have been no less than four attempts to "fix" KVM, and a quick search on lore shows that KVM is not alone.

Will such information trigger any further clarification?

I don't quite follow the question. What information, and what clarification?

I imagine that additional experiences can be shared and discussed for a contribution by Nicolai Stange from 2016-03-22.

debugfs, coccinelle: check for obsolete DEFINE_SIMPLE_ATTRIBUTE() usage
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/scripts/coccinelle/api/debugfs/debugfs_simple_attr.cocci?id=5103068eaca290f890a30aae70085fac44cecaf6
https://lore.kernel.org/cocci/[email protected]/
https://lkml.org/lkml/2016/3/22/412

Regards,
Markus