mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Will Deacon <will.deacon@arm.com>
Cc: Gao Xiang <gaoxiang25@huawei.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Philippe Ombredanne <pombredanne@nexb.com>,
	Kate Stewart <kstewart@linuxfoundation.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	linux-kernel@vger.kernel.org, Miao Xie <miaoxie@huawei.com>,
	Chao Yu <chao@kernel.org>
Subject: Re: [PATCH v2] bit_spinlock: introduce smp_cond_load_relaxed
Date: Tue, 6 Nov 2018 10:06:42 +0100	[thread overview]
Message-ID: <20181106090642.GH22431@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20181105224654.GA25864@brain-police>

On Mon, Nov 05, 2018 at 10:49:21PM +0000, Will Deacon wrote:
> diff --git a/include/asm-generic/bitops/lock.h b/include/asm-generic/bitops/lock.h
> index 3ae021368f48..9de8d3544630 100644
> --- a/include/asm-generic/bitops/lock.h
> +++ b/include/asm-generic/bitops/lock.h
> @@ -6,6 +6,15 @@
>  #include <linux/compiler.h>
>  #include <asm/barrier.h>
>  
> +static inline void spin_until_bit_unlock(unsigned int nr,
> +					 volatile unsigned long *p)
> +{
> +	unsigned long mask = BIT_MASK(bitnum);
> +
> +	p += BIT_WORD(nr);
> +	smp_cond_load_relaxed(p, VAL & mask);
> +}
> +
>  /**
>   * test_and_set_bit_lock - Set a bit and return its old value, for lock
>   * @nr: Bit to set
> diff --git a/include/linux/bit_spinlock.h b/include/linux/bit_spinlock.h
> index bbc4730a6505..d711c62e718c 100644
> --- a/include/linux/bit_spinlock.h
> +++ b/include/linux/bit_spinlock.h
> @@ -26,9 +26,7 @@ static inline void bit_spin_lock(int bitnum, unsigned long *addr)
>  #if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)
>  	while (unlikely(test_and_set_bit_lock(bitnum, addr))) {
>  		preempt_enable();
> -		do {
> -			cpu_relax();
> -		} while (test_bit(bitnum, addr));
> +		spin_until_bit_unlock(bitnum, addr);
>  		preempt_disable();
>  	}
>  #endif

Yes, that's much better. Ideally though, we'd get rid of bit spinlocks
that have significant enough contention for this to matter.



  parent reply	other threads:[~2018-11-06  9:06 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-13  6:47 [RFC PATCH] " Gao Xiang
2018-10-13  7:04 ` Greg Kroah-Hartman
2018-10-13  7:22   ` Gao Xiang
2018-10-13  7:30     ` Greg Kroah-Hartman
2018-10-13  7:44       ` Gao Xiang
2018-10-13  7:30     ` Gao Xiang
2018-10-30  6:04 ` [PATCH v2] " Gao Xiang
2018-10-30  5:52   ` Gao Xiang
2018-11-05 17:11     ` Gao Xiang
2018-11-05 22:49   ` Will Deacon
2018-11-06  1:45     ` Gao Xiang
2018-11-06  9:06     ` Peter Zijlstra [this message]
2018-11-06 10:22       ` Gao Xiang
2018-11-06 11:00         ` Peter Zijlstra
2018-11-06 11:36           ` Gao Xiang
2018-11-06 12:27             ` Peter Zijlstra
2018-11-06 12:33               ` Gao Xiang
2018-11-06 12:38                 ` Gao Xiang
2018-11-06 12:43                 ` Peter Zijlstra

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=20181106090642.GH22431@hirez.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=chao@kernel.org \
    --cc=gaoxiang25@huawei.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=kstewart@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=miaoxie@huawei.com \
    --cc=pombredanne@nexb.com \
    --cc=tglx@linutronix.de \
    --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

all inboxes | Powered by JetHome®