Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752612AbbHCFx3 (ORCPT ); Mon, 3 Aug 2015 01:53:29 -0400 Received: from mga02.intel.com ([134.134.136.20]:7006 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751957AbbHCFx2 convert rfc822-to-8bit (ORCPT ); Mon, 3 Aug 2015 01:53:28 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,599,1432623600"; d="scan'208";a="740920438" 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" , "dan.carpenter@oracle.com" , "joe@perches.com" Subject: [PATCH V2] staging: android: lowmemorykiller: imporve lmk to avoid deadlock issue Thread-Topic: [PATCH V2] staging: android: lowmemorykiller: imporve lmk to avoid deadlock issue Thread-Index: AdDNrvBjoeWu+3AYT6CvP0qnhyjCsg== Date: Mon, 3 Aug 2015 05:53:22 +0000 Message-ID: <09CB0B4607EB8F4DB7E0BE3B06BFBD051DA2E849@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: 1537 Lines: 41 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 Reviewed-by: Zhang Di Reviewed-by: Dan Carpenter Reviewed-by: Joe Perches --- 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 -- 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/