Skip to content

Commit 615d300

Browse files
committed
Merge tag 'trace-v6.8-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace
Pull tracing and eventfs fixes from Steven Rostedt: - Fix histogram tracing_map insertion. The tracing_map_insert copies the value into the elt variable and then assigns the elt to the entry value. But it is possible that the entry value becomes visible on other CPUs before the elt is fully initialized. This is fixed by adding a wmb() between the initialization of the elt variable and assigning it. - Have eventfs directory have unique inode numbers. Having them be all the same proved to be a failure as the 'find' application will think that the directories are causing loops, as it checks for directory loops via their inodes. Have the evenfs dir entries get their inodes assigned when they are referenced and then save them in the eventfs_inode structure. * tag 'trace-v6.8-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace: eventfs: Save directory inodes in the eventfs_inode structure tracing: Ensure visibility when inserting an element into tracing_map
2 parents 7ed2632 + 834bf76 commit 615d300

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
lines changed

fs/tracefs/event_inode.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,15 @@ static DEFINE_MUTEX(eventfs_mutex);
3434

3535
/* Choose something "unique" ;-) */
3636
#define EVENTFS_FILE_INODE_INO 0x12c4e37
37-
#define EVENTFS_DIR_INODE_INO 0x134b2f5
37+
38+
/* Just try to make something consistent and unique */
39+
static int eventfs_dir_ino(struct eventfs_inode *ei)
40+
{
41+
if (!ei->ino)
42+
ei->ino = get_next_ino();
43+
44+
return ei->ino;
45+
}
3846

3947
/*
4048
* The eventfs_inode (ei) itself is protected by SRCU. It is released from
@@ -396,7 +404,7 @@ static struct dentry *create_dir(struct eventfs_inode *ei, struct dentry *parent
396404
inode->i_fop = &eventfs_file_operations;
397405

398406
/* All directories will have the same inode number */
399-
inode->i_ino = EVENTFS_DIR_INODE_INO;
407+
inode->i_ino = eventfs_dir_ino(ei);
400408

401409
ti = get_tracefs(inode);
402410
ti->flags |= TRACEFS_EVENT_INODE;
@@ -802,7 +810,7 @@ static int eventfs_iterate(struct file *file, struct dir_context *ctx)
802810

803811
name = ei_child->name;
804812

805-
ino = EVENTFS_DIR_INODE_INO;
813+
ino = eventfs_dir_ino(ei_child);
806814

807815
if (!dir_emit(ctx, name, strlen(name), ino, DT_DIR))
808816
goto out_dec;

fs/tracefs/internal.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ struct eventfs_inode {
5555
struct eventfs_attr *entry_attrs;
5656
struct eventfs_attr attr;
5757
void *data;
58+
unsigned int is_freed:1;
59+
unsigned int is_events:1;
60+
unsigned int nr_entries:30;
61+
unsigned int ino;
5862
/*
5963
* Union - used for deletion
6064
* @llist: for calling dput() if needed after RCU
@@ -64,9 +68,6 @@ struct eventfs_inode {
6468
struct llist_node llist;
6569
struct rcu_head rcu;
6670
};
67-
unsigned int is_freed:1;
68-
unsigned int is_events:1;
69-
unsigned int nr_entries:30;
7071
};
7172

7273
static inline struct tracefs_inode *get_tracefs(const struct inode *inode)

kernel/trace/tracing_map.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,12 @@ __tracing_map_insert(struct tracing_map *map, void *key, bool lookup_only)
574574
}
575575

576576
memcpy(elt->key, key, map->key_size);
577-
entry->val = elt;
577+
/*
578+
* Ensure the initialization is visible and
579+
* publish the elt.
580+
*/
581+
smp_wmb();
582+
WRITE_ONCE(entry->val, elt);
578583
atomic64_inc(&map->hits);
579584

580585
return entry->val;

0 commit comments

Comments
 (0)