Am Mo, den 16.02.2004 schrieb Jeff Garzik um 03:10:
+ /*
+ * if additional pages cannot be allocated without waiting,
+ * return a partially allocated bio, the caller will then try
+ * to allocate additional bios while submitting this partial bio
+ */
+ if ((i - bio->bi_idx) == (MIN_BIO_PAGES - 1))
+ gfp_mask = (gfp_mask | __GFP_NOWARN) & ~__GFP_WAIT;
If the caller said they can wait, why not wait?
How can the caller say this?
+ set_task_state(current, TASK_INTERRUPTIBLE);
+ while (!(bio = kcryptd_get_bios())) {
+ schedule();
+ if (signal_pending(current))
+ return 0;
+ }
+ set_task_state(current, TASK_RUNNING);
You just keep calling schedule() rapid-fire until you get a bio? That's a bit sub-optimal.
That's wrong anyway. I was just making sure I was calling
kcryptd_get_bios after schedule. schedule() will sleep and woken after
someone added a bio to the list.
I've changed it to an if now and call kcryptd_get_bios after schedule.
I'm calling it twice because it is likely that someone started a new
list while the old list is being processed and I don't want to sleep in
this case, just fall through.
The kcryptd_get_bios needs to be after state = TASK_INTERRUPTIBLE to
avoid a race. If someone wakes the process after kcryptd_get_bios but
before schedule it resets the state to TASK_RUNNING so that the schedule
won't sleep.