Re: [PATCH v3 net-next 01/23] lib: add reference counting tracking infrastructure
flat view
From: Andrzej Hajda <andrzej.hajda@intel.com>
Date: 2021-12-08 15:04:29
On 08.12.2021 15:27, Dmitry Vyukov wrote:
On Wed, 8 Dec 2021 at 15:09, Andrzej Hajda [off-list ref] wrote:quoted
Hi Eric, I've spotted this patchset thanks to LWN, anyway it was merged very quickly, I think it missed more broader review. As the patch touches kernel lib I have added few people who could be interested. On 05.12.2021 05:21, Eric Dumazet wrote:quoted
From: Eric Dumazet <redacted> It can be hard to track where references are taken and released. In networking, we have annoying issues at device or netns dismantles, and we had various proposals to ease root causing them. This patch adds new infrastructure pairing refcount increases and decreases. This will self document code, because programmers will have to associate increments/decrements. This is controled by CONFIG_REF_TRACKER which can be selected by users of this feature. This adds both cpu and memory costs, and thus should probably be used with care. Signed-off-by: Eric Dumazet <redacted> Reviewed-by: Dmitry Vyukov <dvyukov@google.com> ---Life is surprising, I was working on my own framework, solving the same issue, with intention to publish it in few days :) My approach was little different: 1. Instead of creating separate framework I have extended debug_objects. 2. There were no additional fields in refcounted object and trackers - infrastructure of debug_objects was reused - debug_objects tracked both pointers of refcounted object and its users. Have you considered using debug_object? it seems to be good place to put it there, I am not sure about performance differences.Hi Andrzej, How exactly did you do it? Do you have a link to your patch? There still should be something similar to `struct ref_tracker` in this patch, right? Or how do you match decrements with increments and understand when a double-decrement happens?
User during taking/dropping reference should pass pointer of the object who uses the reference (user). And this pointer is tracked by debug_objects: - on taking reference: the pointer is added to in-framework array associated with that reference, - on dropping reference: framework checks if the pointer is in the array/quarantine, and the bug is accordingly reported. - on destroying reference: bug is reported if users array is not empty, - on taking/dropping reference to non-existing/destroyed object: bug is reported. So instead of adding tracker field to user and passing it to the framework, address of the user itself is passed to the framework. Regards Andrzej