add execute_in_process_context() API
A message that is not in the archive (sent off-list or not yet received): 1139342419.6065.8.camel@mulgrave.il.steeleye.com.suse.lists.linux.kernel
James Bottomley <[email protected]> writes:
In general this seems like a lot of code for a simple problem. It might be simpler to just put the work structure into the parent object and do the workqueue unconditionally
Review
Quoted 3 lines
(quoted diff) +3
-0+ if (unlikely(!wqw)) { + printk(KERN_ERR "Failed to allocate memory\n"); + WARN_ON(1);
WARN_ON for GFP_ATOMIC failure is bad. It is not really a bug.
-Andi
Quoted 7 lines · Andi Kleen
James Bottomley <[email protected]> writes:
In general this seems like a lot of code for a simple problem. It might be simpler to just put the work structure into the parent object and do the workqueue unconditionally
That apparently would have really bad performance problems. If we're !in_interrupt() we want to do the work synchronously.
But yes, if we can embed the work_struct inside the structure which the callback will operate on
Quoted 5 lines
Review
Quoted 3 lines
(quoted diff) +3
-0+ if (unlikely(!wqw)) { + printk(KERN_ERR "Failed to allocate memory\n"); + WARN_ON(1);
WARN_ONforGFP_ATOMICfailure is bad. It is not really a bug.
it will solve this problem. (And I think is is a problem: if the allocation fails, we leak things?)
Quoted 11 lines · Andrew Morton
Quoted 7 lines · Andi Kleen
James Bottomley <[email protected]> writes:
In general this seems like a lot of code for a simple problem. It might be simpler to just put the work structure into the parent object and do the workqueue unconditionally
That apparently would have really bad performance problems. If we're !in_interrupt() we want to do the work synchronously.
It depends if it's common or not. If it's uncommon then simpler code is better.
-Andi
Quoted 3 lines · Andi Kleen
In general this seems like a lot of code for a simple problem. It might be simpler to just put the work structure into the parent object and do the workqueue unconditionally
We can't do this. For the target release, there may be multiple calls to the reap function ... if we embed in the structure we have no room for more than one.
Quoted 5 lines
Review
Quoted 3 lines
(quoted diff) +3
-0+ if (unlikely(!wqw)) { + printk(KERN_ERR "Failed to allocate memory\n"); + WARN_ON(1);
WARN_ONforGFP_ATOMICfailure is bad. It is not really a bug.
Here, it means that the requested work wasn't executed. In SCSI that would mean an object is now in place permanently. The problem is that there's no real way to cope with failure in this case.
James
Quoted 2 lines · James Bottomley
The problem is that
there's no real way to cope with failure in this case.
Then you can't use GFP_ATOMIC. You have to redesign.
-Andi
Quoted 5 lines · Andi Kleen
Quoted 2 lines · James Bottomley
The problem is that
there's no real way to cope with failure in this case.Then you can't use
GFP_ATOMIC. You have to redesign.
My mailer seems to have deleted the part of the email with your redesign suggestion in it...
My initial point is that the current scsi_reap_target() infrastructure is more broken than the new API, so it does represent an improvement. I could also mitigate (but not solve) the problem by adding a wqw slab. However, I really think the redesign would be along the lines I suggested to Jens; do you agree?
James
Quoted 5 lines · James Bottomley
Quoted 4 lines · Andi Kleen
Quoted 2 lines · James Bottomley
The problem is that
there's no real way to cope with failure in this case.
Quoted 7 lines
Quoted 1 line
Then you can't use
GFP_ATOMIC. You have to redesign.My mailer seems to have deleted the part of the email with your redesign suggestion in it...
My initial point is that the current
scsi_reap_target()infrastructure is more broken than the new API, so it does represent an improvement.
An improvement that will randomly fail under high load.
-Andi
Quoted 19 lines · James Bottomley
Quoted 3 lines · Andi Kleen
In general this seems like a lot of code for a simple problem. It might be simpler to just put the work structure into the parent object and do the workqueue unconditionally
We can't do this. For the target release, there may be multiple calls to the reap function ... if we embed in the structure we have no room for more than one.
Quoted 5 lines
Review
Quoted 3 lines
(quoted diff) +3
-0+ if (unlikely(!wqw)) { + printk(KERN_ERR "Failed to allocate memory\n"); + WARN_ON(1);
WARN_ONforGFP_ATOMICfailure is bad. It is not really a bug.
Quoted 4 lines
Here, it means that the requested work wasn't executed. In SCSI that would mean an object is now in place permanently. The problem is that there's no real way to cope with failure in this case.
Hi, James.
I haven't really looked at the code carefully, but I think one work struct + atomic counter (say pending_reap_cnt) should do it. queue_work() guarantees the work is run at least once after the call, so bumping pending_reap_cnt and queueing the work in target reap and reaping pending_reap_cnt times in the work should work.
Signature · 1 line
tejun
Quoted 5 lines · Tejun
I haven't really looked at the code carefully, but I think one work struct + atomic counter (say
pending_reap_cnt) should do it.queue_work()guarantees the work is run at least once after the call, so bumpingpending_reap_cntand queueing the work in target reap and reapingpending_reap_cnttimes in the work should work.
Actually, no, unfortunately that doesn't work (and I did actually try it). The problem is that the target_reap actually removes the target from the sysfs namespace. So, if the reap is still pending but you cannot find the target, you'll allocate one, but then you may be racing to add it to the namespace (i.e. a quick succession of scsi remove-single-device followed by scsi add-single-device of the same H/C/T/L shows this). If you lose the race, the add fails because the namespace is already occupied. And, unfortunately, the device_del that does the namespace removal requires user context ...
James