The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Waiman Long <longman@redhat.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@redhat.com>, Will Deacon <will.deacon@arm.com>,
	linux-kernel@vger.kernel.org,
	Bart Van Assche <bvanassche@acm.org>
Subject: Re: [PATCH v6 6/6] locking/lockdep: Reuse freed chain_hlocks entries
Date: Thu, 6 Feb 2020 12:06:45 -0500	[thread overview]
Message-ID: <951c86c9-9340-c4af-35e6-8ac205d702ab@redhat.com> (raw)
In-Reply-To: <20200206160334.GV14914@hirez.programming.kicks-ass.net>

On 2/6/20 11:03 AM, Peter Zijlstra wrote:
> On Thu, Feb 06, 2020 at 10:24:08AM -0500, Waiman Long wrote:
>> +#define for_each_chain_block(bucket, prev, curr)		\
>> +	for ((prev) = -1, (curr) = chain_block_buckets[bucket];	\
>> +	     (curr) >= 0;					\
>> +	     (prev) = (curr), (curr) = chain_block_next(curr))
>> +static inline void add_chain_block(int offset, int size)
>> +{
>> +	int bucket = size_to_bucket(size);
>> +	int next = chain_block_buckets[bucket];
>> +	int prev, curr;
>> +
>> +	if (unlikely(size < 2)) {
>> +		/*
>> +		 * We can't store single entries on the freelist. Leak them.
>> +		 *
>> +		 * One possible way out would be to uniquely mark them, other
>> +		 * than with CHAIN_BLK_FLAG, such that we can recover them when
>> +		 * the block before it is re-added.
>> +		 */
>> +		if (size)
>> +			nr_lost_chain_hlocks++;
>> +		return;
>> +	}
>> +
>> +	nr_free_chain_hlocks += size;
>> +	if (!bucket) {
>> +		nr_large_chain_blocks++;
>> +
>> +		if (unlikely(next >= 0)) {
> I was surprised by this condition..

Yes, this condition is optional and the code will still work as expected
without that. I added that so that for the common case where there is
only 1 chain block in block 0 and it gets deleted and added
repetitively, it will go to the simpler code path instead of the more
complicated one.

Cheers,
Longman


  reply	other threads:[~2020-02-06 17:07 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-06 15:24 [PATCH v6 0/6] locking/lockdep: Reuse zapped chain_hlocks entries Waiman Long
2020-02-06 15:24 ` [PATCH v6 1/6] locking/lockdep: Decrement irq context counters when removing lock chain Waiman Long
2020-02-11 12:48   ` [tip: locking/core] locking/lockdep: Decrement IRQ " tip-bot2 for Waiman Long
2020-02-06 15:24 ` [PATCH v6 2/6] locking/lockdep: Display irq_context names in /proc/lockdep_chains Waiman Long
2020-02-11 12:48   ` [tip: locking/core] " tip-bot2 for Waiman Long
2020-02-06 15:24 ` [PATCH v6 3/6] locking/lockdep: Track number of zapped classes Waiman Long
2020-02-11 12:48   ` [tip: locking/core] " tip-bot2 for Waiman Long
2020-02-06 15:24 ` [PATCH v6 4/6] locking/lockdep: Throw away all lock chains with zapped class Waiman Long
2020-02-11 12:48   ` [tip: locking/core] " tip-bot2 for Waiman Long
2020-02-06 15:24 ` [PATCH v6 5/6] locking/lockdep: Track number of zapped lock chains Waiman Long
2020-02-11 12:48   ` [tip: locking/core] " tip-bot2 for Waiman Long
2020-02-06 15:24 ` [PATCH v6 6/6] locking/lockdep: Reuse freed chain_hlocks entries Waiman Long
2020-02-06 16:03   ` Peter Zijlstra
2020-02-06 17:06     ` Waiman Long [this message]
2020-02-06 16:16   ` Peter Zijlstra
2020-02-06 17:08     ` Waiman Long
2020-02-06 17:31       ` Peter Zijlstra
2020-02-11 12:48   ` [tip: locking/core] " tip-bot2 for Waiman Long

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=951c86c9-9340-c4af-35e6-8ac205d702ab@redhat.com \
    --to=longman@redhat.com \
    --cc=bvanassche@acm.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=will.deacon@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox