all: fix race on wakeup

This commit is contained in:
Thomas Schoebel-Theuer 2020-01-29 09:42:43 +01:00
parent bc0be4fd19
commit 2c19adc550
3 changed files with 15 additions and 9 deletions

View File

@ -30,26 +30,32 @@
#define brick_wait(wq, flag, condition, timeout) \
({ \
unsigned long __tmout = (timeout); \
int __old_flag; \
\
might_sleep(); \
(flag) = false; \
smp_wmb(); \
smp_rmb(); \
__old_flag = (flag); \
\
while (!(condition)) { \
int __new_flag; \
\
__tmout = wait_event_interruptible_timeout( \
wq, \
({ smp_rmb(); (flag); }), \
({ smp_rmb(); \
__new_flag = (flag); \
__old_flag != __new_flag; }), \
__tmout); \
if (__tmout <= 1) \
break; \
(flag) = false; \
smp_wmb(); \
__old_flag = __new_flag; \
} \
__tmout; \
})
#define brick_wake(wq, flag) \
({ \
(flag) = true; \
smp_rmb(); \
(flag)++; \
smp_wmb(); \
wake_up_interruptible_all(wq); \
})

View File

@ -253,7 +253,7 @@ int log_scan(void *buf, int len, loff_t file_pos, int file_offset, bool sloppy,
struct log_status {
// interfacing
wait_queue_head_t *signal_event;
bool *signal_flag;
int *signal_flag;
// tunables
loff_t start_pos;
loff_t end_pos;

View File

@ -240,9 +240,9 @@ struct trans_logger_brick {
// queues
struct logger_queue q_phase[LOGGER_QUEUES];
struct rank_data rkd[LOGGER_QUEUES];
int caller_flag;
int worker_flag;
bool delay_callers;
bool caller_flag;
bool worker_flag;
/* termination */
bool terminate;
bool terminated;