From patchwork Sat Dec 22 02:15:49 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Scott Wood X-Patchwork-Id: 207918 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id A40642C0090 for ; Sat, 22 Dec 2012 14:08:23 +1100 (EST) Received: from localhost ([::1]:55147 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TmEfC-0003tu-Ft for incoming@patchwork.ozlabs.org; Fri, 21 Dec 2012 21:18:10 -0500 Received: from eggs.gnu.org ([208.118.235.92]:37205) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TmEdd-0000go-Bv for qemu-devel@nongnu.org; Fri, 21 Dec 2012 21:16:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TmEdS-0006FJ-Rx for qemu-devel@nongnu.org; Fri, 21 Dec 2012 21:16:33 -0500 Received: from co1ehsobe006.messaging.microsoft.com ([216.32.180.189]:20752 helo=co1outboundpool.messaging.microsoft.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TmEdH-0006Bn-FT; Fri, 21 Dec 2012 21:16:11 -0500 Received: from mail98-co1-R.bigfish.com (10.243.78.201) by CO1EHSOBE002.bigfish.com (10.243.66.65) with Microsoft SMTP Server id 14.1.225.23; Sat, 22 Dec 2012 02:16:10 +0000 Received: from mail98-co1 (localhost [127.0.0.1]) by mail98-co1-R.bigfish.com (Postfix) with ESMTP id 7D3015001B3; Sat, 22 Dec 2012 02:16:10 +0000 (UTC) X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPV:NLI; H:mail.freescale.net; RD:none; EFVD:NLI X-SpamScore: 0 X-BigFish: VS0(zzzz1de0h1202h1e76h1d1ah1d2ahzz8275bhz2dh2a8h668h839hd24he5bhf0ah1288h12a5h12a9h12bdh12e5h137ah139eh13b6h1441h1504h1537h162dh1631h1758h1155h) Received: from mail98-co1 (localhost.localdomain [127.0.0.1]) by mail98-co1 (MessageSwitch) id 1356142567816115_1015; Sat, 22 Dec 2012 02:16:07 +0000 (UTC) Received: from CO1EHSMHS014.bigfish.com (unknown [10.243.78.221]) by mail98-co1.bigfish.com (Postfix) with ESMTP id C4B18C00046; Sat, 22 Dec 2012 02:16:07 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by CO1EHSMHS014.bigfish.com (10.243.66.24) with Microsoft SMTP Server (TLS) id 14.1.225.23; Sat, 22 Dec 2012 02:16:07 +0000 Received: from az84smr01.freescale.net (10.64.34.197) by 039-SN1MMR1-003.039d.mgd.msft.net (10.84.1.16) with Microsoft SMTP Server (TLS) id 14.2.318.3; Sat, 22 Dec 2012 02:16:06 +0000 Received: from snotra.am.freescale.net ([10.214.82.10]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id qBM2FqSX024989; Fri, 21 Dec 2012 19:16:05 -0700 From: Scott Wood To: Alexander Graf Date: Fri, 21 Dec 2012 20:15:49 -0600 Message-ID: <1356142552-13453-13-git-send-email-scottwood@freescale.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1356142552-13453-1-git-send-email-scottwood@freescale.com> References: <1356142552-13453-1-git-send-email-scottwood@freescale.com> MIME-Version: 1.0 X-OriginatorOrg: freescale.com X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 X-Received-From: 216.32.180.189 Cc: Scott Wood , qemu-ppc@nongnu.org, qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 12/15] openpic: IRQ_check: search the queue a word at a time X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Search the queue more efficiently by first looking for a non-zero word, and then using the common bit-searching function to find the bit within the word. It would be even nicer if bitops_ffsl() could be hooked up to the compiler intrinsic so that bit-searching instructions could be used, but that's another matter. Signed-off-by: Scott Wood --- hw/openpic.c | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/hw/openpic.c b/hw/openpic.c index f2ac286..5accff5 100644 --- a/hw/openpic.c +++ b/hw/openpic.c @@ -270,21 +270,35 @@ static inline int IRQ_testbit(IRQ_queue_t *q, int n_IRQ) static void IRQ_check(OpenPICState *opp, IRQ_queue_t *q) { - int next, i; + int next, word, irq, base; int priority; next = -1; priority = -1; - for (i = 0; i < opp->max_irq; i++) { - if (IRQ_testbit(q, i)) { + + for (word = 0, base = 0; word < ARRAY_SIZE(q->queue); + word++, base += BITS_PER_LONG) { + unsigned long map = q->queue[word]; + + if (!map) { + continue; + } + + while (map) { + int offset = bitops_ffsl(map); + irq = base + offset; + map &= ~(1UL << offset); + DPRINTF("IRQ_check: irq %d set ivpr_pr=%d pr=%d\n", - i, IVPR_PRIORITY(opp->src[i].ivpr), priority); - if (IVPR_PRIORITY(opp->src[i].ivpr) > priority) { - next = i; - priority = IVPR_PRIORITY(opp->src[i].ivpr); + irq, IVPR_PRIORITY(opp->src[irq].ivpr), priority); + + if (IVPR_PRIORITY(opp->src[irq].ivpr) > priority) { + next = irq; + priority = IVPR_PRIORITY(opp->src[irq].ivpr); } } } + q->next = next; q->priority = priority; }