Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

epoll: fix some comments

Fixes some epoll code comments.

Signed-off-by: Davide Libenzi <davidel@xmailserver.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Davide Libenzi and committed by
Linus Torvalds
67647d0f c7ea7630

+27 -21
+27 -21
fs/eventpoll.c
··· 134 134 * have an entry of this type linked to the "rbr" RB tree. 135 135 */ 136 136 struct epitem { 137 - /* RB-Tree node used to link this structure to the eventpoll rb-tree */ 137 + /* RB tree node used to link this structure to the eventpoll RB tree */ 138 138 struct rb_node rbn; 139 139 140 140 /* List header used to link this structure to the eventpoll ready list */ ··· 191 191 /* List of ready file descriptors */ 192 192 struct list_head rdllist; 193 193 194 - /* RB-Tree root used to store monitored fd structs */ 194 + /* RB tree root used to store monitored fd structs */ 195 195 struct rb_root rbr; 196 196 197 197 /* ··· 241 241 static struct kmem_cache *pwq_cache __read_mostly; 242 242 243 243 244 - /* Setup the structure that is used as key for the rb-tree */ 244 + /* Setup the structure that is used as key for the RB tree */ 245 245 static inline void ep_set_ffd(struct epoll_filefd *ffd, 246 246 struct file *file, int fd) 247 247 { ··· 249 249 ffd->fd = fd; 250 250 } 251 251 252 - /* Compare rb-tree keys */ 252 + /* Compare RB tree keys */ 253 253 static inline int ep_cmp_ffd(struct epoll_filefd *p1, 254 254 struct epoll_filefd *p2) 255 255 { ··· 257 257 (p1->file < p2->file ? -1 : p1->fd - p2->fd)); 258 258 } 259 259 260 - /* Special initialization for the rb-tree node to detect linkage */ 260 + /* Special initialization for the RB tree node to detect linkage */ 261 261 static inline void ep_rb_initnode(struct rb_node *n) 262 262 { 263 263 rb_set_parent(n, n); 264 264 } 265 265 266 - /* Removes a node from the rb-tree and marks it for a fast is-linked check */ 266 + /* Removes a node from the RB tree and marks it for a fast is-linked check */ 267 267 static inline void ep_rb_erase(struct rb_node *n, struct rb_root *r) 268 268 { 269 269 rb_erase(n, r); 270 270 rb_set_parent(n, n); 271 271 } 272 272 273 - /* Fast check to verify that the item is linked to the main rb-tree */ 273 + /* Fast check to verify that the item is linked to the main RB tree */ 274 274 static inline int ep_rb_linked(struct rb_node *n) 275 275 { 276 276 return rb_parent(n) != n; ··· 531 531 * We don't want to get "file->f_ep_lock" because it is not 532 532 * necessary. It is not necessary because we're in the "struct file" 533 533 * cleanup path, and this means that noone is using this file anymore. 534 + * So, for example, epoll_ctl() cannot hit here sicne if we reach this 535 + * point, the file counter already went to zero and fget() would fail. 534 536 * The only hit might come from ep_free() but by holding the mutex 535 537 * will correctly serialize the operation. We do need to acquire 536 538 * "ep->mtx" after "epmutex" because ep_remove() requires it when called ··· 804 802 805 803 /* 806 804 * We need to do this because an event could have been arrived on some 807 - * allocated wait queue. 805 + * allocated wait queue. Note that we don't care about the ep->ovflist 806 + * list, since that is used/cleaned only inside a section bound by "mtx". 807 + * And ep_insert() is called with "mtx" held. 808 808 */ 809 809 spin_lock_irqsave(&ep->lock, flags); 810 810 if (ep_is_linked(&epi->rdllink)) ··· 849 845 850 846 /* 851 847 * If the item is "hot" and it is not registered inside the ready 852 - * list, push it inside. If the item is not "hot" and it is currently 853 - * registered inside the ready list, unlink it. 848 + * list, push it inside. 854 849 */ 855 850 if (revents & event->events) { 856 851 if (!ep_is_linked(&epi->rdllink)) { ··· 969 966 ep->ovflist = EP_UNACTIVE_PTR; 970 967 971 968 /* 972 - * In case of error in the event-send loop, we might still have items 973 - * inside the "txlist". We need to splice them back inside ep->rdllist. 969 + * In case of error in the event-send loop, or in case the number of 970 + * ready events exceeds the userspace limit, we need to splice the 971 + * "txlist" back inside ep->rdllist. 974 972 */ 975 973 list_splice(&txlist, &ep->rdllist); 976 974 977 975 if (!list_empty(&ep->rdllist)) { 978 976 /* 979 977 * Wake up (if active) both the eventpoll wait list and the ->poll() 980 - * wait list. 978 + * wait list (delayed after we release the lock). 981 979 */ 982 980 if (waitqueue_active(&ep->wq)) 983 981 __wake_up_locked(&ep->wq, TASK_UNINTERRUPTIBLE | ··· 1068 1064 } 1069 1065 1070 1066 /* 1071 - * It opens an eventpoll file descriptor by suggesting a storage of "size" 1072 - * file descriptors. The size parameter is just an hint about how to size 1073 - * data structures. It won't prevent the user to store more than "size" 1074 - * file descriptors inside the epoll interface. It is the kernel part of 1075 - * the userspace epoll_create(2). 1067 + * It opens an eventpoll file descriptor. The "size" parameter is there 1068 + * for historical reasons, when epoll was using an hash instead of an 1069 + * RB tree. With the current implementation, the "size" parameter is ignored 1070 + * (besides sanity checks). 1076 1071 */ 1077 1072 asmlinkage long sys_epoll_create(int size) 1078 1073 { ··· 1117 1114 /* 1118 1115 * The following function implements the controller interface for 1119 1116 * the eventpoll file that enables the insertion/removal/change of 1120 - * file descriptors inside the interest set. It represents 1121 - * the kernel part of the user space epoll_ctl(2). 1117 + * file descriptors inside the interest set. 1122 1118 */ 1123 1119 asmlinkage long sys_epoll_ctl(int epfd, int op, int fd, 1124 1120 struct epoll_event __user *event) ··· 1169 1167 1170 1168 mutex_lock(&ep->mtx); 1171 1169 1172 - /* Try to lookup the file inside our RB tree */ 1170 + /* 1171 + * Try to lookup the file inside our RB tree, Since we grabbed "mtx" 1172 + * above, we can be sure to be able to use the item looked up by 1173 + * ep_find() till we release the mutex. 1174 + */ 1173 1175 epi = ep_find(ep, tfile, fd); 1174 1176 1175 1177 error = -EINVAL;