Skip to content

Commit ca78ef2

Browse files
vaibhav92mpe
authored andcommitted
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(). Fixes: 2d02bf8 ("powerpc/papr_scm: Fetch nvdimm performance stats from PHYP") Signed-off-by: Vaibhav Jain <vaibhav@linux.ibm.com> Reviewed-by: Ira Weiny <ira.weiny@intel.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/20200912081451.66225-1-vaibhav@linux.ibm.com
1 parent 8f7e57e commit ca78ef2

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

‎arch/powerpc/platforms/pseries/papr_scm.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,8 @@ static int papr_scm_ndctl(struct nvdimm_bus_descriptor *nd_desc,
785785
static ssize_t perf_stats_show(struct device *dev,
786786
struct device_attribute *attr, char *buf)
787787
{
788-
int index, rc;
788+
int index;
789+
ssize_t rc;
789790
struct seq_buf s;
790791
struct papr_scm_perf_stat *stat;
791792
struct papr_scm_perf_stats *stats;
@@ -820,7 +821,7 @@ static ssize_t perf_stats_show(struct device *dev,
820821

821822
free_stats:
822823
kfree(stats);
823-
return rc ? rc : seq_buf_used(&s);
824+
return rc ? rc : (ssize_t)seq_buf_used(&s);
824825
}
825826
DEVICE_ATTR_ADMIN_RO(perf_stats);
826827

0 commit comments

Comments
 (0)