Re: [PATCH v5 6/7] locking/lockdep: Reuse freed chain_hlocks entries

From: Waiman Long
Date: Wed Feb 05 2020 - 08:59:30 EST


On 2/5/20 4:41 AM, Peter Zijlstra wrote:
> On Tue, Feb 04, 2020 at 11:45:15AM -0500, Waiman Long wrote:
>> On 2/4/20 7:36 AM, Peter Zijlstra wrote:
>>> --- a/kernel/locking/lockdep_proc.c
>>> +++ b/kernel/locking/lockdep_proc.c
>>> @@ -278,9 +278,11 @@ static int lockdep_stats_show(struct seq
>>> #ifdef CONFIG_PROVE_LOCKING
>>> seq_printf(m, " dependency chains: %11lu [max: %lu]\n",
>>> lock_chain_count(), MAX_LOCKDEP_CHAINS);
>>> - seq_printf(m, " dependency chain hlocks: %11lu [max: %lu]\n",
>>> - MAX_LOCKDEP_CHAIN_HLOCKS - nr_free_chain_hlocks,
>>> + seq_printf(m, " dependency chain hlocks used: %11lu [max: %lu]\n",
>>> + MAX_LOCKDEP_CHAIN_HLOCKS - (nr_free_chain_hlocks - nr_lost_chain_hlocks),
>>> MAX_LOCKDEP_CHAIN_HLOCKS);
>>> + seq_printf(m, " dependency chain hlocks free: %11lu\n", nr_free_chain_hlocks);
>>> + seq_printf(m, " dependency chain hlocks lost: %11lu\n", nr_lost_chain_hlocks);
>> I do have some comments on this. There are three buckets now - free,
>> lost, used. They add up to MAX_LOCKDEP_CHAIN_HLOCKS. I don't think we
>> need to list all three. We can compute the third one by subtracting max
>> from the other two.
>>
>> Something like:
>>
>> diff --git a/kernel/locking/lockdep_proc.c b/kernel/locking/lockdep_proc.c
>> index 14932ea50317..6fe6a21c58d3 100644
>> --- a/kernel/locking/lockdep_proc.c
>> +++ b/kernel/locking/lockdep_proc.c
>> @@ -278,9 +278,12 @@ static int lockdep_stats_show(struct seq_file *m,
>> void *v)
>> Â#ifdef CONFIG_PROVE_LOCKING
>> ÂÂÂÂÂÂÂ seq_printf(m, " dependency chains:ÂÂÂÂÂÂÂÂÂÂÂÂ %11lu [max: %lu]\n",
>> ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ lock_chain_count(), MAX_LOCKDEP_CHAINS);
>> -ÂÂÂÂÂÂ seq_printf(m, " dependency chain hlocks:ÂÂÂÂÂÂ %11lu [max: %lu]\n",
>> -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ MAX_LOCKDEP_CHAIN_HLOCKS - nr_free_chain_hlocks,
>> +ÂÂÂÂÂÂ seq_printf(m, " dependency chain hlocks used:Â %11lu [max: %lu]\n",
>> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ MAX_LOCKDEP_CHAIN_HLOCKS -
>> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ (nr_free_chain_hlocks + nr_lost_chain_hlocks),
>> ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ MAX_LOCKDEP_CHAIN_HLOCKS);
>> +ÂÂÂÂÂÂ seq_printf(m, " dependency chain hlocks lost:Â %11lu\n",
>> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ nr_lost_chain_hlocks);
>> Â#endif
>> Â
> Sure, also I tihnk the compiler is unhappy about %lu vs 'unsigned int'
> for some of them.
>
Yes, I found that after I compiled the code :-)

Cheers,
Longman