History

Merge branch 'core-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip

* 'core-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: rcu: create new rcu_access_index() and use in mce WARN_ON_SMP(): Add comment to explain ({0;})

Linus Torvalds committed 15 years ago

Commit fb9a7d72 parents 4acfaf8 56790273 files · +28 −1Browse files

Unified · Split

3 files
  1. arch/x86/kernel/cpu/mcheck/mce.c +1 −1
  2. include/asm-generic/bug.h +7 −0
  3. include/linux/rcupdate.h +20 −0
arch/x86/kernel/cpu/mcheck/mce.c+1−1
@@ -1626,7 +1626,7 @@ out: · 1625 unmodified lines
1626static unsigned int mce_poll(struct file *file, poll_table *wait)1626static unsigned int mce_poll(struct file *file, poll_table *wait)
1627{1627{
1628 poll_wait(file, &mce_wait, wait);1628 poll_wait(file, &mce_wait, wait);
1629 if (rcu_dereference_check_mce(mcelog.next))1629 if (rcu_access_index(mcelog.next))
1630 return POLLIN | POLLRDNORM;1630 return POLLIN | POLLRDNORM;
1631 if (!mce_apei_read_done && apei_check_mce())1631 if (!mce_apei_read_done && apei_check_mce())
1632 return POLLIN | POLLRDNORM;1632 return POLLIN | POLLRDNORM;
include/asm-generic/bug.h+7−0
@@ -194,6 +194,13 @@ extern void warn_slowpath_null(const char *file, const int line); · 193 unmodified lines
194#ifdef CONFIG_SMP194#ifdef CONFIG_SMP
195# define WARN_ON_SMP(x) WARN_ON(x)195# define WARN_ON_SMP(x) WARN_ON(x)
196#else196#else
197/*
198 * Use of ({0;}) because WARN_ON_SMP(x) may be used either as
199 * a stand alone line statement or as a condition in an if ()
200 * statement.
201 * A simple "0" would cause gcc to give a "statement has no effect"
202 * warning.
203 */
197# define WARN_ON_SMP(x) ({0;})204# define WARN_ON_SMP(x) ({0;})
198#endif205#endif
199 206
include/linux/rcupdate.h+20−0
@@ -339,6 +339,12 @@ extern int rcu_my_thread_group_empty(void); · 338 unmodified lines
339 ((typeof(*p) __force __kernel *)(p)); \339 ((typeof(*p) __force __kernel *)(p)); \
340 })340 })
341 341
342#define __rcu_access_index(p, space) \
343 ({ \
344 typeof(p) _________p1 = ACCESS_ONCE(p); \
345 rcu_dereference_sparse(p, space); \
346 (_________p1); \
347 })
342#define __rcu_dereference_index_check(p, c) \348#define __rcu_dereference_index_check(p, c) \
343 ({ \349 ({ \
344 typeof(p) _________p1 = ACCESS_ONCE(p); \350 typeof(p) _________p1 = ACCESS_ONCE(p); \
@@ -428,6 +434,20 @@ extern int rcu_my_thread_group_empty(void); · 83 unmodified lines
428 434
429#define rcu_dereference_raw(p) rcu_dereference_check(p, 1) /*@@@ needed? @@@*/435#define rcu_dereference_raw(p) rcu_dereference_check(p, 1) /*@@@ needed? @@@*/
430 436
437/**
438 * rcu_access_index() - fetch RCU index with no dereferencing
439 * @p: The index to read
440 *
441 * Return the value of the specified RCU-protected index, but omit the
442 * smp_read_barrier_depends() and keep the ACCESS_ONCE(). This is useful
443 * when the value of this index is accessed, but the index is not
444 * dereferenced, for example, when testing an RCU-protected index against
445 * -1. Although rcu_access_index() may also be used in cases where
446 * update-side locks prevent the value of the index from changing, you
447 * should instead use rcu_dereference_index_protected() for this use case.
448 */
449#define rcu_access_index(p) __rcu_access_index((p), __rcu)
450
431/**451/**
432 * rcu_dereference_index_check() - rcu_dereference for indices with debug checking452 * rcu_dereference_index_check() - rcu_dereference for indices with debug checking
433 * @p: The pointer to read, prior to dereferencing453 * @p: The pointer to read, prior to dereferencing