err = i915_syncmap_set(sync, context, seqno); if (err) return err;
if ((*sync)->height) {
pr_err("Inserting first context=%llx did not return leaf (height=%d, prefix=%llx\n",
context, (*sync)->height, (*sync)->prefix); return -EINVAL;
}
if ((*sync)->parent) {
pr_err("Inserting first context=%llx created branches!\n",
context); return -EINVAL;
}
if (hweight32((*sync)->bitmap) != 1) {
pr_err("First bitmap does not contain a single entry, found %x (count=%d)!\n",
(*sync)->bitmap, hweight32((*sync)->bitmap)); return -EINVAL;
}
err = check_seqno((*sync), ilog2((*sync)->bitmap), seqno); if (err) return err;
if (!i915_syncmap_is_later(sync, context, seqno)) {
pr_err("Lookup of first context=%llx/seqno=%x failed!\n",
context, seqno); return -EINVAL;
}
return 0;
}
staticint igt_syncmap_one(void *arg)
{
I915_RND_STATE(prng);
IGT_TIMEOUT(end_time); struct i915_syncmap *sync; unsignedlong max = 1; int err;
/* * Check that inserting a new id, creates a leaf and only that leaf.
*/
i915_syncmap_init(&sync);
do {
u64 context = i915_prandom_u64_state(&prng); unsignedlong loop;
err = check_syncmap_free(&sync); if (err) goto out;
for (loop = 0; loop <= max; loop++) {
err = check_one(&sync, context,
prandom_u32_state(&prng)); if (err) goto out;
}
max++;
} while (!__igt_timeout(end_time, NULL));
pr_debug("%s: Completed %lu single insertions\n",
__func__, max * (max - 1) / 2);
out: return dump_syncmap(sync, err);
}
err = i915_syncmap_set(sync, context, seqno); if (err) return err;
if ((*sync)->height) {
pr_err("Inserting context=%llx did not return leaf (height=%d, prefix=%llx\n",
context, (*sync)->height, (*sync)->prefix); return -EINVAL;
}
if (hweight32((*sync)->bitmap) != 1) {
pr_err("First entry into leaf (context=%llx) does not contain a single entry, found %x (count=%d)!\n",
context, (*sync)->bitmap, hweight32((*sync)->bitmap)); return -EINVAL;
}
err = check_seqno((*sync), ilog2((*sync)->bitmap), seqno); if (err) return err;
if (!i915_syncmap_is_later(sync, context, seqno)) {
pr_err("Lookup of first entry context=%llx/seqno=%x failed!\n",
context, seqno); return -EINVAL;
}
/* * When we have a new id that doesn't fit inside the existing tree, * we need to add a new layer above. * * 1: 0x00000001 * 2: 0x00000010 * 3: 0x00000100 * 4: 0x00001000 * ... * Each pass the common prefix shrinks and we have to insert a join. * Each join will only contain two branches, the latest of which * is always a leaf. * * If we then reuse the same set of contexts, we expect to build an * identical tree.
*/ for (pass = 0; pass < 3; pass++) { for (order = 0; order < 64; order += SHIFT) {
u64 context = BIT_ULL(order); struct i915_syncmap *join;
err = check_leaf(&sync, context, 0); if (err) goto out;
join = sync->parent; if (!join) /* very first insert will have no parents */ continue;
if (!join->height) {
pr_err("Parent with no height!\n");
err = -EINVAL; goto out;
}
if (hweight32(join->bitmap) != 2) {
pr_err("Join does not have 2 children: %x (%d)\n",
join->bitmap, hweight32(join->bitmap));
err = -EINVAL; goto out;
}
/* * Check that we can split a compacted branch by replacing it with * a join.
*/ for (step = 0; step < KSYNCMAP; step++) { for (order = 64 - SHIFT; order > 0; order -= SHIFT) {
u64 context = step * BIT_ULL(order);
err = i915_syncmap_set(&sync, context, 0); if (err) goto out;
if (sync->height) {
pr_err("Inserting context=%llx (order=%d, step=%d) did not return leaf (height=%d, prefix=%llx\n",
context, order, step, sync->height, sync->prefix);
err = -EINVAL; goto out;
}
}
}
for (step = 0; step < KSYNCMAP; step++) { for (order = SHIFT; order < 64; order += SHIFT) {
u64 context = step * BIT_ULL(order);
/* * The syncmap are "space efficient" compressed radix trees - any * branch with only one child is skipped and replaced by the child. * * If we construct a tree with ids that are neighbouring at a non-zero * height, we form a join but each child of that join is directly a * leaf holding the single id.
*/ for (order = SHIFT; order < 64; order += SHIFT) {
err = check_syncmap_free(&sync); if (err) goto out;
/* Create neighbours in the parent */ for (idx = 0; idx < KSYNCMAP; idx++) {
u64 context = idx * BIT_ULL(order) + idx;
err = i915_syncmap_set(&sync, context, 0); if (err) goto out;
if (sync->height) {
pr_err("Inserting context=%llx (order=%d, idx=%d) did not return leaf (height=%d, prefix=%llx\n",
context, order, idx,
sync->height, sync->prefix);
err = -EINVAL; goto out;
}
}
sync = sync->parent; if (sync->parent) {
pr_err("Parent (join) of last leaf was not the sync!\n");
err = -EINVAL; goto out;
}
if (sync->height != order) {
pr_err("Join does not have the expected height, found %d, expected %d\n",
sync->height, order);
err = -EINVAL; goto out;
}
if (sync->bitmap != BIT(KSYNCMAP) - 1) {
pr_err("Join is not full!, found %x (%d) expected %lx (%d)\n",
sync->bitmap, hweight32(sync->bitmap),
BIT(KSYNCMAP) - 1, KSYNCMAP);
err = -EINVAL; goto out;
}
/* Each of our children should be a leaf */ for (idx = 0; idx < KSYNCMAP; idx++) { struct i915_syncmap *leaf = __sync_child(sync)[idx];
if (leaf->height) {
pr_err("Child %d is a not leaf!\n", idx);
err = -EINVAL; goto out;
}
if (leaf->parent != sync) {
pr_err("Child %d is not attached to us!\n",
idx);
err = -EINVAL; goto out;
}
if (!is_power_of_2(leaf->bitmap)) {
pr_err("Child %d holds more than one id, found %x (%d)\n",
idx, leaf->bitmap, hweight32(leaf->bitmap));
err = -EINVAL; goto out;
}
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.