Commit 3e60028
committed
Remove redundant memory barrier
The memory barrier before queuing AI work was intended to ensure that
changes to the global variables 'finish' and 'turn' are visible to other
CPUs. However, as documented in workqueue.h, 'queue_work()' provides
the required memory-ordering guarantees: all stores preceding the call
to 'queue_work()' will be visible to the CPU that executes the work
before the work function begins.
In this project, two AI work items take turns making moves. A work item
is only queued after the other has finished executing,
ensuring that at any given time, at most one AI work item is on the
workqueue. Under this usage pattern, 'queue_work()' always returns true,
which implies that the ordering guarantees are valid and the work was
not already queued. Therefore, extra memory barriers are unnecessary.
Tested by executing over 1000 games to verify that the turn ordering
is always correct (i.e., strictly alternating between O and X).1 parent 04978e7 commit 3e60028
1 file changed
+0
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
292 | 292 | | |
293 | 293 | | |
294 | 294 | | |
295 | | - | |
296 | 295 | | |
297 | 296 | | |
298 | 297 | | |
299 | | - | |
300 | 298 | | |
301 | 299 | | |
302 | 300 | | |
| |||
0 commit comments