mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-23 04:34:11 +08:00
e3818b8dce
Disabling BH can stand in for rcu_read_lock_bh(), and this patch updates rcu_read_lock_bh_held() to allow for this. In order to avoid include-file hell, this function is moved out of line to kernel/rcupdate.c. This fixes a false positive RCU warning. Reported-by: Arnd Bergmann <arnd@arndb.de> Reported-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Acked-by: Lai Jiangshan <laijs@cn.fujitsu.com> Cc: dipankar@in.ibm.com Cc: mathieu.desnoyers@polymtl.ca Cc: josh@joshtriplett.org Cc: dvhltc@us.ibm.com Cc: niv@us.ibm.com Cc: peterz@infradead.org Cc: rostedt@goodmis.org Cc: Valdis.Kletnieks@vt.edu Cc: dhowells@redhat.com LKML-Reference: <20100316000343.GA25857@linux.vnet.ibm.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
118 lines
3.7 KiB
C
118 lines
3.7 KiB
C
/*
|
|
* Read-Copy Update mechanism for mutual exclusion
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
*
|
|
* Copyright IBM Corporation, 2001
|
|
*
|
|
* Authors: Dipankar Sarma <dipankar@in.ibm.com>
|
|
* Manfred Spraul <manfred@colorfullife.com>
|
|
*
|
|
* Based on the original work by Paul McKenney <paulmck@us.ibm.com>
|
|
* and inputs from Rusty Russell, Andrea Arcangeli and Andi Kleen.
|
|
* Papers:
|
|
* http://www.rdrop.com/users/paulmck/paper/rclockpdcsproof.pdf
|
|
* http://lse.sourceforge.net/locking/rclock_OLS.2001.05.01c.sc.pdf (OLS2001)
|
|
*
|
|
* For detailed explanation of Read-Copy Update mechanism see -
|
|
* http://lse.sourceforge.net/locking/rcupdate.html
|
|
*
|
|
*/
|
|
#include <linux/types.h>
|
|
#include <linux/kernel.h>
|
|
#include <linux/init.h>
|
|
#include <linux/spinlock.h>
|
|
#include <linux/smp.h>
|
|
#include <linux/interrupt.h>
|
|
#include <linux/sched.h>
|
|
#include <asm/atomic.h>
|
|
#include <linux/bitops.h>
|
|
#include <linux/percpu.h>
|
|
#include <linux/notifier.h>
|
|
#include <linux/cpu.h>
|
|
#include <linux/mutex.h>
|
|
#include <linux/module.h>
|
|
#include <linux/kernel_stat.h>
|
|
#include <linux/hardirq.h>
|
|
|
|
#ifdef CONFIG_DEBUG_LOCK_ALLOC
|
|
static struct lock_class_key rcu_lock_key;
|
|
struct lockdep_map rcu_lock_map =
|
|
STATIC_LOCKDEP_MAP_INIT("rcu_read_lock", &rcu_lock_key);
|
|
EXPORT_SYMBOL_GPL(rcu_lock_map);
|
|
|
|
static struct lock_class_key rcu_bh_lock_key;
|
|
struct lockdep_map rcu_bh_lock_map =
|
|
STATIC_LOCKDEP_MAP_INIT("rcu_read_lock_bh", &rcu_bh_lock_key);
|
|
EXPORT_SYMBOL_GPL(rcu_bh_lock_map);
|
|
|
|
static struct lock_class_key rcu_sched_lock_key;
|
|
struct lockdep_map rcu_sched_lock_map =
|
|
STATIC_LOCKDEP_MAP_INIT("rcu_read_lock_sched", &rcu_sched_lock_key);
|
|
EXPORT_SYMBOL_GPL(rcu_sched_lock_map);
|
|
#endif
|
|
|
|
int rcu_scheduler_active __read_mostly;
|
|
EXPORT_SYMBOL_GPL(rcu_scheduler_active);
|
|
|
|
#ifdef CONFIG_DEBUG_LOCK_ALLOC
|
|
|
|
/**
|
|
* rcu_read_lock_bh_held - might we be in RCU-bh read-side critical section?
|
|
*
|
|
* Check for bottom half being disabled, which covers both the
|
|
* CONFIG_PROVE_RCU and not cases. Note that if someone uses
|
|
* rcu_read_lock_bh(), but then later enables BH, lockdep (if enabled)
|
|
* will show the situation.
|
|
*
|
|
* Check debug_lockdep_rcu_enabled() to prevent false positives during boot.
|
|
*/
|
|
int rcu_read_lock_bh_held(void)
|
|
{
|
|
if (!debug_lockdep_rcu_enabled())
|
|
return 1;
|
|
return in_softirq();
|
|
}
|
|
EXPORT_SYMBOL_GPL(rcu_read_lock_bh_held);
|
|
|
|
#endif /* #ifdef CONFIG_DEBUG_LOCK_ALLOC */
|
|
|
|
/*
|
|
* This function is invoked towards the end of the scheduler's initialization
|
|
* process. Before this is called, the idle task might contain
|
|
* RCU read-side critical sections (during which time, this idle
|
|
* task is booting the system). After this function is called, the
|
|
* idle tasks are prohibited from containing RCU read-side critical
|
|
* sections.
|
|
*/
|
|
void rcu_scheduler_starting(void)
|
|
{
|
|
WARN_ON(num_online_cpus() != 1);
|
|
WARN_ON(nr_context_switches() > 0);
|
|
rcu_scheduler_active = 1;
|
|
}
|
|
|
|
/*
|
|
* Awaken the corresponding synchronize_rcu() instance now that a
|
|
* grace period has elapsed.
|
|
*/
|
|
void wakeme_after_rcu(struct rcu_head *head)
|
|
{
|
|
struct rcu_synchronize *rcu;
|
|
|
|
rcu = container_of(head, struct rcu_synchronize, head);
|
|
complete(&rcu->completion);
|
|
}
|