diff options
Diffstat (limited to 'fs/eventfd.c')
| -rw-r--r-- | fs/eventfd.c | 9 | 
1 files changed, 9 insertions, 0 deletions
diff --git a/fs/eventfd.c b/fs/eventfd.c index 08d3bd602f73..8aa0ea8c55e8 100644 --- a/fs/eventfd.c +++ b/fs/eventfd.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-only  /*   *  fs/eventfd.c   * @@ -21,6 +22,9 @@  #include <linux/eventfd.h>  #include <linux/proc_fs.h>  #include <linux/seq_file.h> +#include <linux/idr.h> + +static DEFINE_IDA(eventfd_ida);  struct eventfd_ctx {  	struct kref kref; @@ -35,6 +39,7 @@ struct eventfd_ctx {  	 */  	__u64 count;  	unsigned int flags; +	int id;  };  /** @@ -69,6 +74,8 @@ EXPORT_SYMBOL_GPL(eventfd_signal);  static void eventfd_free_ctx(struct eventfd_ctx *ctx)  { +	if (ctx->id >= 0) +		ida_simple_remove(&eventfd_ida, ctx->id);  	kfree(ctx);  } @@ -297,6 +304,7 @@ static void eventfd_show_fdinfo(struct seq_file *m, struct file *f)  	seq_printf(m, "eventfd-count: %16llx\n",  		   (unsigned long long)ctx->count);  	spin_unlock_irq(&ctx->wqh.lock); +	seq_printf(m, "eventfd-id: %d\n", ctx->id);  }  #endif @@ -400,6 +408,7 @@ static int do_eventfd(unsigned int count, int flags)  	init_waitqueue_head(&ctx->wqh);  	ctx->count = count;  	ctx->flags = flags; +	ctx->id = ida_simple_get(&eventfd_ida, 0, 0, GFP_KERNEL);  	fd = anon_inode_getfd("[eventfd]", &eventfd_fops, ctx,  			      O_RDWR | (flags & EFD_SHARED_FCNTL_FLAGS));  |