Skip to content

Commit f2f4963

Browse files
committed
eventfs: Remove "is_freed" union with rcu head
The eventfs_inode->is_freed was a union with the rcu_head with the assumption that when it was on the srcu list the head would contain a pointer which would make "is_freed" true. But that was a wrong assumption as the rcu head is a single link list where the last element is NULL. Instead, split the nr_entries integer so that "is_freed" is one bit and the nr_entries is the next 31 bits. As there shouldn't be more than 10 (currently there's at most 5 to 7 depending on the config), this should not be a problem. Link: https://lkml.kernel.org/r/20231101172649.049758712@goodmis.org Cc: stable@vger.kernel.org Cc: Mark Rutland <mark.rutland@arm.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Ajay Kaher <akaher@vmware.com> Fixes: 6394044 ("eventfs: Implement eventfs lookup, read, open functions") Reviewed-by: Masami Hiramatsu (Google) <mhiramat@kernel.org> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
1 parent 9037caa commit f2f4963

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

fs/tracefs/event_inode.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -824,6 +824,8 @@ static void eventfs_remove_rec(struct eventfs_inode *ei, struct list_head *head,
824824
eventfs_remove_rec(ei_child, head, level + 1);
825825
}
826826

827+
ei->is_freed = 1;
828+
827829
list_del_rcu(&ei->list);
828830
list_add_tail(&ei->del_list, head);
829831
}

fs/tracefs/internal.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ struct tracefs_inode {
2323
* @d_parent: pointer to the parent's dentry
2424
* @d_children: The array of dentries to represent the files when created
2525
* @data: The private data to pass to the callbacks
26+
* @is_freed: Flag set if the eventfs is on its way to be freed
2627
* @nr_entries: The number of items in @entries
2728
*/
2829
struct eventfs_inode {
@@ -38,14 +39,13 @@ struct eventfs_inode {
3839
* Union - used for deletion
3940
* @del_list: list of eventfs_inode to delete
4041
* @rcu: eventfs_inode to delete in RCU
41-
* @is_freed: node is freed if one of the above is set
4242
*/
4343
union {
4444
struct list_head del_list;
4545
struct rcu_head rcu;
46-
unsigned long is_freed;
4746
};
48-
int nr_entries;
47+
unsigned int is_freed:1;
48+
unsigned int nr_entries:31;
4949
};
5050

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

0 commit comments

Comments
 (0)