aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorAlan Stern <stern@rowland.harvard.edu>2006-10-04 05:17:05 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-10-04 10:55:30 -0400
commite6a92013ba458804161c0c5b6d134d82204dc233 (patch)
treeecee5fdcef80d1dba0ac6ea87370931ea39ffecd /kernel
parenteabc069401bcf45bcc3f19e643017bf761780aa8 (diff)
[PATCH] SRCU: report out-of-memory errors
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. [akpm@osdl.org: avoid statement-with-side-effect in macro] Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Acked-by: Paul E. McKenney <paulmck@us.ibm.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/srcu.c5
-rw-r--r--kernel/sys.c3
2 files changed, 5 insertions, 3 deletions
diff --git a/kernel/srcu.c b/kernel/srcu.c
index 7e1979f624ba..3507cabe963b 100644
--- a/kernel/srcu.c
+++ b/kernel/srcu.c
@@ -42,11 +42,12 @@
42 * to any other function. Each srcu_struct represents a separate domain 42 * to any other function. Each srcu_struct represents a separate domain
43 * of SRCU protection. 43 * of SRCU protection.
44 */ 44 */
45void init_srcu_struct(struct srcu_struct *sp) 45int init_srcu_struct(struct srcu_struct *sp)
46{ 46{
47 sp->completed = 0; 47 sp->completed = 0;
48 sp->per_cpu_ref = alloc_percpu(struct srcu_struct_array);
49 mutex_init(&sp->mutex); 48 mutex_init(&sp->mutex);
49 sp->per_cpu_ref = alloc_percpu(struct srcu_struct_array);
50 return (sp->per_cpu_ref ? 0 : -ENOMEM);
50} 51}
51 52
52/* 53/*
diff --git a/kernel/sys.c b/kernel/sys.c
index fd5c71006775..98489d82801b 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -517,7 +517,8 @@ EXPORT_SYMBOL_GPL(srcu_notifier_call_chain);
517void srcu_init_notifier_head(struct srcu_notifier_head *nh) 517void srcu_init_notifier_head(struct srcu_notifier_head *nh)
518{ 518{
519 mutex_init(&nh->mutex); 519 mutex_init(&nh->mutex);
520 init_srcu_struct(&nh->srcu); 520 if (init_srcu_struct(&nh->srcu) < 0)
521 BUG();
521 nh->head = NULL; 522 nh->head = NULL;
522} 523}
523 524