From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LjZHh-0002rI-4n for qemu-devel@nongnu.org; Tue, 17 Mar 2009 09:24:45 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LjZHb-0002qb-MZ for qemu-devel@nongnu.org; Tue, 17 Mar 2009 09:24:43 -0400 Received: from [199.232.76.173] (port=44415 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LjZHb-0002qY-FP for qemu-devel@nongnu.org; Tue, 17 Mar 2009 09:24:39 -0400 Received: from mx1.redhat.com ([66.187.233.31]:42571) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LjZHb-0002oG-2q for qemu-devel@nongnu.org; Tue, 17 Mar 2009 09:24:39 -0400 Message-ID: <49BFA492.2010400@redhat.com> Date: Tue, 17 Mar 2009 15:24:34 +0200 From: Avi Kivity MIME-Version: 1.0 Subject: Re: [Qemu-devel] Re: branches are expensive References: <49BF8A5B.7070706@siemens.com> <200903171251.41148.paul@codesourcery.com> In-Reply-To: <200903171251.41148.paul@codesourcery.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Steffen Liebergeld Paul Brook wrote: >> The ratio is quite bad. Do you have any documentation on when Qemu does the >> chaining and more important, when it does not. For example are >> unconditional jumps always chained, or only in one direction (forward or >> backward). >> > > Direct jumps[1] within the same page are chained (including ). Indirect > jumps[2] and direct jumps to a different page are not chained. Chaining jumps > between pages would require breaking TB chains every time a TLB flush occurs. > You could optimize interpage direct jumps as follows: if (tb->tlb_generation != global_tlb_generation) revalidate_interpage_branch(); asm ("B target_address") A tlb flush (or switching execution to a different cpu) increments global_tlb_generation; revalidate_interpage_branch() sets target_address to the slow path which does the tb lookup, and sets tlb_generation = global_tlb_generation. Should compile an unconditional branch to 5 instructions. -- error compiling committee.c: too many arguments to function