All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dave Young <dyoung@redhat.com>
To: Cong Wang <xiyou.wangcong@gmail.com>
Cc: linux-kernel@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>,
	Prarit Bhargava <prarit@redhat.com>,
	Arnd Bergmann <arnd@arndb.de>,
	Greg Kroah-Hartman <greg@kroah.com>
Subject: Re: [Patch] lkdtm: avoid calling lkdtm_do_action() with spin lock held
Date: Sun, 29 Jan 2012 09:15:42 +0800	[thread overview]
Message-ID: <4F249DBE.8070203@redhat.com> (raw)
In-Reply-To: <1327755168-12240-1-git-send-email-xiyou.wangcong@gmail.com>

On 01/28/2012 08:52 PM, Cong Wang wrote:

> lkdtm_do_action() may call sleeping functions like kmalloc(),
> so do not call it with spin lock held.
> 
> Cc: Prarit Bhargava <prarit@redhat.com>
> Signed-off-by: WANG Cong <xiyou.wangcong@gmail.com>


Reviewed-by: Dave Young <dyoung@redhat.com>

> 
> ---
> diff --git a/drivers/misc/lkdtm.c b/drivers/misc/lkdtm.c
> index 150cd70..28adefe 100644
> --- a/drivers/misc/lkdtm.c
> +++ b/drivers/misc/lkdtm.c
> @@ -354,6 +354,7 @@ static void lkdtm_do_action(enum ctype which)
>  static void lkdtm_handler(void)
>  {
>  	unsigned long flags;
> +	bool do_it = false;
>  
>  	spin_lock_irqsave(&count_lock, flags);
>  	count--;
> @@ -361,10 +362,13 @@ static void lkdtm_handler(void)
>  			cp_name_to_str(cpoint), cp_type_to_str(cptype), count);
>  
>  	if (count == 0) {
> -		lkdtm_do_action(cptype);
> +		do_it = true;
>  		count = cpoint_count;
>  	}
>  	spin_unlock_irqrestore(&count_lock, flags);
> +
> +	if (do_it)
> +		lkdtm_do_action(cptype);
>  }
>  
>  static int lkdtm_register_cpoint(enum cname which)
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/



-- 
Thanks
Dave

  reply	other threads:[~2012-01-29  1:13 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-28 12:52 [Patch] lkdtm: avoid calling lkdtm_do_action() with spin lock held Cong Wang
2012-01-29  1:15 ` Dave Young [this message]
2012-01-30 20:54 ` Andrew Morton
2012-01-31 13:25   ` Cong Wang
2012-01-31 15:35     ` Arnd Bergmann
2012-02-01  3:01       ` Cong Wang
2012-02-01 15:29         ` Arnd Bergmann
2012-02-02 13:31           ` Cong Wang

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=4F249DBE.8070203@redhat.com \
    --to=dyoung@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=prarit@redhat.com \
    --cc=xiyou.wangcong@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.