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 25142EE14A9 for ; Wed, 6 Sep 2023 23:10:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 76E648D001F; Wed, 6 Sep 2023 19:10:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6F6C98D0005; Wed, 6 Sep 2023 19:10:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 570B58D001F; Wed, 6 Sep 2023 19:10:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 420D88D0005 for ; Wed, 6 Sep 2023 19:10:47 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id EEE3E120BB2 for ; Wed, 6 Sep 2023 23:10:46 +0000 (UTC) X-FDA: 81207719292.03.F64F231 Received: from mail-il1-f174.google.com (mail-il1-f174.google.com [209.85.166.174]) by imf06.hostedemail.com (Postfix) with ESMTP id 001A9180012 for ; Wed, 6 Sep 2023 23:10:44 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=joelfernandes.org header.s=google header.b=fhL1smGH; dmarc=none; spf=pass (imf06.hostedemail.com: domain of joel@joelfernandes.org designates 209.85.166.174 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=1694041845; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=ZYm4i3hdu7juwyOUQk1xpuXZZsw548ZwUyNloE+R6Ac=; b=Jirudm2kyRXXaBC7ZhOEoX9GRNE0Ggb4U5DcSVZM7FkHsqb2a4+x7QxQiiftHgVTUzWGUS ZVG+oxl7TnWnpjAcgs39kvW9S83VIGK8VTa1mp/eiYCPR5y2T0OGpb//FKVEFqMLaLrZTY Oa3azCuYlyipWujyPlDVWllcsJVueUE= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=joelfernandes.org header.s=google header.b=fhL1smGH; dmarc=none; spf=pass (imf06.hostedemail.com: domain of joel@joelfernandes.org designates 209.85.166.174 as permitted sender) smtp.mailfrom=joel@joelfernandes.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694041845; a=rsa-sha256; cv=none; b=DdgSOQU+P3WHpHwzRn86GAOmt3qOU1zkcAlZlUWDU8vGXwhrGaxjN/YDDzJKAToWuWbWf1 HKILRbPk6IFk4uQAa0hn/+NJ61adu7NKL7n1YgXBJNRVLOBvhuxFLgsphRQg6ZSOGZ+dL9 Rv/DTZ46cNG9YEqrjygvGjQYheHxqms= Received: by mail-il1-f174.google.com with SMTP id e9e14a558f8ab-34e15f33a72so1190285ab.3 for ; Wed, 06 Sep 2023 16:10:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; t=1694041844; x=1694646644; darn=kvack.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=ZYm4i3hdu7juwyOUQk1xpuXZZsw548ZwUyNloE+R6Ac=; b=fhL1smGHZ2PBEYWUBbbXLEMAr4Oue/oha5VKCucwINPZ9Z2jloJtNzDmcNSqbSQvJi 7vnD2UUuroubv6+wdGCJ5TwRG1+u/Z+o7JRSCrQdSpHU38eXageVYtYBdgBkakEUgUwG hwKqQCIKMxfT1MabJr7BQ9lnhb750nnV5/nMM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1694041844; x=1694646644; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=ZYm4i3hdu7juwyOUQk1xpuXZZsw548ZwUyNloE+R6Ac=; b=UCEQz4TCKi3CvbBRyZkPw3VxG2o4ZCpgK+AzrIoJkJmlwo309deLgNP5I80IfaFBQb K9OB2YHRR9ES5kt8i3hwRonX+WMfBkFPfhet1O4eBflzwQbVMXqREmD7qQghFr4hmStd tCalUtwUDHlGoLW2rLfRf4Mv+wzAzmAmPzj12NfvFhE1iYZkNsZC+lrbLTd+kKfsoIiT e8vfQjsvaIxtScPNvNIy9BiKZ/yR7R/JcV8ipQXLZY0s4UxPWLLOAOWehRAdOJWVnKD8 fKSQrJyJr02zmkPRyMhTNaB6BUldE2AuPqljOmi3qjuANdSWu361oIgvJf9aTQ0Gv/5K HNVg== X-Gm-Message-State: AOJu0YwOPcusFwV+VW2br2qRDetzT548DUTAKeFEsreCJMAYS6tAd2cw luxGqh1+PDb+LAaWT3LQ7arkSQ== X-Google-Smtp-Source: AGHT+IHNaizib5VvwK0oLEc0my890WJH2cjyEtGdhjY466dsxuMemrbybowAPHrFM9H94DX9Sflh3g== X-Received: by 2002:a05:6e02:1bcf:b0:349:9745:89f with SMTP id x15-20020a056e021bcf00b003499745089fmr20615111ilv.17.1694041844112; Wed, 06 Sep 2023 16:10:44 -0700 (PDT) Received: from localhost (156.190.123.34.bc.googleusercontent.com. [34.123.190.156]) by smtp.gmail.com with ESMTPSA id o2-20020a056638124200b0042b669f5084sm5326529jas.62.2023.09.06.16.10.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Sep 2023 16:10:43 -0700 (PDT) Date: Wed, 6 Sep 2023 23:10:42 +0000 From: Joel Fernandes To: "Paul E. McKenney" Cc: Catalin Marinas , Christoph Paasch , Andrew Morton , linux-mm@kvack.org, MPTCP Upstream , rcu@vger.kernel.org, urezki@gmail.com Subject: Re: kmemleak handling of kfree_rcu Message-ID: <20230906231042.GA1296802@google.com> References: <20230905111725.GA3737639@google.com> <20230906143529.GB1127143@google.com> <24f3d4fc-56c0-46bd-8e5b-af57f09fa777@paulmck-laptop> <38f21251-4911-4300-9b53-e390e621e68a@paulmck-laptop> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <38f21251-4911-4300-9b53-e390e621e68a@paulmck-laptop> X-Rspam-User: X-Stat-Signature: 3nwctsb4fa7ea9fa78kcuk44xfjmgpi3 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 001A9180012 X-HE-Tag: 1694041844-452010 X-HE-Meta: U2FsdGVkX18FS/bqd/qNJwbn0+UduEhlc0BHAf6qX5qnKAPHaL2eru4KyKwueo+EoCz2v3LMHPrFviBm3dOJNRESjQE5dVj5jdE4ln5bH3W8pLiDjxJcPcJdxS4fjrWDGf8Rige7EV7ieWebQJbYuO3t9jFavakQC3mcFNB113h4I2O5nOQDct1g2TkMgJDgeLRv/1oQkw5cC2+tJhpxc+omJZgcAsqOFSVQwOV+Ef1a0ewr3t6VSGk/rp+TU9xa18NJktFKtDo2C+Xt34iIg/e3EacBg2l0944cjwxia54fFv4h/m0JTeZh0plM3SQT6ZXPgZOj+jpabCT5msCeKNz4vGHLoHbHd5iTJyW+OniwJsj7YeQxlI4PcIyPbCX2TXL6V3o6LmWpGVDwEc3UkTtH6G6iWPbk6tRit68CXqXzNESAR+a9jOlDPhsHm1JWud87SYT/FgsO695GPxM7+gu74GVeChAaIYApJ+zMDMkkjB/foQXbxDXSeIdGyuW6ZxYQFVBcNsC7JNxpDNlHZSF2ZVP91G1raWj9MhJ+LB6Y615eamo4Jf/31jFLGQXq9fbARUUmumjdjTI+paTLBsizBVp+mQ7pMiYf63KJE7Oox8hnwscQcdK5KM1ZoWFWD/ueoWY09KKdNReegabkj9og1aHDJPXt01Bhs7EBsVUT5Ml5J6hlPnILEEE0JPTCl4ojbhq+lPVL623OQ/wb2nZ6Q2DC80qkCkjWi/+D7TyfG2YlMFadWu5VK0DOkoHoXZN79QXhIi/asUS3iP0qSeIk7AT0bHdBANbQF009r0Jzf5H+zhaGsSBoP1TpsKzFdVeQObFPCZ2edz+JXNnOTH6A1Bv8Kxm68FlaRFnsKA+w4Pbyyco/CDV4DBhE6I6i8Vs6vZ6M+/bdffi70M9TNXmRKtjD2+i2avdHdtJWlj5NaPIXhPr3qdOZ9HiE5lQQoQWcxYLZ89hqH5vJTXe B4gT17ZC 9VgG1WVSdeCZV54RdPhGQrtKdLlTeM4207+Yj8rk9hUjS4q55l3Q4k5JfcjVeT32CIWu9SqGQNVWnL1eaZBdwFYhgAK93q6qNaKwB8R4r6c8tH04W9NHZPEcTrUZkalkeUbnlzxitQANngFU42Ok04nJKb7hn0Plcv6SXARN/cuyoalLERLG7UcO+iVf7RTGz2meW5AdAgbcGbQMFH56iiyqExYGLH4w/5mUrEts3giGY705hs5/1vuPwAuvXbybhvyxQC0cXDzf1NzDRfiQLjDJzfRqYYRju+cFHab0Wga9rrnxel0sLEpsEswwdLczgLV/pTLf6ZQXzXrE4riFgxqullNVgJhEbHO2ug8PmqfwYDA8= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000013, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, Sep 06, 2023 at 03:02:45PM -0700, Paul E. McKenney wrote: > On Wed, Sep 06, 2023 at 10:37:40PM +0100, Catalin Marinas wrote: > > On Wed, Sep 06, 2023 at 12:11:12PM -0700, Paul E. McKenney wrote: > > > On Wed, Sep 06, 2023 at 06:15:49PM +0100, Catalin Marinas wrote: > > > > On Wed, Sep 06, 2023 at 02:35:29PM +0000, Joel Fernandes wrote: > > > > > On Tue, Sep 05, 2023 at 03:41:32PM +0100, Catalin Marinas wrote: > > > > > > On Tue, Sep 05, 2023 at 11:17:25AM +0000, Joel Fernandes wrote: > > > > > > > The correct fix then should probably be to mark the object as > > > > > > > kmemleak_not_leak() until a grace period elapses. This will cause the object > > > > > > > to not be reported but still be scanned until eventually the lower layers > > > > > > > will remove the object from kmemleak-tracking after the grace period. Per the > > > > > > > docs also, that API is used to prevent false-positives. > > > > > > > > > > > > This should work as well but I'd use kmemleak_ignore() instead of > > > > > > kmemleak_not_leak(). The former, apart from masking the false positive, > > > > > > also tells kmemleak not to scan the object. After a kvfree_rcu(), the > > > > > > object shouldn't have any valid references to other objects, so not > > > > > > worth scanning. > > > > > > > > > > Yes I am also OK with that, however to me I consider the object as alive as > > > > > long as the grace period does not end. But I agree with you and it may not be > > > > > worth tracking them or scanning them. > > > > > > > > I guess from an RCU perspective, the object is still alive. From the > > > > kvfree_rcu() caller perspective though, it can disappear at any point > > > > after the grace period, so it shouldn't rely on its content being valid > > > > and referencing other objects (other than transiently e.g. in RCU list > > > > traversal). > > > > > > > > It probably only matters if we have some very long grace periods (I'm > > > > not up to date with the recent RCU developments). In such cases, the > > > > object still being scanned could introduce false negatives. That's my > > > > reasoning for suggesting kmemleak_ignore() rather than > > > > kmemleak_not_leak(). > > > > > > Very long RCU readers still result in very long RCU grace periods. And, > > > after some tens of seconds, RCU CPU stall warnings. So don't let your > > > RCU readers run for that long. But you knew that already. ;-) > > > > That's still ok. I was more thinking of deferred freeing well past the > > RCU readers completing. > > Ah, that can happen. Some kernels are built with CONFIG_RCU_LAZY=y, which > delays freeing in order to reduce power consumption. And kfree_rcu() > will also delay for a bit. But in both cases, a flood of callbacks > should get things going again. > > But an isolated kfree_rcu() might well see a few seconds delay. > Saving your battery! ;-) I agree with both of you. I also think kmemleak_ignore() is the right thing to do for kfree_rcu(). thanks, - Joel