Commit 9f4e163e authored by Nils Goroll's avatar Nils Goroll

for tree traversal, register the thread which got to the front

parent 55e1abb0
...@@ -246,6 +246,7 @@ struct bytes_tree { ...@@ -246,6 +246,7 @@ struct bytes_tree {
pthread_cond_t cond; pthread_cond_t cond;
struct node *root; struct node *root;
struct node *front; struct node *front;
struct worker *front_owner;
struct worker *unpend_owner; struct worker *unpend_owner;
int npending; int npending;
int retval; int retval;
...@@ -1306,6 +1307,11 @@ ved_decode_len(struct req *req, const uint8_t **pp) ...@@ -1306,6 +1307,11 @@ ved_decode_len(struct req *req, const uint8_t **pp)
* to minimize lock contention, we walk the tree and gather work on a list * to minimize lock contention, we walk the tree and gather work on a list
*/ */
#define set_front(tree, node, wrk) do { \
(tree)->front = node; \
(tree)->front_owner = wrk; \
} while(0)
static void static void
bytes_unpend_worklist(struct req *req, struct bytes_tree *tree, bytes_unpend_worklist(struct req *req, struct bytes_tree *tree,
struct node_head *work) struct node_head *work)
...@@ -1363,7 +1369,7 @@ bytes_unpend_worklist(struct req *req, struct bytes_tree *tree, ...@@ -1363,7 +1369,7 @@ bytes_unpend_worklist(struct req *req, struct bytes_tree *tree,
VSLdbgv(req, "bytes_unpend: return at " VSLdbgv(req, "bytes_unpend: return at "
"node %p state %u - await sibling", "node %p state %u - await sibling",
node, node->state); node, node->state);
tree->front = node; set_front(tree, node, req->wrk);
return; return;
} }
...@@ -1380,7 +1386,7 @@ bytes_unpend_worklist(struct req *req, struct bytes_tree *tree, ...@@ -1380,7 +1386,7 @@ bytes_unpend_worklist(struct req *req, struct bytes_tree *tree,
AZ(node); AZ(node);
VSLdbgv(req, "bytes_unpend: reached root"); VSLdbgv(req, "bytes_unpend: reached root");
tree->front = tree->root; set_front(tree, tree->root, req->wrk);
return; return;
} }
...@@ -1388,7 +1394,7 @@ bytes_unpend_worklist(struct req *req, struct bytes_tree *tree, ...@@ -1388,7 +1394,7 @@ bytes_unpend_worklist(struct req *req, struct bytes_tree *tree,
VSLdbgv(req, "bytes_unpend: return at " VSLdbgv(req, "bytes_unpend: return at "
"node %p state %u - private", "node %p state %u - private",
node, node->state); node, node->state);
tree->front = node; set_front(tree, node, req->wrk);
return; return;
} }
...@@ -1402,7 +1408,7 @@ bytes_unpend_worklist(struct req *req, struct bytes_tree *tree, ...@@ -1402,7 +1408,7 @@ bytes_unpend_worklist(struct req *req, struct bytes_tree *tree,
if (node->state == ST_OPEN) { if (node->state == ST_OPEN) {
VSLdbg(req, "bytes_unpend: init node no children"); VSLdbg(req, "bytes_unpend: init node no children");
tree->front = node; set_front(tree, node, req->wrk);
return; return;
} }
...@@ -1438,6 +1444,7 @@ bytes_unpend_worklist(struct req *req, struct bytes_tree *tree, ...@@ -1438,6 +1444,7 @@ bytes_unpend_worklist(struct req *req, struct bytes_tree *tree,
check = CHK_ANY; check = CHK_ANY;
} }
} }
#undef set_front
/* /*
* restore the original subreq state and take care that we do not mess up flags, * restore the original subreq state and take care that we do not mess up flags,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment