[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <C2D7FE5348E1B147BCA15975FBA23075F44CB43D@IN01WEMBXA.internal.synopsys.com>
Date: Tue, 20 Oct 2015 08:00:46 +0000
From: Vineet Gupta <Vineet.Gupta1@...opsys.com>
To: Peter Zijlstra <peterz@...radead.org>,
Noam Camus <noamc@...hip.com>
CC: Andi Kleen <andi@...stfloor.org>,
Alexey Brodkin <Alexey.Brodkin@...opsys.com>,
Gilad Ben Yossef <giladb@...hip.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"linux-perf-users@...r.kernel.org" <linux-perf-users@...r.kernel.org>,
"dvhart@...ux.intel.com" <dvhart@...ux.intel.com>,
"dsahern@...il.com" <dsahern@...il.com>,
"acme@...hat.com" <acme@...hat.com>
Subject: Re: [RFC] perf: fix building for ARCv1
On Monday 19 October 2015 03:22 PM, Peter Zijlstra wrote:
> On Mon, Oct 19, 2015 at 09:46:35AM +0000, Vineet Gupta wrote:
>> On ARC we could use the atomic EXchange to implement a user space only binary
>> semaphore - these atomic ops will be small duration so it is OK to spin wait for a
>> little bit. That's how the old pthread library worked for ARC w/o any atomic support.
> That has the obvious problem of lock-holder-preemption and the horrible
> performance issues that result from that.
>
> I think the syscall at least has deterministic behaviour, whereas that
> userspace spin loop has this abysmal worst case thing.
I don't have issue with adding the syscall per-se. But that comes with it's own
headaches of ABI change - more importantly it requires several things to match,
libc, kernel... It would be easier if change was confined to say perf.
Can we use existing syscall(s) - again this is what our good old pthread library
code did.
static void __pthread_acquire(int * spinlock)
{
int cnt = 0;
struct timespec tm;
READ_MEMORY_BARRIER();
while (testandset(spinlock)) { <---- atomic EXchange
if (cnt < 50) {
sched_yield();
cnt++;
} else {
tm.tv_sec = 0;
tm.tv_nsec = 2000001;
nanosleep(&tm, ((void *)0));
cnt = 0;
}
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists