From patchwork Wed Oct 26 02:10:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 618764 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp113148pvb; Tue, 25 Oct 2022 19:19:27 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5B/Q/05Xlgxbb3Pj6muT5N+o4RLs5+af9ZEmdFir0+lj3Vl0eJu9zGXwqiznitBtEcq54z X-Received: by 2002:a05:622a:1452:b0:39d:9de:171c with SMTP id v18-20020a05622a145200b0039d09de171cmr26219073qtx.294.1666750767453; Tue, 25 Oct 2022 19:19:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666750767; cv=none; d=google.com; s=arc-20160816; b=xwtweXFUXNAeMT8LiRFqktEGsX5CBOzw04BaY7KuICFtgJWu9P/vLUxG6cXduFT96Q 7aBYU2Njbs7CtOZ71AlXGB0FXEBQXHdAYgJXrdJE3ltccDsQv3WrzjX73CCAozIPbFQu s4bCAOdAtM9sgWYwx2dB3rAzQ7tVHnsh1zRsxGEcyJ029cHPQ0DtnUVQw+HWydoSO86i P7MIpIiqNSRl4z4W9NC7zq7Ek5VdyQymhh1UR7V41eqpjHSQ3nhSs/oA86eSVwVfGbml mlPipkWjst56Bn807JfU21xMJzjnzLQcSt6nIuF56GtcIUd/aioOTTcllXLFHNBvzPbo /rVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=cbu+XeGtZCwlJENuQOWLw8zlHTHpS+i5rpNgMNp+qA8=; b=mli6KfB2ZpL7vmzv9IN4vqAbGQW6e/QCKquZBOmdwt6qJXAluHjyHB+uLqzWVvMwZ/ ZXUXpvZy2CBV9m86KYwL91f0oXsPbOINTfqzyg0AiNDCNjQvIQVy5eRXabD+OO6Cv5wB WX9CC8gECyfq4sJkyUfntNu7AlADkGmGLSdP6+ZGBibjmAHAoZk9wAx2C628G3ulf+wd 8f6bk4GPTAHWsRuAcgQJaIHLC8uT8boq0/2hwlxJZYz8Sn43bIVlzxjQnGN7M1Lxh5yq KHiUd07XC9O+u7SPBiEsEuGhqf48Pi8DlbNAhHq7tcJH8U5uGt5D9jVG/gOcRk7QatV7 Q4Kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="one/8hid"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id bw26-20020a05622a099a00b00399ae6c0b72si2977357qtb.538.2022.10.25.19.19.27 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 25 Oct 2022 19:19:27 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="one/8hid"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1onVtU-0004qY-M9; Tue, 25 Oct 2022 22:11:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1onVtL-0004gJ-D4 for qemu-devel@nongnu.org; Tue, 25 Oct 2022 22:11:39 -0400 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1onVtJ-00013O-BF for qemu-devel@nongnu.org; Tue, 25 Oct 2022 22:11:38 -0400 Received: by mail-pf1-x431.google.com with SMTP id d10so13895957pfh.6 for ; Tue, 25 Oct 2022 19:11:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=cbu+XeGtZCwlJENuQOWLw8zlHTHpS+i5rpNgMNp+qA8=; b=one/8hid87nUEQI2d4fPIVuOkq7zfO/4f2pqZ9K2ab8tVEqrLIXFG5519cC+EKnSuo KkbrawDMSx7mqCFXSI3MhUcFjGRpwaROd/zQas9iCmfmsKxja3031Y3P1I/4GOPQfpib oezjQSHzwvEwezz+/uJj84Ydl++B3ciWod8OMNbApl/o+o73h0GsFgkmwKIiUAluVKPX Lw4/V7luoodUsdNY8BuQzuQr2M4+AqZlu/BqH3TQ4XgLNWpco7Ka/MDuV+88Uc3fN+rG GlnFzQ/BWV+ZJnYY9ty9edJBNRIe2PZGK4Kzk2bJWeuK3VsCmXJVxOFsIhiy3kViIgch 9JKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cbu+XeGtZCwlJENuQOWLw8zlHTHpS+i5rpNgMNp+qA8=; b=UrdhSxmALw4YdRpBZaigIccnWhHkfcNDWqeyMzWmA+YKml5nZYu4YYZe/7EH27a4ID NK4O0rXSi5jHZ16BqFTvYRf019NeVsUaa6N2yJt7NXlIYHDqoWdguwt6PSs7ptDK6i+G F/rtDrZ+8OyXZF5J/3KHfNIQpOtHh9IaM7GYfNQEjx+YoS+lhQsMIoXdBPWJCz8Nl+J3 vupzPtNZwaaHjo+c5DFj8OYpsEIl2SL4mnCi9dngjV3aW8cb1PYvIWPgE7cKc5FiY1H1 KndcGtxuSAa4DX1FO/mpNJIr0ibCrUQ6QAAe4UDB9qpH+yCJ64NaR5z69Z7/pVDzFqic f6Rg== X-Gm-Message-State: ACrzQf3jG6pRZxtdo6lYXPBuVEP6EKmrm0nZQBIUA1M+eY5SRlMibYZK OrojxBFX4vfIKstJtktKs/2VQmaolgaUjRxD X-Received: by 2002:a05:6a00:178a:b0:563:7ada:f70 with SMTP id s10-20020a056a00178a00b005637ada0f70mr41848574pfg.69.1666750295917; Tue, 25 Oct 2022 19:11:35 -0700 (PDT) Received: from stoup.hotspotlogin.services ([103.100.225.182]) by smtp.gmail.com with ESMTPSA id o29-20020a635d5d000000b0043c9da02729sm1897833pgm.6.2022.10.25.19.11.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Oct 2022 19:11:35 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, Leandro Lupori Subject: [PULL 04/47] accel/tcg: Add a quicker check for breakpoints Date: Wed, 26 Oct 2022 12:10:33 +1000 Message-Id: <20221026021116.1988449-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221026021116.1988449-1-richard.henderson@linaro.org> References: <20221026021116.1988449-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::431; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x431.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Leandro Lupori Profiling QEMU during Fedora 35 for PPC64 boot revealed that a considerable amount of time was being spent in check_for_breakpoints() (0.61% of total time on PPC64 and 2.19% on amd64), even though it was just checking that its queue was empty and returning, when no breakpoints were set. It turns out this function is not inlined by the compiler and it's always called by helper_lookup_tb_ptr(), one of the most called functions. By leaving only the check for empty queue in check_for_breakpoints() and moving the remaining code to check_for_breakpoints_slow(), called only when the queue is not empty, it's possible to avoid the call overhead. An improvement of about 3% in total time was measured on POWER9. Signed-off-by: Leandro Lupori Reviewed-by: Richard Henderson Message-Id: <20221025202424.195984-2-leandro.lupori@eldorado.org.br> Signed-off-by: Richard Henderson --- accel/tcg/cpu-exec.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index f9e5cc9ba0..bb4b9e92ce 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -304,16 +304,12 @@ static void log_cpu_exec(target_ulong pc, CPUState *cpu, } } -static bool check_for_breakpoints(CPUState *cpu, target_ulong pc, - uint32_t *cflags) +static bool check_for_breakpoints_slow(CPUState *cpu, target_ulong pc, + uint32_t *cflags) { CPUBreakpoint *bp; bool match_page = false; - if (likely(QTAILQ_EMPTY(&cpu->breakpoints))) { - return false; - } - /* * Singlestep overrides breakpoints. * This requirement is visible in the record-replay tests, where @@ -374,6 +370,13 @@ static bool check_for_breakpoints(CPUState *cpu, target_ulong pc, return false; } +static inline bool check_for_breakpoints(CPUState *cpu, target_ulong pc, + uint32_t *cflags) +{ + return unlikely(!QTAILQ_EMPTY(&cpu->breakpoints)) && + check_for_breakpoints_slow(cpu, pc, cflags); +} + /** * helper_lookup_tb_ptr: quick check for next tb * @env: current cpu state