From nobody Fri Sep 25 02:09:39 2026 Received: from stravinsky.debian.org (stravinsky.debian.org [82.195.75.108]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D1E185437D8; Thu, 17 Sep 2026 13:47:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=82.195.75.108 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789652876; cv=none; b=K8CJW1DvJPcu7hwMvWWqhXeTvFBHmwdfWOQ1wWHhID2umbEiI7z70ektWxdGLCHgYwRuRhlX6uZ0wnnYEo25JeKRrWqhLacUC34seaBiC7rB6FTkxXw9+PPAhbqHkPSct3nC1McN3P1vjWQE9mLJc6BQFowTFIWpvEt9Q3BuHog= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789652876; c=relaxed/simple; bh=Eto8hzL6OaM80EOgMASH5eHiPO+2/yag486xyFWRXFs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=P+ZwgIywyGPYcVGIVTBTLNif4eByayFMSmMMlBH+fF1aHNUQ8bmNLrC07R7xrRUeNku9zSSVX42FPI3nCX+K/yBcCzD+85mkKj7un6p3OIm8Oyp02F+HvMhE5T3JyQqvr20RCcqSV/kwcFbnnTBfcPzI78aYEXFP5wnRKknTHJk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=debian.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b=OZbSwR3S; arc=none smtp.client-ip=82.195.75.108 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=debian.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b="OZbSwR3S" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debian.org; s=smtpauto.stravinsky; h=X-Debian-User:Cc:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description; bh=Ei3la3t9mnU7egxeLLJVw2Dg0OUQm68UUC9EQYYQZPU=; b=OZbSwR3SjmBfb5UAnj4ffQD6uQ TnjMK9ApQipb6geHD2ciiCEgIrqtdkUn9RlswO2B+bAs0vnx7Cdt7JFqDQN7Qq+A4sV7TVoIFiJjQ Fz/Eyp89W1W/SDkZqdLsWxzn2Et+iLJI2l5v2/i5ZHMffUItE99Jrpx6ezW7bF3xYFQwW6LCRMgeq XoWbleh2m8YDA10ftf6zFEU/KyfGOena69dRPNDTHt3R8QlLFwNRvS85ZNvIz3bhwN6Y86F653ks1 7watHq8HPqMgU5esr5b7Zuhfv53dQJgHbLLjc/zT+Gc/BXnqajgprSnmadIY99+ecjiSyM7FN136t Qau2ZyAQ==; Received: from authenticated-user by stravinsky.debian.org with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.96) (envelope-from ) id 1x7CSq-005zBN-3A; Thu, 17 Sep 2026 13:47:50 +0000 From: Breno Leitao Date: Thu, 17 Sep 2026 06:47:35 -0700 Subject: [PATCH 1/3] Documentation: kmemleak: describe the metadata pool, not the early log Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260917-b4-kmemleak-doc-v1-1-84fde6d1f749@debian.org> References: <20260917-b4-kmemleak-doc-v1-0-84fde6d1f749@debian.org> In-Reply-To: <20260917-b4-kmemleak-doc-v1-0-84fde6d1f749@debian.org> To: Catalin Marinas , Jonathan Corbet , Shuah Khan , Randy Dunlap , Andrew Morton Cc: workflows@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Breno Leitao , kernel-team@meta.com X-Mailer: b4 0.15-dev-47773 X-Developer-Signature: v=1; a=openpgp-sha256; l=1862; i=leitao@debian.org; h=from:subject:message-id; bh=Eto8hzL6OaM80EOgMASH5eHiPO+2/yag486xyFWRXFs=; b=owEBbQKS/ZANAwAIATWjk5/8eHdtAcsmYgBqq+97bAZLPHORsUJDZJBGyd9jqqoLSrsRu/m3E VBvWYZmKpKJAjMEAAEIAB0WIQSshTmm6PRnAspKQ5s1o5Of/Hh3bQUCaqvvewAKCRA1o5Of/Hh3 bRDoEACF4IxIhijugl9oV3FI0E3zTWGkO2KSgHIGnOFvv3K+Mxi7194KcfTdMmIjI9ji7+GZoNt NpL8YVh1hCdQCSTm5HgQoDZ9WYjsL54UDncCxyxP8ambZSREXC6bJ8XllyzuDj5ssVhbQVmEnDd o3lqWniw3AIY9G9fPj4XnhxEXi+4g0Rgx4aHU/8Vr7xtqgjrTv/tmeTKjyUmiikvfcFC97wisd0 Gj+gh3tJtMEHxQN0QTCY0bj/xk88IQqRFTxAExrs2Nx9QR7RjBwUSknYB5epCfhXUiPIMrpt08n eCwD4bBW+JcBmARaWxuwFNijmIJR+x/BbX86Vc3I31xmMpOaA+cVS4N8HZkdDv50E0wTZu0nMgf hYQMTt14KYGauGp6dYZG0SOINEcjLnpxxBRLa0ziC8wjtZh9QeRg7LLJCoTCHtHhZE+oj5TwWcI JHFFCM+WAa7qnbLEC8wWSizAbjC5SnzVO3O/AH4w0yPQBFhLaC2EztbEFSUq6TZdTi6/soCw2nJ OE5tJqPQbbWO/VSu6Kl6vxmbhIKqFtzcByJHi3eQBPGZWvzelhSOb2ThoGeDFjXONSrp9ED1kfO fh34x+4Iy6sntbm6zwD9b4zoRPNwSUGqlf3LHn7UH9oMrW6O5bjxbS2j/flSoQ3KQXElTYt8OMg Ozo5kvCKQkEis6Q== X-Developer-Key: i=leitao@debian.org; a=openpgp; fpr=AC8539A6E8F46702CA4A439B35A3939FFC78776D X-Debian-User: leitao commit c5665868183f ("mm: kmemleak: use the memory pool for early allocations") removed the early log buffer in favour of a static pool of kmemleak_object structures, but the documentation still describes the old mechanism. Fix the documentation by describing what the pool actually is, matching the Kconfig help text. Fixes: c5665868183f ("mm: kmemleak: use the memory pool for early allocatio= ns") Signed-off-by: Breno Leitao Reviewed-by: Catalin Marinas --- Documentation/dev-tools/kmemleak.rst | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Documentation/dev-tools/kmemleak.rst b/Documentation/dev-tools= /kmemleak.rst index d1b690b171696..8dad7647742d3 100644 --- a/Documentation/dev-tools/kmemleak.rst +++ b/Documentation/dev-tools/kmemleak.rst @@ -66,9 +66,14 @@ Memory scanning parameters can be modified at run-time b= y writing to the Kmemleak can also be disabled at boot-time by passing ``kmemleak=3Doff`` on the kernel command line. =20 -Memory may be allocated or freed before kmemleak is initialised and -these actions are stored in an early log buffer. The size of this buffer -is configured via the CONFIG_DEBUG_KMEMLEAK_MEM_POOL_SIZE option. +Memory may be allocated or freed before kmemleak is initialised, so a +static pool of metadata objects is used to track those allocations. Once +kmemleak is fully initialised the pool becomes an emergency reserve, used +whenever a metadata object cannot be allocated from the slab. The number +of objects in the pool is configured via the +CONFIG_DEBUG_KMEMLEAK_MEM_POOL_SIZE option. Exhausting it at run time +prints "Cannot allocate a kmemleak_object structure" and disables +kmemleak. =20 If CONFIG_DEBUG_KMEMLEAK_DEFAULT_OFF are enabled, the kmemleak is disabled by default. Passing ``kmemleak=3Don`` on the kernel command --=20 2.53.0-Meta From nobody Fri Sep 25 02:09:39 2026 Received: from stravinsky.debian.org (stravinsky.debian.org [82.195.75.108]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0BDDC545DAB; Thu, 17 Sep 2026 13:47:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=82.195.75.108 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789652884; cv=none; b=tX2xJiDge12D/u1ZJd1U8J+7oNvaKhSr0taLs+StbDfTjlpjA75kfnKQ/u6WugPAS1fau/3wCcgj7cj0eYa0/6q1/uBd6BP/92PtlhTrUNBHIODAaUkDR1O/gBO+WqavuYNShlMKcR6qI40IfrpWBAa+o76aQH8JnUdi8tgz6MU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789652884; c=relaxed/simple; bh=p24D+Y5mMAxUcwtK7qfgEk0iOjQX9ouDJmkvpzS+HXs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=DniurPidcg9szPXJgrW7VgFa8b6jWEBU57Bsn06q3svO5xces8qKoIcJ/FAS411RRfvMdgscfQMfy2AcZ6hIxe46wRn5wM+82Tuoiq7hDSyMvL6Stdf8QVJA6Cj52/YYvRJMw+6zxIGVelOTocIOEJ+dAVKLjj5WXSH11J5Tef4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=debian.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b=AS80hN1X; arc=none smtp.client-ip=82.195.75.108 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=debian.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b="AS80hN1X" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debian.org; s=smtpauto.stravinsky; h=X-Debian-User:Cc:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description; bh=nPjOXpzA/XnC1Tb4O4aCY53qynGLKUHPRgytpT1S63A=; b=AS80hN1X/D0p5tmjULL2+XTpFU SwHLhpq05pRXs+GrgUJcXEKZ8WX30VStxQ9nFXOHZAZMLiwwgL+ns512tTOFPklYXp1NXsVT7b+Sd QOqjx21GroC0F9lTIHv1sf6AJjaK+c8Xv+LA1haXEeCjH6IN2LmAXL/UJmLkafBkUAWuS82aLTDHx I2YC+YNVLjU0GYqmwcsvqs70aT5N+7D+qTruLNZ7KLgwboc6DUIHNkHZ/gJiyY79CzohoS/Ar6ffZ x1t74FqQmLLKCR62SXe8hxw9ig3Ua/y9fmAbd8zjS2M8vRZCq4Gk8FgFfeM26m1kUPqGxDSR7X3Fu f/6c5BZQ==; Received: from authenticated-user by stravinsky.debian.org with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.96) (envelope-from ) id 1x7CSy-005zBf-15; Thu, 17 Sep 2026 13:47:57 +0000 From: Breno Leitao Date: Thu, 17 Sep 2026 06:47:36 -0700 Subject: [PATCH 2/3] Documentation: kmemleak: fix stale statements about scanning Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260917-b4-kmemleak-doc-v1-2-84fde6d1f749@debian.org> References: <20260917-b4-kmemleak-doc-v1-0-84fde6d1f749@debian.org> In-Reply-To: <20260917-b4-kmemleak-doc-v1-0-84fde6d1f749@debian.org> To: Catalin Marinas , Jonathan Corbet , Shuah Khan , Randy Dunlap , Andrew Morton Cc: workflows@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Breno Leitao , kernel-team@meta.com X-Mailer: b4 0.15-dev-47773 X-Developer-Signature: v=1; a=openpgp-sha256; l=2852; i=leitao@debian.org; h=from:subject:message-id; bh=p24D+Y5mMAxUcwtK7qfgEk0iOjQX9ouDJmkvpzS+HXs=; b=owEBbQKS/ZANAwAIATWjk5/8eHdtAcsmYgBqq+970Fp97dAda87X6OngoqU3eRhC2dhmhroPo xigP+AGHgmJAjMEAAEIAB0WIQSshTmm6PRnAspKQ5s1o5Of/Hh3bQUCaqvvewAKCRA1o5Of/Hh3 bWKqD/4w8CiiSkOwxv7iO2uPBGQ/tekba9aTlo2+PySjYKXcHo100mEBxl09ukUdpjObFFkB4xG hBS5f9+G44gxRvry7D/ciz9QoBylUviDYkkRahoxdyKSUNAVIXd31JDGP9zd5ukQREQa7872TH1 iMJFUYYgo1185Y5A4EwxtT5CRwa51CJoVaGIhtWkR600C11v7uzjo69LKi3TW2u7/XvWYp1LHxB zaMv+ga46OOmvnLQi962t+5jsEgYVIxm0PpdaztffKfMPheFQKE6COYPY1Ju3+CEZPaL2d7uut+ q51fic9sjP+lHbqIH3CsiijWSLM9W0c7HJhsbKReqThxxcmRy6AJ94vgIHarlyEQymomocrmBMe QuULRu0r6L4fezH92SXyHyK3CnAKboPsmHYfmZsUnFvtKSzS7j8doRjlPLo7ScwAA+J/relfETo O3Im8ZO8vlrUsqy8IjXGN8fX9y2gwekfSA23tkQG4M85dXsMZuWHR7nOp2+Xg8IcxpoByt4SZtq d5r48CTCptw97wuJ9HV0QqLMvIvOTEFRHphZ9CksLhJ68rZgBHQ3F+zpDnPqquWkWfgU66C5O05 PxI3Lcy/9IPWwQq09nU0Q5V4rJl7SumCAjphf5WZdRaZ+eEYYREH8n2SuLVP37BeRrHH6kyLxSu S6HMBQ/GBjUI5bg== X-Developer-Key: i=leitao@debian.org; a=openpgp; fpr=AC8539A6E8F46702CA4A439B35A3939FFC78776D X-Debian-User: leitao Three statements in the "false positives/negatives" and "Limitations" sections have never matched the code: - task stack scanning is on by default (kmemleak_stack_scan =3D 1), as the parameter list earlier in the same document already states; - MSECS_MIN_AGE has been 5000, not 1000, since the initial commit; - scanning is done by a periodic kthread. Reading the debugfs file only lists what the last scan found; kmemleak_open() calls seq_open() and never scans. Fixes: 04f70336c80c ("kmemleak: Add documentation on the memory leak detect= or") Fixes: e0a2a1601bec ("kmemleak: Enable task stacks scanning by default") Signed-off-by: Breno Leitao Reviewed-by: Catalin Marinas --- Documentation/dev-tools/kmemleak.rst | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Documentation/dev-tools/kmemleak.rst b/Documentation/dev-tools= /kmemleak.rst index 8dad7647742d3..b5fe7e671d0f8 100644 --- a/Documentation/dev-tools/kmemleak.rst +++ b/Documentation/dev-tools/kmemleak.rst @@ -190,7 +190,8 @@ reported by kmemleak because values found during the me= mory scanning point to such objects. To reduce the number of false negatives, kmemleak provides the kmemleak_ignore, kmemleak_scan_area, kmemleak_no_scan and kmemleak_erase functions (see above). The task stacks also increase the -amount of false negatives and their scanning is not enabled by default. +amount of false negatives and their scanning is enabled by default; it +can be turned off with ``stack=3Doff``. =20 The false positives are objects wrongly reported as being memory leaks (orphan). For objects known not to be leaks, kmemleak provides the @@ -200,7 +201,7 @@ longer be scanned. =20 Some of the reported leaks are only transient, especially on SMP systems, because of pointers temporarily stored in CPU registers or -stacks. Kmemleak defines MSECS_MIN_AGE (defaulting to 1000) representing +stacks. Kmemleak defines MSECS_MIN_AGE (defaulting to 5000) representing the minimum age of an object to be reported as a memory leak. =20 The ``min_unref_scans`` module parameter requires an object to be seen @@ -217,8 +218,10 @@ Limitations and Drawbacks ------------------------- =20 The main drawback is the reduced performance of memory allocation and -freeing. To avoid other penalties, the memory scanning is only performed -when the /sys/kernel/debug/kmemleak file is read. Anyway, this tool is +freeing. To avoid other penalties, the memory scanning is performed by a +periodic thread rather than on every allocation. Reading the +/sys/kernel/debug/kmemleak file only lists the objects found by the last +scan; writing ``scan`` to it triggers a new one. Anyway, this tool is intended for debugging purposes where the performance might not be the most important requirement. =20 --=20 2.53.0-Meta From nobody Fri Sep 25 02:09:39 2026 Received: from stravinsky.debian.org (stravinsky.debian.org [82.195.75.108]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BD33754DAC0; Thu, 17 Sep 2026 13:48:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=82.195.75.108 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789652890; cv=none; b=Kf0YuXBz3dFhlf5tBBJafArw2PZEV/VIPMvpmrH0uSIqI1fdrw0C+wdg259gtNfzS5a2YLftgsl1DhZL/Cji5rryiQxjbuWk6csMekc8zd5vk4jnV9j5XUu04QriliOlt3BfYxOn7+oYx5GiPuBGamKAsgIUSxXoKUOK6+LGLTU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789652890; c=relaxed/simple; bh=+q6xDl34YUOS8Avf5cU8XdLmZVvvs+tZYTzpjpHrFfE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=m8hMVkQl3fvSjB5mXo311wXQxOuf+xZ1pP7P9vBh3Yz6BGqgOiAg96gnzgf7f/R3yS7JUg9qRww4+zOfrpGpUDgf8d6a6HcRLfNQiAVeJcfL9h5XgzyurDiNiV3H9b+0y0QSPKn1AHrx+fBqcicvoywlXKlLMqLZkTO5BaXTKqs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=debian.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b=AJQr/362; arc=none smtp.client-ip=82.195.75.108 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=debian.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b="AJQr/362" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debian.org; s=smtpauto.stravinsky; h=X-Debian-User:Cc:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description; bh=FJzQcNI6ERpoXaAHSV1A2WIicaI84oaHobrpffLzFwo=; b=AJQr/362+8Dn/1bQmS3G6lbGp9 TQhbJJirbYuCXe79pG2OsxmjdEIi6JcALZvo57jSw1uhKe9RFGPJw30oEcnRKXHHNaAzFC+gTUHhj KDHi01VMQK1ej46sFVY5tYAPnueEnTfkRUcWEWxUEYBqtOZDOjeuXLT2SRSD2TOZY0r+H/Dgcib6C fAsu9JS0QREFQk8gteX2rDKndhp4XeGbolWPn0WzntUgO8z76QlUyIZdJWDemmsVZfgzJsvSiEhcA LHUNlW3wPsyeXpd2njRns35wwSaIdUjo5pa40ulSxNPEYVVj+7uMKgC02Oqd6PnXCIoCyippBQNZl TAgrazaQ==; Received: from authenticated-user by stravinsky.debian.org with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.96) (envelope-from ) id 1x7CT4-005zBu-0p; Thu, 17 Sep 2026 13:48:03 +0000 From: Breno Leitao Date: Thu, 17 Sep 2026 06:47:37 -0700 Subject: [PATCH 3/3] mm: kmemleak: raise min_unref_scans to 3 for verbose auto-scan Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260917-b4-kmemleak-doc-v1-3-84fde6d1f749@debian.org> References: <20260917-b4-kmemleak-doc-v1-0-84fde6d1f749@debian.org> In-Reply-To: <20260917-b4-kmemleak-doc-v1-0-84fde6d1f749@debian.org> To: Catalin Marinas , Jonathan Corbet , Shuah Khan , Randy Dunlap , Andrew Morton Cc: workflows@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Breno Leitao , kernel-team@meta.com X-Mailer: b4 0.15-dev-47773 X-Developer-Signature: v=1; a=openpgp-sha256; l=2472; i=leitao@debian.org; h=from:subject:message-id; bh=+q6xDl34YUOS8Avf5cU8XdLmZVvvs+tZYTzpjpHrFfE=; b=owEBbQKS/ZANAwAIATWjk5/8eHdtAcsmYgBqq+97HiS12bKDm59NAUX6612dYs4+CKNi1kW0B Sye5XuP6jWJAjMEAAEIAB0WIQSshTmm6PRnAspKQ5s1o5Of/Hh3bQUCaqvvewAKCRA1o5Of/Hh3 bRXZD/9gOr2ZVF/m47Q7MyVKTJ/pd5BoLlLNCHSYpmV1T8x5aMO9Pc6TVnsLOVtlO3cpWIA7+YN fanPS0vkin+q7U47J2sLd7XHMVOEGmEE7Qr0MZ1c4GcTZpg/edkYDZgQ2Rjtd/wigKKdyl0a44/ 3uKSmBukPPCeq+E2F7yx87ERv5NANBYmU1crrR1O3imSN6PDVWiZtXM7Y9PtByrSc/bcJl70Q/5 zkpns8QDBr/QgSclq8oWGlva5LQt8bZIqRKz+VwngVR97OOX7y1H6KSBZGQaCmyhEy1AgvjDEMT f4FVVk242Z93y7HdXp2W9ZHNhdcenhDoQrlTJcqsrpFQRv4fTt8tfwD/IuNuX9Rfv7XIO5rBxEq UIDPmahLS9rXcQk+pOSSHV4cGogL66IEPC52bGcRlPNyGdE2rcuJr7CqtU6gWYxMLtuhQwZcYW/ gT05/1Rz8p39fm8ccG930jhfh/uNteROrYxEE8r7Z1Uh0yp6smXjt9IavDkHyt4ljbz4QDVXN1g bX0kvFKB0eDTlPw8R3o9ct57FyoqFTCE/3PFtB3hPCuwrevYTfdun50E3AFy1uaKaea1UiAprJH 4/o+AWUdDBxBAn9QuWm645trNK/QV2k8aZ0JpS5oqbHLE2GK23ba6FYH/FeDn7LYNdbcKu8+bgb EYLTQSDazJ6jmAQ== X-Developer-Key: i=leitao@debian.org; a=openpgp; fpr=AC8539A6E8F46702CA4A439B35A3939FFC78776D X-Debian-User: leitao CONFIG_DEBUG_KMEMLEAK_VERBOSE sends every report to the console, so a transient false positive there is broadcast to whatever collects the kernel log rather than sitting in the debugfs file until someone looks. That asymmetry justifies being more conservative than the general case. Require one more consecutive unreferenced scan before reporting. The only cost is that a genuine leak is reported one scan interval later (600s by default); the value stays writable at run time through the module parameter. Kernels without CONFIG_DEBUG_KMEMLEAK_VERBOSE keep reporting on the first unreferenced scan. I've been running constant upstream kernel with CONFIG_DEBUG_KMEMLEAK_VERBOSE set, and I am still seeing some rare false positive, that goes away with min_unref_scans=3D3, so, making it the default based on my heuristic. Signed-off-by: Breno Leitao Reviewed-by: Catalin Marinas --- Documentation/dev-tools/kmemleak.rst | 2 +- mm/kmemleak.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/dev-tools/kmemleak.rst b/Documentation/dev-tools= /kmemleak.rst index b5fe7e671d0f8..c0d3293723425 100644 --- a/Documentation/dev-tools/kmemleak.rst +++ b/Documentation/dev-tools/kmemleak.rst @@ -206,7 +206,7 @@ the minimum age of an object to be reported as a memory= leak. =20 The ``min_unref_scans`` module parameter requires an object to be seen unreferenced in that many consecutive scans before it is reported. It -defaults to 2 when CONFIG_DEBUG_KMEMLEAK_VERBOSE is enabled, where the +defaults to 3 when CONFIG_DEBUG_KMEMLEAK_VERBOSE is enabled, where the periodic scan thread confirms a leak on its own, and to 1 otherwise. A value of 1 preserves the historical behaviour; higher values filter the transient false positives described above, at the cost of delaying genuine diff --git a/mm/kmemleak.c b/mm/kmemleak.c index 8fa409a4f9fb2..5d0daea93c471 100644 --- a/mm/kmemleak.c +++ b/mm/kmemleak.c @@ -238,7 +238,7 @@ static struct task_struct *scan_thread; static unsigned long jiffies_min_age; /* consecutive scans an object must stay unreferenced before reporting */ static unsigned int min_unref_scans =3D - IS_ENABLED(CONFIG_DEBUG_KMEMLEAK_VERBOSE) ? 2 : 1; + IS_ENABLED(CONFIG_DEBUG_KMEMLEAK_VERBOSE) ? 3 : 1; module_param(min_unref_scans, uint, 0644); static unsigned long jiffies_last_scan; /* delay between automatic memory scannings */ --=20 2.53.0-Meta