public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Paul E. McKenney" <paulmck@us.ibm.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Andrew Morton <akpm@osdl.org>,
	Jesse Brandeburg <jesse.brandeburg@gmail.com>,
	Kernel development list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/2] SRCU: report out-of-memory errors
Date: Wed, 2 Aug 2006 13:57:30 -0700	[thread overview]
Message-ID: <20060802205730.GD1292@us.ibm.com> (raw)
In-Reply-To: <Pine.LNX.4.44L0.0608021621210.8004-100000@iolanthe.rowland.org>

On Wed, Aug 02, 2006 at 04:38:28PM -0400, Alan Stern wrote:
> Currently the init_srcu_struct() routine has no way to report 
> out-of-memory errors.  This patch (as761) makes it return -ENOMEM when the 
> per-cpu data allocation fails.
> 
> The patch also makes srcu_init_notifier_head() report a BUG if a notifier
> head can't be initialized.  Perhaps it should return -ENOMEM instead, but
> in the most likely cases where this might occur I don't think any recovery
> is possible.  Notifier chains generally are not created dynamically.

Acked-by: Paul E. McKenney <paulmck@us.ibm.com>

> Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
> 
> ---
> 
> Paul, I trust you will agree with the changes this makes to the SRCU code.

Indeed I do...  Good catch!!!

							Thanx, Paul

> The second part of this patch series will convert the cpufreq transition 
> notifier chain to use SRCU, with the initialization occuring in a 
> core_initcall routine.  Although I haven't actually tried it, it seems 
> very likely that an attempt to use the notifier chain before it has been 
> initialized will cause a memory-address fault.
> 
> Alan Stern
> 
> 
> Index: 2.6.18-rc2-mm1/kernel/sys.c
> ===================================================================
> --- 2.6.18-rc2-mm1.orig/kernel/sys.c
> +++ 2.6.18-rc2-mm1/kernel/sys.c
> @@ -516,7 +516,7 @@ EXPORT_SYMBOL_GPL(srcu_notifier_call_cha
>  void srcu_init_notifier_head(struct srcu_notifier_head *nh)
>  {
>  	mutex_init(&nh->mutex);
> -	init_srcu_struct(&nh->srcu);
> +	BUG_ON(init_srcu_struct(&nh->srcu) < 0);
>  	nh->head = NULL;
>  }
>  
> Index: 2.6.18-rc2-mm1/kernel/srcu.c
> ===================================================================
> --- 2.6.18-rc2-mm1.orig/kernel/srcu.c
> +++ 2.6.18-rc2-mm1/kernel/srcu.c
> @@ -42,11 +42,12 @@
>   * to any other function.  Each srcu_struct represents a separate domain
>   * of SRCU protection.
>   */
> -void init_srcu_struct(struct srcu_struct *sp)
> +int init_srcu_struct(struct srcu_struct *sp)
>  {
>  	sp->completed = 0;
> -	sp->per_cpu_ref = alloc_percpu(struct srcu_struct_array);
>  	mutex_init(&sp->mutex);
> +	sp->per_cpu_ref = alloc_percpu(struct srcu_struct_array);
> +	return (sp->per_cpu_ref ? 0 : -ENOMEM);
>  }
>  
>  /*
> Index: 2.6.18-rc2-mm1/include/linux/srcu.h
> ===================================================================
> --- 2.6.18-rc2-mm1.orig/include/linux/srcu.h
> +++ 2.6.18-rc2-mm1/include/linux/srcu.h
> @@ -43,7 +43,7 @@ struct srcu_struct {
>  #define srcu_barrier()
>  #endif /* #else #ifndef CONFIG_PREEMPT */
>  
> -void init_srcu_struct(struct srcu_struct *sp);
> +int init_srcu_struct(struct srcu_struct *sp);
>  void cleanup_srcu_struct(struct srcu_struct *sp);
>  int srcu_read_lock(struct srcu_struct *sp);
>  void srcu_read_unlock(struct srcu_struct *sp, int idx);
> 

  reply	other threads:[~2006-08-02 20:56 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-30  6:27 Linux v2.6.18-rc3 Linus Torvalds
2006-07-30  8:30 ` Russell King
2006-07-31  8:02   ` Junio C Hamano
2006-07-31  4:13 ` Jesse Brandeburg
2006-07-31  4:27   ` Andrew Morton
2006-07-31 14:54     ` Alan Stern
2006-07-31 15:11       ` Andrew Morton
2006-07-31 15:59         ` Alan Stern
2006-07-31 20:34         ` Alan Stern
2006-08-02  4:31           ` Jesse Brandeburg
2006-08-02  4:59             ` Andrew Morton
2006-08-02 19:57               ` Jesse Brandeburg
2006-08-02 20:16                 ` Rafael J. Wysocki
2006-08-02 20:23                   ` Russell King
2006-08-02 20:26                     ` Rafael J. Wysocki
2006-08-02 20:32                     ` Dave Jones
2006-08-02 20:58                       ` Russell King
2006-08-02 21:01                         ` Dave Jones
2006-08-02 21:18                         ` Linus Torvalds
2006-08-02 21:38                           ` Russell King
2006-08-02 22:04                             ` Linus Torvalds
2006-08-02 22:05                             ` Russell King
2006-08-02 20:38                 ` [PATCH 1/2] SRCU: report out-of-memory errors Alan Stern
2006-08-02 20:57                   ` Paul E. McKenney [this message]
2006-08-02 20:38                 ` [PATCH 2/2] cpufreq: make the transition_notifier chain use SRCU Alan Stern
2006-08-03 15:58 ` Linux v2.6.18-rc3 Avuton Olrich
2006-08-03 16:40   ` Adrian Bunk

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=20060802205730.GD1292@us.ibm.com \
    --to=paulmck@us.ibm.com \
    --cc=akpm@osdl.org \
    --cc=jesse.brandeburg@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stern@rowland.harvard.edu \
    /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