mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jason Baron <jbaron@akamai.com>
To: akpm@linux-foundation.org
Cc: linux-kernel@vger.kernel.org, Davidlohr Bueso <dave@stgolabs.net>,
	Roman Penyaev <rpenyaev@suse.de>,
	Al Viro <viro@zeniv.linux.org.uk>,
	Eric Wong <normalperson@yhbt.net>
Subject: Re: [PATCH] epoll: simplify ep_poll_safewake() for CONFIG_DEBUG_LOCK_ALLOC
Date: Mon, 23 Sep 2019 11:43:07 -0400	[thread overview]
Message-ID: <a07adc0e-590e-623c-3c80-e28af39bd19c@akamai.com> (raw)
In-Reply-To: <1567628549-11501-1-git-send-email-jbaron@akamai.com>



On 9/4/19 4:22 PM, Jason Baron wrote:
> 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()")
> 
> Signed-off-by: Jason Baron <jbaron@akamai.com>
> Cc: Davidlohr Bueso <dave@stgolabs.net>
> Cc: Roman Penyaev <rpenyaev@suse.de>
> Cc: Al Viro <viro@zeniv.linux.org.uk>
> Cc: Eric Wong <normalperson@yhbt.net>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> ---
>  fs/eventpoll.c | 36 +++++++++++++-----------------------
>  1 file changed, 13 insertions(+), 23 deletions(-)
> 
> diff --git a/fs/eventpoll.c b/fs/eventpoll.c
> index d7f1f50..a9b2737 100644
> --- a/fs/eventpoll.c
> +++ b/fs/eventpoll.c
> @@ -551,28 +551,23 @@ static int ep_call_nested(struct nested_calls *ncalls,
>   */
>  #ifdef CONFIG_DEBUG_LOCK_ALLOC
>  
> -static struct nested_calls poll_safewake_ncalls;
> -
> -static int ep_poll_wakeup_proc(void *priv, void *cookie, int call_nests)
> -{
> -	unsigned long flags;
> -	wait_queue_head_t *wqueue = (wait_queue_head_t *)cookie;
> -
> -	spin_lock_irqsave_nested(&wqueue->lock, flags, call_nests + 1);
> -	wake_up_locked_poll(wqueue, EPOLLIN);
> -	spin_unlock_irqrestore(&wqueue->lock, flags);
> -
> -	return 0;
> -}
> +static DEFINE_PER_CPU(int, wakeup_nest);
>  
>  static void ep_poll_safewake(wait_queue_head_t *wq)
>  {
> -	int this_cpu = get_cpu();
> -
> -	ep_call_nested(&poll_safewake_ncalls,
> -		       ep_poll_wakeup_proc, NULL, wq, (void *) (long) this_cpu);
> +	unsigned long flags;
> +	int subclass;
>  
> -	put_cpu();
> +	local_irq_save(flags);
> +	preempt_disable();
> +	subclass = __this_cpu_read(wakeup_nest);
> +	spin_lock_nested(&wq->lock, subclass + 1);
> +	__this_cpu_inc(wakeup_nest);
> +	wake_up_locked_poll(wq, POLLIN);
> +	__this_cpu_dec(wakeup_nest);
> +	spin_unlock(&wq->lock);
> +	local_irq_restore(flags);
> +	preempt_enable();
>  }
>  
>  #else
> @@ -2370,11 +2365,6 @@ static int __init eventpoll_init(void)
>  	 */
>  	ep_nested_calls_init(&poll_loop_ncalls);
>  
> -#ifdef CONFIG_DEBUG_LOCK_ALLOC
> -	/* Initialize the structure used to perform safe poll wait head wake ups */
> -	ep_nested_calls_init(&poll_safewake_ncalls);
> -#endif
> -
>  	/*
>  	 * We can have many thousands of epitems, so prevent this from
>  	 * using an extra cache line on 64-bit (and smaller) CPUs
> 


Hi,

Any thoughts on this one?

Thanks,

-Jason

  reply	other threads:[~2019-09-23 15:44 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-04 20:22 Jason Baron
2019-09-23 15:43 ` Jason Baron [this message]
2019-09-23 19:23   ` Roman Penyaev
2019-09-24 17:34     ` Jason Baron
2019-09-24 17:52       ` Roman Penyaev
2020-01-06 19:38         ` [PATCH] fs/epoll: rework safewake " Davidlohr Bueso
2020-01-06 20:28           ` Jason Baron
2020-01-06 21:01             ` Davidlohr Bueso
2020-01-17 19:16               ` [PATCH] fs/epoll: make nesting accounting safe for -rt kernel Jason Baron
2020-02-25  0:38                 ` Andrew Morton
2020-02-26 17:56                   ` [PATCH v2] " Jason Baron
2020-03-17 16:34                     ` Davidlohr Bueso

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a07adc0e-590e-623c-3c80-e28af39bd19c@akamai.com \
    --to=jbaron@akamai.com \
    --cc=akpm@linux-foundation.org \
    --cc=dave@stgolabs.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=normalperson@yhbt.net \
    --cc=rpenyaev@suse.de \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®