Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753853AbbG3GuE (ORCPT ); Thu, 30 Jul 2015 02:50:04 -0400 Received: from mga01.intel.com ([192.55.52.88]:55649 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751024AbbG3GuD convert rfc822-to-8bit (ORCPT ); Thu, 30 Jul 2015 02:50:03 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,575,1432623600"; d="scan'208";a="758184198" From: "Wang, Biao" To: "gregkh@linuxfoundation.org" , "arve@android.com" , "riandrews@android.com" CC: "devel@driverdev.osuosl.org" , "linux-kernel@vger.kernel.org" , "Zhang, Di" , "Li, Fei" Subject: [PATCH] improve lmk to avoid deadlock issue Thread-Topic: [PATCH] improve lmk to avoid deadlock issue Thread-Index: AdDKk55Mcs0kwC8jTcKguG1aGXOi5g== Date: Thu, 30 Jul 2015 06:49:53 +0000 Message-ID: <09CB0B4607EB8F4DB7E0BE3B06BFBD051DA2DCAB@SHSMSX101.ccr.corp.intel.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1774 Lines: 51 From: "wang, biao" 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 Signed-off-by: Zhang Di --- 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/