[PATCH 4/4] EDAC/mc_sysfs: Begin deprecating legacy sysfs EDAC interface

Avadhut Naik posted 4 patches 2 months ago
[PATCH 4/4] EDAC/mc_sysfs: Begin deprecating legacy sysfs EDAC interface
Posted by Avadhut Naik 2 months ago
The legacy sysfs EDAC interface has been made obsolete more than a decade
ago through the introduction of a new per-DIMM interface.

The legacy interface however, hasn't been removed till date.

Begin deprecating it so that it can eventually be removed by v6.21.

Signed-off-by: Avadhut Naik <avadhut.naik@amd.com>
---
 drivers/edac/Kconfig         |  2 +-
 drivers/edac/edac_mc.h       |  5 +++++
 drivers/edac/edac_mc_sysfs.c | 16 ++++++++++++++++
 3 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/drivers/edac/Kconfig b/drivers/edac/Kconfig
index 39352b9b7a7e..fdfeba848114 100644
--- a/drivers/edac/Kconfig
+++ b/drivers/edac/Kconfig
@@ -25,7 +25,7 @@ if EDAC
 
 config EDAC_LEGACY_SYSFS
 	bool "EDAC legacy sysfs"
-	default y
+	default n
 	help
 	  Enable the compatibility sysfs nodes.
 	  Use 'Y' if your edac utilities aren't ported to work with the newer
