From patchwork Wed Aug 5 18:12:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 247451 Delivered-To: patch@linaro.org Received: by 2002:a92:cc90:0:0:0:0:0 with SMTP id x16csp758048ilo; Wed, 5 Aug 2020 11:18:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwIVSalUy8fB4RECUAGKYLVeOtYIjVtGJhSGoNGpVgHxJ6Y5Puo9hWQf5zYLaJx3/ES6Zm2 X-Received: by 2002:a25:c60b:: with SMTP id k11mr6376541ybf.482.1596651498638; Wed, 05 Aug 2020 11:18:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596651498; cv=none; d=google.com; s=arc-20160816; b=dBjCaAJD+6gbwxSUQ802769cUFI2idxgrcEqXhI/Xx/q8PYxluqu7QLgUHyeHTUi6Z pEo2qnEp5V4mSdX8UODCekgD264RA+FZ8qeJQc+3eAMSL9oQiHYSCiwZyYh4EUlVPtdp puPwEH/wPyXYpOmSUvVnFAQplDjceOWRNwoPGGWeD+Z9EKR2pNp0K2QwdHLYnV0aOaxl Krgc3dtcXKicn/TxWU/OSa0ZJEgXFqMVoA7hbDi+2OKrJgBOeFtxL2D8Hbdkwu9wZiyl b5mpCsFWSe+UvVay2Czj6sFsZrCzz/YA+byRTrQXnSWu+9h4V+sXPI4o/GfG8LF4/rW6 F6GA== 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:references:in-reply-to :message-id:date:subject:to:from:dkim-signature; bh=4mUrzxN38KgTWVnwLLnwWRuKmcxV8e0+CR7Czj1dxnk=; b=klm48IU185FeDaORJZtnrCm74TaRxZvL8lHm4PUCs8EqpfD4qsPMqmt8y2CFgo76aI +DXsewy1Mh0gHdI2pzC2VcYdQGDRxd70XAa8LZwfg0Ixcq7AXP+z/D9/dpgbJ/xxo/GB rIrtCdBq3j+XFHKgOxiTrO17zYB9yQ/BLRef33etmkoWg+Z1fFkaLvPIQWoVjnHFu710 wgT+HWoKCdbyQmRodNwnFQo5vAlG81PAChIHBCQmqReVCOhIxYymSa48OqFsH7wC8Lpg dRxop13+aCTRfk91dncg3pVA5obdL4Ous2fR5yHthcKwollvjBoxARYntqUsImUKACA7 KyDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="h/RqssUP"; 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 s11si2393423ybi.305.2020.08.05.11.18.18 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 05 Aug 2020 11:18:18 -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="h/RqssUP"; 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]:43424 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k3NzW-0003oo-5V for patch@linaro.org; Wed, 05 Aug 2020 14:18:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49748) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k3NyU-0003ln-Ov for qemu-devel@nongnu.org; Wed, 05 Aug 2020 14:17:14 -0400 Received: from mail-pg1-x531.google.com ([2607:f8b0:4864:20::531]:34929) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k3NyR-0006Rz-RP for qemu-devel@nongnu.org; Wed, 05 Aug 2020 14:17:14 -0400 Received: by mail-pg1-x531.google.com with SMTP id o5so6956454pgb.2 for ; Wed, 05 Aug 2020 11:17:11 -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:in-reply-to:references; bh=4mUrzxN38KgTWVnwLLnwWRuKmcxV8e0+CR7Czj1dxnk=; b=h/RqssUPjaOf96oNkU3g32Vos9LqhECbWbowgWHUFifSflEfsOn/kL93ShZCbnRynI FegZL/HBc1U88j37iHp+whCF6yPEuSytg9vaor99axMywu+MeXWi1ObiYFZ0YGeZkd79 nOGihwnRZ7qP2tvlpripBITtBEnVQQNrtQGkOv3+3XxGILeEourfAS68aVvxZHtxaV43 oVrO2P/A0g5T0tz5IAQM+1hlrMPBOjIWeOfkGCkJLQknVOAP8oJ+IlwX60LNS+N2L3c3 kk4XQNCkZ1qpKRcW0LKd4iW6TIs579ChYJFaTKTiV5M3+jzJmu2bqibBQ7b8EwjGRDtf uIWg== 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:in-reply-to :references; bh=4mUrzxN38KgTWVnwLLnwWRuKmcxV8e0+CR7Czj1dxnk=; b=NoIAWFCYabDTZTDm8yGpDLdljwcy3jxpoClq0xuKeBJs/nagAt6lzPp80A9R9oXzg5 RHTQkVwgcRRr/OouJVKqJajy6yWTB5+ZQDWPTVnyRSAi2X0Nlo+ZnQlTfczRfummrtWy x42M3zQ1UeusCMccFSsNdAY/JwOVQm7xptowRlxusyApZCjocy0+oKstIXgxB1Irpc/V kLpMogJdTywZJ4C0D8yvM+lFoGa9EQ9dVquPievwAKvcXzqmIafoH3sxQqKJFenEAwNh CcOt5HGn/FEr337Y8KMvIxvRo2SRFohVctdDsxD+gmOEHkfL/KcdfhNMGWjf1YIZH9I5 zhYg== X-Gm-Message-State: AOAM532NmDemvKgDsvTPUg2fjpmownP1ZV2Q6h5wLQPv5lbtt1IPleC2 1DipqCFxyWs/9Wzb9S6TVOwmfj8Qgsc= X-Received: by 2002:a63:f108:: with SMTP id f8mr3994297pgi.96.1596651429548; Wed, 05 Aug 2020 11:17:09 -0700 (PDT) Received: from Rfoley-MA01.hsd1.ma.comcast.net ([2601:199:4480:60c0:38ab:50b1:ff8a:26ef]) by smtp.gmail.com with ESMTPSA id a15sm3670196pfo.185.2020.08.05.11.17.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Aug 2020 11:17:08 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v1 02/21] target/alpha: add BQL to do_interrupt and cpu_exec_interrupt Date: Wed, 5 Aug 2020 14:12:44 -0400 Message-Id: <20200805181303.7822-3-robert.foley@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200805181303.7822-1-robert.foley@linaro.org> References: <20200805181303.7822-1-robert.foley@linaro.org> Received-SPF: pass client-ip=2607:f8b0:4864:20::531; envelope-from=robert.foley@linaro.org; helo=mail-pg1-x531.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: robert.foley@linaro.org, cota@braap.org, peter.puhov@linaro.org, pbonzini@redhat.com, alex.bennee@linaro.org, Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This is part of a series of changes to remove the implied BQL from the common code of cpu_handle_interrupt and cpu_handle_exception. As part of removing the implied BQL from the common code, we are pushing the BQL holding down into the per-arch implementation functions of do_interrupt and cpu_exec_interrupt. The purpose of this set of changes is to set the groundwork so that an arch could move towards removing the BQL from the cpu_handle_interrupt/exception paths. This approach was suggested by Paolo Bonzini. For reference, here are two key posts in the discussion, explaining the reasoning/benefits of this approach. https://lists.gnu.org/archive/html/qemu-devel/2020-07/msg08731.html https://lists.gnu.org/archive/html/qemu-devel/2020-08/msg00044.html Signed-off-by: Robert Foley --- target/alpha/helper.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) -- 2.17.1 diff --git a/target/alpha/helper.c b/target/alpha/helper.c index 55d7274d94..18169ae1c5 100644 --- a/target/alpha/helper.c +++ b/target/alpha/helper.c @@ -299,8 +299,12 @@ void alpha_cpu_do_interrupt(CPUState *cs) { AlphaCPU *cpu = ALPHA_CPU(cs); CPUAlphaState *env = &cpu->env; - int i = cs->exception_index; - + int i; + bool bql = !qemu_mutex_iothread_locked(); + if (bql) { + qemu_mutex_lock_iothread(); + } + i = cs->exception_index; if (qemu_loglevel_mask(CPU_LOG_INT)) { static int count; const char *name = ""; @@ -405,6 +409,9 @@ void alpha_cpu_do_interrupt(CPUState *cs) /* Switch to PALmode. */ env->flags |= ENV_FLAG_PAL_MODE; #endif /* !USER_ONLY */ + if (bql) { + qemu_mutex_unlock_iothread(); + } } bool alpha_cpu_exec_interrupt(CPUState *cs, int interrupt_request) @@ -412,9 +419,11 @@ bool alpha_cpu_exec_interrupt(CPUState *cs, int interrupt_request) AlphaCPU *cpu = ALPHA_CPU(cs); CPUAlphaState *env = &cpu->env; int idx = -1; + qemu_mutex_lock_iothread(); /* We never take interrupts while in PALmode. */ if (env->flags & ENV_FLAG_PAL_MODE) { + qemu_mutex_unlock_iothread(); return false; } @@ -446,8 +455,10 @@ bool alpha_cpu_exec_interrupt(CPUState *cs, int interrupt_request) cs->exception_index = idx; env->error_code = 0; alpha_cpu_do_interrupt(cs); + qemu_mutex_unlock_iothread(); return true; } + qemu_mutex_unlock_iothread(); return false; }