From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?utf-8?B?T25kxZllaiBCw61sa2E=?= Subject: Re: [RFC PATCH] getcpu_cache system call: caching current CPU number (x86) Date: Tue, 21 Jul 2015 17:16:13 +0200 Message-ID: <20150721151613.GA12856@domone> References: <1436724386-30909-1-git-send-email-mathieu.desnoyers@efficios.com> <55AD14A4.6030101@redhat.com> <2010227315.699.1437438300542.JavaMail.zimbra@efficios.com> <20150721073053.GA14716@domone> <894137397.137.1437483493715.JavaMail.zimbra@efficios.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Return-path: Content-Disposition: inline In-Reply-To: <894137397.137.1437483493715.JavaMail.zimbra-vg+e7yoeK/dWk0Htik3J/w@public.gmane.org> Sender: linux-api-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Mathieu Desnoyers Cc: Linus Torvalds , Andy Lutomirski , Ben Maurer , Ingo Molnar , libc-alpha , Andrew Morton , linux-api , rostedt , "Paul E. McKenney" , Florian Weimer , Josh Triplett , Lai Jiangshan , Paul Turner , Andrew Hunter , Peter Zijlstra List-Id: linux-api@vger.kernel.org On Tue, Jul 21, 2015 at 12:58:13PM +0000, Mathieu Desnoyers wrote: > ----- On Jul 21, 2015, at 3:30 AM, Ond=C5=99ej B=C3=ADlka neleai@sezn= am.cz wrote: >=20 > > On Tue, Jul 21, 2015 at 12:25:00AM +0000, Mathieu Desnoyers wrote: > >> >> Does it solve the Wine problem? If Wine uses gs for something = and > >> >> calls a function that does this, Wine still goes boom, right? > >> >=20 > >> > So the advantage of just making a global segment descriptor avai= lable > >> > is that it's not *that* expensive to just save/restore segments.= So > >> > either wine could do it, or any library users would do it. > >> >=20 > >> > But anyway, I'm not sure this is a good idea. The advantage of i= t is > >> > that the kernel support really is _very_ minimal. > >>=20 > >> Considering that we'd at least also want this feature on ARM and > >> PowerPC 32/64, and that the gs segment selector approach clashes w= ith > >> existing apps (wine), I'm not sure that implementing a gs segment > >> selector based approach to cpu number caching would lead to an ove= rall > >> decrease in complexity if it leads to performance similar to those= of > >> portable approaches. > >>=20 > >> I'm perfectly fine with architecture-specific tweaks that lead to > >> fast-path speedups, but if we have to bite the bullet and implemen= t > >> an approach based on TLS and registering a memory area at thread s= tart > >> through a system call on other architectures anyway, it might end = up > >> being less complex to add a new system call on x86 too, especially= if > >> fast path overhead is similar. > >>=20 > >> But I'm inclined to think that some aspect of the question eludes = me, > >> especially given the amount of interest generated by the gs-segmen= t > >> selector approach. What am I missing ? > >>=20 > > As I wrote before you don't have to bite bullet as I said before. I= t > > suffices to create 128k element array with cpu for each tid, make t= hat > > mmapable file and userspace could get cpu with nearly same performa= nce > > without hacks. >=20 > I don't see how this would be acceptable on memory-constrained embedd= ed > systems. They have multiple cores, and performance requirements, so > having a fast getcpu would be useful there (e.g. telecom industry), > but they clearly cannot afford a 512kB table per process just for tha= t. >=20 Which just means that you need more complicated api and implementation for that but idea stays same. You would need syscalls register/deregister_cpuid_idx that would give you index used instead tid. A kernel would need to handle that many ids could be registered fo= r each thread and resize mmaped file in syscalls.