From patchwork Wed Aug 19 18:28:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 247988 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:522:0:0:0:0 with SMTP id h2csp693581ils; Wed, 19 Aug 2020 11:31:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyuOyVa9Lf8b+p87BqyB3QDaRV9MqB5DPY9gTNVrUREsiLmiaxHv/f4UZHX5NTKYQey7p0s X-Received: by 2002:a25:2644:: with SMTP id m65mr35373975ybm.94.1597861872893; Wed, 19 Aug 2020 11:31:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597861872; cv=none; d=google.com; s=arc-20160816; b=mS9MZ8yrhhpJl2/gIx2JNCUitYZr54X41qP5/fVE+Ybx0Nm0luPvD7UnN/z6fAn35Q LIv9AmkbYg8B59nTFpNs4P9vvswpD2srE/VoEcDLl4Hl+Q6GtoLFKrsfIXIC82V5sJfl 0WtI7yO2cDkG4L7WPcVT91h0VfefYesH5zyYGlglerByeeqBhABUQdI0EZ2gMZTAkLC5 3CWjTsabD0GJiinbv5U4/PCyh3sBZkjADHzPUsW8OY96J5mYE7oeg05x6XmeK38GYvQJ Kts9Hcl00PgRSY8uodBek7beMOa5x3tgFA43nTzexbg0g2KG6QcGW7Oj+MHPaubWi76r l+pA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:message-id:date:subject:to:from :dkim-signature; bh=V9nJrsd8JiF+VgbSMGAG3E/1ioxtLa3h0cElJSac/HA=; b=M1kQnOqQZVLzbmCpnoAiJ12C7z3bqFxwnk+vk0Fsx1EwemEw0iIn5MGZW8/FD2bt4R RKy4JBmO+bm952Qf5FO3o9jo161osZ0ViL3eKtvTaURBf7ZdnJ1f0pd+HYBleIUNF2Eq ZPVhUACnLxF+LIQOYZ2GqV1KvNYv2QKvuPSoa1OsbNz3SbLWpqUbPj2zXXEiUQsoBMbs 10zPTtO2VJOtlS2YpLsd0SiEtCrMfI/S1wEasFlIkAVs2bOkUXeZlpVmyKXpKFkzpBv0 Le/9wVLtgDkKTdBck2BHD9jR2tA6u0QIuCmBaNpBkfdLffdZ/ecNLWl4TNONTgy/dU+V /myw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=eCzi2gOL; 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=fail (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 m4si24744469yba.121.2020.08.19.11.31.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 19 Aug 2020 11:31:12 -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=fail header.i=@linaro.org header.s=google header.b=eCzi2gOL; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:50254 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k8Srg-0002qp-7O for patch@linaro.org; Wed, 19 Aug 2020 14:31:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59976) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k8Sqh-0002qO-Nc for qemu-devel@nongnu.org; Wed, 19 Aug 2020 14:30:11 -0400 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]:42018) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k8Sqe-0001vA-1e for qemu-devel@nongnu.org; Wed, 19 Aug 2020 14:30:10 -0400 Received: by mail-pg1-x541.google.com with SMTP id j21so11792909pgi.9 for ; Wed, 19 Aug 2020 11:30:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=V9nJrsd8JiF+VgbSMGAG3E/1ioxtLa3h0cElJSac/HA=; b=eCzi2gOLnRb4jN0Jbdbsff625hwbR3Tbc4o/Q04zY9C8Jz7QyM6ABnDGw1LtSp8ump 8y99W6ZaBsW9qQRmhZDr3tuUQ6SruLRHeBQFzHv+2iKMOHA47kSlxAkrwK6ppwR9l69r /7Bo/in3ANMDO0XAYnvMBUfSkVowUW2BUmdQDWH5P43yUv0JaCvI9tsz+utJaHp4rNiv F5GRMzhP9qk7/6wLa5ytVjebKWARZRBsb4IThFLN2NfrIHcmGdLj9S4ji86tckjdpvla O3+hbywCBdH9OROQwlUbD0UWzeTxLEkSNbj/D9k0UqHuqjzXTBMq1gsCmGOcyq19cSAR 7vHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=V9nJrsd8JiF+VgbSMGAG3E/1ioxtLa3h0cElJSac/HA=; b=R/ORxCkHTEYkYyP3VhSFNe7yGPK2rDz7bV6ubez+tEGlU8Qg460Xlehp0zUdbbJOMa X3kRMg6eS/76EAYfoVpVM3nPDEDaQ8IEWn6B/vTPZHoyyuBkK47xXUSzmM1iNjVZma4F izm6Jh39UComlueYP3Hp/hTiV0JflFTvuF5yLN+gKCwo99FW+D3u5yDIoZ9iNZF32O+j XXzbMuTBEI2MSsVMX67aaDaV4dm/U7m6dx+1DizsjKxgDARvbqI63Yp+XG//Pe2b0sbF 17bij+JTeCF7ZUmeUpOfikyBwVqRhQMfkWmOiSjjSPs8Blyjcpkwi+zhpblgyjtBqQJ5 YGwQ== X-Gm-Message-State: AOAM533pt0DDIzJ8ffx6zUGZLDyXQYt2noq2OadcWXT498AAZDAb6A8f gU0xTBAHEoih15F281al/sVu1JWi99Eeco0r X-Received: by 2002:aa7:9813:: with SMTP id e19mr20211458pfl.285.1597861804845; Wed, 19 Aug 2020 11:30:04 -0700 (PDT) Received: from Rfoley-MA01.hsd1.ma.comcast.net (c-73-47-162-176.hsd1.ma.comcast.net. [73.47.162.176]) by smtp.gmail.com with ESMTPSA id p20sm220766pjg.44.2020.08.19.11.30.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Aug 2020 11:30:04 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v2 0/7] accel/tcg: remove implied BQL from cpu_handle_interrupt/exception path Date: Wed, 19 Aug 2020 14:28:49 -0400 Message-Id: <20200819182856.4893-1-robert.foley@linaro.org> X-Mailer: git-send-email 2.17.1 Received-SPF: pass client-ip=2607:f8b0:4864:20::541; envelope-from=robert.foley@linaro.org; helo=mail-pg1-x541.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Sarah Harris , Cornelia Huck , Sagar Karandikar , David Hildenbrand , Anthony Green , Mark Cave-Ayland , Thomas Huth , Jiaxun Yang , Max Filippov , Alistair Francis , "Edgar E. Iglesias" , Guan Xuetao , Eduardo Habkost , Marek Vasut , Yoshinori Sato , Aleksandar Markovic , Richard Henderson , Artyom Tarasenko , Aleksandar Rikalo , robert.foley@linaro.org, Michael Rolnik , pbonzini@redhat.com, Stafford Horne , alex.bennee@linaro.org, David Gibson , Bastian Koppelmann , Chris Wulff , Laurent Vivier , Michael Walle , Palmer Dabbelt , peter.puhov@linaro.org, Aurelien Jarno Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The purpose of this change is to set the groundwork so that an arch could move towards removing the BQL from the cpu_handle_interrupt/exception paths. The BQL is a bottleneck in scaling to more cores. And this cpu_handle_interrupt/exception path is one of the key BQL users as measured by the QEMU sync profiling (qsp). As the first step in removing the BQL from this path, we will make changes to the core/common functions of cpu_handle_interrupt/exception to drop the holding of the BQL. The holding of the BQL is pushed down to the per-arch implementation code. This patch goes through several transitions of the code in order to maintain correctness (bisectability). In order to maintain bisectability across these steps some patches need to touch many files across different arches, however most of the changes are trivial. The general order of the changes is below where each step represents one patch. 1) rename all *_do_interrupt functions to *_do_interrupt_locked 2) add a new function *_do_interrupt that takes the BQL and calls *_do_interrupt_locked, point ->do_interrupt to it, and remove the BQL from cpu-exec.c's cpu_handle_exception. 3) modify the BQL critical sections around ->cpu_exec_interrupt, so that the BQL critical section covers just the call to ->cpu_exec_interrupt. 4/5) same as 1/2 for ->cpu_exec_interrupt. This removes the BQL from cpu_handle_exception. This approach of pushing the BQL down to the per arch functions was suggested by Paolo Bonzini. For reference, here are several key posts in the discussion, explaining the reasoning/benefits of this approach. https://lists.gnu.org/archive/html/qemu-devel/2020-08/msg00784.html https://lists.gnu.org/archive/html/qemu-devel/2020-08/msg01517.html https://lists.gnu.org/archive/html/qemu-devel/2020-07/msg08731.html https://lists.gnu.org/archive/html/qemu-devel/2020-08/msg00044.html This patch series is based on the per-CPU locks patch: https://lists.gnu.org/archive/html/qemu-devel/2020-06/msg05314.html Our most recent WIP tree is here: https://github.com/rf972/qemu/tree/interrupts_v2.7 Robert Foley (7): target: rename all *_do_interupt functions to _do_interrupt_locked target/arm: add ARMCPUClass->do_interrupt_locked target/cris: add CRISCPUClass->do_interrupt_locked target: Push BQL on ->do_interrupt down into per-arch implementation accel/tcg: Change BQL critical section in cpu_handle_interrupt target: rename all *_cpu_exec_interrupt functions to *_cpu_exec_interrupt_locked target: Push BQL on ->cpu_exec_interrupt down into per-arch implementation accel/tcg/cpu-exec.c | 8 +------- hw/ppc/spapr_events.c | 2 +- target/alpha/helper.c | 22 +++++++++++++++++++--- target/arm/cpu-qom.h | 3 +++ target/arm/cpu.c | 16 +++++++++++++--- target/arm/cpu.h | 2 ++ target/arm/cpu_tcg.c | 19 +++++++++++++++---- target/arm/helper.c | 10 +++++++++- target/arm/m_helper.c | 2 +- target/avr/helper.c | 27 ++++++++++++++++++++++----- target/cris/cpu-qom.h | 3 +++ target/cris/cpu.c | 11 ++++++----- target/cris/cpu.h | 3 ++- target/cris/helper.c | 35 ++++++++++++++++++++++++++--------- target/hppa/int_helper.c | 22 +++++++++++++++++++--- target/i386/seg_helper.c | 20 ++++++++++++++++++-- target/lm32/helper.c | 22 +++++++++++++++++++--- target/m68k/op_helper.c | 22 +++++++++++++++++++--- target/microblaze/helper.c | 24 ++++++++++++++++++++---- target/mips/helper.c | 22 +++++++++++++++++++--- target/moxie/cpu.c | 2 +- target/moxie/cpu.h | 2 +- target/moxie/helper.c | 2 +- target/nios2/cpu.c | 13 +++++++++++-- target/nios2/cpu.h | 1 + target/nios2/helper.c | 13 +++++++++++-- target/openrisc/interrupt.c | 23 ++++++++++++++++++++--- target/ppc/cpu.h | 1 + target/ppc/excp_helper.c | 22 +++++++++++++++++++--- target/ppc/kvm.c | 2 +- target/riscv/cpu_helper.c | 24 +++++++++++++++++++++--- target/rx/cpu.h | 1 + target/rx/helper.c | 22 +++++++++++++++++++--- target/s390x/excp_helper.c | 24 ++++++++++++++++++++---- target/s390x/internal.h | 1 + target/sh4/helper.c | 25 +++++++++++++++++++++---- target/sparc/cpu.c | 13 +++++++++++-- target/sparc/cpu.h | 1 + target/sparc/int32_helper.c | 9 ++++++++- target/sparc/int64_helper.c | 9 ++++++++- target/tilegx/cpu.c | 23 ++++++++++++++++++++--- target/unicore32/cpu.h | 1 + target/unicore32/helper.c | 13 +++++++++++-- target/unicore32/softmmu.c | 9 ++++++++- target/xtensa/exc_helper.c | 25 +++++++++++++++++++++---- 45 files changed, 476 insertions(+), 100 deletions(-) -- 2.17.1