mirror of
https://github.com/torvalds/linux.git
synced 2026-07-28 10:09:10 +02:00
eventpoll: relocate KCMP helpers near compat syscalls
ep_find_tfd() and get_epoll_tfile_raw_ptr() are only used when CONFIG_KCMP=y. They implement the lookup side of the kcmp(2) KCMP_EPOLL_TFD query. The helpers currently live between ep_find() and ep_poll_callback(), interrupting the run of hot-path code (callback, wait-queue setup, path check, insert, modify, send_events, poll) with a feature-gated block. Move the #ifdef CONFIG_KCMP block next to #ifdef CONFIG_COMPAT, which is also a peripheral ABI extension. Hot-path code becomes a contiguous span, and the userspace-adjacent extensions cluster at the end of the file just before eventpoll_init(). Pure code movement; diff is 44 removed and 44 added, all within one block. No functional change. Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org> Link: https://patch.msgid.link/20260424-work-epoll-rework-v1-9-249ed00a20f3@kernel.org Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
parent
6a3f1a494b
commit
7de0309926
|
|
@ -1399,50 +1399,6 @@ static struct epitem *ep_find(struct eventpoll *ep, struct file *file, int fd)
|
|||
return epir;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_KCMP
|
||||
static struct epitem *ep_find_tfd(struct eventpoll *ep, int tfd, unsigned long toff)
|
||||
{
|
||||
struct rb_node *rbp;
|
||||
struct epitem *epi;
|
||||
|
||||
for (rbp = rb_first_cached(&ep->rbr); rbp; rbp = rb_next(rbp)) {
|
||||
epi = rb_entry(rbp, struct epitem, rbn);
|
||||
if (epi->ffd.fd == tfd) {
|
||||
if (toff == 0)
|
||||
return epi;
|
||||
else
|
||||
toff--;
|
||||
}
|
||||
cond_resched();
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct file *get_epoll_tfile_raw_ptr(struct file *file, int tfd,
|
||||
unsigned long toff)
|
||||
{
|
||||
struct file *file_raw;
|
||||
struct eventpoll *ep;
|
||||
struct epitem *epi;
|
||||
|
||||
if (!is_file_epoll(file))
|
||||
return ERR_PTR(-EINVAL);
|
||||
|
||||
ep = file->private_data;
|
||||
|
||||
mutex_lock(&ep->mtx);
|
||||
epi = ep_find_tfd(ep, tfd, toff);
|
||||
if (epi)
|
||||
file_raw = epi->ffd.file;
|
||||
else
|
||||
file_raw = ERR_PTR(-ENOENT);
|
||||
mutex_unlock(&ep->mtx);
|
||||
|
||||
return file_raw;
|
||||
}
|
||||
#endif /* CONFIG_KCMP */
|
||||
|
||||
/*
|
||||
* This is the callback that is passed to the wait queue wakeup
|
||||
* mechanism. It is called by the stored file descriptors when they
|
||||
|
|
@ -2733,6 +2689,50 @@ SYSCALL_DEFINE6(epoll_pwait2, int, epfd, struct epoll_event __user *, events,
|
|||
sigmask, sigsetsize);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_KCMP
|
||||
static struct epitem *ep_find_tfd(struct eventpoll *ep, int tfd, unsigned long toff)
|
||||
{
|
||||
struct rb_node *rbp;
|
||||
struct epitem *epi;
|
||||
|
||||
for (rbp = rb_first_cached(&ep->rbr); rbp; rbp = rb_next(rbp)) {
|
||||
epi = rb_entry(rbp, struct epitem, rbn);
|
||||
if (epi->ffd.fd == tfd) {
|
||||
if (toff == 0)
|
||||
return epi;
|
||||
else
|
||||
toff--;
|
||||
}
|
||||
cond_resched();
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct file *get_epoll_tfile_raw_ptr(struct file *file, int tfd,
|
||||
unsigned long toff)
|
||||
{
|
||||
struct file *file_raw;
|
||||
struct eventpoll *ep;
|
||||
struct epitem *epi;
|
||||
|
||||
if (!is_file_epoll(file))
|
||||
return ERR_PTR(-EINVAL);
|
||||
|
||||
ep = file->private_data;
|
||||
|
||||
mutex_lock(&ep->mtx);
|
||||
epi = ep_find_tfd(ep, tfd, toff);
|
||||
if (epi)
|
||||
file_raw = epi->ffd.file;
|
||||
else
|
||||
file_raw = ERR_PTR(-ENOENT);
|
||||
mutex_unlock(&ep->mtx);
|
||||
|
||||
return file_raw;
|
||||
}
|
||||
#endif /* CONFIG_KCMP */
|
||||
|
||||
#ifdef CONFIG_COMPAT
|
||||
static int do_compat_epoll_pwait(int epfd, struct epoll_event __user *events,
|
||||
int maxevents, struct timespec64 *timeout,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user