Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp87174img; Thu, 21 Mar 2019 14:47:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqxLMUMaFGQLagSVloBB/CmYGC//WQzLJzgb7s25lyiLaOWXvtuzpaWbKBMRLJ2LZpcv7jmt X-Received: by 2002:a65:628f:: with SMTP id f15mr5560401pgv.410.1553204820285; Thu, 21 Mar 2019 14:47:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553204820; cv=none; d=google.com; s=arc-20160816; b=00NrPHLWpKCpr/deuhFs8cUYNSHkPQcbAZtFh9oRtJbRUrVby4+WQUuw/N6QV743Sh LdLp9QlyAldAvOOfJAiqzKaOqEarrh6WBPQjyPLVmHMgZ+2diBchYlBvBPq3DEmfyYe7 XB6H8ho6GLMyDcN+69LjtLJgMO4Vp0o7+gA9da9l9ST1XYsgUcOfoFIbHr9+xXCXVzie 0STG+MgfEw4uOTsg9S+YJicOmoTWrAQMd+EM6Cc1cKBaaEl0GrngW0p7ncigmdbTBp61 MaoWb2ANDQIJ8+pyGJhWsNiAF94o3ZeAnekaPFi/ofsHlGPf4eBydwxTM0FZ9SH6jOad Cf0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=Y4YszG8UJ+yJH47v3WLGgBXhW0qq+XiWeAF5pYJLxlk=; b=VDR/ZYHu7BUPV/qNhDkRPrtpDkqzIRZEye3kfouFiKSlnNaQZxXpJvMmXcGdLOOhV9 SyC+7ss5fS98jCCUGeslW5LCRfes3nA4XSSNg2DNe+uxhygyesM7HLUY8Ky92YTbfStY w8by2QG/ZnyxeORgCYKBipVolQu3N2h9sNAG/zRx1skifHSHlf1ukkxpTGmwkAnGMRwt yCP6YjrlUoYGWriGqJALxwA2hp1FZTEDtZ1XwmE62Ytxt8/jHPljyUaSTGaqZmG5wn5U u08mBMqFWI4am05ShSlzwXHRxTplwyIfPUBihpBqLGsfwdKFvi+cR8ufvSUCGqpeqjuE pZMQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 7si1195517pfh.34.2019.03.21.14.46.41; Thu, 21 Mar 2019 14:47:00 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727304AbfCUVpq (ORCPT + 99 others); Thu, 21 Mar 2019 17:45:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:61443 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725962AbfCUVpo (ORCPT ); Thu, 21 Mar 2019 17:45:44 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BC171C00735D; Thu, 21 Mar 2019 21:45:43 +0000 (UTC) Received: from llong.com (dhcp-17-47.bos.redhat.com [10.18.17.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 013D75C659; Thu, 21 Mar 2019 21:45:40 +0000 (UTC) From: Waiman Long To: Andrew Morton , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, selinux@vger.kernel.org, Paul Moore , Stephen Smalley , Eric Paris , "Peter Zijlstra (Intel)" , Oleg Nesterov , Waiman Long Subject: [PATCH 4/4] mm: Do periodic rescheduling when freeing objects in kmem_free_up_q() Date: Thu, 21 Mar 2019 17:45:12 -0400 Message-Id: <20190321214512.11524-5-longman@redhat.com> In-Reply-To: <20190321214512.11524-1-longman@redhat.com> References: <20190321214512.11524-1-longman@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 21 Mar 2019 21:45:43 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(); } } EXPORT_SYMBOL_GPL(kmem_free_up_q); -- 2.18.1