Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1531567
| Path | csiph.com!aioe.org!bofh.it!news.nic.it!robomod |
|---|---|
| From | Matthew Wilcox <mawilcox@linuxonhyperv.com> |
| Newsgroups | linux.kernel |
| Subject | [PATCH v3 07/33] radix tree test suite: iteration test misuses RCU |
| Date | Mon, 28 Nov 2016 21:00:01 +0100 |
| Message-ID | <sIAfL-6sT-7@gated-at.bofh.it> (permalink) |
| References | <sIAfL-6sT-3@gated-at.bofh.it> |
| X-Originating-IP | 72.167.245.219 |
| X-Mailer | git-send-email 1.7.4.1 |
| X-Cmae-Envelope | MS4wfPu6VWr3ivE3AIRQlphy6f7oXVzSquxKUZ7iqShwBAcoNjJTrtPDLpHLBxVf53avmhYmqJIIp85RK1qa7Nqv3khOlpG2bi06X3hJrxuz9NB+gmWEWLZF 5Ok0U+ClfhKJ4H2IoyRzY5wFTlWBrXEFRdKN/6MQLbT2oG6N++tLNFXOFy7nSUurQHXYqDXsnQXfwlF3U5bGCUUjeRWm9ccuDDyoGkN0UKyaUZdOaHK8gU7k dLQNsPwNjDquqf6HuVkVDTDuMHQK16tfbb2w/OvmTB0NlwxWgvAtaWq8nB5Dzadi9pO0/5YUjnuWa1y9hUk/1ECfBpwcOouyGxJ8IRlGFDlpuqwaMT65UhMF l3Pxuf/muOTxno8s9LKPo+kPNrfEj4GKviUz92I7x9KVlnvIonr19b8LxpFDgpAROFtPZlKdXH0C/LTSmv0ta4XtQKcVdS3VQWAcPRdnrjOmvSrFQOk= |
| Sender | robomod@news.nic.it |
| List-ID | <linux-kernel.vger.kernel.org> |
| X-Mailing-List | linux-kernel@vger.kernel.org |
| Approved | robomod@news.nic.it |
| Lines | 111 |
| Organization | linux.* mail to news gateway |
| X-Original-Cc | Matthew Wilcox <mawilcox@microsoft.com>, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, "Kirill A . Shutemov" <kirill.shutemov@linux.intel.com> |
| X-Original-Date | Mon, 28 Nov 2016 13:50:11 -0800 |
| X-Original-Message-ID | <1480369871-5271-8-git-send-email-mawilcox@linuxonhyperv.com> |
| X-Original-References | <1480369871-5271-1-git-send-email-mawilcox@linuxonhyperv.com> |
| X-Original-Sender | linux-kernel-owner@vger.kernel.org |
| Xref | csiph.com linux.kernel:1531567 |
Show key headers only | View raw
From: Matthew Wilcox <mawilcox@microsoft.com>
Each thread needs to register itself with RCU, otherwise the reading
thread's read lock has no effect and the freeing thread will free the
memory in the tree without waiting for the read lock to be dropped.
Signed-off-by: Matthew Wilcox <mawilcox@microsoft.com>
---
tools/testing/radix-tree/iteration_check.c | 28 ++++++++++++++++++++++++++--
1 file changed, 26 insertions(+), 2 deletions(-)
diff --git a/tools/testing/radix-tree/iteration_check.c b/tools/testing/radix-tree/iteration_check.c
index 11d570c..df71cb8 100644
--- a/tools/testing/radix-tree/iteration_check.c
+++ b/tools/testing/radix-tree/iteration_check.c
@@ -29,6 +29,8 @@ static void *add_entries_fn(void *arg)
{
int pgoff;
+ rcu_register_thread();
+
while (!test_complete) {
for (pgoff = 0; pgoff < 100; pgoff++) {
pthread_mutex_lock(&tree_lock);
@@ -38,6 +40,8 @@ static void *add_entries_fn(void *arg)
}
}
+ rcu_unregister_thread();
+
return NULL;
}
@@ -53,6 +57,8 @@ static void *tagged_iteration_fn(void *arg)
struct radix_tree_iter iter;
void **slot;
+ rcu_register_thread();
+
while (!test_complete) {
rcu_read_lock();
radix_tree_for_each_tagged(slot, &tree, &iter, 0, TAG) {
@@ -72,12 +78,18 @@ static void *tagged_iteration_fn(void *arg)
continue;
}
- if (rand_r(&seeds[0]) % 50 == 0)
+ if (rand_r(&seeds[0]) % 50 == 0) {
slot = radix_tree_iter_next(&iter);
+ rcu_read_unlock();
+ rcu_barrier();
+ rcu_read_lock();
+ }
}
rcu_read_unlock();
}
+ rcu_unregister_thread();
+
return NULL;
}
@@ -93,6 +105,8 @@ static void *untagged_iteration_fn(void *arg)
struct radix_tree_iter iter;
void **slot;
+ rcu_register_thread();
+
while (!test_complete) {
rcu_read_lock();
radix_tree_for_each_slot(slot, &tree, &iter, 0) {
@@ -112,12 +126,18 @@ static void *untagged_iteration_fn(void *arg)
continue;
}
- if (rand_r(&seeds[1]) % 50 == 0)
+ if (rand_r(&seeds[1]) % 50 == 0) {
slot = radix_tree_iter_next(&iter);
+ rcu_read_unlock();
+ rcu_barrier();
+ rcu_read_lock();
+ }
}
rcu_read_unlock();
}
+ rcu_unregister_thread();
+
return NULL;
}
@@ -127,6 +147,8 @@ static void *untagged_iteration_fn(void *arg)
*/
static void *remove_entries_fn(void *arg)
{
+ rcu_register_thread();
+
while (!test_complete) {
int pgoff;
@@ -137,6 +159,8 @@ static void *remove_entries_fn(void *arg)
pthread_mutex_unlock(&tree_lock);
}
+ rcu_unregister_thread();
+
return NULL;
}
--
2.10.2
Back to linux.kernel | Previous | Next | Find similar | Unroll thread
[PATCH v3 07/33] radix tree test suite: iteration test misuses RCU Matthew Wilcox <mawilcox@linuxonhyperv.com> - 2016-11-28 21:00 +0100
csiph-web