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

Configure Feed

Select the types of activity you want to include in your feed.

epoll: simplify ep_poll_safewake() for CONFIG_DEBUG_LOCK_ALLOC

Currently, ep_poll_safewake() in the CONFIG_DEBUG_LOCK_ALLOC case uses
ep_call_nested() in order to pass the correct subclass argument to
spin_lock_irqsave_nested(). However, ep_call_nested() adds unnecessary
checks for epoll depth and loops that are already verified when doing
EPOLL_CTL_ADD. This mirrors a conversion that was done for
!CONFIG_DEBUG_LOCK_ALLOC in: commit 37b5e5212a44 ("epoll: remove
ep_call_nested() from ep_eventpoll_poll()")

Link: http://lkml.kernel.org/r/1567628549-11501-1-git-send-email-jbaron@akamai.com
Signed-off-by: Jason Baron <jbaron@akamai.com>
Reviewed-by: Roman Penyaev <rpenyaev@suse.de>
Cc: Davidlohr Bueso <dave@stgolabs.net>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Jason Baron and committed by
Linus Torvalds
f6520c52 cd28b119

+13 -23
+13 -23
fs/eventpoll.c
··· 551 551 */ 552 552 #ifdef CONFIG_DEBUG_LOCK_ALLOC 553 553 554 - static struct nested_calls poll_safewake_ncalls; 555 - 556 - static int ep_poll_wakeup_proc(void *priv, void *cookie, int call_nests) 557 - { 558 - unsigned long flags; 559 - wait_queue_head_t *wqueue = (wait_queue_head_t *)cookie; 560 - 561 - spin_lock_irqsave_nested(&wqueue->lock, flags, call_nests + 1); 562 - wake_up_locked_poll(wqueue, EPOLLIN); 563 - spin_unlock_irqrestore(&wqueue->lock, flags); 564 - 565 - return 0; 566 - } 554 + static DEFINE_PER_CPU(int, wakeup_nest); 567 555 568 556 static void ep_poll_safewake(wait_queue_head_t *wq) 569 557 { 570 - int this_cpu = get_cpu(); 558 + unsigned long flags; 559 + int subclass; 571 560 572 - ep_call_nested(&poll_safewake_ncalls, 573 - ep_poll_wakeup_proc, NULL, wq, (void *) (long) this_cpu); 574 - 575 - put_cpu(); 561 + local_irq_save(flags); 562 + preempt_disable(); 563 + subclass = __this_cpu_read(wakeup_nest); 564 + spin_lock_nested(&wq->lock, subclass + 1); 565 + __this_cpu_inc(wakeup_nest); 566 + wake_up_locked_poll(wq, POLLIN); 567 + __this_cpu_dec(wakeup_nest); 568 + spin_unlock(&wq->lock); 569 + local_irq_restore(flags); 570 + preempt_enable(); 576 571 } 577 572 578 573 #else ··· 2364 2369 * inclusion loops checks. 2365 2370 */ 2366 2371 ep_nested_calls_init(&poll_loop_ncalls); 2367 - 2368 - #ifdef CONFIG_DEBUG_LOCK_ALLOC 2369 - /* Initialize the structure used to perform safe poll wait head wake ups */ 2370 - ep_nested_calls_init(&poll_safewake_ncalls); 2371 - #endif 2372 2372 2373 2373 /* 2374 2374 * We can have many thousands of epitems, so prevent this from