Skip to contentSkip to conversation

nvme: fix the placement of set_current_state to TASK_INTERRUPTIBLE

PATCH New Matthew Wilcox 2 participants 2 messages Feb 19, 2013 1 message not in the archive NVMe

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 2/2 nvme: fix the placement of set_current_state to TASK_INTERRUPTIBLE

Quoted 11 lines · Arjan van de Ven

the nvme driver has a kthread that processes certain events periodically. However, the kthread also gets woken for certain urgent actions.

The current code does not use the current_state logic correctly; it calls set_current_state(TASK_INTERRUPTIBLE); right before doing a schedule_timeout(), with the result that there is a race condition where a wakeup can get lost, and thus delayed by one second.

This patch moves the set_current_state(TASK_INTERRUPTIBLE); to before the place where the queue of outstanding work is checked, to close the race condition

The thing is, that's not a queue of outstanding work, that's the list of devices that exist in the system. Your patch makes the kthread do all of its work in the TASK_INTERRUPTIBLE state, which I don't think is right either (is it?)

We could add a flag to indicate that there's urgent work to be done (checked after setting TASK_INTERRUPTIBLE), or just live with the occasional race.

Alternatively, we could get rid of the kthread in favour of timers for cancelling commands and a workqueue for dealing with urgent work. I have this on my long-term todo list, but in the absence of having hardware to test with on large-scale systems, I didn't want to make such a large change.

#2 lore raw

PATCH 2/2 nvme: fix the placement of set_current_state to TASK_INTERRUPTIBLE

Quoted 9 lines · Matthew Wilcox
Quoted 8 lines · Arjan van de Ven

the nvme driver has a kthread that processes certain events periodically. However, the kthread also gets woken for certain urgent actions.

The current code does not use the current_state logic correctly; it calls set_current_state(TASK_INTERRUPTIBLE); right before doing a schedule_timeout(), with the result that there is a race condition where a wakeup can get lost, and thus delayed by one second.

Quoted 8 lines
Quoted 3 lines

This patch moves the set_current_state(TASK_INTERRUPTIBLE); to before the place where the queue of outstanding work is checked, to close the race condition

The thing is, that's not a queue of outstanding work, that's the list of devices that exist in the system. Your patch makes the kthread do all of its work in the TASK_INTERRUPTIBLE state, which I don't think is right either (is it?)

eh why not?
it counts to load average, but frankly, you're using CPU... you count anyway