ib-release-locks-in-the-proper-order
PATCH 1/1 ib-release-locks-in-the-proper-order
Please consider the following patch - originally from Steven Rostedt. It solves a problem for rt which is very sensitive to the lock ordering. It should have a no impact on non-rt.
The patch applies to current tip/master - but it is fine with me if it would be more appropriate for one of the infiniband people to take it.
Thanks
Quoted 1 line
From
e533f2b9ee9b0bd95aaa4c3369e79b350c9895d3Mon Sep 17 00:00:00 2001
From: Steven Rostedt <[email protected]>
Date: Mon, 21 Sep 2009 21:23:46 +0200
Subject: [PATCH] ib: release locks in the proper order
RT is very sensitive to the order locks are taken and released wrt read write locks. We must do
lock(a); lock(b); lock(c);
[...]
unlock(c); unlock(b); unlock(a);
otherwise bad things can happen.
--- drivers/infiniband/core/uverbs_cmd.c | 20 ++++++++++---------- 1 files changed, 10 insertions(+), 10 deletions(-)
drivers/infiniband/core/uverbs_cmd.c +10 -10
@@ -1116,12 +1116,12 @@ ssize_t ib_uverbs_create_qp(struct ib_uverbs_file *file, goto err_copy; } -put_pd_read (pd); -put_cq_read (scq); -if (rcq != scq) -put_cq_read (rcq);if (srq)put_srq_read (srq); +if (rcq != scq) +put_cq_read (rcq); +put_cq_read (scq); +put_pd_read (pd);mutex_lock (&file->mutex);list_add_tail (&obj->uevent.uobject.list, &file->ucontext->qp_list);
@@ -1140,14 +1140,14 @@ err_destroy:ib_destroy_qp (qp); err_put: -if (pd) -put_pd_read (pd); -if (scq) -put_cq_read (scq); -if (rcq && rcq != scq) -put_cq_read (rcq);if (srq)put_srq_read (srq); +if (rcq && rcq != scq) +put_cq_read (rcq); +if (scq) +put_cq_read (scq); +if (pd) +put_pd_read (pd);put_uobj_write (&obj->uevent.uobject);return ret;
Signature · 1 line
1.6.0.6
Quoted 27 lines · John Kacur
Please consider the following patch - originally from Steven Rostedt. It solves a problem for rt which is very sensitive to the lock ordering. It should have a no impact on non-rt.
The patch applies to current tip/master - but it is fine with me if it would be more appropriate for one of the infiniband people to take it.
Thanks
Quoted 1 line
From
e533f2b9ee9b0bd95aaa4c3369e79b350c9895d3Mon Sep 17 00:00:00 2001From: Steven Rostedt <[email protected]>
Date: Mon, 21 Sep 2009 21:23:46 +0200
Subject: [PATCH] ib: release locks in the proper orderRT is very sensitive to the order locks are taken and released wrt read write locks. We must do
lock(a); lock(b); lock(c);[...]
unlock(c); unlock(b); unlock(a);
Quoted 5 lines
otherwise bad things can happen.
Signed-off-by Ken Cox <[email protected]>Signed-off-by Clark Williams <[email protected]>Signed-off-by John Kacur <[email protected]>
The -rt patch doesn't use the multi rwlock code anymore (the reason for the first patch), and the last revision of that code was able to handle that too.
Linus totally ripped into this idea. A lock must be able to handle any order of unlocking. There should be no technical reason a lock must be unlocked in reverse order they were locked.
What exactly is sensitive about this?
-- Steve
Quoted 45 lines · ----- "Steven Rostedt
Quoted 1 line · John Kacur
Please consider the following patch - originally from Steven
Rostedt.
Quoted 1 line
It solves a problem for rt which is very sensitive to the lock
ordering.
Quoted 3 lines
It should have a no impact on non-rt.
The patch applies to current tip/master - but it is fine with me if
it
Quoted 1 line
would be more appropriate for one of the infiniband people to take
it.
Quoted 4 lines
Thanks
Quoted 1 line
From
e533f2b9ee9b0bd95aaa4c3369e79b350c9895d3Mon Sep 17 00:00:002001
Quoted 17 lines
From: Steven Rostedt <[email protected]>
Date: Mon, 21 Sep 2009 21:23:46 +0200
Subject: [PATCH] ib: release locks in the proper orderRT is very sensitive to the order locks are taken and released wrt read write locks. We must do
lock(a); lock(b); lock(c);[...]
unlock(c); unlock(b); unlock(a);Quoted 5 lines
otherwise bad things can happen.
Signed-off-by Ken Cox <[email protected]>Signed-off-by Clark Williams <[email protected]>Signed-off-by John Kacur <[email protected]>The -rt patch doesn't use the multi rwlock code anymore (the reason for
the first patch), and the last revision of that code was able to handle
that too.
Quoted 8 lines
Linus totally ripped into this idea. A lock must be able to handle any
order of unlocking. There should be no technical reason a lock must be
unlocked in reverse order they were locked.What exactly is sensitive about this?
Thanks Steve!
I hereby withdraw this patch!!!!