Lines Matching refs:epi
241 struct epitem *epi; member
298 struct epitem *epi= container_of(p, struct epitem, fllink); in unlist_file() local
299 spin_lock(&epi->ffd.file->f_lock); in unlist_file()
303 spin_unlock(&epi->ffd.file->f_lock); in unlist_file()
360 static inline int ep_is_linked(struct epitem *epi) in ep_is_linked() argument
362 return !list_empty(&epi->rdllink); in ep_is_linked()
427 static inline void ep_set_busy_poll_napi_id(struct epitem *epi) in ep_set_busy_poll_napi_id() argument
437 sock = sock_from_file(epi->ffd.file); in ep_set_busy_poll_napi_id()
446 ep = epi->ep; in ep_set_busy_poll_napi_id()
466 static inline void ep_set_busy_poll_napi_id(struct epitem *epi) in ep_set_busy_poll_napi_id() argument
499 static void ep_poll_safewake(struct eventpoll *ep, struct epitem *epi, in ep_poll_safewake() argument
521 if (epi) { in ep_poll_safewake()
522 if ((is_file_epoll(epi->ffd.file))) { in ep_poll_safewake()
523 ep_src = epi->ffd.file->private_data; in ep_poll_safewake()
538 static void ep_poll_safewake(struct eventpoll *ep, struct epitem *epi, in ep_poll_safewake() argument
567 static void ep_unregister_pollwait(struct eventpoll *ep, struct epitem *epi) in ep_unregister_pollwait() argument
569 struct eppoll_entry **p = &epi->pwqlist; in ep_unregister_pollwait()
580 static inline struct wakeup_source *ep_wakeup_source(struct epitem *epi) in ep_wakeup_source() argument
582 return rcu_dereference_check(epi->ws, lockdep_is_held(&epi->ep->mtx)); in ep_wakeup_source()
586 static inline void ep_pm_stay_awake(struct epitem *epi) in ep_pm_stay_awake() argument
588 struct wakeup_source *ws = ep_wakeup_source(epi); in ep_pm_stay_awake()
594 static inline bool ep_has_wakeup_source(struct epitem *epi) in ep_has_wakeup_source() argument
596 return rcu_access_pointer(epi->ws) ? true : false; in ep_has_wakeup_source()
600 static inline void ep_pm_stay_awake_rcu(struct epitem *epi) in ep_pm_stay_awake_rcu() argument
605 ws = rcu_dereference(epi->ws); in ep_pm_stay_awake_rcu()
636 struct epitem *epi, *nepi; in ep_done_scan() local
644 for (nepi = READ_ONCE(ep->ovflist); (epi = nepi) != NULL; in ep_done_scan()
645 nepi = epi->next, epi->next = EP_UNACTIVE_PTR) { in ep_done_scan()
652 if (!ep_is_linked(epi)) { in ep_done_scan()
657 list_add(&epi->rdllink, &ep->rdllist); in ep_done_scan()
658 ep_pm_stay_awake(epi); in ep_done_scan()
684 struct epitem *epi = container_of(head, struct epitem, rcu); in epi_rcu_free() local
685 kmem_cache_free(epi_cache, epi); in epi_rcu_free()
721 static bool __ep_remove(struct eventpoll *ep, struct epitem *epi, bool force) in __ep_remove() argument
723 struct file *file = epi->ffd.file; in __ep_remove()
732 ep_unregister_pollwait(ep, epi); in __ep_remove()
736 if (epi->dying && !force) { in __ep_remove()
743 if (head->first == &epi->fllink && !epi->fllink.next) { in __ep_remove()
753 hlist_del_rcu(&epi->fllink); in __ep_remove()
757 rb_erase_cached(&epi->rbn, &ep->rbr); in __ep_remove()
760 if (ep_is_linked(epi)) in __ep_remove()
761 list_del_init(&epi->rdllink); in __ep_remove()
764 wakeup_source_unregister(ep_wakeup_source(epi)); in __ep_remove()
772 call_rcu(&epi->rcu, epi_rcu_free); in __ep_remove()
781 static void ep_remove_safe(struct eventpoll *ep, struct epitem *epi) in ep_remove_safe() argument
783 WARN_ON_ONCE(__ep_remove(ep, epi, false)); in ep_remove_safe()
789 struct epitem *epi; in ep_clear_and_put() local
802 epi = rb_entry(rbp, struct epitem, rbn); in ep_clear_and_put()
804 ep_unregister_pollwait(ep, epi); in ep_clear_and_put()
818 epi = rb_entry(rbp, struct epitem, rbn); in ep_clear_and_put()
819 ep_remove_safe(ep, epi); in ep_clear_and_put()
840 static __poll_t ep_item_poll(const struct epitem *epi, poll_table *pt, int depth);
846 struct epitem *epi, *tmp; in __ep_eventpoll_poll() local
861 list_for_each_entry_safe(epi, tmp, &txlist, rdllink) { in __ep_eventpoll_poll()
862 if (ep_item_poll(epi, &pt, depth + 1)) { in __ep_eventpoll_poll()
871 __pm_relax(ep_wakeup_source(epi)); in __ep_eventpoll_poll()
872 list_del_init(&epi->rdllink); in __ep_eventpoll_poll()
898 static struct file *epi_fget(const struct epitem *epi) in epi_fget() argument
902 file = epi->ffd.file; in epi_fget()
913 static __poll_t ep_item_poll(const struct epitem *epi, poll_table *pt, in ep_item_poll() argument
916 struct file *file = epi_fget(epi); in ep_item_poll()
926 pt->_key = epi->event.events; in ep_item_poll()
932 return res & epi->event.events; in ep_item_poll()
948 struct epitem *epi = rb_entry(rbp, struct epitem, rbn); in ep_show_fdinfo() local
949 struct inode *inode = file_inode(epi->ffd.file); in ep_show_fdinfo()
953 epi->ffd.fd, epi->event.events, in ep_show_fdinfo()
954 (long long)epi->event.data, in ep_show_fdinfo()
955 (long long)epi->ffd.file->f_pos, in ep_show_fdinfo()
982 struct epitem *epi; in eventpoll_release_file() local
993 epi = hlist_entry(file->f_ep->first, struct epitem, fllink); in eventpoll_release_file()
994 epi->dying = true; in eventpoll_release_file()
1001 ep = epi->ep; in eventpoll_release_file()
1003 dispose = __ep_remove(ep, epi, true); in eventpoll_release_file()
1045 struct epitem *epi, *epir = NULL; in ep_find() local
1050 epi = rb_entry(rbp, struct epitem, rbn); in ep_find()
1051 kcmp = ep_cmp_ffd(&ffd, &epi->ffd); in ep_find()
1057 epir = epi; in ep_find()
1069 struct epitem *epi; in ep_find_tfd() local
1072 epi = rb_entry(rbp, struct epitem, rbn); in ep_find_tfd()
1073 if (epi->ffd.fd == tfd) { in ep_find_tfd()
1075 return epi; in ep_find_tfd()
1090 struct epitem *epi; in get_epoll_tfile_raw_ptr() local
1098 epi = ep_find_tfd(ep, tfd, toff); in get_epoll_tfile_raw_ptr()
1099 if (epi) in get_epoll_tfile_raw_ptr()
1100 file_raw = epi->ffd.file; in get_epoll_tfile_raw_ptr()
1168 static inline bool chain_epi_lockless(struct epitem *epi) in chain_epi_lockless() argument
1170 struct eventpoll *ep = epi->ep; in chain_epi_lockless()
1173 if (epi->next != EP_UNACTIVE_PTR) in chain_epi_lockless()
1177 if (cmpxchg(&epi->next, EP_UNACTIVE_PTR, NULL) != EP_UNACTIVE_PTR) in chain_epi_lockless()
1181 epi->next = xchg(&ep->ovflist, epi); in chain_epi_lockless()
1207 struct epitem *epi = ep_item_from_wait(wait); in ep_poll_callback() local
1208 struct eventpoll *ep = epi->ep; in ep_poll_callback()
1215 ep_set_busy_poll_napi_id(epi); in ep_poll_callback()
1223 if (!(epi->event.events & ~EP_PRIVATE_BITS)) in ep_poll_callback()
1232 if (pollflags && !(pollflags & epi->event.events)) in ep_poll_callback()
1242 if (chain_epi_lockless(epi)) in ep_poll_callback()
1243 ep_pm_stay_awake_rcu(epi); in ep_poll_callback()
1244 } else if (!ep_is_linked(epi)) { in ep_poll_callback()
1246 if (list_add_tail_lockless(&epi->rdllink, &ep->rdllist)) in ep_poll_callback()
1247 ep_pm_stay_awake_rcu(epi); in ep_poll_callback()
1255 if ((epi->event.events & EPOLLEXCLUSIVE) && in ep_poll_callback()
1259 if (epi->event.events & EPOLLIN) in ep_poll_callback()
1263 if (epi->event.events & EPOLLOUT) in ep_poll_callback()
1284 ep_poll_safewake(ep, epi, pollflags & EPOLL_URING_WAKE); in ep_poll_callback()
1286 if (!(epi->event.events & EPOLLEXCLUSIVE)) in ep_poll_callback()
1316 struct epitem *epi = epq->epi; in ep_ptable_queue_proc() local
1319 if (unlikely(!epi)) // an earlier allocation has failed in ep_ptable_queue_proc()
1324 epq->epi = NULL; in ep_ptable_queue_proc()
1330 pwq->base = epi; in ep_ptable_queue_proc()
1331 if (epi->event.events & EPOLLEXCLUSIVE) in ep_ptable_queue_proc()
1335 pwq->next = epi->pwqlist; in ep_ptable_queue_proc()
1336 epi->pwqlist = pwq; in ep_ptable_queue_proc()
1339 static void ep_rbtree_insert(struct eventpoll *ep, struct epitem *epi) in ep_rbtree_insert() argument
1349 kcmp = ep_cmp_ffd(&epi->ffd, &epic->ffd); in ep_rbtree_insert()
1356 rb_link_node(&epi->rbn, parent, p); in ep_rbtree_insert()
1357 rb_insert_color_cached(&epi->rbn, &ep->rbr, leftmost); in ep_rbtree_insert()
1399 struct epitem *epi; in reverse_path_check_proc() local
1405 hlist_for_each_entry_rcu(epi, refs, fllink) { in reverse_path_check_proc()
1406 struct hlist_head *refs = &epi->ep->refs; in reverse_path_check_proc()
1443 static int ep_create_wakeup_source(struct epitem *epi) in ep_create_wakeup_source() argument
1448 if (!epi->ep->ws) { in ep_create_wakeup_source()
1449 epi->ep->ws = wakeup_source_register(NULL, "eventpoll"); in ep_create_wakeup_source()
1450 if (!epi->ep->ws) in ep_create_wakeup_source()
1454 take_dentry_name_snapshot(&n, epi->ffd.file->f_path.dentry); in ep_create_wakeup_source()
1460 rcu_assign_pointer(epi->ws, ws); in ep_create_wakeup_source()
1466 static noinline void ep_destroy_wakeup_source(struct epitem *epi) in ep_destroy_wakeup_source() argument
1468 struct wakeup_source *ws = ep_wakeup_source(epi); in ep_destroy_wakeup_source()
1470 RCU_INIT_POINTER(epi->ws, NULL); in ep_destroy_wakeup_source()
1481 static int attach_epitem(struct file *file, struct epitem *epi) in attach_epitem() argument
1509 hlist_add_head_rcu(&epi->fllink, file->f_ep); in attach_epitem()
1523 struct epitem *epi; in ep_insert() local
1537 if (!(epi = kmem_cache_zalloc(epi_cache, GFP_KERNEL))) { in ep_insert()
1543 INIT_LIST_HEAD(&epi->rdllink); in ep_insert()
1544 epi->ep = ep; in ep_insert()
1545 ep_set_ffd(&epi->ffd, tfile, fd); in ep_insert()
1546 epi->event = *event; in ep_insert()
1547 epi->next = EP_UNACTIVE_PTR; in ep_insert()
1552 if (unlikely(attach_epitem(tfile, epi) < 0)) { in ep_insert()
1555 kmem_cache_free(epi_cache, epi); in ep_insert()
1567 ep_rbtree_insert(ep, epi); in ep_insert()
1579 ep_remove_safe(ep, epi); in ep_insert()
1583 if (epi->event.events & EPOLLWAKEUP) { in ep_insert()
1584 error = ep_create_wakeup_source(epi); in ep_insert()
1586 ep_remove_safe(ep, epi); in ep_insert()
1592 epq.epi = epi; in ep_insert()
1602 revents = ep_item_poll(epi, &epq.pt, 1); in ep_insert()
1609 if (unlikely(!epq.epi)) { in ep_insert()
1610 ep_remove_safe(ep, epi); in ep_insert()
1618 ep_set_busy_poll_napi_id(epi); in ep_insert()
1621 if (revents && !ep_is_linked(epi)) { in ep_insert()
1622 list_add_tail(&epi->rdllink, &ep->rdllist); in ep_insert()
1623 ep_pm_stay_awake(epi); in ep_insert()
1645 static int ep_modify(struct eventpoll *ep, struct epitem *epi, in ep_modify() argument
1660 epi->event.events = event->events; /* need barrier below */ in ep_modify()
1661 epi->event.data = event->data; /* protected by mtx */ in ep_modify()
1662 if (epi->event.events & EPOLLWAKEUP) { in ep_modify()
1663 if (!ep_has_wakeup_source(epi)) in ep_modify()
1664 ep_create_wakeup_source(epi); in ep_modify()
1665 } else if (ep_has_wakeup_source(epi)) { in ep_modify()
1666 ep_destroy_wakeup_source(epi); in ep_modify()
1695 if (ep_item_poll(epi, &pt, 1)) { in ep_modify()
1697 if (!ep_is_linked(epi)) { in ep_modify()
1698 list_add_tail(&epi->rdllink, &ep->rdllist); in ep_modify()
1699 ep_pm_stay_awake(epi); in ep_modify()
1720 struct epitem *epi, *tmp; in ep_send_events() local
1742 list_for_each_entry_safe(epi, tmp, &txlist, rdllink) { in ep_send_events()
1758 ws = ep_wakeup_source(epi); in ep_send_events()
1765 list_del_init(&epi->rdllink); in ep_send_events()
1772 revents = ep_item_poll(epi, &pt, 1); in ep_send_events()
1776 events = epoll_put_uevent(revents, epi->event.data, events); in ep_send_events()
1778 list_add(&epi->rdllink, &txlist); in ep_send_events()
1779 ep_pm_stay_awake(epi); in ep_send_events()
1785 if (epi->event.events & EPOLLONESHOT) in ep_send_events()
1786 epi->event.events &= EP_PRIVATE_BITS; in ep_send_events()
1787 else if (!(epi->event.events & EPOLLET)) { in ep_send_events()
1799 list_add_tail(&epi->rdllink, &ep->rdllist); in ep_send_events()
1800 ep_pm_stay_awake(epi); in ep_send_events()
2006 struct epitem *epi; in ep_loop_check_proc() local
2011 epi = rb_entry(rbp, struct epitem, rbn); in ep_loop_check_proc()
2012 if (unlikely(is_file_epoll(epi->ffd.file))) { in ep_loop_check_proc()
2014 ep_tovisit = epi->ffd.file->private_data; in ep_loop_check_proc()
2032 list_file(epi->ffd.file); in ep_loop_check_proc()
2159 struct epitem *epi; in do_epoll_ctl() local
2253 epi = ep_find(ep, tf.file, fd); in do_epoll_ctl()
2258 if (!epi) { in do_epoll_ctl()
2265 if (epi) { in do_epoll_ctl()
2270 ep_remove_safe(ep, epi); in do_epoll_ctl()
2277 if (epi) { in do_epoll_ctl()
2278 if (!(epi->event.events & EPOLLEXCLUSIVE)) { in do_epoll_ctl()
2280 error = ep_modify(ep, epi, epds); in do_epoll_ctl()