Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp739903img; Fri, 22 Mar 2019 07:36:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqxBICEDyhdfXvgvx75Jxs803Ccs4rclkhqCoweYFhclwwItzaPXFTos/gXrcFbLuL6DWo1D X-Received: by 2002:a62:564d:: with SMTP id k74mr9425008pfb.19.1553265404966; Fri, 22 Mar 2019 07:36:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553265404; cv=none; d=google.com; s=arc-20160816; b=09BWgsd82fWVX2oBvl1RrhdIOykb4L5MoG7bHDOGfigMcE9sjG+200sVL8Z8law64x 6bl2ddEs6Aq9dm0HaeOuTnR67BK74oOVcYmClWgq21xrSXO5b5uvVjE+gM5VwbD4Ckt7 3EA0kobvGCJlI4tWgA6pqS3GnSxsHBbsKH6LjYhSe++p2W8iMB+WZf08yi8bn0uEBuIm RqKwyPACyB/tDjhKkD3HaZBWAlfsxJIumH/J665WD3qan9FzK8ZqG342kgLj3zatmbRE Ghvw3Z8Z9J3EWLmNh0z7B6iRh2CD8JzGPg5eHutULSbmwLX1QsbvdT+LFmRjnFEdtnyW raYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:organization:autocrypt:openpgp:from:references:cc:to :subject; bh=pLPPXAfElSV+eLwLcnJGPUAEA79wHbNbWg4yR8J8abI=; b=M4ljlhb2VSpWPK9F5ZN8rzYnkC4SO4XA7aNpln2PGHuCIK3hG7sdPEm9OBjbFmCrjB T83fd+WZ8OcDr6+cENnJSG7qqlpVqNA3pUJZZyraawFkEy/Vlm7mUyFKDfA97lAETAIh IgRUL7KWGL8moJx6i2AWEanrdScGxUhaWkjdpo2hZdwMQLP8IUowKjdxxFXqmieWMy6z 2Q9lLWbU/rbSV6oN4tTUlEStBqNSHBgbnmJwMEWRfdHWEjocdNVrVNBDcAXYLZf2cYiL aITC/40q9gHgJwp/wrfASlJm9d80rv/Od4ZKnqubFll2wTIlulriCHsz78hnaatnCYeG FQdw== 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 g5si6766077pgk.402.2019.03.22.07.36.26; Fri, 22 Mar 2019 07:36:44 -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 S1729158AbfCVOfZ (ORCPT + 99 others); Fri, 22 Mar 2019 10:35:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56970 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728332AbfCVOfY (ORCPT ); Fri, 22 Mar 2019 10:35:24 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 57B723078AB5; Fri, 22 Mar 2019 14:35:23 +0000 (UTC) Received: from llong.remote.csb (dhcp-17-47.bos.redhat.com [10.18.17.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8F7A219C59; Fri, 22 Mar 2019 14:35:18 +0000 (UTC) Subject: Re: [PATCH 4/4] mm: Do periodic rescheduling when freeing objects in kmem_free_up_q() To: Peter Zijlstra 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 References: <20190321214512.11524-1-longman@redhat.com> <20190321214512.11524-5-longman@redhat.com> <20190321220035.GF7905@worktop.programming.kicks-ass.net> From: Waiman Long Openpgp: preference=signencrypt Autocrypt: addr=longman@redhat.com; prefer-encrypt=mutual; keydata= xsFNBFgsZGsBEAC3l/RVYISY3M0SznCZOv8aWc/bsAgif1H8h0WPDrHnwt1jfFTB26EzhRea XQKAJiZbjnTotxXq1JVaWxJcNJL7crruYeFdv7WUJqJzFgHnNM/upZuGsDIJHyqBHWK5X9ZO jRyfqV/i3Ll7VIZobcRLbTfEJgyLTAHn2Ipcpt8mRg2cck2sC9+RMi45Epweu7pKjfrF8JUY r71uif2ThpN8vGpn+FKbERFt4hW2dV/3awVckxxHXNrQYIB3I/G6mUdEZ9yrVrAfLw5M3fVU CRnC6fbroC6/ztD40lyTQWbCqGERVEwHFYYoxrcGa8AzMXN9CN7bleHmKZrGxDFWbg4877zX 0YaLRypme4K0ULbnNVRQcSZ9UalTvAzjpyWnlnXCLnFjzhV7qsjozloLTkZjyHimSc3yllH7 VvP/lGHnqUk7xDymgRHNNn0wWPuOpR97J/r7V1mSMZlni/FVTQTRu87aQRYu3nKhcNJ47TGY evz/U0ltaZEU41t7WGBnC7RlxYtdXziEn5fC8b1JfqiP0OJVQfdIMVIbEw1turVouTovUA39 Qqa6Pd1oYTw+Bdm1tkx7di73qB3x4pJoC8ZRfEmPqSpmu42sijWSBUgYJwsziTW2SBi4hRjU h/Tm0NuU1/R1bgv/EzoXjgOM4ZlSu6Pv7ICpELdWSrvkXJIuIwARAQABzR9Mb25nbWFuIExv bmcgPGxsb25nQHJlZGhhdC5jb20+wsF/BBMBAgApBQJYLGRrAhsjBQkJZgGABwsJCAcDAgEG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X4lV1uhN1XsZjBbRHdKF2W9g weim8xU= Organization: Red Hat Message-ID: <2434d78c-b77c-571d-7add-e111f9d81485@redhat.com> Date: Fri, 22 Mar 2019 10:35:18 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20190321220035.GF7905@worktop.programming.kicks-ass.net> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Language: en-US X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Fri, 22 Mar 2019 14:35:23 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/21/2019 06:00 PM, Peter Zijlstra wrote: > 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() ? cond_resched() calls ___might_sleep(). So it is prudent to check for process context first to avoid erroneous message. Yes, I can call cond_resched() after every free. I added the count just to not call it too frequently. Cheers, Longman