From patchwork Tue Jun 14 22:03:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Waiman Long X-Patchwork-Id: 12881651 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6EE94C433EF for ; Tue, 14 Jun 2022 22:04:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 48BBE6B0072; Tue, 14 Jun 2022 18:04:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 437996B0074; Tue, 14 Jun 2022 18:04:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 17B716B0078; Tue, 14 Jun 2022 18:04:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id E8B026B0072 for ; Tue, 14 Jun 2022 18:04:20 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id B798AF61 for ; Tue, 14 Jun 2022 22:04:20 +0000 (UTC) X-FDA: 79578220680.22.1835AA2 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf16.hostedemail.com (Postfix) with ESMTP id 593D318009A for ; Tue, 14 Jun 2022 22:04:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655244259; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=v9dxoAUFdvaKxjatlIHTfIiF/lhvDFU0vdCFYvfgo9U=; b=aI+IiQ3PfY994AFhLTLtAe8w+oVHuzGy5prMKPnNh06h4Y3Du0HEw64wAX/Q+4lcg0qlFd u8aIiHjra6smLCIJtposGzUUiaDyunGhKSuGwtyQgNfhpwJhRyf//ZAoBuRr6WiXWFwnfX YEL3+7s2x+RJgTBfJEC3+5Dx9yRMr7I= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-314-g4PcdfaWOASxu_lcFaIdqw-1; Tue, 14 Jun 2022 18:04:14 -0400 X-MC-Unique: g4PcdfaWOASxu_lcFaIdqw-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 09BFF381079B; Tue, 14 Jun 2022 22:04:14 +0000 (UTC) Received: from llong.com (unknown [10.22.33.116]) by smtp.corp.redhat.com (Postfix) with ESMTP id F0CC5492CA2; Tue, 14 Jun 2022 22:04:12 +0000 (UTC) From: Waiman Long To: Catalin Marinas , Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Muchun Song , Waiman Long Subject: [PATCH v2 0/3] mm/kmemleak: Avoid soft lockup in kmemleak_scan() Date: Tue, 14 Jun 2022 18:03:56 -0400 Message-Id: <20220614220359.59282-1-longman@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655244260; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=v9dxoAUFdvaKxjatlIHTfIiF/lhvDFU0vdCFYvfgo9U=; b=aaCq7xq1ybG30G9gWraCCCqDsbM2eWF71H5D22Bt0mKYtxeHQG/i1VAdP1yu2lG9p4aaDb oTYscb6kzpx9U70Uv9/radYmaHNv5VPj9uxEqv5DW6GvhEiEAetcGV0/yAKpxlQLCanAhU TWxj4PoxTrUV63lf1CEmC70f/CwFEBM= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=aI+IiQ3P; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf16.hostedemail.com: domain of longman@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=longman@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655244260; a=rsa-sha256; cv=none; b=DS5gI0TXmx+HDnBcteGZ0vGCK212jclor9cwVwk5H7xo+UmNmXKmF36J0PzpgyTqvbnFqB 6FrAmcqUwfWzGhS4KiYrWsyhqddTOY8GzSFk1u+CeJyjB4vw4t+ZrBaP2mBY8lan/DViZb ARbOyImMaS4V0/tV+hs7ixXDtimUsWg= X-Rspamd-Queue-Id: 593D318009A X-Rspam-User: X-Stat-Signature: 6qfamcqhe1gtazjc1wjz76yzica8nnzj Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=aI+IiQ3P; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf16.hostedemail.com: domain of longman@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=longman@redhat.com X-Rspamd-Server: rspam04 X-HE-Tag: 1655244260-771854 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: v2: - Update patch 3 to count the objects checked instead of being gray for determining when to do cond_resched(). This is more reliable. There are 3 RCU-based object iteration loops in kmemleak_scan(). Because of the need to take RCU read lock, we can't insert cond_resched() into the loop like other parts of the function. As there can be millions of objects to be scanned, it takes a while to iterate all of them. The kmemleak functionality is usually enabled in a debug kernel which is much slower than a non-debug kernel. With sufficient number of kmemleak objects, the time to iterate them all may exceed 22s causing soft lockup. watchdog: BUG: soft lockup - CPU#3 stuck for 22s! [kmemleak:625] This patch series make changes to the 3 object iteration loops in kmemleak_scan() to prevent them from causing soft lockup. Waiman Long (3): mm/kmemleak: Use _irq lock/unlock variants in kmemleak_scan/_clear() mm/kmemleak: Skip unlikely objects in kmemleak_scan() without taking lock mm/kmemleak: Prevent soft lockup in first object iteration loop of kmemleak_scan() mm/kmemleak.c | 60 +++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 49 insertions(+), 11 deletions(-)