* [PATCH] improve lmk to avoid deadlock issue
@ 2015-07-30 6:49 Wang, Biao
2015-07-30 10:09 ` Dan Carpenter
0 siblings, 1 reply; 3+ messages in thread
From: Wang, Biao @ 2015-07-30 6:49 UTC (permalink / raw)
To: gregkh@linuxfoundation.org, arve@android.com,
riandrews@android.com
Cc: devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org,
Zhang, Di, Li, Fei
From: "wang, biao" <biao.wang@intel.com>
Date: Thu, 30 Jul 2015 14:14:44 +0800
Subject: [PATCH] improve lmk to avoid deadlock issue
Consider the following case:
Task A trigger lmk with a lock held, while process B try to
get this lock, but unfortunately B is the very culprit Task lmk select to
kill.
So B will never be killed, and A will forever select B to kill and
such dead lock 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>
Signed-off-by: Zhang Di <di.zhang@intel.com>
---
drivers/staging/android/lowmemorykiller.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/drivers/staging/android/lowmemorykiller.c b/drivers/staging/android/lowmemorykiller.c
index feafa17..efabeb7 100644
--- a/drivers/staging/android/lowmemorykiller.c
+++ b/drivers/staging/android/lowmemorykiller.c
@@ -127,11 +127,15 @@ 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)) {
- task_unlock(p);
- rcu_read_unlock();
- return 0;
+ if (test_tsk_thread_flag(p, TIF_MEMDIE)) {
+ if (time_before_eq(jiffies, lowmem_deathpending_timeout)) {
+ task_unlock(p);
+ rcu_read_unlock();
+ return 0;
+ } else {
+ task_unlock(p);
+ continue;
+ }
}
oom_score_adj = p->signal->oom_score_adj;
if (oom_score_adj < min_score_adj) {
--
1.7.9.5
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] improve lmk to avoid deadlock issue
2015-07-30 6:49 [PATCH] improve lmk to avoid deadlock issue Wang, Biao
@ 2015-07-30 10:09 ` Dan Carpenter
2015-07-30 12:29 ` Joe Perches
0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2015-07-30 10:09 UTC (permalink / raw)
To: Wang, Biao
Cc: gregkh@linuxfoundation.org, arve@android.com,
riandrews@android.com, devel@driverdev.osuosl.org, Zhang, Di,
Li, Fei, linux-kernel@vger.kernel.org
I'm not an android dev but this patch seems reasonable enough. There
are some process issues though.
1) The subject should have a subsystem prefix:
[PATCH] Staing: android: lowmemorykiller: improve lmk to avoid deadlock issue
On Thu, Jul 30, 2015 at 06:49:53AM +0000, Wang, Biao wrote:
> From: "wang, biao" <biao.wang@intel.com>
> Date: Thu, 30 Jul 2015 14:14:44 +0800
> Subject: [PATCH] improve lmk to avoid deadlock issue
2) Don't put these lines in the patch.
>
> Consider the following case:
> Task A trigger lmk with a lock held, while process B try to
> get this lock, but unfortunately B is the very culprit Task lmk select to
> kill.
> So B will never be killed, and A will forever select B to kill and
> such dead lock 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>
3) Use capital letters for your name here. It should match your email
address.
> Signed-off-by: Zhang Di <di.zhang@intel.com>
4) Did Zhang write this patch? If so then add a From: tag at the top
of the email to give authorship credit. Signed-off-by tags mean that
the patch went through your hands somehow. Otherwise use the
Reviewed-by, Reported-by, or Acked-by tag whichever is appropriate.
> ---
> drivers/staging/android/lowmemorykiller.c | 14 +++++++++-----
> 1 file changed, 9 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/staging/android/lowmemorykiller.c b/drivers/staging/android/lowmemorykiller.c
> index feafa17..efabeb7 100644
> --- a/drivers/staging/android/lowmemorykiller.c
> +++ b/drivers/staging/android/lowmemorykiller.c
> @@ -127,11 +127,15 @@ 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)) {
> - task_unlock(p);
> - rcu_read_unlock();
> - return 0;
> + if (test_tsk_thread_flag(p, TIF_MEMDIE)) {
> + if (time_before_eq(jiffies, lowmem_deathpending_timeout)) {
5) This goes over the 80 character limit. Could you break it up like
this:
if (test_tsk_thread_flag(p, TIF_MEMDIE)) {
if (time_before_eq(jiffies,
lowmem_deathpending_timeout)) {
task_unlock(p);
Anyway, thank for this patch. Please fix these small process issues
and resend.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] improve lmk to avoid deadlock issue
2015-07-30 10:09 ` Dan Carpenter
@ 2015-07-30 12:29 ` Joe Perches
0 siblings, 0 replies; 3+ messages in thread
From: Joe Perches @ 2015-07-30 12:29 UTC (permalink / raw)
To: Dan Carpenter
Cc: Wang, Biao, gregkh@linuxfoundation.org, arve@android.com,
riandrews@android.com, devel@driverdev.osuosl.org, Zhang, Di,
Li, Fei, linux-kernel@vger.kernel.org
On Thu, 2015-07-30 at 13:09 +0300, Dan Carpenter wrote:
> > diff --git a/drivers/staging/android/lowmemorykiller.c b/drivers/staging/android/lowmemorykiller.c
[]
> > @@ -127,11 +127,15 @@ 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)) {
> > - task_unlock(p);
> > - rcu_read_unlock();
> > - return 0;
> > + if (test_tsk_thread_flag(p, TIF_MEMDIE)) {
> > + if (time_before_eq(jiffies, lowmem_deathpending_timeout)) {
>
> 5) This goes over the 80 character limit. Could you break it up like
> this:
>
> if (test_tsk_thread_flag(p, TIF_MEMDIE)) {
> if (time_before_eq(jiffies,
> lowmem_deathpending_timeout)) {
> task_unlock(p);
>
> Anyway, thank for this patch. Please fix these small process issues
> and resend.
Can the task_unlock in each branch be hoisted?
Another way to write this might be to use time_after:
if (test_tsk_thread_flag(p, TIF_MEMDIE)) {
task_unlock(p);
if (time_after(jiffies, lowmem_deathpending_timeout))
continue;
rcu_read_unlock();
return 0;
}
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-07-30 12:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-30 6:49 [PATCH] improve lmk to avoid deadlock issue Wang, Biao
2015-07-30 10:09 ` Dan Carpenter
2015-07-30 12:29 ` Joe Perches
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox