Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp96153img; Thu, 21 Mar 2019 15:02:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqwmiiWPXS8VenQwxhQn0C3YjShvyU0+Ux/xSxvrHWtkRQJD0JdlkNORRiMornH1Kw7mhiOf X-Received: by 2002:a17:902:3a5:: with SMTP id d34mr5687940pld.174.1553205737474; Thu, 21 Mar 2019 15:02:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553205737; cv=none; d=google.com; s=arc-20160816; b=kxeCHfFAAL2QvZ8X26cwGxedA48bn2PQuXpzwa8kzRATV9InSLN4siTNK0agdcrCwx zhYaRlhcL7ixbmQv7qq6XWLyInQFWIA7lCJTpt8kMcESWD0gPz3etZfO8TNhHwO3Wztb gSWEf8hGdLAUpd9QdzzT8G1Q1Ic3cohcLn/3NzROsdiiNBIktdOCDzfMdVbQ1qh3bl9/ ReP8Z6+fhpE4rJ4v6kVrDS+THjNsXnCS0zzvQZD00k11H3k0DjFNrQUmYFpRs01z2Gkf S8qz8qYHUssjbc9iuKr/aF/AOyhCMRDa9ddanVHz7na1OgejoZTuqi0XZULhIXNAcb8I U1OA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=JVdztBDJcSey0QI9UZ8uSOMuJf9GvmkjJ47WwH+ajqs=; b=Vc6s7/NSI6382Y9Wwwc5b9Rgi2lgrDZDQWkqyrHZG0oECNIyKJ4ihHM63+PMdBQODx h+5cf77KPt+gLMbjHDOALWfBLr8GTE2YW/XDjdaZX6gkBwenYc8sCjVgKmiHsnfnFLB9 evTUobcqMcnwYv7wpTjE+6MUBoUhgARI2TTXp/7+HPcP0hf1vpf3zi7PWVMK+mMTCASb kjzwLcEs2f9WzVh1H9nwpMjCk3KEK6Hs78A86oO9zDyhGdC3+tpkfwxiDHrPRdK/4Fqx cSnewLGWas623NIsOeALB3zCjCfSZcRjr4DTKw5NT2WkwrFiGnIvxatW/PwljmJEBqSO KyWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=pSWHajQs; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n16si2461665pgb.274.2019.03.21.15.02.02; Thu, 21 Mar 2019 15:02:17 -0700 (PDT) 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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=pSWHajQs; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727433AbfCUWAu (ORCPT + 99 others); Thu, 21 Mar 2019 18:00:50 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:37608 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727246AbfCUWAu (ORCPT ); Thu, 21 Mar 2019 18:00:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=JVdztBDJcSey0QI9UZ8uSOMuJf9GvmkjJ47WwH+ajqs=; b=pSWHajQsPC7Dnpe2r+iQ7C2or UFxfv/su+iL/pKAP1gL41nDsBFsAb+DZM7b3AC8jaWN1Nbr6zTLE4rlY7vXWA6ShCSc+lKp24ZqUG qhRw/NfaVJZq1G/CZ36bCkP/M+xVdDArAkWcgTFPjD32YIh0KrgZKLFiUJQHkaz2C83VSRMMOm2GV D2jvftVr170zAbhGkv4lfpzXvHNnGDd0q40AKVeo7vgk2svIcocNRSlzTKx1GjXiti2EhTXA7ASG4 6fLbS8rQB6J+iUyMkw9PqSK7xGSs6ue2cucX/lcfS8l9qu+ffGrvUpFoYiWLToHMAzHZhgA5KgGNU 6C1Eh4s7w==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=worktop.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1h75jr-0001Fe-Im; Thu, 21 Mar 2019 22:00:40 +0000 Received: by worktop.programming.kicks-ass.net (Postfix, from userid 1000) id 737E7984EEA; Thu, 21 Mar 2019 23:00:35 +0100 (CET) Date: Thu, 21 Mar 2019 23:00:35 +0100 From: Peter Zijlstra To: Waiman Long Cc: Andrew Morton , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , linux-kernel@vger.kernel.org, linux-mm@kvack.org, selinux@vger.kernel.org, Paul Moore , Stephen Smalley , Eric Paris , Oleg Nesterov Subject: Re: [PATCH 4/4] mm: Do periodic rescheduling when freeing objects in kmem_free_up_q() Message-ID: <20190321220035.GF7905@worktop.programming.kicks-ass.net> References: <20190321214512.11524-1-longman@redhat.com> <20190321214512.11524-5-longman@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190321214512.11524-5-longman@redhat.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 21, 2019 at 05:45:12PM -0400, Waiman Long wrote: > If the freeing queue has many objects, freeing all of them consecutively > may cause soft lockup especially on a debug kernel. So kmem_free_up_q() > is modified to call cond_resched() if running in the process context. > > Signed-off-by: Waiman Long > --- > mm/slab_common.c | 11 ++++++++++- > 1 file changed, 10 insertions(+), 1 deletion(-) > > diff --git a/mm/slab_common.c b/mm/slab_common.c > index dba20b4208f1..633a1d0f6d20 100644 > --- a/mm/slab_common.c > +++ b/mm/slab_common.c > @@ -1622,11 +1622,14 @@ EXPORT_SYMBOL_GPL(kmem_free_q_add); > * kmem_free_up_q - free all the objects in the freeing queue > * @head: freeing queue head > * > - * Free all the objects in the freeing queue. > + * Free all the objects in the freeing queue. The caller cannot hold any > + * non-sleeping locks. > */ > void kmem_free_up_q(struct kmem_free_q_head *head) > { > struct kmem_free_q_node *node, *next; > + bool do_resched = !in_irq(); > + int cnt = 0; > > for (node = head->first; node; node = next) { > next = node->next; > @@ -1634,6 +1637,12 @@ void kmem_free_up_q(struct kmem_free_q_head *head) > kmem_cache_free(node->cachep, node); > else > kfree(node); > + /* > + * Call cond_resched() every 256 objects freed when in > + * process context. > + */ > + if (do_resched && !(++cnt & 0xff)) > + cond_resched(); Why not just: cond_resched() ? > } > } > EXPORT_SYMBOL_GPL(kmem_free_up_q); > -- > 2.18.1 >