From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 85D30CCA47A for ; Tue, 14 Jun 2022 22:04:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354852AbiFNWEX (ORCPT ); Tue, 14 Jun 2022 18:04:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230024AbiFNWER (ORCPT ); Tue, 14 Jun 2022 18:04:17 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id BA8C72FE6F for ; Tue, 14 Jun 2022 15:04:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655244255; 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=JbKT3w2NfDupaJito6m7UIsXrjnWTW8x9BqkqDcA5qDzbAc89sBLL/osl71Cjvs3bqQCG1 zs9wQxvZ45LMhNLgq7hzFRHyBmgfjaeN+6gUeVadfdtUx6ivj0N9iQEdf6ktrOF7VHPLtT v6cg2Bx6AC2FlRrcSJIfdOvFl4uoBro= 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 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) -- 2.31.1