public inbox for linuxppc-dev@ozlabs.org 
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead•org>
To: Torsten Duwe <duwe@lst•de>
Cc: Tom Musta <tommusta@gmail•com>,
	linux-kernel@vger•kernel.org, Paul Mackerras <paulus@samba•org>,
	Anton Blanchard <anton@samba•org>,
	Scott Wood <scottwood@freescale•com>,
	"Paul E. McKenney" <paulmck@linux•vnet.ibm.com>,
	linuxppc-dev@lists•ozlabs.org, Ingo Molnar <mingo@kernel•org>
Subject: Re: [PATCH v2] powerpc ticket locks
Date: Mon, 10 Feb 2014 18:53:25 +0100	[thread overview]
Message-ID: <20140210175325.GA27965@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <20140210155217.GF2107@lst.de>

On Mon, Feb 10, 2014 at 04:52:17PM +0100, Torsten Duwe wrote:
> Opinions, anyone?

Since the holder thing is a performance thing, not a correctness thing;
one thing you could do is something like:

static const int OWNER_HASH_SIZE = CONFIG_NR_CPUS * 4;
static const int OWNER_HASH_BITS = ilog2(OWNER_HASH_SIZE);

u16 lock_owner_array[OWNER_HASH_SIZE] = { 0, };

void set_owner(struct arch_spinlock_t *lock, int owner)
{
	int hash = hash_ptr(lock, OWNER_HASH_BITS);
	lock_owner_array[hash] = owner;
}

void yield_to_owner(struct arch_spinlock_t *lock)
{
	int hash = hash_ptr(lock, OWNER_HASH_BITS);
	int owner = lock_owner_array[hash];
	yield_to_cpu(owner);
}

And call set_owner() after the ticket lock is acquired, and don't bother
clearing it again; a new acquire will overwrite, a collision we have to
live with.

It should on average get you the right yield and does away with having
to track the owner field in place.

It does however get you an extra cacheline miss on acquire :/

One could consider patching it out when you know your kernel is not
running on an overloaded partition.

  reply	other threads:[~2014-02-10 17:53 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-07 16:58 [PATCH v2] powerpc ticket locks Torsten Duwe
2014-02-07 17:12 ` Peter Zijlstra
2014-02-07 17:55   ` Torsten Duwe
2014-02-10  3:10 ` Benjamin Herrenschmidt
2014-02-10 15:52   ` Torsten Duwe
2014-02-10 17:53     ` Peter Zijlstra [this message]
2014-02-11  2:44     ` Benjamin Herrenschmidt
2014-02-11  2:56       ` Al Viro
2014-02-11  3:38         ` Benjamin Herrenschmidt
2014-02-11  9:53   ` Raghavendra KT
2014-02-11 10:40     ` Torsten Duwe
2014-02-11 18:30       ` Scott Wood
2014-02-11 19:34         ` Benjamin Herrenschmidt
2014-02-11  9:39 ` Raghavendra KT

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=20140210175325.GA27965@twins.programming.kicks-ass.net \
    --to=peterz@infradead$(echo .)org \
    --cc=anton@samba$(echo .)org \
    --cc=duwe@lst$(echo .)de \
    --cc=linux-kernel@vger$(echo .)kernel.org \
    --cc=linuxppc-dev@lists$(echo .)ozlabs.org \
    --cc=mingo@kernel$(echo .)org \
    --cc=paulmck@linux$(echo .)vnet.ibm.com \
    --cc=paulus@samba$(echo .)org \
    --cc=scottwood@freescale$(echo .)com \
    --cc=tommusta@gmail$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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