* [PATCH] arc:kernel:perf_event.c : replaced sprintf with sysfs_emit()
@ 2025-07-05 7:30 Rujra Bhatt
2025-07-18 10:27 ` Rujra Bhatt
0 siblings, 1 reply; 4+ messages in thread
From: Rujra Bhatt @ 2025-07-05 7:30 UTC (permalink / raw)
To: peterz, mingo, acme, namhyung, mark.rutland, alexander.shishkin,
jolsa, irogers, adrian.hunter, kan.liang, vgupta
Cc: linux-perf-users, linux-kernel, linux-snps-arc, skhan
Replaced sprintf() with sysfs_emit() in sysfs*_show() function in
perf_event.c file to follow the kernel's guidlines from
documentation/filesystems/sysfs.rst
This will improve consistency, safety, and makes it easier to maintain
and update in future.
Signed-off-by: Rujra Bhatt <braker.noob.kernel@gmail.com>
---
arch/arc/kernel/perf_event.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arc/kernel/perf_event.c b/arch/arc/kernel/perf_event.c
index ed6d4f0cd621..424ec072c441 100644
--- a/arch/arc/kernel/perf_event.c
+++ b/arch/arc/kernel/perf_event.c
@@ -648,7 +648,7 @@ static ssize_t arc_pmu_events_sysfs_show(struct device *dev,
struct perf_pmu_events_attr *pmu_attr;
pmu_attr = container_of(attr, struct perf_pmu_events_attr, attr);
- return sprintf(page, "event=0x%04llx\n", pmu_attr->id);
+ return sysfs_emit(page, "event=0x%04llx\n", pmu_attr->id);
}
/*
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] arc:kernel:perf_event.c : replaced sprintf with sysfs_emit()
2025-07-05 7:30 [PATCH] arc:kernel:perf_event.c : replaced sprintf with sysfs_emit() Rujra Bhatt
@ 2025-07-18 10:27 ` Rujra Bhatt
2025-07-18 11:47 ` Greg KH
0 siblings, 1 reply; 4+ messages in thread
From: Rujra Bhatt @ 2025-07-18 10:27 UTC (permalink / raw)
To: peterz, mingo, acme, namhyung, mark.rutland, alexander.shishkin,
jolsa, irogers, adrian.hunter, kan.liang, vgupta
Cc: linux-perf-users, linux-kernel, linux-snps-arc, skhan,
linux-kernel-mentees
Hi,
On Sat, Jul 5, 2025 at 1:00 PM Rujra Bhatt <braker.noob.kernel@gmail.com> wrote:
>
> Replaced sprintf() with sysfs_emit() in sysfs*_show() function in
> perf_event.c file to follow the kernel's guidelines from
> documentation/filesystems/sysfs.rst
> This will improve consistency, safety, and makes it easier to maintain
> and update in future.
>
> Signed-off-by: Rujra Bhatt <braker.noob.kernel@gmail.com>
> ---
> arch/arc/kernel/perf_event.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/arc/kernel/perf_event.c b/arch/arc/kernel/perf_event.c
> index ed6d4f0cd621..424ec072c441 100644
> --- a/arch/arc/kernel/perf_event.c
> +++ b/arch/arc/kernel/perf_event.c
> @@ -648,7 +648,7 @@ static ssize_t arc_pmu_events_sysfs_show(struct device *dev,
> struct perf_pmu_events_attr *pmu_attr;
>
> pmu_attr = container_of(attr, struct perf_pmu_events_attr, attr);
> - return sprintf(page, "event=0x%04llx\n", pmu_attr->id);
> + return sysfs_emit(page, "event=0x%04llx\n", pmu_attr->id);
> }
>
> /*
> --
> 2.43.0
>
Gentle reminder for the replacement of sprintf() with the sysfs_emit(), kindly
review it.
Thanking you,
regards,
Rujra Bhatt
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] arc:kernel:perf_event.c : replaced sprintf with sysfs_emit()
2025-07-18 10:27 ` Rujra Bhatt
@ 2025-07-18 11:47 ` Greg KH
2025-07-22 3:52 ` Rujra Bhatt
0 siblings, 1 reply; 4+ messages in thread
From: Greg KH @ 2025-07-18 11:47 UTC (permalink / raw)
To: Rujra Bhatt
Cc: peterz, mingo, acme, namhyung, mark.rutland, alexander.shishkin,
jolsa, irogers, adrian.hunter, kan.liang, vgupta,
linux-perf-users, linux-kernel, linux-snps-arc, skhan,
linux-kernel-mentees
On Fri, Jul 18, 2025 at 03:57:20PM +0530, Rujra Bhatt wrote:
> Hi,
>
> On Sat, Jul 5, 2025 at 1:00 PM Rujra Bhatt <braker.noob.kernel@gmail.com> wrote:
> >
> > Replaced sprintf() with sysfs_emit() in sysfs*_show() function in
> > perf_event.c file to follow the kernel's guidelines from
> > documentation/filesystems/sysfs.rst
> > This will improve consistency, safety, and makes it easier to maintain
> > and update in future.
> >
> > Signed-off-by: Rujra Bhatt <braker.noob.kernel@gmail.com>
> > ---
> > arch/arc/kernel/perf_event.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/arch/arc/kernel/perf_event.c b/arch/arc/kernel/perf_event.c
> > index ed6d4f0cd621..424ec072c441 100644
> > --- a/arch/arc/kernel/perf_event.c
> > +++ b/arch/arc/kernel/perf_event.c
> > @@ -648,7 +648,7 @@ static ssize_t arc_pmu_events_sysfs_show(struct device *dev,
> > struct perf_pmu_events_attr *pmu_attr;
> >
> > pmu_attr = container_of(attr, struct perf_pmu_events_attr, attr);
> > - return sprintf(page, "event=0x%04llx\n", pmu_attr->id);
> > + return sysfs_emit(page, "event=0x%04llx\n", pmu_attr->id);
> > }
> >
> > /*
> > --
> > 2.43.0
> >
>
> Gentle reminder for the replacement of sprintf() with the sysfs_emit(), kindly
> review it.
Why is this required? There is no bug in the current code, so no need
to change it at all. Please just use sysfs_emit() for new sysfs files,
no need to churn the tree and change all existing entries, otherwise we
would have done this a long time ago when we introduced these functions.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] arc:kernel:perf_event.c : replaced sprintf with sysfs_emit()
2025-07-18 11:47 ` Greg KH
@ 2025-07-22 3:52 ` Rujra Bhatt
0 siblings, 0 replies; 4+ messages in thread
From: Rujra Bhatt @ 2025-07-22 3:52 UTC (permalink / raw)
To: Greg KH
Cc: peterz, mingo, acme, namhyung, mark.rutland, alexander.shishkin,
jolsa, irogers, adrian.hunter, kan.liang, vgupta,
linux-perf-users, linux-kernel, linux-snps-arc, skhan,
linux-kernel-mentees
On Fri, Jul 18, 2025 at 5:18 PM Greg KH <greg@kroah.com> wrote:
>
> On Fri, Jul 18, 2025 at 03:57:20PM +0530, Rujra Bhatt wrote:
> > Hi,
> >
> > On Sat, Jul 5, 2025 at 1:00 PM Rujra Bhatt <braker.noob.kernel@gmail.com> wrote:
> > >
> > > Replaced sprintf() with sysfs_emit() in sysfs*_show() function in
> > > perf_event.c file to follow the kernel's guidelines from
> > > documentation/filesystems/sysfs.rst
> > > This will improve consistency, safety, and makes it easier to maintain
> > > and update in future.
> > >
> > > Signed-off-by: Rujra Bhatt <braker.noob.kernel@gmail.com>
> > > ---
> > > arch/arc/kernel/perf_event.c | 2 +-
> > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/arch/arc/kernel/perf_event.c b/arch/arc/kernel/perf_event.c
> > > index ed6d4f0cd621..424ec072c441 100644
> > > --- a/arch/arc/kernel/perf_event.c
> > > +++ b/arch/arc/kernel/perf_event.c
> > > @@ -648,7 +648,7 @@ static ssize_t arc_pmu_events_sysfs_show(struct device *dev,
> > > struct perf_pmu_events_attr *pmu_attr;
> > >
> > > pmu_attr = container_of(attr, struct perf_pmu_events_attr, attr);
> > > - return sprintf(page, "event=0x%04llx\n", pmu_attr->id);
> > > + return sysfs_emit(page, "event=0x%04llx\n", pmu_attr->id);
> > > }
> > >
> > > /*
> > > --
> > > 2.43.0
> > >
> >
> > Gentle reminder for the replacement of sprintf() with the sysfs_emit(), kindly
> > review it.
>
> Why is this required? There is no bug in the current code, so no need
> to change it at all. Please just use sysfs_emit() for new sysfs files,
> no need to churn the tree and change all existing entries, otherwise we
> would have done this a long time ago when we introduced these functions.
>
Hi Greg,
I appreciate your feedback.
I wanted to bring the formatting in line with the
latest guidance, especially since sysfs_emit() has become the recommended
method for sysfs output. I see now, though, that I should restrict myself to
using that helper only in the context of genuine bug fixes or in the course
of adding features.
I'll make sure to only use sysfs_emit() for new sysfs entries or when
modifying existing files for actual bugs or feature changes,
as per your guidance.
Thank you so much for pointing this out.
regards,
Rujra Bhatt
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-07-22 3:53 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-05 7:30 [PATCH] arc:kernel:perf_event.c : replaced sprintf with sysfs_emit() Rujra Bhatt
2025-07-18 10:27 ` Rujra Bhatt
2025-07-18 11:47 ` Greg KH
2025-07-22 3:52 ` Rujra Bhatt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).