From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg0-f71.google.com (mail-pg0-f71.google.com [74.125.83.71]) by kanga.kvack.org (Postfix) with ESMTP id 0CC276B0268 for ; Mon, 27 Nov 2017 23:04:26 -0500 (EST) Received: by mail-pg0-f71.google.com with SMTP id s18so30813047pge.19 for ; Mon, 27 Nov 2017 20:04:26 -0800 (PST) Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id 59sor11193222plp.43.2017.11.27.20.04.24 for (Google Transport Security); Mon, 27 Nov 2017 20:04:25 -0800 (PST) From: zhouzhouyi@gmail.com Subject: [PATCH 1/1] kasan: fix livelock in qlist_move_cache Date: Tue, 28 Nov 2017 04:04:02 +0000 Message-Id: <1511841842-3786-1-git-send-email-zhouzhouyi@gmail.com> Sender: owner-linux-mm@kvack.org List-ID: To: aryabinin@virtuozzo.com, glider@google.com, dvyukov@google.com, kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Zhouyi Zhou From: Zhouyi Zhou This patch fix livelock by conditionally release cpu to let others has a chance to run. Tested on x86_64. Signed-off-by: Zhouyi Zhou --- mm/kasan/quarantine.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/mm/kasan/quarantine.c b/mm/kasan/quarantine.c index 3a8ddf8..33eeff4 100644 --- a/mm/kasan/quarantine.c +++ b/mm/kasan/quarantine.c @@ -265,10 +265,13 @@ static void qlist_move_cache(struct qlist_head *from, struct kmem_cache *cache) { struct qlist_node *curr; + struct qlist_head tmp_head; + unsigned long flags; if (unlikely(qlist_empty(from))) return; + qlist_init(&tmp_head); curr = from->head; qlist_init(from); while (curr) { @@ -278,10 +281,17 @@ static void qlist_move_cache(struct qlist_head *from, if (obj_cache == cache) qlist_put(to, curr, obj_cache->size); else - qlist_put(from, curr, obj_cache->size); + qlist_put(&tmp_head, curr, obj_cache->size); curr = next; + + if (need_resched()) { + spin_unlock_irqrestore(&quarantine_lock, flags); + cond_resched(); + spin_lock_irqsave(&quarantine_lock, flags); + } } + qlist_move_all(&tmp_head, from); } static void per_cpu_remove_cache(void *arg) -- 2.1.4 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org