diff mbox series

[-next,2/5] mm/kmemleak: skip update_checksum for OBJECT_NO_SCAN objects

Message ID 20200921020007.35803-3-chenjun102@huawei.com
State New
Headers show
Series mm/kmemleak´╝Üsupport for percpu memory leak detect | expand

Commit Message

Chen Jun Sept. 21, 2020, 2 a.m. UTC
From: Wei Yongjun <weiyongjun1@huawei.com>

Objects marked with OBJECT_NO_SCAN are never scanned.
So there is no need to update checksum for them.

Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Signed-off-by: Chen Jun <chenjun102@huawei.com>
---
 mm/kmemleak.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Catalin Marinas Sept. 22, 2020, 9:03 a.m. UTC | #1
On Mon, Sep 21, 2020 at 02:00:04AM +0000, Chen Jun wrote:
> From: Wei Yongjun <weiyongjun1@huawei.com>
> 
> Objects marked with OBJECT_NO_SCAN are never scanned.
> So there is no need to update checksum for them.
> 
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
> Signed-off-by: Chen Jun <chenjun102@huawei.com>
> ---
>  mm/kmemleak.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/mm/kmemleak.c b/mm/kmemleak.c
> index b3f603fd9fc3..c09c6b59eda6 100644
> --- a/mm/kmemleak.c
> +++ b/mm/kmemleak.c
> @@ -1166,6 +1166,10 @@ static bool update_checksum(struct kmemleak_object *object)
>  {
>  	u32 old_csum = object->checksum;
>  
> +	/* always return false for not scan object */
> +	if (object->flags & OBJECT_NO_SCAN)
> +		return false;

The reason for OBJECT_NO_SCAN is to avoid introducing more false
negatives. The point of the checksum is to reduce the false positives -
i.e. an object that is being modified between scans won't be considered
a (transient) leak even if kmemleak couldn't find a reference pointer to
it.

So please drop this patch.
diff mbox series

Patch

diff --git a/mm/kmemleak.c b/mm/kmemleak.c
index b3f603fd9fc3..c09c6b59eda6 100644
--- a/mm/kmemleak.c
+++ b/mm/kmemleak.c
@@ -1166,6 +1166,10 @@  static bool update_checksum(struct kmemleak_object *object)
 {
 	u32 old_csum = object->checksum;
 
+	/* always return false for not scan object */
+	if (object->flags & OBJECT_NO_SCAN)
+		return false;
+
 	kasan_disable_current();
 	kcsan_disable_current();
 	object->checksum = crc32(0, (void *)object->pointer, object->size);