+ <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Why this empty line?
+ }I don't see the strategy:
+
+ sem_unlock(sma, locknum);
+ rcu_read_unlock();
+ wake_up_q(&wake_q);
+
+ goto out_free;
}
- if (error <= 0)
- goto out_unlock_free;
I've used the approach that cleanup is at the end, to reduce duplicated code, even if it means that error codepaths unnecessarily call wakeup for an empty list and that the list is always initialized.
With patch 1 of the series, you start to optimize for that.
Now this patch reintroduces some wake_up_q calls for error paths.
So: What is the aim?
I would propose to skip patch 1 and leave the wake_up_q at the end.
Or, if we really want to avoid the wakeup calls, then do it entirely.
Perhaps:
if(error == 0) { /* nonblocking codepath 1, with wakeups */This would have an advantage, because the WAKE_Q would be initialized only when needed
[...]
}
if (error < 0} goto out_unlock_free;