Received: from eggs.gnu.org ([2001:4830:134:3::10]:40112) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YMGKM-0007Et-Ow for qemu-devel@nongnu.org; Fri, 13 Feb 2015 08:30:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YMGKI-0004Xo-7N for qemu-devel@nongnu.org; Fri, 13 Feb 2015 08:30:38 -0500 Received: from roura.ac.upc.es ([147.83.33.10]:47983) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YMGKH-0004Xa-S5 for qemu-devel@nongnu.org; Fri, 13 Feb 2015 08:30:34 -0500 From: =?utf-8?Q?Llu=C3=ADs_Vilanova?= References: <31B94C07-29A9-4595-95ED-FA860B527BD8@suse.de> <54DCC8FF.7000609@suse.de> <87oaoy233p.fsf@fimbulvetr.bsc.es> Date: Fri, 13 Feb 2015 14:30:29 +0100 In-Reply-To: (Mark Burton's message of "Fri, 13 Feb 2015 08:37:28 +0100") Message-ID: <87lhk2uefe.fsf@fimbulvetr.bsc.es> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] Help on TLB Flush List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Mark Burton Cc: mttcg@greensocs.com, Peter Maydell , Alexander Graf , qemu-devel Mark Burton writes: >> On 13 Feb 2015, at 08:24, Peter Maydell wrote: >>=20 >> On 13 February 2015 at 07:16, Mark Burton wr= ote: >>> If the kernel is doing this - then effectively - for X86, each CPU only >>> flush=E2=80=99s it=E2=80=99s own TLB (from the perspective of Qemu) - c= orrect? >>> (in which case, for Qemu itself - for x86) - we dont need to implement >>> a global flush, and hence we dont need to build the mechanism to sync ? >> The semantics you need are "flush the QEMU TLB for CPU X" (where >> X may not be the CPU you're running on). This is what tlb_flush() >> does: it takes a CPU argument to act on. (Ditto tlb_flush_page, etc.) >> We then use that to implement the target's required semantics >> (eg in ARM the tlbiall_is_write() function is handled by iterating >> through all CPUs and calling tlb_flush on them). > What Lluis implied seemed to be that the kernel arranged to signal the CP= U that would flush. Hence, (for X86), we would only ever flush our own TLB. That's correct. [...] > For our immediate concern, in the interests of getting the thing working = and > making sure we=E2=80=99ve turned over all the stones, on ARM - it MAY hel= p us to check > that the flush has happened =E2=80=98in the next memory barrier=E2=80=99= =E2=80=A6. > - I dont know if that will help us or not, and - even if it does, I agre= e with you, it would be more messy than it need be. > However, in the interests of making sure that there are no other issues -= we may =E2=80=98hack=E2=80=99 something before we put in place a more eleg= ant solution=E2=80=A6.=20 > (right now, we have some mutex issues, shifting the sync to the barrier M= AY help us avoid that=E2=80=A6. To Be Seen=E2=80=A6. and anyway - it would = only be a temporary fix). But you shouldn't assume that everyone either uses x86's semantics (aka, ea= ch CPU gets an IPI), or the ARM semantics you described where the global TLB f= lush instruction has asynchronous effects. First, in ARM you still have to ensure other CPUs did what you asked them to (whenever the arch manual says you mu= st do so). Second, it seems like ARM does not always behave in the way you descri= bed: http://lxr.free-electrons.com/source/arch/arm/kernel/smp.c?v=3D2.6.32#L630 Granted, this is just the same behaviour as x86, but noone guarantees you t= hat some other operation in any of the multiple architectures supported by QEMU= will never need a synchronous instruction with global effects. I understand the pressure of getting something running and work from that, = but I think that having a framework for asynchronous cross-CPU messaging would be rather useful in the future. That can be then complemented with a mechanism= to wait for these asynchronous messages. You can achieve any desired behaviour= by composing these two. Cheers, Lluis --=20 "And it's much the same thing with knowledge, for whenever you learn something new, the whole world becomes that much richer." -- The Princess of Pure Reason, as told by Norton Juster in The Phantom Tollbooth