Skip to content

Commit 005a79e

Browse files
gerald-schaefertorvalds
authored andcommitted
mm/slub: fix endianness bug for alloc/free_traces attributes
On big-endian s390, the alloc/free_traces attributes produce endless output, because of always 0 idx in slab_debugfs_show(). idx is de-referenced from *v, which points to a loff_t value, with unsigned int idx = *(unsigned int *)v; This will only give the upper 32 bits on big-endian, which remain 0. Instead of only fixing this de-reference, during discussion it seemed more appropriate to change the seq_ops so that they use an explicit iterator in private loc_track struct. This patch adds idx to loc_track, which will also fix the endianness bug. Link: https://lore.kernel.org/r/[email protected] Link: https://lkml.kernel.org/r/[email protected] Fixes: 64dd684 ("mm: slub: move sysfs slab alloc/free interfaces to debugfs") Signed-off-by: Gerald Schaefer <[email protected]> Reported-by: Steffen Maier <[email protected]> Acked-by: Vlastimil Babka <[email protected]> Cc: Faiyaz Mohammed <[email protected]> Cc: Greg Kroah-Hartman <[email protected]> Cc: Christoph Lameter <[email protected]> Cc: Pekka Enberg <[email protected]> Cc: David Rientjes <[email protected]> Cc: Joonsoo Kim <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 9ab3b0c commit 005a79e

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

mm/slub.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5081,6 +5081,7 @@ struct loc_track {
50815081
unsigned long max;
50825082
unsigned long count;
50835083
struct location *loc;
5084+
loff_t idx;
50845085
};
50855086

50865087
static struct dentry *slab_debugfs_root;
@@ -6052,11 +6053,11 @@ __initcall(slab_sysfs_init);
60526053
#if defined(CONFIG_SLUB_DEBUG) && defined(CONFIG_DEBUG_FS)
60536054
static int slab_debugfs_show(struct seq_file *seq, void *v)
60546055
{
6055-
6056-
struct location *l;
6057-
unsigned int idx = *(unsigned int *)v;
60586056
struct loc_track *t = seq->private;
6057+
struct location *l;
6058+
unsigned long idx;
60596059

6060+
idx = (unsigned long) t->idx;
60606061
if (idx < t->count) {
60616062
l = &t->loc[idx];
60626063

@@ -6105,16 +6106,18 @@ static void *slab_debugfs_next(struct seq_file *seq, void *v, loff_t *ppos)
61056106
{
61066107
struct loc_track *t = seq->private;
61076108

6108-
v = ppos;
6109-
++*ppos;
6109+
t->idx = ++(*ppos);
61106110
if (*ppos <= t->count)
6111-
return v;
6111+
return ppos;
61126112

61136113
return NULL;
61146114
}
61156115

61166116
static void *slab_debugfs_start(struct seq_file *seq, loff_t *ppos)
61176117
{
6118+
struct loc_track *t = seq->private;
6119+
6120+
t->idx = *ppos;
61186121
return ppos;
61196122
}
61206123

0 commit comments

Comments
 (0)