From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alexey Brodkin Subject: Re: [RFC] perf: fix building for ARCv1 Date: Thu, 29 Oct 2015 15:58:16 +0000 Message-ID: <1446134296.3203.27.camel@synopsys.com> References: <1445166916.9672.10.camel@synopsys.com> <87a8rf6a6p.fsf@tassilo.jf.intel.com> <8761235rwe.fsf@tassilo.jf.intel.com> <20151019093549.GK3816@twins.programming.kicks-ass.net> <20151019095157.GM3816@twins.programming.kicks-ass.net> <20151020101133.GA17308@twins.programming.kicks-ass.net> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 Return-path: Received: from us01smtprelay-2.synopsys.com ([198.182.60.111]:44678 "EHLO smtprelay.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750967AbbJ2P6W (ORCPT ); Thu, 29 Oct 2015 11:58:22 -0400 In-Reply-To: Content-Language: en-US Content-ID: <5DBBFCF0CCBB7E488A58FF1FCF05652B@internal.synopsys.com> Sender: linux-perf-users-owner@vger.kernel.org List-ID: To: Vineet Gupta Cc: "linux-kernel@vger.kernel.org" , "peterz@infradead.org" , "tglx@linutronix.de" , "andi@firstfloor.org" , "linux-snps-arc@lists.infradead.org" , "acme@redhat.com" , "linux-perf-users@vger.kernel.org" , "giladb@ezchip.com" , "dsahern@gmail.com" , "dvhart@linux.intel.com" , "noamc@ezchip.com" SGkgVmluZWV0LA0KDQpPbiBUdWUsIDIwMTUtMTAtMjAgYXQgMTA6NDUgKzAwMDAsIFZpbmVldCBH dXB0YSB3cm90ZToNCj4gT24gVHVlc2RheSAyMCBPY3RvYmVyIDIwMTUgMDM6NDEgUE0sIFBldGVy IFppamxzdHJhIHdyb3RlOg0KPiA+ID4gPiBDYW4gd2UgdXNlIGV4aXN0aW5nIHN5c2NhbGwocykg LSBhZ2FpbiB0aGlzIGlzIHdoYXQgb3VyIGdvb2Qgb2xkIHB0aHJlYWQgbGlicmFyeQ0KPiA+ID4g PiBjb2RlI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IHZlcnNpb24gZG9lc24ndCBoYXZlIGFsbCBvZiB0aGlzIHNvbmctbi1kYW5jZSBhbmQg cmVsaWVzIG9uIGZ1dGV4ZXMuIFRoZQ0KPiBjaGFuZ2Ugd2UgYXJlIHRhbGtpbmcgYWJvdXQgaXMg b25seSBmb3IgdGhlIGF0b21pY3MgaW4gcGVyZiBpdHNlbGYuIEkgZG8NCj4gdW5kZXJzdGFuZCB5 b3VyIFBPViB0aG91Z2guDQo+IA0KPiA+IChhbHNvLCBmb3IgQUNRVUlSRSB5b3Ugd2FudCB0aGUg UkVBRF9NRU1PUllfQkFSUklFUigpIF9hZnRlcl8gdGhlDQo+ID4gdGVzdC1hbmQtc2V0IGNvbnRy b2wgZGVwZW5kZW5jeS4pDQo+IA0KPiBBYnNvbHV0ZWx5IGFuZCBpbiB0aGlzIGNhc2UgaXQgd2ls bCBoYXZlIHRvIGJlIGFkZGVkIGJvdGggaW5zaWRlIHRoZSBsb29wIGFuZCBvbmUNCj4gYXQgdGhl IGVuZCB0byBjb3ZlciBib3RoIHRoZSBzY2VuYXJpb3MgIQ0KPiANCg0KSSdtIHdvbmRlcmluZyB3 aGF0IGFyZSBvdXIgcGxhbnMgZm9yIG5vdz8NCkFyZSB3ZSBnb2luZyB0byBhY2NlcHQgcHJvcG9z ZWQgZml4IGp1c3QgZm9yIEFSQyBpbiA0LjQgKGFuZCB0byBhbGwgc3RhYmxlcyB0aGVuKQ0Kb3Ig d2UnbGwgdHJ5IHRvIGNvbWUgdXAgd2l0aCBtb3JlIGdlbmVyYWwgc29sdXRpb24/DQoNCi1BbGV4 ZXk= From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alexey.Brodkin@synopsys.com (Alexey Brodkin) Date: Thu, 29 Oct 2015 15:58:16 +0000 Subject: [RFC] perf: fix building for ARCv1 In-Reply-To: References: <1445166916.9672.10.camel@synopsys.com> <87a8rf6a6p.fsf@tassilo.jf.intel.com> <8761235rwe.fsf@tassilo.jf.intel.com> <20151019093549.GK3816@twins.programming.kicks-ass.net> <20151019095157.GM3816@twins.programming.kicks-ass.net> <20151020101133.GA17308@twins.programming.kicks-ass.net> List-ID: Message-ID: <1446134296.3203.27.camel@synopsys.com> To: linux-snps-arc@lists.infradead.org Hi Vineet, On Tue, 2015-10-20@10:45 +0000, Vineet Gupta wrote: > On Tuesday 20 October 2015 03:41 PM, Peter Zijlstra wrote: > > > > 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; > > > > } > > > > } > > *shudder* that is quite horrible. > > > > This means all your 'atomics' are broken for anything SCHED_FIFO and the > > like. You simply _cannot_ run a realtime system. > > The code above is from uClibc old threading library which we don't use anymore. > The NPTL version doesn't have all of this song-n-dance and relies on futexes. The > change we are talking about is only for the atomics in perf itself. I do > understand your POV though. > > > (also, for ACQUIRE you want the READ_MEMORY_BARRIER() _after_ the > > test-and-set control dependency.) > > Absolutely and in this case it will have to be added both inside the loop and one > at the end to cover both the scenarios ! > I'm wondering what are our plans for now? Are we going to accept proposed fix just for ARC in 4.4 (and to all stables then) or we'll try to come up with more general solution? -Alexey From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757453AbbJ2P6Y (ORCPT ); Thu, 29 Oct 2015 11:58:24 -0400 Received: from us01smtprelay-2.synopsys.com ([198.182.60.111]:44678 "EHLO smtprelay.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750967AbbJ2P6W (ORCPT ); Thu, 29 Oct 2015 11:58:22 -0400 From: Alexey Brodkin To: Vineet Gupta CC: "linux-kernel@vger.kernel.org" , "peterz@infradead.org" , "tglx@linutronix.de" , "andi@firstfloor.org" , "linux-snps-arc@lists.infradead.org" , "acme@redhat.com" , "linux-perf-users@vger.kernel.org" , "giladb@ezchip.com" , "dsahern@gmail.com" , "dvhart@linux.intel.com" , "noamc@ezchip.com" Subject: Re: [RFC] perf: fix building for ARCv1 Thread-Topic: [RFC] perf: fix building for ARCv1 Thread-Index: AQHRCjH5qUIZ06l560WdnGKbYbcPA56CoBcA Date: Thu, 29 Oct 2015 15:58:16 +0000 Message-ID: <1446134296.3203.27.camel@synopsys.com> References: <1445166916.9672.10.camel@synopsys.com> <87a8rf6a6p.fsf@tassilo.jf.intel.com> <8761235rwe.fsf@tassilo.jf.intel.com> <20151019093549.GK3816@twins.programming.kicks-ass.net> <20151019095157.GM3816@twins.programming.kicks-ass.net> <20151020101133.GA17308@twins.programming.kicks-ass.net> In-Reply-To: Accept-Language: en-US, ru-RU Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.121.8.144] Content-Type: text/plain; charset="utf-8" Content-ID: <5DBBFCF0CCBB7E488A58FF1FCF05652B@internal.synopsys.com> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by mail.home.local id t9TFwSkY015213 Hi Vineet, On Tue, 2015-10-20 at 10:45 +0000, Vineet Gupta wrote: > On Tuesday 20 October 2015 03:41 PM, Peter Zijlstra wrote: > > > > 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; > > > > } > > > > } > > *shudder* that is quite horrible. > > > > This means all your 'atomics' are broken for anything SCHED_FIFO and the > > like. You simply _cannot_ run a realtime system. > > The code above is from uClibc old threading library which we don't use anymore. > The NPTL version doesn't have all of this song-n-dance and relies on futexes. The > change we are talking about is only for the atomics in perf itself. I do > understand your POV though. > > > (also, for ACQUIRE you want the READ_MEMORY_BARRIER() _after_ the > > test-and-set control dependency.) > > Absolutely and in this case it will have to be added both inside the loop and one > at the end to cover both the scenarios ! > I'm wondering what are our plans for now? Are we going to accept proposed fix just for ARC in 4.4 (and to all stables then) or we'll try to come up with more general solution? -Alexey{.n++%ݶw{.n+{G{ayʇڙ,jfhz_(階ݢj"mG?&~iOzv^m ?I