linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V2]  staging: android: lowmemorykiller: imporve lmk to avoid deadlock issue
@ 2015-08-03  5:53 Wang, Biao
  2015-08-03  6:15 ` Dan Carpenter
  2015-08-03 14:06 ` Dave Hansen
  0 siblings, 2 replies; 5+ messages in thread
From: Wang, Biao @ 2015-08-03  5:53 UTC (permalink / raw)
  To: gregkh, arve, riandrews
  Cc: devel, linux-kernel, Zhang, Di, Li, Fei, dan.carpenter, joe

Consider the following case:
Task A trigger lmk with a lock held, while task B try to
get this lock, but unfortunately B is the very culprit task lmk select to
kill. Then B will never be killed, and A will forever select B to kill.
Such dead lock will trigger softlock up issue.

This patch try to pick the next task to break this loop.

Signed-off-by: Wang Biao <biao.wang@intel.com>
Reviewed-by: Zhang Di <di.zhang@intel.com>
Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Joe Perches <joe@perches.com>
---
 drivers/staging/android/lowmemorykiller.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/android/lowmemorykiller.c b/drivers/staging/android/lowmemorykiller.c
index feafa17..23d9832 100644
--- a/drivers/staging/android/lowmemorykiller.c
+++ b/drivers/staging/android/lowmemorykiller.c
@@ -127,9 +127,10 @@ static unsigned long lowmem_scan(struct shrinker *s, struct shrink_control *sc)
 		if (!p)
 			continue;
 
-		if (test_tsk_thread_flag(p, TIF_MEMDIE) &&
-		    time_before_eq(jiffies, lowmem_deathpending_timeout)) {
+		if (test_tsk_thread_flag(p, TIF_MEMDIE)) {
 			task_unlock(p);
+			if (time_after(jiffies, lowmem_deathpending_timeout)) 
+				continue;
 			rcu_read_unlock();
 			return 0;
 		}
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH V2]  staging: android: lowmemorykiller: imporve lmk to avoid deadlock issue
  2015-08-03  5:53 [PATCH V2] staging: android: lowmemorykiller: imporve lmk to avoid deadlock issue Wang, Biao
@ 2015-08-03  6:15 ` Dan Carpenter
  2015-08-03  7:16   ` Dan Carpenter
  2015-08-03  7:58   ` Joe Perches
  2015-08-03 14:06 ` Dave Hansen
  1 sibling, 2 replies; 5+ messages in thread
From: Dan Carpenter @ 2015-08-03  6:15 UTC (permalink / raw)
  To: Wang, Biao
  Cc: gregkh, arve, riandrews, devel, linux-kernel, Zhang, Di, Li, Fei, joe

On Mon, Aug 03, 2015 at 05:53:22AM +0000, Wang, Biao wrote:
> Consider the following case:
> Task A trigger lmk with a lock held, while task B try to
> get this lock, but unfortunately B is the very culprit task lmk select to
> kill. Then B will never be killed, and A will forever select B to kill.
> Such dead lock will trigger softlock up issue.
> 
> This patch try to pick the next task to break this loop.
> 
> Signed-off-by: Wang Biao <biao.wang@intel.com>
> Reviewed-by: Zhang Di <di.zhang@intel.com>
> Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>

I don't really feel comfortable saying I reviewed this code.  I just
commented on a few process issues.  I don't know the subsystem well
enough to give it a seal of approval.

> Reviewed-by: Joe Perches <joe@perches.com>

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH V2]  staging: android: lowmemorykiller: imporve lmk to avoid deadlock issue
  2015-08-03  6:15 ` Dan Carpenter
@ 2015-08-03  7:16   ` Dan Carpenter
  2015-08-03  7:58   ` Joe Perches
  1 sibling, 0 replies; 5+ messages in thread
From: Dan Carpenter @ 2015-08-03  7:16 UTC (permalink / raw)
  To: Wang, Biao
  Cc: gregkh, arve, riandrews, devel, linux-kernel, Zhang, Di, Li, Fei, joe

On Mon, Aug 03, 2015 at 09:15:56AM +0300, Dan Carpenter wrote:
> > Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> I don't really feel comfortable saying I reviewed this code.  I just
> commented on a few process issues.  I don't know the subsystem well
> enough to give it a seal of approval.
> 

Biao was asking off list, how to fix this.  I guess just leave it.  I
more care about going forward that we don't start doing this all the
time.

I recently added a reviewed-by tag for someone.  He told me off list
that the patch "looks OK".  He was the subsystem expert and we were
patching his code so it was his responsibility to review the fix.  If
the patch breaks everyone's system then he's absolutely the guy that I
want people to blame.  :)

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH V2]  staging: android: lowmemorykiller: imporve lmk to avoid deadlock issue
  2015-08-03  6:15 ` Dan Carpenter
  2015-08-03  7:16   ` Dan Carpenter
@ 2015-08-03  7:58   ` Joe Perches
  1 sibling, 0 replies; 5+ messages in thread
From: Joe Perches @ 2015-08-03  7:58 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Wang, Biao, gregkh, arve, riandrews, devel, linux-kernel, Zhang,
	Di, Li, Fei

On Mon, 2015-08-03 at 09:15 +0300, Dan Carpenter wrote:
> On Mon, Aug 03, 2015 at 05:53:22AM +0000, Wang, Biao wrote:
> > Consider the following case:
> > Task A trigger lmk with a lock held, while task B try to
> > get this lock, but unfortunately B is the very culprit task lmk 
> > select to
> > kill. Then B will never be killed, and A will forever select B to 
> > kill.
> > Such dead lock will trigger softlock up issue.
> > 
> > This patch try to pick the next task to break this loop.
> > 
> > Signed-off-by: Wang Biao <biao.wang@intel.com>
> > Reviewed-by: Zhang Di <di.zhang@intel.com>
> > Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> I don't really feel comfortable saying I reviewed this code.  I just
> commented on a few process issues.  I don't know the subsystem well
> enough to give it a seal of approval.
> 
> > Reviewed-by: Joe Perches <joe@perches.com>

Please don't say I reviewed this either.

I may have commented on it, but I certainly
did't add a "Reviewed-by" signature.

Please don't add signatures unless people
specifically state so.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH V2]  staging: android: lowmemorykiller: imporve lmk to avoid deadlock issue
  2015-08-03  5:53 [PATCH V2] staging: android: lowmemorykiller: imporve lmk to avoid deadlock issue Wang, Biao
  2015-08-03  6:15 ` Dan Carpenter
@ 2015-08-03 14:06 ` Dave Hansen
  1 sibling, 0 replies; 5+ messages in thread
From: Dave Hansen @ 2015-08-03 14:06 UTC (permalink / raw)
  To: Wang, Biao, gregkh, arve, riandrews
  Cc: devel, linux-kernel, Zhang, Di, Li, Fei, dan.carpenter, joe

On 08/02/2015 10:53 PM, Wang, Biao wrote:
> Consider the following case:
> Task A trigger lmk with a lock held, while task B try to
> get this lock, but unfortunately B is the very culprit task lmk select to
> kill. Then B will never be killed, and A will forever select B to kill.
> Such dead lock will trigger softlock up issue.

It would be interesting to have some actual data about where this helps.
 For instance, which locks does this happen on?  What kind of
allocation?  Also, we apparently _do_ mark a lowmemorykiller victim as
an oom victim and let them use memory reserves.  Why does that not allow
the allocation to complete at least long enough to get the kill signal
to the victim?

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-08-03 14:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-03  5:53 [PATCH V2] staging: android: lowmemorykiller: imporve lmk to avoid deadlock issue Wang, Biao
2015-08-03  6:15 ` Dan Carpenter
2015-08-03  7:16   ` Dan Carpenter
2015-08-03  7:58   ` Joe Perches
2015-08-03 14:06 ` Dave Hansen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).