From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42964) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bflEA-00038n-DQ for qemu-devel@nongnu.org; Fri, 02 Sep 2016 05:57:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bflE2-0004TE-98 for qemu-devel@nongnu.org; Fri, 02 Sep 2016 05:57:38 -0400 Received: from 8.mo179.mail-out.ovh.net ([46.105.75.26]:34507) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bflE2-0004T5-2g for qemu-devel@nongnu.org; Fri, 02 Sep 2016 05:57:30 -0400 Received: from player698.ha.ovh.net (b7.ovh.net [213.186.33.57]) by mo179.mail-out.ovh.net (Postfix) with ESMTP id 247891008209 for ; Fri, 2 Sep 2016 11:57:29 +0200 (CEST) Date: Fri, 2 Sep 2016 11:57:21 +0200 From: Greg Kurz Message-ID: <20160902115721.37d95700@bahia.lan> In-Reply-To: <877faur6qb.fsf@abhimanyu.i-did-not-set--mail-host-address--so-tickle-me> References: <1472797976-24210-1-git-send-email-nikunj@linux.vnet.ibm.com> <1472797976-24210-2-git-send-email-nikunj@linux.vnet.ibm.com> <20160902105348.6ea4a550@bahia.lan> <877faur6qb.fsf@abhimanyu.i-did-not-set--mail-host-address--so-tickle-me> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH RFC 1/4] spapr-hcall: take iothread lock during handler call List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Nikunj A Dadhania Cc: alex.bennee@linaro.org, rth@twiddle.net, qemu-ppc@nongnu.org, qemu-devel@nongnu.org, david@gibson.dropbear.id.au On Fri, 02 Sep 2016 14:58:12 +0530 Nikunj A Dadhania wrote: > Greg Kurz writes: > > > On Fri, 2 Sep 2016 12:02:53 +0530 > > Nikunj A Dadhania wrote: > > > >> Signed-off-by: Nikunj A Dadhania > >> --- > >> hw/ppc/spapr_hcall.c | 11 +++++++++-- > >> 1 file changed, 9 insertions(+), 2 deletions(-) > >> > >> diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c > >> index e5eca67..daea7a0 100644 > >> --- a/hw/ppc/spapr_hcall.c > >> +++ b/hw/ppc/spapr_hcall.c > >> @@ -1075,20 +1075,27 @@ target_ulong spapr_hypercall(PowerPCCPU *cpu, target_ulong opcode, > >> target_ulong *args) > >> { > >> sPAPRMachineState *spapr = SPAPR_MACHINE(qdev_get_machine()); > >> + target_ulong ret; > >> > >> if ((opcode <= MAX_HCALL_OPCODE) > >> && ((opcode & 0x3) == 0)) { > >> spapr_hcall_fn fn = papr_hypercall_table[opcode / 4]; > >> > >> if (fn) { > >> - return fn(cpu, spapr, opcode, args); > >> + qemu_mutex_lock_iothread(); > >> + ret = fn(cpu, spapr, opcode, args); > >> + qemu_mutex_unlock_iothread(); > >> + return ret; > >> } > >> } else if ((opcode >= KVMPPC_HCALL_BASE) && > >> (opcode <= KVMPPC_HCALL_MAX)) { > >> spapr_hcall_fn fn = kvmppc_hypercall_table[opcode - KVMPPC_HCALL_BASE]; > >> > >> if (fn) { > >> - return fn(cpu, spapr, opcode, args); > >> + qemu_mutex_lock_iothread(); > >> + ret = fn(cpu, spapr, opcode, args); > >> + qemu_mutex_unlock_iothread(); > >> + return ret; > >> } > >> } > >> > > > > This will serialize all hypercalls, even when it is not needed... Isn't that > > too much coarse grain locking ? > > You are right, I was thinking to do this only for emulation case, as > this is not needed for hardware acceleration. > Yes, at the very least. And even in the MTTCG case, shouldn't we serialize only when we know I/O will actually happen ? > Regards > Nikunj > > Cheers. -- Greg