[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <81ae464f-ade8-fb3c-6bfa-11de19c21845@intel.com>
Date: Mon, 20 Mar 2023 16:39:01 +0100
From: Andrzej Hajda <andrzej.hajda@...el.com>
To: Andi Shyti <andi.shyti@...ux.intel.com>
Cc: Chris Wilson <chris.p.wilson@...el.com>, netdev@...r.kernel.org,
intel-gfx@...ts.freedesktop.org, linux-kernel@...r.kernel.org,
Chris Wilson <chris@...is-wilson.co.uk>,
Eric Dumazet <edumazet@...gle.com>,
dri-devel@...ts.freedesktop.org, Daniel Vetter <daniel@...ll.ch>,
Rodrigo Vivi <rodrigo.vivi@...el.com>,
Jakub Kicinski <kuba@...nel.org>,
David Airlie <airlied@...il.com>,
Dmitry Vyukov <dvyukov@...gle.com>
Subject: Re: [Intel-gfx] [PATCH v4 02/10] lib/ref_tracker:
__ref_tracker_dir_print improve printing
On 20.03.2023 00:11, Andi Shyti wrote:
> Hi Andrzej,
>
> looks good, few comments below,
>
> On Mon, Mar 06, 2023 at 05:31:58PM +0100, Andrzej Hajda wrote:
>> To improve readability of ref_tracker printing following changes
>> have been performed:
>> - reports are printed per stack_handle - log is more compact,
>> - added display name for ref_tracker_dir,
>> - stack trace is printed indented, in the same printk call,
>> - total number of references is printed every time,
>> - print info about dropped references.
>
> nit: I think you can do better with the log :)
>
>> Signed-off-by: Andrzej Hajda <andrzej.hajda@...el.com>
>> ---
>> include/linux/ref_tracker.h | 15 ++++++--
>> lib/ref_tracker.c | 90 +++++++++++++++++++++++++++++++++++++++------
>> 2 files changed, 91 insertions(+), 14 deletions(-)
>>
>> diff --git a/include/linux/ref_tracker.h b/include/linux/ref_tracker.h
>> index 3e9e9df2a41f5f..a2cf1f6309adb2 100644
>> --- a/include/linux/ref_tracker.h
>> +++ b/include/linux/ref_tracker.h
>> @@ -17,12 +17,19 @@ struct ref_tracker_dir {
>> bool dead;
>> struct list_head list; /* List of active trackers */
>> struct list_head quarantine; /* List of dead trackers */
>> + char name[32];
>> #endif
>> };
>>
>> #ifdef CONFIG_REF_TRACKER
>> -static inline void ref_tracker_dir_init(struct ref_tracker_dir *dir,
>> - unsigned int quarantine_count)
>> +
>> +// Temporary allow two and three arguments, until consumers are converted
>
> I thought only Linus was allowed to use '//' :)
>
>> +#define ref_tracker_dir_init(_d, _q, args...) _ref_tracker_dir_init(_d, _q, ##args, #_d)
>> +#define _ref_tracker_dir_init(_d, _q, _n, ...) __ref_tracker_dir_init(_d, _q, _n)
>
> [...]
>
>> +void __ref_tracker_dir_print(struct ref_tracker_dir *dir,
>> + unsigned int display_limit)
>> +{
>> + struct ref_tracker_dir_stats *stats;
>> + unsigned int i = 0, skipped;
>> + depot_stack_handle_t stack;
>> + char *sbuf;
>> +
>> + lockdep_assert_held(&dir->lock);
>> +
>> + if (list_empty(&dir->list))
>> + return;
>> +
>> + stats = ref_tracker_get_stats(dir, display_limit);
>> + if (IS_ERR(stats)) {
>> + pr_err("%s@%pK: couldn't get stats, error %pe\n",
>> + dir->name, dir, stats);
>> + return;
>> }
>> +
>> + sbuf = kmalloc(STACK_BUF_SIZE, GFP_NOWAIT | __GFP_NOWARN);
>> +
>> + for (i = 0, skipped = stats->total; i < stats->count; ++i) {
>> + stack = stats->stacks[i].stack_handle;
>> + if (sbuf && !stack_depot_snprint(stack, sbuf, STACK_BUF_SIZE, 4))
>> + sbuf[0] = 0;
>> + pr_err("%s@%pK has %d/%d users at\n%s\n", dir->name, dir,
>> + stats->stacks[i].count, stats->total, sbuf);
>
> what if sbuf is NULL?
Then "(NULL)" will be printed, I suspect it will occur only on very rare
occasions.
>
>> + skipped -= stats->stacks[i].count;
>> + }
>> +
>> + if (skipped)
>
> is skipped used to double check whether stats->count is equal to
> all the stacks[].conunts? What are the cases when skipped is > 0?
There is display_limit parameter, so the function prints up to
display_limit reports, and brief summary on remaining ones - the skipped
ones.
Regards
Andrzej
>
> Andi
>
>> + pr_err("%s@%pK skipped reports about %d/%d users.\n",
>> + dir->name, dir, skipped, stats->total);
>> +
>> + kfree(sbuf);
>> +
>> + kfree(stats);
>> }
>> EXPORT_SYMBOL(__ref_tracker_dir_print);
>>
>>
>> --
>> 2.34.1
Powered by blists - more mailing lists