diff --git a/drivers/edac/edac_mc.h b/drivers/edac/edac_mc.h
index 881b00eadf7a..78b49d6906fd 100644
--- a/drivers/edac/edac_mc.h
+++ b/drivers/edac/edac_mc.h
@@ -95,6 +95,11 @@ do {									\
 
 #define to_mci(k) container_of(k, struct mem_ctl_info, dev)
 
+static inline void deprecate_interface(void)
+{
+	pr_warn_once("NOTICE: The legacy EDAC sysfs interface has been deprecated and will be removed by v6.21. Please switch to the new interface!\n");
+}
+
 /**
  * edac_mc_alloc() - Allocate and partially fill a struct &mem_ctl_info.
  *
diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
index 8689631f1905..8ed4b239b7f1 100644
--- a/drivers/edac/edac_mc_sysfs.c
+++ b/drivers/edac/edac_mc_sysfs.c
@@ -144,6 +144,8 @@ struct dev_ch_attribute {
 static ssize_t csrow_ue_count_show(struct device *dev,
 				   struct device_attribute *mattr, char *data)
 {
+	deprecate_interface();
+
 	struct csrow_info *csrow = to_csrow(dev);
 
 	return sysfs_emit(data, "%u\n", csrow->ue_count);
@@ -152,6 +154,8 @@ static ssize_t csrow_ue_count_show(struct device *dev,
 static ssize_t csrow_ce_count_show(struct device *dev,
 				   struct device_attribute *mattr, char *data)
 {
+	deprecate_interface();
+
 	struct csrow_info *csrow = to_csrow(dev);
 
 	return sysfs_emit(data, "%u\n", csrow->ce_count);
@@ -160,6 +164,8 @@ static ssize_t csrow_ce_count_show(struct device *dev,
 static ssize_t csrow_size_show(struct device *dev,
 			       struct device_attribute *mattr, char *data)
 {
+	deprecate_interface();
+
 	struct csrow_info *csrow = to_csrow(dev);
 	int i;
 	u32 nr_pages = 0;
@@ -172,6 +178,8 @@ static ssize_t csrow_size_show(struct device *dev,
 static ssize_t csrow_mem_type_show(struct device *dev,
 				   struct device_attribute *mattr, char *data)
 {
+	deprecate_interface();
+
 	struct csrow_info *csrow = to_csrow(dev);
 
 	return sysfs_emit(data, "%s\n", edac_mem_types[csrow->channels[0]->dimm->mtype]);
@@ -180,6 +188,8 @@ static ssize_t csrow_mem_type_show(struct device *dev,
 static ssize_t csrow_dev_type_show(struct device *dev,
 				   struct device_attribute *mattr, char *data)
 {
+	deprecate_interface();
+
 	struct csrow_info *csrow = to_csrow(dev);
 
 	return sysfs_emit(data, "%s\n", dev_types[csrow->channels[0]->dimm->dtype]);
@@ -189,6 +199,8 @@ static ssize_t csrow_edac_mode_show(struct device *dev,
 				    struct device_attribute *mattr,
 				    char *data)
 {
+	deprecate_interface();
+
 	struct csrow_info *csrow = to_csrow(dev);
 
 	return sysfs_emit(data, "%s\n", edac_caps[csrow->channels[0]->dimm->edac_mode]);
@@ -199,6 +211,8 @@ static ssize_t channel_dimm_label_show(struct device *dev,
 				       struct device_attribute *mattr,
 				       char *data)
 {
+	deprecate_interface();
+
 	struct csrow_info *csrow = to_csrow(dev);
 	unsigned int chan = to_channel(mattr);
 	struct rank_info *rank = csrow->channels[chan];
@@ -238,6 +252,8 @@ static ssize_t channel_dimm_label_store(struct device *dev,
 static ssize_t channel_ce_count_show(struct device *dev,
 				     struct device_attribute *mattr, char *data)
 {
+	deprecate_interface();
+
 	struct csrow_info *csrow = to_csrow(dev);
 	unsigned int chan = to_channel(mattr);
 	struct rank_info *rank = csrow->channels[chan];
-- 
2.43.0
Re: [PATCH 4/4] EDAC/mc_sysfs: Begin deprecating legacy sysfs EDAC interface
Posted by Borislav Petkov 1 month, 2 weeks ago
+ Greg to tell us whether that would be a proper deprecation strategy.

On Mon, Oct 13, 2025 at 05:30:43PM +0000, Avadhut Naik wrote:
> The legacy sysfs EDAC interface has been made obsolete more than a decade
> ago through the introduction of a new per-DIMM interface.
> 
> The legacy interface however, hasn't been removed till date.
> 
> Begin deprecating it so that it can eventually be removed by v6.21.
> 
> Signed-off-by: Avadhut Naik <avadhut.naik@amd.com>
> ---
>  drivers/edac/Kconfig         |  2 +-
>  drivers/edac/edac_mc.h       |  5 +++++
>  drivers/edac/edac_mc_sysfs.c | 16 ++++++++++++++++
>  3 files changed, 22 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/edac/Kconfig b/drivers/edac/Kconfig
> index 39352b9b7a7e..fdfeba848114 100644
> --- a/drivers/edac/Kconfig
> +++ b/drivers/edac/Kconfig
> @@ -25,7 +25,7 @@ if EDAC
>  
>  config EDAC_LEGACY_SYSFS
>  	bool "EDAC legacy sysfs"

Add "DEPRECATED: EDAC ..."

here.

> -	default y
> +	default n
>  	help
>  	  Enable the compatibility sysfs nodes.
>  	  Use 'Y' if your edac utilities aren't ported to work with the newer
> diff --git a/drivers/edac/edac_mc.h b/drivers/edac/edac_mc.h
> index 881b00eadf7a..78b49d6906fd 100644
> --- a/drivers/edac/edac_mc.h
> +++ b/drivers/edac/edac_mc.h
> @@ -95,6 +95,11 @@ do {									\
>  
>  #define to_mci(k) container_of(k, struct mem_ctl_info, dev)
>  
> +static inline void deprecate_interface(void)
> +{
> +	pr_warn_once("NOTICE: The legacy EDAC sysfs interface has been deprecated and will be removed by v6.21. Please switch to the new interface!\n");
> +}

You don't need to have a function which you replicate everywhere. Simply dump
this notice once...

edac_create_sysfs_mci_device:

	...

#ifdef CONFIG_EDAC_LEGACY_SYSFS

<--- here.

        err = edac_create_csrow_objects(mci);
        if (err < 0)
                goto fail;
#endif

So that it gets issued and hopefully someone sees it.

Then, I'd say around 6.19 we should make those functions return an error
unconditionally and then zap them in 6.21.

That is, if no one comes crawling out of the woodwork with a valid use case.

Thx.

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
Re: [PATCH 4/4] EDAC/mc_sysfs: Begin deprecating legacy sysfs EDAC interface
Posted by Greg KH 1 month, 2 weeks ago
On Wed, Oct 29, 2025 at 06:24:19PM +0100, Borislav Petkov wrote:
> + Greg to tell us whether that would be a proper deprecation strategy.
> 
> On Mon, Oct 13, 2025 at 05:30:43PM +0000, Avadhut Naik wrote:
> > The legacy sysfs EDAC interface has been made obsolete more than a decade
> > ago through the introduction of a new per-DIMM interface.
> > 
> > The legacy interface however, hasn't been removed till date.
> > 
> > Begin deprecating it so that it can eventually be removed by v6.21.
> > 
> > Signed-off-by: Avadhut Naik <avadhut.naik@amd.com>
> > ---
> >  drivers/edac/Kconfig         |  2 +-
> >  drivers/edac/edac_mc.h       |  5 +++++
> >  drivers/edac/edac_mc_sysfs.c | 16 ++++++++++++++++
> >  3 files changed, 22 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/edac/Kconfig b/drivers/edac/Kconfig
> > index 39352b9b7a7e..fdfeba848114 100644
> > --- a/drivers/edac/Kconfig
> > +++ b/drivers/edac/Kconfig
> > @@ -25,7 +25,7 @@ if EDAC
> >  
> >  config EDAC_LEGACY_SYSFS
> >  	bool "EDAC legacy sysfs"
> 
> Add "DEPRECATED: EDAC ..."
> 
> here.

Hah, good luck!

> > -	default y
> > +	default n
> >  	help
> >  	  Enable the compatibility sysfs nodes.
> >  	  Use 'Y' if your edac utilities aren't ported to work with the newer
> > diff --git a/drivers/edac/edac_mc.h b/drivers/edac/edac_mc.h
> > index 881b00eadf7a..78b49d6906fd 100644
> > --- a/drivers/edac/edac_mc.h
> > +++ b/drivers/edac/edac_mc.h
> > @@ -95,6 +95,11 @@ do {									\
> >  
> >  #define to_mci(k) container_of(k, struct mem_ctl_info, dev)
> >  
> > +static inline void deprecate_interface(void)
> > +{
> > +	pr_warn_once("NOTICE: The legacy EDAC sysfs interface has been deprecated and will be removed by v6.21. Please switch to the new interface!\n");
> > +}
> 
> You don't need to have a function which you replicate everywhere. Simply dump
> this notice once...
> 
> edac_create_sysfs_mci_device:
> 
> 	...
> 
> #ifdef CONFIG_EDAC_LEGACY_SYSFS
> 
> <--- here.
> 
>         err = edac_create_csrow_objects(mci);
>         if (err < 0)
>                 goto fail;
> #endif
> 
> So that it gets issued and hopefully someone sees it.
> 
> Then, I'd say around 6.19 we should make those functions return an error
> unconditionally and then zap them in 6.21.
> 
> That is, if no one comes crawling out of the woodwork with a valid use case.

No one is going to notice this type of kernel log message.  If you think
that no one is using the sysfs files, delete them now.  Why wait?

sysfs is meant to be such that userspace can handle file removals (i.e.
that value is not present.)  Unfortunately, sometimes this does not
actually happen and user tools do mess up and rely on things.  So either
no one uses the file and it can be removed now, OR you have to leave it
in for "forever".  There's no real chance to remove it later, that's
just postponing the decision.

good luck!

greg k-h
Re: [PATCH 4/4] EDAC/mc_sysfs: Begin deprecating legacy sysfs EDAC interface
Posted by Borislav Petkov 1 month, 2 weeks ago
On Thu, Oct 30, 2025 at 04:01:43PM +0100, Greg KH wrote:
> No one is going to notice this type of kernel log message.  If you think
> that no one is using the sysfs files, delete them now.  Why wait?
> 
> sysfs is meant to be such that userspace can handle file removals (i.e.
> that value is not present.)  Unfortunately, sometimes this does not
> actually happen and user tools do mess up and rely on things.  So either
> no one uses the file and it can be removed now, OR you have to leave it
> in for "forever".  There's no real chance to remove it later, that's
> just postponing the decision.

Lemme try to repeat what you're proposing to make sure we're on the same page:

we simply zap the files and see if anyone complains. If yes, we figure out why
they're using them and if they can't be moved to the new interface, we restore
them and maintain them forever.

Right?

Thx.

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
Re: [PATCH 4/4] EDAC/mc_sysfs: Begin deprecating legacy sysfs EDAC interface
Posted by Greg KH 1 month, 2 weeks ago
On Thu, Oct 30, 2025 at 08:18:58PM +0100, Borislav Petkov wrote:
> On Thu, Oct 30, 2025 at 04:01:43PM +0100, Greg KH wrote:
> > No one is going to notice this type of kernel log message.  If you think
> > that no one is using the sysfs files, delete them now.  Why wait?
> > 
> > sysfs is meant to be such that userspace can handle file removals (i.e.
> > that value is not present.)  Unfortunately, sometimes this does not
> > actually happen and user tools do mess up and rely on things.  So either
> > no one uses the file and it can be removed now, OR you have to leave it
> > in for "forever".  There's no real chance to remove it later, that's
> > just postponing the decision.
> 
> Lemme try to repeat what you're proposing to make sure we're on the same page:
> 
> we simply zap the files and see if anyone complains. If yes, we figure out why
> they're using them and if they can't be moved to the new interface, we restore
> them and maintain them forever.
> 
> Right?

Yup!
Re: [PATCH 4/4] EDAC/mc_sysfs: Begin deprecating legacy sysfs EDAC interface
Posted by Borislav Petkov 1 month, 2 weeks ago
On Fri, Oct 31, 2025 at 01:38:57PM +0100, Greg KH wrote:
> Yup!

Thanks.

@Avadhut: you can send the next revision now. :)

Thx.


-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
[PATCH 4/4] EDAC/mc_sysfs: Begin deprecating legacy sysfs EDAC interface
Posted by Naik, Avadhut 1 month, 2 weeks ago

On 10/31/2025 07:54, Borislav Petkov wrote:
> On Fri, Oct 31, 2025 at 01:38:57PM +0100, Greg KH wrote:
>> Yup!
> 
> Thanks.
> 
> @Avadhut: you can send the next revision now. :)
> 
> Thx.
> 
> 
Will do. Will remove the interface and resubmit this set.
-- 
Thanks,
Avadhut Naik
Re: [PATCH 4/4] EDAC/mc_sysfs: Begin deprecating legacy sysfs EDAC interface
Posted by Naik, Avadhut 1 month, 2 weeks ago

On 10/29/2025 12:24, Borislav Petkov wrote:
> + Greg to tell us whether that would be a proper deprecation strategy.
> 
> On Mon, Oct 13, 2025 at 05:30:43PM +0000, Avadhut Naik wrote:
>> The legacy sysfs EDAC interface has been made obsolete more than a decade
>> ago through the introduction of a new per-DIMM interface.
>>
>> The legacy interface however, hasn't been removed till date.
>>
>> Begin deprecating it so that it can eventually be removed by v6.21.
>>
>> Signed-off-by: Avadhut Naik <avadhut.naik@amd.com>
>> ---
>>  drivers/edac/Kconfig         |  2 +-
>>  drivers/edac/edac_mc.h       |  5 +++++
>>  drivers/edac/edac_mc_sysfs.c | 16 ++++++++++++++++
>>  3 files changed, 22 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/edac/Kconfig b/drivers/edac/Kconfig
>> index 39352b9b7a7e..fdfeba848114 100644
>> --- a/drivers/edac/Kconfig
>> +++ b/drivers/edac/Kconfig
>> @@ -25,7 +25,7 @@ if EDAC
>>  
>>  config EDAC_LEGACY_SYSFS
>>  	bool "EDAC legacy sysfs"
> 
> Add "DEPRECATED: EDAC ..."
> 
> here.
> 
Okay!
>> -	default y
>> +	default n
>>  	help
>>  	  Enable the compatibility sysfs nodes.
>>  	  Use 'Y' if your edac utilities aren't ported to work with the newer
>> diff --git a/drivers/edac/edac_mc.h b/drivers/edac/edac_mc.h
>> index 881b00eadf7a..78b49d6906fd 100644
>> --- a/drivers/edac/edac_mc.h
>> +++ b/drivers/edac/edac_mc.h
>> @@ -95,6 +95,11 @@ do {									\
>>  
>>  #define to_mci(k) container_of(k, struct mem_ctl_info, dev)
>>  
>> +static inline void deprecate_interface(void)
>> +{
>> +	pr_warn_once("NOTICE: The legacy EDAC sysfs interface has been deprecated and will be removed by v6.21. Please switch to the new interface!\n");
>> +}
> 
> You don't need to have a function which you replicate everywhere. Simply dump
> this notice once...
> 
> edac_create_sysfs_mci_device:
> 
> 	...
> 
> #ifdef CONFIG_EDAC_LEGACY_SYSFS
> 
> <--- here.
> 
>         err = edac_create_csrow_objects(mci);
>         if (err < 0)
>                 goto fail;
> #endif
> 
> So that it gets issued and hopefully someone sees it.
> 
> Then, I'd say around 6.19 we should make those functions return an error
> unconditionally and then zap them in 6.21.
> 
> That is, if no one comes crawling out of the woodwork with a valid use case.
> 
> Thx.
> 
Sounds good! Will do!

Just one question:

Wouldn't it be more prudent to have a log of our intentions available when someone
tries to access or read stuff the old interface too?

-- 
Thanks,
Avadhut Naik