Re: [RFC PATCH bpf-next 08/16] bpf: add task and task/file targets

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Apr 08, 2020 at 04:25:29PM -0700, Yonghong Song wrote:
> +
> +	spin_lock(&files->file_lock);
> +	for (; sfd < files_fdtable(files)->max_fds; sfd++) {
> +		struct file *f;
> +
> +		f = fcheck_files(files, sfd);
> +		if (!f)
> +			continue;
> +
> +		*fd = sfd;
> +		get_file(f);
> +		spin_unlock(&files->file_lock);
> +		return f;
> +	}
> +
> +	/* the current task is done, go to the next task */
> +	spin_unlock(&files->file_lock);
> +	put_files_struct(files);

I think spin_lock is unnecessary.
It's similarly unnecessary in bpf_task_fd_query().
Take a look at proc_readfd_common() in fs/proc/fd.c.
It only needs rcu_read_lock() to iterate fd array.



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux