Received: by 10.223.164.202 with SMTP id h10csp2563498wrb; Mon, 27 Nov 2017 20:06:57 -0800 (PST) X-Google-Smtp-Source: AGs4zMauOsJ/2pd6mibc96iIL7XBxo4ydsq4nM2OJ65kqqJsy2H7TLZayCjkA45UPWDDiQj2Zc0A X-Received: by 10.159.218.72 with SMTP id x8mr41545858plv.257.1511842017892; Mon, 27 Nov 2017 20:06:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511842017; cv=none; d=google.com; s=arc-20160816; b=JtcyCJaYw9lNCPgXxRoXbbnpWxWr+bNNDT5bE4OrYE0hRmju0WcMienrT7o5HqX0fc elqRnFWhYPb1FlHe4QsIG68mYw4m5KFd5ttTVhq+K8Q9LydMhNz0F/MssuXAy3cp8hrE PCVSgKkSU/i8RXS2TQG8gmwn6E1xaZ0E4Mx9rENn9CRALTh2mm+PZ6WKZsiZ4BSEYtfs kIuKmbhg/+R5CDxldAj0OOUl+bjn4XXrF2UUnLYvURU8gk46rCOMckyu0ozZY0tjaljP HGaVhQ/rqFjKbmhiuys40eCjYx5QxocDEr5gtZASdFmpgY1fZwrIfikR66TNkmUMMYEB nN8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=xyFNxOSdCKp+75TTqur+KcLmM11R9ZgmX/ndKVEbC7M=; b=E45dDcCIczErbdPwXjSm+kDLnJh34+lXT4OzEPCDxQgdnIMtdoBZRrnsABSno5YAaF YlNw0qMfSvW8pkknQZKMFj/i5GB4NioJoNVvbtm4n5yBz8y5RT8FTB9L8h2X1huOkyP0 LZp3vdvKbU9nPf2nODHHiM8OuU5K/9bKVkjne0Q7uF/adg2bjH3YdRMjiquL61JX8Jmu 4T0SDB+suT6gHTjulkGLzvE6b5AklzViKtlBph2u9yF+LkE6b5Ukb0mSCDl3foQsiR/K PPhRqnYB+0MBkgHbZVjxixcf/GI3PzZAoh5C5Rn3/lMSsb1Xf3VJZZp8LjcNpvAArbs+ Y+3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=nRqNxe7Q; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w5si16452840pgm.49.2017.11.27.20.06.45; Mon, 27 Nov 2017 20:06:57 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=nRqNxe7Q; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752585AbdK1EF7 (ORCPT + 77 others); Mon, 27 Nov 2017 23:05:59 -0500 Received: from mail-it0-f68.google.com ([209.85.214.68]:44698 "EHLO mail-it0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751859AbdK1EF6 (ORCPT ); Mon, 27 Nov 2017 23:05:58 -0500 Received: by mail-it0-f68.google.com with SMTP id b5so23925793itc.3 for ; Mon, 27 Nov 2017 20:05:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=xyFNxOSdCKp+75TTqur+KcLmM11R9ZgmX/ndKVEbC7M=; b=nRqNxe7QqYYxsU4azLC63gUVsHSaQadxxM7sDbYrXPSi5Nohz4Q0w1WdYK347PuWJ5 2eVbbWodUDaLh6etxwAS6YqiMBq0cEl7DzzXrL/j1sLARnwR19N+AJ5JYLEARNirBzCe ewMbivChmAMSLc7jWAbvMFbAOk+TL/94Myqx1u64Jg1yeOIOmzMXGC+XDmA7MluHPc+G BILI0tk0y03T5Dp8dCuLYd8Y1Z7nrN/83osJOawRj9IMX8NWdEnIEQjt0P/iQWMcWL5x AyHezJJScGCKVXQdzEswkXg+pkRA8Vqg/plcmwrm7qEV6XCfac27hsjPjELgXhDspzVw YrwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=xyFNxOSdCKp+75TTqur+KcLmM11R9ZgmX/ndKVEbC7M=; b=fo/HF04u1eBFK8VoE4MoR3awSjTjS+L4Fb+vM8Ng1Oz3ySc3xwcncucYuqk+GFUhEN F4ReKGDwzxPtojS/m0Ag89Y4QV+NxSsdr3sWGI7LN/L5Ot3+HOphgY1IjWgZi2/swIwX gVjOdNxN2Q4cjWJzWLiYkv2ba7GUAZCdeJrq3DkDEXMYeBpZYlmXX9uVorjvos1pHDvZ JHOfoc4lSS+FZPmc8XOpPekl+bDYlj+P4SxPjxEh8fnrLOc1kJQ5fioLMYAMSybf/27N h7A7uy+DVYmQ7Mbz1ajdE+ijvTEFRKZR2BIGowxY4onauZ00fp7DbLZ+SBT9dpL7BcLJ fsGg== X-Gm-Message-State: AJaThX4Q21PoyzUdxtuu7GHTlzBo4FF2mG2cZjHc7b/XmZOgEjjNm/40 0xUcU/QmU5wpoUDJCxU+iIGr1tuMwCpo+7Pcwcs= X-Received: by 10.36.218.6 with SMTP id z6mr737577itg.24.1511841957377; Mon, 27 Nov 2017 20:05:57 -0800 (PST) MIME-Version: 1.0 Received: by 10.107.5.21 with HTTP; Mon, 27 Nov 2017 20:05:56 -0800 (PST) In-Reply-To: <1511841842-3786-1-git-send-email-zhouzhouyi@gmail.com> References: <1511841842-3786-1-git-send-email-zhouzhouyi@gmail.com> From: Zhouyi Zhou Date: Tue, 28 Nov 2017 12:05:56 +0800 Message-ID: Subject: Re: [PATCH 1/1] kasan: fix livelock in qlist_move_cache To: aryabinin@virtuozzo.com, Alexander Potapenko , Dmitry Vyukov , kasan-dev@googlegroups.com, linux-mm@kvack.org, "linux-kernel@vger.kernel.org" Cc: Zhouyi Zhou Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When there are huge amount of quarantined cache allocates in system, number of entries in global_quarantine[i] will be great. Meanwhile, there is no relax in while loop in function qlist_move_cache which hold quarantine_lock. As a result, some userspace programs for example libvirt will complain. On Tue, Nov 28, 2017 at 12:04 PM, wrote: > 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 > From 1585281151451498932@xxx Tue Nov 28 04:05:18 +0000 2017 X-GM-THRID: 1585281151451498932 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread