On Tue, Aug 12, 2008 at 08:09:27PM +0200, Jarek Poplawski wrote:The usual problem with re-reading in a separate read-side critical section is that someone might have removed/destroyed it in the meantime. Consider the following example: Task 0: rcu_read_lock(); p = rcu_dereference(global_pointer); if (p == NULL) { rcu_read_unlock(); goto somewhere_else; } do_something_with(p); rcu_read_unlock(); do_some_unrelated_stuff(); rcu_read_lock(); do_something_else_with(p); /* BUG!!! */ rcu_read_unlock(); somewhere_else: Task 1: spin_lock(&mylock); p = global_pointer; global_pointer = NULL; spin_unlock(&mylock); synchronize_rcu(); kfree(p); Suppose task 0 picks up the global_pointer just before task 1 NULLs it. Then Task 1's synchronize_rcu() is within its rights to return as soon as task 0 executes its first rcu_read_unlock(). This means that task 1's kfree(p) might happen before task 0's do_something_else_with(p), which could cause general death and destruction. It looks to me like Dave believes that there is in fact a problem: http://marc.info/?l=linux-netdev&m=121851965707714&w=2 But if it gets postponed into ksoftirqd... the RCU will pass too early. I'm still thinking about how to fix this without avoiding RCU and without adding new synchronization primitives. The only change to Dave's comment that I would make is to his first paragraph: But if it gets postponed into ksoftirqd or if the kernel has been built with CONFIG_PREEMPT_RCU... the RCU will pass too early. My thought would be to use a reference count as noted earlier, on the grounds that postponing to softirq should be relatively rare. But again I really cannot claim to understand this code. Or am I missing something here? Thanx, Paul -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
| Greg KH | [GIT PATCH] driver core patches against 2.6.24 |
| James Bottomley | Re: Announce: Linux-next (Or Andrew's dream :-)) |
| Andrew Morton | echo mem > /sys/power/state |
| Peter Zijlstra | [PATCH 00/23] per device dirty throttling -v8 |
git: | |
| David Miller | Re: [PATCH] pkt_sched: Destroy gen estimators under rtnl_lock(). |
| David Miller | [GIT]: Networking |
| Gerrit Renker | [PATCH 18/37] dccp: Support for Mandatory options |
| Michael S. Tsirkin | Re: [RFC PATCH v2 03/19] vbus: add connection-client helper infrastructure |
| NeilBrown | [PATCH 00/18] Assorted md patches headed for 2.6.30 |
| Justin Piszcz | General question (scheduler) with SSDs? |
| Neil Brown | Re: Any hope for a 27 disk RAID6+1HS array with four disks reporting "No md superb... |
| Ryan Wagoner | High IO Wait with RAID 1 |
