- if (!flagged) {
- if (is_removed(next))
- goto end;
- /* set deletion flag */
- if ((old = uatomic_cmpxchg(&iter->next, next,
- flag_removed(next))) != next) {
- if (old == flag_removed(next))
- goto end;
- else
- goto retry;
- }
- flagged = 1;
- }
- /*
- * Remove the element from the list.
- * - Retry if there has been a concurrent add before us.
- * - Retry if the prev node has been deleted (its next removed
- * flag would be set).
- * - There cannot be a concurrent delete for our position, because
- * we won the deletion flag cmpxchg.
- * - If there is a concurrent add or remove after us while our
- * removed flag is set, it will skip us and link directly after
- * the prior non-removed node before us. In this case, the
- * retry will not find the node in the list anymore.
- */