// SPDX-License-Identifier: GPL-2.0-only /* * iteration_check.c: test races having to do with xarray iteration * Copyright (c) 2016 Intel Corporation * Author: Ross Zwisler <ross.zwisler@linux.intel.com>
*/ #include <pthread.h> #include"test.h"
/* * Iterate over tagged entries, retrying when we find ourselves in a deleted * node and randomly pausing the iteration.
*/ staticvoid *tagged_iteration_fn(void *arg)
{
XA_STATE(xas, &array, 0); void *entry;
rcu_register_thread();
while (!test_complete) {
xas_set(&xas, 0);
rcu_read_lock();
xas_for_each_marked(&xas, entry, ULONG_MAX, TAG) { if (xas_retry(&xas, entry)) continue;
/* * Iterate over the entries, retrying when we find ourselves in a deleted * node and randomly pausing the iteration.
*/ staticvoid *untagged_iteration_fn(void *arg)
{
XA_STATE(xas, &array, 0); void *entry;
rcu_register_thread();
while (!test_complete) {
xas_set(&xas, 0);
rcu_read_lock();
xas_for_each(&xas, entry, ULONG_MAX) { if (xas_retry(&xas, entry)) continue;
/* * Randomly remove entries to help induce retries in the * two iteration functions.
*/ staticvoid *remove_entries_fn(void *arg)
{
rcu_register_thread();
while (!test_complete) { int pgoff; struct item *item;
pgoff = rand_r(&seeds[2]) % MAX_IDX;
item = xa_erase(&array, pgoff); if (item)
item_free(item, pgoff);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.