powerpc/papr_scm: Fix warning triggered by perf_stats_show()
Subsystems (2)
PATCH v2 1/1 powerpc/papr_scm: Fix warning triggered by perf_stats_show()
A warning is reported by the kernel in case perf_stats_show() returns an error code. The warning is of the form below:
papr_scm ibm,persistent-memory:ibm,pmemory@44100001:
Failed to query performance stats, Err:-10
dev_attr_show: perf_stats_show+0x0/0x1c0 [papr_scm] returned bad count
fill_read_buffer: dev_attr_show+0x0/0xb0 returned bad count
On investigation it looks like that the compiler is silently truncating the return value of drc_pmem_query_stats() from 'long' to 'int', since the variable used to store the return code 'rc' is an 'int'. This truncated value is then returned back as a 'ssize_t' back from perf_stats_show() to 'dev_attr_show()' which thinks of it as a large unsigned number and triggers this warning..
To fix this we update the type of variable 'rc' from 'int' to 'ssize_t' that prevents the compiler from truncating the return value of drc_pmem_query_stats() and returning correct signed value back from perf_stats_show().
stats from PHYP')
---
Changelog:
v2: Added an explicit cast to the expression calling 'seq_buf_used()'
and triggering this issue. [ Ira ]
--- arch/powerpc/platforms/pseries/papr_scm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
arch/powerpc/platforms/pseries/papr_scm.c +3 -2
@@ -785,7 +785,8 @@ static int papr_scm_ndctl(struct nvdimm_bus_descriptor *nd_desc,static ssize_t perf_stats_show (struct device *dev,struct device_attribute *attr,char *buf) { -int index, rc; +int index; +ssize_t rc;struct seq_buf s;struct papr_scm_perf_stat *stat;struct papr_scm_perf_stats *stats;
@@ -820,7 +821,7 @@ static ssize_t perf_stats_show(struct device *dev, free_stats:kfree (stats); -return rc ? rc :seq_buf_used (&s); +return rc ? rc : (ssize_t )seq_buf_used (&s); }DEVICE_ATTR_ADMIN_RO (perf_stats);
Signature · 4 lines
2.26.2 _______________________________________________ Linux-nvdimm mailing list -- [email protected] To unsubscribe send an email to [email protected]
Quoted 15 lines · Vaibhav Jain
A warning is reported by the kernel in case
perf_stats_show()returns an error code. The warning is of the form below:
papr_scmibm,persistent-memory:ibm,pmemory@44100001:
Failed to query performance stats, Err:-10
dev_attr_show:perf_stats_show+0x0/0x1c0[papr_scm] returned bad count
fill_read_buffer:dev_attr_show+0x0/0xb0returned bad countOn investigation it looks like that the compiler is silently truncating the return value of
drc_pmem_query_stats()from 'long' to 'int', since the variable used to store the return code 'rc' is an 'int'. This truncated value is then returned back as a 'ssize_t' back fromperf_stats_show()to 'dev_attr_show()' which thinks of it as a large unsigned number and triggers this warning..
Quoted 8 lines
To fix this we update the type of variable 'rc' from 'int' to '
ssize_t' that prevents the compiler from truncating the return value ofdrc_pmem_query_stats()and returning correct signed value back fromperf_stats_show().Fixes 2d02bf835e573 ('powerpc/papr_scm: Fetch nvdimm performancestats from PHYP')
Signed-off-by Vaibhav Jain <[email protected]>
Quoted 35 lines
---
Changelog:v2: Added an explicit cast to the expression calling '
seq_buf_used()'
and triggering this issue. [ Ira ]--- arch/powerpc/platforms/pseries/papr_scm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)arch/powerpc/platforms/pseries/papr_scm.c +3
-2@@ -785,7 +785,8 @@ static int papr_scm_ndctl(struct nvdimm_bus_descriptor *nd_desc,static ssize_t perf_stats_show (struct device *dev,struct device_attribute *attr,char *buf) { -int index, rc; +int index; +ssize_t rc;struct seq_buf s;struct papr_scm_perf_stat *stat;struct papr_scm_perf_stats *stats;@@ -820,7 +821,7 @@ static ssize_t perf_stats_show(struct device *dev, free_stats:kfree (stats); -return rc ? rc :seq_buf_used (&s); +return rc ? rc : (ssize_t )seq_buf_used (&s); }DEVICE_ATTR_ADMIN_RO (perf_stats);Signature · 1 line
2.26.2
_______________________________________________
Linux-nvdimm mailing list -- [email protected] To unsubscribe send an email to [email protected]
Michael Ellerman
reviewerQuoted 15 lines · Vaibhav Jain
A warning is reported by the kernel in case
perf_stats_show()returns an error code. The warning is of the form below:
papr_scmibm,persistent-memory:ibm,pmemory@44100001:
Failed to query performance stats, Err:-10
dev_attr_show:perf_stats_show+0x0/0x1c0[papr_scm] returned bad count
fill_read_buffer:dev_attr_show+0x0/0xb0returned bad countOn investigation it looks like that the compiler is silently truncating the return value of
drc_pmem_query_stats()from 'long' to 'int', since the variable used to store the return code 'rc' is an 'int'. This truncated value is then returned back as a 'ssize_t' back fromperf_stats_show()to 'dev_attr_show()' which thinks of it as a large unsigned number and triggers this warning..
Quoted 7 lines
To fix this we update the type of variable 'rc' from 'int' to '
ssize_t' that prevents the compiler from truncating the return value ofdrc_pmem_query_stats()and returning correct signed value back fromperf_stats_show().Fixes 2d02bf835e573 ('powerpc/papr_scm: Fetch nvdimm performancestats from PHYP')
Please don't word wrap the Fixes tag it breaks b4.
I've fixed it up this time.
cheers
_______________________________________________
Linux-nvdimm mailing list -- [email protected] To unsubscribe send an email to [email protected]
Quoted 21 lines · Michael Ellerman
Quoted 20 lines · Vaibhav Jain
A warning is reported by the kernel in case
perf_stats_show()returns an error code. The warning is of the form below:
papr_scmibm,persistent-memory:ibm,pmemory@44100001:
Failed to query performance stats, Err:-10
dev_attr_show:perf_stats_show+0x0/0x1c0[papr_scm] returned bad count
fill_read_buffer:dev_attr_show+0x0/0xb0returned bad countOn investigation it looks like that the compiler is silently truncating the return value of
drc_pmem_query_stats()from 'long' to 'int', since the variable used to store the return code 'rc' is an 'int'. This truncated value is then returned back as a 'ssize_t' back fromperf_stats_show()to 'dev_attr_show()' which thinks of it as a large unsigned number and triggers this warning..To fix this we update the type of variable 'rc' from 'int' to '
ssize_t' that prevents the compiler from truncating the return value ofdrc_pmem_query_stats()and returning correct signed value back fromperf_stats_show().
Quoted 6 lines
Quoted 2 lines
Fixes 2d02bf835e573 ('powerpc/papr_scm: Fetch nvdimm performancestats from PHYP')
Please don't word wrap the Fixes tag it breaks b4.
I've fixed it up this time.
Thanks Mpe
Quoted 2 lines
cheers
Signature · 5 lines
Cheers ~ Vaibhav _______________________________________________ Linux-nvdimm mailing list -- [email protected] To unsubscribe send an email to [email protected]
Michael Ellerman
AppliedQuoted 9 lines · Vaibhav Jain
A warning is reported by the kernel in case
perf_stats_show()returns an error code. The warning is of the form below:
papr_scmibm,persistent-memory:ibm,pmemory@44100001:
Failed to query performance stats, Err:-10
dev_attr_show:perf_stats_show+0x0/0x1c0[papr_scm] returned bad count
fill_read_buffer:dev_attr_show+0x0/0xb0returned bad count[...]
Applied to powerpc/next.
[1/1] powerpc/papr_scm: Fix warning triggered by perf_stats_show()
https://git.kernel.org/powerpc/c/ca78ef2f08ccfa29b711d644964cdf9d7ace15e5
cheers
_______________________________________________
Linux-nvdimm mailing list -- [email protected] To unsubscribe send an email to [email protected]