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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 507BFCA0ECA for ; Tue, 12 Sep 2023 13:33:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C3AC66B00EC; Tue, 12 Sep 2023 09:33:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BEAAF6B00ED; Tue, 12 Sep 2023 09:33:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AB2576B00EE; Tue, 12 Sep 2023 09:33:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 98D3B6B00EC for ; Tue, 12 Sep 2023 09:33:02 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 62B7A80AB4 for ; Tue, 12 Sep 2023 13:33:02 +0000 (UTC) X-FDA: 81228036204.15.7AB51BA Received: from mail-qk1-f175.google.com (mail-qk1-f175.google.com [209.85.222.175]) by imf15.hostedemail.com (Postfix) with ESMTP id 5842BA0035 for ; Tue, 12 Sep 2023 13:32:59 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=joelfernandes.org header.s=google header.b=Al1Y9KAz; dmarc=none; spf=pass (imf15.hostedemail.com: domain of joel@joelfernandes.org designates 209.85.222.175 as permitted sender) smtp.mailfrom=joel@joelfernandes.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1694525579; 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:in-reply-to:references:references:dkim-signature; bh=svmbrtqWlENrRfjFLkk8+XzIqzX9R6UBCXGlZ2j0y4U=; b=5zvhwVQ3JNCF2QySO3n4jVqd9zhqjQ7xLxDmznFSW/hkNkUsHlxIkJGmWwL0/yZ6IovFP5 cgFUxGZytPe+sLxwGJqywkxBYUncGJ1dr+TIpPf8uFVG9JuGdmuxjf2R70Xz0JzoC2qlCY /MuegLj+bNemepc5vfdUw1yc+xtZxfk= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=joelfernandes.org header.s=google header.b=Al1Y9KAz; dmarc=none; spf=pass (imf15.hostedemail.com: domain of joel@joelfernandes.org designates 209.85.222.175 as permitted sender) smtp.mailfrom=joel@joelfernandes.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694525579; a=rsa-sha256; cv=none; b=G1WZ1Ock5B9p4umnAt3bsxEVKuuLvQ4PR00OwsWBt6/o6K/rGtaJUf4rUXP9p+l84bwCJv //YzLteumx1J5f1NWYe6QeOcGg4i3rQ8QT5K2QxJYUTOVrc31r6CwcgZrpu9fqwERi6Tik B9ygky+MsYOnUnsx/hueG84xlZpd3vQ= Received: by mail-qk1-f175.google.com with SMTP id af79cd13be357-76ef8b91a4bso356118485a.2 for ; Tue, 12 Sep 2023 06:32:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; t=1694525578; x=1695130378; darn=kvack.org; h=to:references:message-id:date:cc:in-reply-to:from:subject :mime-version:content-transfer-encoding:from:to:cc:subject:date :message-id:reply-to; bh=svmbrtqWlENrRfjFLkk8+XzIqzX9R6UBCXGlZ2j0y4U=; b=Al1Y9KAzqFEHcEeBTiU9qIX7EYccWNZgvC9is6S+kQaNLIaKDf3iHVVhzOVrbLxvY7 00AAHWDd87kdWjVV2aq4xTH/UDBVwNj4Pnw7mUhSmOwoStOG5SCfzobCybJJ1fzDgRx4 Rf4hHqWFOTzbBc/WPggXwwnvyS388txEOQ0TA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694525578; x=1695130378; h=to:references:message-id:date:cc:in-reply-to:from:subject :mime-version:content-transfer-encoding:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=svmbrtqWlENrRfjFLkk8+XzIqzX9R6UBCXGlZ2j0y4U=; b=ZeSdHY2B32XmSJbDImqvGoaRbSiW8xzpGRYOX4jycn9tjnXkC4fEOLasuE+62/UhLh aVNIfXx7FDtwBNrx4n4e5quZZZ0j+liJ4OAoLXkATOPgoFGbM/xSLspWF3OSD0Rdqn1k pgkCCaxVdFjhLbI3BYfdSTiAPgIpN60q1rx0SoOsIRuqjFZ/iEn1HvqE0bSLfeaT7rsn W4kb8AIDbc3BfnWlUXu2J5/dEop8RA0s7RuC1LyBbTBE+qjE9829sL/DZSOdjaRbV7Eh 8zAmrjrH3cTmfVoz0bWT0Xwtt4REijXp+T74pdYkWgz1yEFMZlh4+gskAuCvbHbBr0+D Xz2A== X-Gm-Message-State: AOJu0YwcBA3csPQWETJOjb7EcG06leMc+VO71GMQkS4htkoOqVV6dF0B qU16rFkarkT84Oa5RMjIka39xGNfRN1y3XJ9bqs= X-Google-Smtp-Source: AGHT+IEWmiZ0EGY1O/9xetI5jQSsVfvw8K2frb4QEsfc2ct2W79miQrJDwoAIrb/amscRDLXZA6ZgQ== X-Received: by 2002:a05:620a:19a7:b0:76e:fd91:5f6f with SMTP id bm39-20020a05620a19a700b0076efd915f6fmr14641824qkb.37.1694525577897; Tue, 12 Sep 2023 06:32:57 -0700 (PDT) Received: from smtpclient.apple ([45.88.220.69]) by smtp.gmail.com with ESMTPSA id pj24-20020a05620a1d9800b0076e1e2d6496sm3203685qkn.104.2023.09.12.06.32.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 12 Sep 2023 06:32:56 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (1.0) Subject: Re: kmemleak handling of kfree_rcu From: Joel Fernandes In-Reply-To: <6bd9f6cc-84d0-4f6a-bfd7-912dcb8e476a@tessares.net> Cc: Catalin Marinas , Christoph Paasch , Andrew Morton , linux-mm@kvack.org, MPTCP Upstream , rcu@vger.kernel.org Date: Tue, 12 Sep 2023 09:32:46 -0400 Message-Id: <5FAC49DB-0849-4F83-9802-571E62819ACC@joelfernandes.org> References: <6bd9f6cc-84d0-4f6a-bfd7-912dcb8e476a@tessares.net> To: Matthieu Baerts X-Mailer: iPhone Mail (20B101) X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 5842BA0035 X-Stat-Signature: yqzc9u4y5icuuno9sstqoxuww1w3fh1w X-HE-Tag: 1694525579-659732 X-HE-Meta: U2FsdGVkX19iyMPAz89ntyPYGqtyqvt/4gAa0ff3SIyFvdK50gPmLWyoW+BgjdHD2yRGX5QHIEKRSVaGsafPkZWNspKnHheawo9LWspDic6ON+pmTyHztoGyE848awDcZpgFLl2p4xkUnUXFVhb66AWb9ao1cAjUv7fzbbh2xEQLoGSwUX2imvuGNoAqVG+CipeRLrW+x9B0qcLpLKzsOyM0MVEkraemuLnXPqS4PLzKcaNMj1seKKliMqDPOA1lT8ZUrn0LTrvm91KPjf93WrPZvbgrRsBcD3OadEIMm4YFTIJwdHiRknT519929vb+OtBhkP9K0rDhv0NTriGYvJpGtXeBgD121qgeiCqxECQ//8xFCtVvxHdEkuYf8r57mCQCySIr1JfY4x8ld9LdiFQ0QEcfCs+yKOBhailZDSPCAn9zhmHXRPKflKHfuHdiDORF4jtFc2lVkdh32wjNp3rOCacUcVyxSPR3qN4Db9VS345+eSOF/TgvChy6L0tAGnfvq9jwvCMlO4yBVccIZ+m/EYfS+h5zBHTxb3Seq6pPoQHZ4nGsN6W1LxLC2aWSKjApieNGHRoibPi1ReEWohmtNoRE/dyysAIzrIM8e9syMxNLbxafsRq88JQ3B+UeK6AAuuMnqpWcOWRu0EontvUZPpJeQbpGDyFfOWybKXCvslmEJ193hrZ7PY7nYdbfqAIo30PWo6x30985D8SXwVmliA8NzSqnqUz9Yh5eY65hzqanqhQLBzjGp93KhN2q3Iffn48+ce3+jHbGqVAdrtuZQq8vxSHlRbCC/QksXng5v9tTG+CXXHZd25yiaXbbMV/5LR5wcoIopTZiHfrzUTG0zXe6M6tk1yEtuGcx51dpRsCLHIQsl+HMzZtFiOit/fAMsNseB0E1DstA/HRbVTxBecfxlQlDsjNl9wvTS5DNyVARrAo+604aGuW+mD21VhL8QoYvVDk70DDtGgr b+rz5LVM d5R01MVVSGgQakuqbcOTy4QHCtlTe8wzFVjmGUG/4lpKE5VO/AQYvmWrLf8KAAF1L0EvBv74S6CNfqsTzvAuYsPI4JB1UBb/WynCMzVha3sQfq7NmWkSXOzfYqBsa/enXgu53dEEXvAlDk2a0TvH9TzEGcTesUeAqyvj1P9gvUvauEne4lCGGu6XsQUEhAsW1hRuwa18K0ipJuFFI324R46aiJgs5jijEGtaHC9WLYDU6kwylFxAJgQ8QkVV9KxsQ7CdAtV1Mcn+keMUcGDv9nVjUdj0KP/mSjqhZP3z0NQ5JX6qUwjThQ2vhn+98BhEmUev/rw3meLmpUDtqaD4TX3cBptq42idY11CWbS+VVdYtY2CXt6AzgZaOerb6dI3dKDIRvncZaB9/bBSPJOFtCXhmQoOAi8GiaT4roWe8f3zyY76aE4E9FU48/6+6HIn9TyZcOyyIfrSbR5q3NRgPG/X0yZ6++5MP6ZWa3lbjIUj0/L39LESN/GbG2GYymQH2bYfn3l3gSuO5lTiOP6VP0X87EZcHTmY871xY5SnpKL9ipuNEVKZN6HZgigGVtdgggUq5 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: > On Sep 12, 2023, at 9:15 AM, Matthieu Baerts wrote: > =EF=BB=BFHi Catalin, >=20 > On 06/09/2023 19:15, Catalin Marinas wrote: >=20 > (...) >=20 >> I had a patch already but got distracted by a few (real) leaks reported >> while testing it. Feel free to pick it up and change _ignore to >> _not_leak if you find that more suitable. Well, it would be good for >> Christoph to test it as I haven't managed to reproduce the false >> positive. >=20 > Thank you for the patch! >=20 >> ----------------------8<-------------------------- >> =46rom b25350cb6f8a906a6164b625bfd57021190cb105 Mon Sep 17 00:00:00 2001 >> From: Catalin Marinas >> Date: Wed, 6 Sep 2023 17:52:45 +0100 >> Subject: [PATCH] rcu: kmemleak: Ignore kmemleak false positives when >> RCU-freeing objects >>=20 >> Since the actual slab freeing is deferred when calling kvfree_rcu(), so >> is the kmemleak_free() callback informing kmemleak of the object >> deletion. =46rom the perspective of the kvfree_rcu() caller, the object i= s >> freed and it may remove any references to it. Since kmemleak does not >> scan the tree RCU internal data storing the pointer, it will report such >> objects as leaks during the grace period. >>=20 >> Tell kmemleak to ignore such objects on the kvfree_call_rcu() path. Note >> that the tiny RCU implementation does not have such issue since the >> objects can be tracked from the rcu_ctrlblk structure. >>=20 >> Signed-off-by: Catalin Marinas >> Reported-by: Christoph Paasch >> --- >> kernel/rcu/tree.c | 9 +++++++++ >> 1 file changed, 9 insertions(+) >>=20 >> diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c >> index cb1caefa8bd0..2ac39b5705df 100644 >> --- a/kernel/rcu/tree.c >> +++ b/kernel/rcu/tree.c >> @@ -31,6 +31,7 @@ >> #include >> #include >> #include >> +#include >> #include >> #include >> #include >> @@ -3388,6 +3389,14 @@ void kvfree_call_rcu(struct rcu_head *head, void *= ptr) >> success =3D true; >> } >>=20 >> + /* >> + * The kvfree_rcu() caller considers the pointer freed at this point= >> + * and likely removes any references to it. Since the the actual sla= b >=20 > Just in case you didn't send this patch, checkpatch.pl noticed that the > word "the" was repeated in the comment here above ("Since the the actual")= . Sounds like you detected a leak in the word the. :-) (Sorry could not resist). - Joel >=20 > Cheers, > Matt >=20 >> + * freeing (and kmemleak_free()) is deferred, tell kmemleak to ignor= e >> + * this object (no scanning or false positives reporting). >> + */ >> + kmemleak_ignore(ptr); >> + >> // Set timer to drain after KFREE_DRAIN_JIFFIES. >> if (rcu_scheduler_active =3D=3D RCU_SCHEDULER_RUNNING) >> schedule_delayed_monitor_work(krcp); >=20 > --=20 > Tessares | Belgium | Hybrid Access Solutions > www.tessares.net