public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Davidlohr Bueso <dave@stgolabs.net>
To: Laurent Dufour <ldufour@linux.vnet.ibm.com>
Cc: mingo@kernel.org, peterz@infradead.org,
	akpm@linux-foundation.org, jack@suse.cz,
	kirill.shutemov@linux.intel.com, mhocko@suse.com,
	mgorman@techsingularity.net, linux-kernel@vger.kernel.org,
	Davidlohr Bueso <dbueso@suse.de>
Subject: Re: [PATCH 2/6] locking: Introduce range reader/writer lock
Date: Thu, 20 Apr 2017 09:01:33 -0700	[thread overview]
Message-ID: <20170420155125.GA20746@linux-80c1.suse> (raw)
In-Reply-To: <b1a53492-7fb3-a3cd-80d1-92dc4be5d8c4@linux.vnet.ibm.com>

On Tue, 18 Apr 2017, Laurent Dufour wrote:

>On 06/04/2017 10:46, Davidlohr Bueso wrote:
>> +__range_read_lock_common(struct range_rwlock_tree *tree,
>> +			 struct range_rwlock *lock, long state)
>> +{
>> +	struct interval_tree_node *node;
>> +	unsigned long flags;
>> +
>> +	spin_lock_irqsave(&tree->lock, flags);
>> +	range_lock_set_reader(lock);
>> +
>> +	if (!__range_intersects_intree(tree, lock))
>> +		goto insert;
>> +
>> +	range_interval_tree_foreach(node, &tree->root,
>> +				    lock->node.start, lock->node.last) {
>> +		struct range_rwlock *blocked_lock;
>> +		blocked_lock = range_entry(node, struct range_rwlock, node);
>> +
>> +		if (!range_lock_is_reader(blocked_lock))
>> +			lock->blocking_ranges++;
>> +	}
>> +insert:
>> +	__range_tree_insert(tree, lock);
>> +
>> +	lock->waiter = current;
>
>Hi Davidlohr,
>
>Setting lock->waiter after calling range_lock_set_reader() is resetting
>the reader flag. Moving the call to range_lock_set_reader() here fixes that.

Yeah, I moved the set_reader() call to after setting lock->waiter.

>
>> +	spin_unlock_irqrestore(&tree->lock, flags);
>> +
>> +	return wait_for_ranges(tree, lock, state);
>> +}

[...]

>> +int range_read_trylock(struct range_rwlock_tree *tree, struct range_rwlock *lock)
>> +{
>> +	int ret = true;
>> +	unsigned long flags;
>> +	struct interval_tree_node *node;
>> +
>> +	spin_lock_irqsave(&tree->lock, flags);
>> +
>> +	if (!__range_intersects_intree(tree, lock))
>> +		goto insert;
>> +
>> +	/*
>> +	 * We have overlapping ranges in the tree, ensure that we can
>> +	 * in fact share the lock.
>> +	 */
>> +	range_interval_tree_foreach(node, &tree->root,
>> +				    lock->node.start, lock->node.last) {
>> +		struct range_rwlock *blocked_lock;
>> +		blocked_lock = range_entry(node, struct range_rwlock, node);
>> +
>> +		if (!range_lock_is_reader(blocked_lock)) {
>> +			ret = false;
>> +			goto unlock;
>> +		}
>> +	}
>> +insert:
>> +	range_lock_set_reader(lock);
>
>Here, the lock->waiter field should have been set to current before
>calling range_lock_set_reader()

But this is a trylock attempt, there is no waiting going on.

Thanks,
Davidlohr

  reply	other threads:[~2017-04-20 16:02 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-06  8:46 [PATCH v2 -tip 0/6] locking: Introduce range reader/writer lock Davidlohr Bueso
2017-04-06  8:46 ` [PATCH 1/6] interval-tree: Build unconditionally Davidlohr Bueso
2017-04-06  8:46 ` [PATCH 2/6] locking: Introduce range reader/writer lock Davidlohr Bueso
2017-04-06  9:01   ` Laurent Dufour
2017-04-06 16:50     ` Davidlohr Bueso
2017-04-13  8:07       ` Laurent Dufour
2017-04-13  8:38         ` Jan Kara
2017-04-13  8:58           ` Laurent Dufour
2017-04-06 10:24   ` Peter Zijlstra
2017-04-18 13:57   ` Laurent Dufour
2017-04-20 16:01     ` Davidlohr Bueso [this message]
2017-04-21  7:00       ` Laurent Dufour
2017-04-06  8:46 ` [PATCH 3/6] locking/locktorture: Fix rwsem reader_delay Davidlohr Bueso
2017-04-06  8:46 ` [PATCH 4/6] locking/locktorture: Fix num reader/writer corner cases Davidlohr Bueso
2017-04-06  8:46 ` [PATCH 5/6] locking/locktorture: Support range rwlocks Davidlohr Bueso
2017-04-06  8:46 ` [PATCH 6/6] staging/lustre: Use generic range rwlock Davidlohr Bueso
2017-04-07 10:08   ` Dilger, Andreas
2017-04-19 12:37 ` [PATCH v2 -tip 0/6] locking: Introduce range reader/writer lock Peter Zijlstra
2017-04-20 17:13   ` Davidlohr Bueso
2017-04-20 17:53     ` Peter Zijlstra
2017-04-20 18:36       ` Davidlohr Bueso
2017-04-20 19:10         ` Peter Zijlstra
2017-05-15  9:19           ` Davidlohr Bueso
  -- strict thread matches above, loose matches on Subject: below --
2017-05-15  9:07 [PATCH v3 " Davidlohr Bueso
2017-05-15  9:07 ` [PATCH 2/6] " Davidlohr Bueso
2017-05-15 13:02   ` Peter Zijlstra
2017-05-16 22:19     ` Davidlohr Bueso
2017-05-15 13:44   ` Peter Zijlstra
2017-05-16 21:17     ` Davidlohr Bueso
2017-05-15 13:59   ` Peter Zijlstra
2017-05-23 15:12   ` Laurent Dufour

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=20170420155125.GA20746@linux-80c1.suse \
    --to=dave@stgolabs.net \
    --cc=akpm@linux-foundation.org \
    --cc=dbueso@suse.de \
    --cc=jack@suse.cz \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=ldufour@linux.vnet.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@techsingularity.net \
    --cc=mhocko@suse.com \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    /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