4343 * LOCKING:
4444 * There are three level of locking required by epoll :
4545 *
46- * 1) epmutex (mutex)
46+ * 1) epnested_mutex (mutex)
4747 * 2) ep->mtx (mutex)
4848 * 3) ep->lock (rwlock)
4949 *
5757 * we need a lock that will allow us to sleep. This lock is a
5858 * mutex (ep->mtx). It is acquired during the event transfer loop,
5959 * during epoll_ctl(EPOLL_CTL_DEL) and during eventpoll_release_file().
60- * The epmutex is acquired when inserting an epoll fd onto another epoll
61- * fd. We do this so that we walk the epoll tree and ensure that this
60+ * The epnested_mutex is acquired when inserting an epoll fd onto another
61+ * epoll fd. We do this so that we walk the epoll tree and ensure that this
6262 * insertion does not create a cycle of epoll file descriptors, which
6363 * could lead to deadlock. We need a global mutex to prevent two
6464 * simultaneous inserts (A into B and B into A) from racing and
7474 * of epoll file descriptors, we use the current recursion depth as
7575 * the lockdep subkey.
7676 * It is possible to drop the "ep->mtx" and to use the global
77- * mutex "epmutex " (together with "ep->lock") to have it working,
77+ * mutex "epnested_mutex " (together with "ep->lock") to have it working,
7878 * but having "ep->mtx" will make the interface more scalable.
79- * Events that require holding "epmutex " are very rare, while for
79+ * Events that require holding "epnested_mutex " are very rare, while for
8080 * normal operations the epoll private "ep->mtx" will guarantee
8181 * a better scalability.
8282 */
@@ -248,7 +248,7 @@ struct ep_pqueue {
248248static long max_user_watches __read_mostly ;
249249
250250/* Used for cycles detection */
251- static DEFINE_MUTEX (epmutex );
251+ static DEFINE_MUTEX (epnested_mutex );
252252
253253static u64 loop_check_gen = 0 ;
254254
@@ -263,7 +263,7 @@ static struct kmem_cache *pwq_cache __read_mostly;
263263
264264/*
265265 * List of files with newly added links, where we may need to limit the number
266- * of emanating paths. Protected by the epmutex .
266+ * of emanating paths. Protected by the epnested_mutex .
267267 */
268268struct epitems_head {
269269 struct hlist_head epitems ;
@@ -1337,7 +1337,7 @@ static void ep_rbtree_insert(struct eventpoll *ep, struct epitem *epi)
13371337 * is connected to n file sources. In this case each file source has 1 path
13381338 * of length 1. Thus, the numbers below should be more than sufficient. These
13391339 * path limits are enforced during an EPOLL_CTL_ADD operation, since a modify
1340- * and delete can't add additional paths. Protected by the epmutex .
1340+ * and delete can't add additional paths. Protected by the epnested_mutex .
13411341 */
13421342static const int path_limits [PATH_ARR_SIZE ] = { 1000 , 500 , 100 , 50 , 10 };
13431343static int path_count [PATH_ARR_SIZE ];
@@ -2167,7 +2167,7 @@ int do_epoll_ctl(int epfd, int op, int fd, struct epoll_event *epds,
21672167 * We do not need to take the global 'epumutex' on EPOLL_CTL_ADD when
21682168 * the epoll file descriptor is attaching directly to a wakeup source,
21692169 * unless the epoll file descriptor is nested. The purpose of taking the
2170- * 'epmutex ' on add is to prevent complex toplogies such as loops and
2170+ * 'epnested_mutex ' on add is to prevent complex toplogies such as loops and
21712171 * deep wakeup paths from forming in parallel through multiple
21722172 * EPOLL_CTL_ADD operations.
21732173 */
@@ -2178,7 +2178,7 @@ int do_epoll_ctl(int epfd, int op, int fd, struct epoll_event *epds,
21782178 if (READ_ONCE (f .file -> f_ep ) || ep -> gen == loop_check_gen ||
21792179 is_file_epoll (tf .file )) {
21802180 mutex_unlock (& ep -> mtx );
2181- error = epoll_mutex_lock (& epmutex , 0 , nonblock );
2181+ error = epoll_mutex_lock (& epnested_mutex , 0 , nonblock );
21822182 if (error )
21832183 goto error_tgt_fput ;
21842184 loop_check_gen ++ ;
@@ -2239,7 +2239,7 @@ int do_epoll_ctl(int epfd, int op, int fd, struct epoll_event *epds,
22392239 if (full_check ) {
22402240 clear_tfile_check_list ();
22412241 loop_check_gen ++ ;
2242- mutex_unlock (& epmutex );
2242+ mutex_unlock (& epnested_mutex );
22432243 }
22442244
22452245 fdput (tf );
0 commit comments