From patchwork Wed Aug 5 18:12:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 247450 Delivered-To: patch@linaro.org Received: by 2002:a92:cc90:0:0:0:0:0 with SMTP id x16csp757870ilo; Wed, 5 Aug 2020 11:18:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz540fok7Vu8Rq12CiHspxJVQ5lbgr2M2XRBS2Iud6UY/Gnk0PVjhuKPWe/8ldpP+EZZM8R X-Received: by 2002:a25:505:: with SMTP id 5mr6570644ybf.98.1596651483341; Wed, 05 Aug 2020 11:18:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596651483; cv=none; d=google.com; s=arc-20160816; b=Ud4ua8ArsCoCl+MCeLuf85P56e1eUC4OiK36G+ONSuZAqmoPaVIXsaNKZaWzOi+e9q 2lVCBWd/usZ3WXWl9edQilswVnMQEs1j8kUYgTFuFoyTHG81EHyGBbQpn1y66vTFvlhS XSMc+Jv3DKB8BEydYwbBaQwXzBtpAbcrlG/6n8rbwQxAK9usPaevO18HLSiRccc640lu y7yAY3ajEJF0RAZUld2/Hx234kpkGSzKPXngZEsgIvmLnODyODprPvopStjv+ojdqLS3 /8SffXowz1uCz3kvRADsCsxqBYwj8c8mce9v64ooVDKzUvQyK3u6g14oJmsRdSpbinql /X4A== 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=Cw3yBPmbCJhRgO2KPinIHhC/h5HD4KqFIy/v1BHn1wY=; b=Sv7izVaODeXYX2la670U9e0wWs14nFW5CLyiqQJ59XHZTmvAbHrJ6OsPxbKYzq46pe 09acWm2BvDWTnaPDFqduwMXMpR5gMxw6u2d2a2yzh8mefHeE39JULYMotd3RfEAePNAU cuWFHlZOjKwyKi0TlerC4gOAuYa7ZQ60tHJ7TeKaP6RdJIK91PCFyGK4jaZQt5+mrqo+ 4PD6UMSaJOf8kFuy+qPlQTkQJx4h1nmxX6B9WLGUKCuQYeHg5h0uFIj/rN/i4YdokeCX VziKO1L+EgOBqtoIE3XwA3mPzAvQAXGxUtj+Yn5GrmhiVqtr/5wNzLe3vz8bL1WBry3O pcOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Bhggd3ul; 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 v200si2313495ybe.91.2020.08.05.11.18.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 05 Aug 2020 11:18:03 -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=Bhggd3ul; 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]:43128 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k3NzG-0003hC-PO for patch@linaro.org; Wed, 05 Aug 2020 14:18:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49668) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k3NyQ-0003g1-PK for qemu-devel@nongnu.org; Wed, 05 Aug 2020 14:17:10 -0400 Received: from mail-pj1-x1041.google.com ([2607:f8b0:4864:20::1041]:55414) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k3NyP-0006Qg-3A for qemu-devel@nongnu.org; Wed, 05 Aug 2020 14:17:10 -0400 Received: by mail-pj1-x1041.google.com with SMTP id 2so5004791pjx.5 for ; Wed, 05 Aug 2020 11:17:08 -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=Cw3yBPmbCJhRgO2KPinIHhC/h5HD4KqFIy/v1BHn1wY=; b=Bhggd3ulq5KNGlj9qpCKMy3jq1VNUUSfukireTCdkVoibCCIY95b4VB79aZSdtwkta IQphqe+Y8zJlBYWP8Ontj70VFnHgHVLEukWsgAuKbANEKPuqbW5Xem5jOq63FeGsImPt kwrE3vaqJfibhmU9on03gdaMugvoqLF8ndRAs0/cM26SsODxzlrEGKim/GyNwK0R0j1B Ts/yaV3Lk1BngITshCseGrUPK6qn3BWs7qNoWZk+BjIj2GMIGgUv/Bdl8b3B7N4s7C5l OZ43BmzdedN88BUQWPcyQZkp9gsgQbtfFcKfZrjXDqJYlqVOfvEtkjkb+TIqmoeAdSqM y5Aw== 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=Cw3yBPmbCJhRgO2KPinIHhC/h5HD4KqFIy/v1BHn1wY=; b=dNC+bfBlVPTPeslrjSYfM+ajoou9BS1UceSUQRWi55QebuLnArmuUBJMZQqSfX0OYE j4iktieSiWjLCwxI63wLrxQ7qQl86jGWErwMRN9HBakwfiJoEnenCyY4ufqakRcsAHtY euGe23wrGFAYMv1WgRz5NxjtqZ8BbbD2kMUCrEusf/6+hWJBLGG01W0EN2CEc7P0Z1aw uP56yUCGYggQ1JTTItm78wZXQjQ8vNHrJX+6x0UjbtKs3MuJjb9VnPa9P0bzrW96FW2x D2RpKWc/o0dEg8pjTzSl7OjVe7Jc5Skx88EYm3kLjvkvSlFTN1jxu/rTcYZNqT9AWmuV 5Z1g== X-Gm-Message-State: AOAM533l/aGQqOfmo6kJPm+LnYgDANlmA69qmT9B+nz6/+OTvYrqUN7v 2A1vQv3ZiEhwtSF0tbJ/Kfn16jvWaSY= X-Received: by 2002:a17:902:834a:: with SMTP id z10mr4382242pln.5.1596651427371; Wed, 05 Aug 2020 11:17:07 -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.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Aug 2020 11:17:06 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v1 01/21] accel/tcg: Change interrupt/exception handling to remove implied BQL Date: Wed, 5 Aug 2020 14:12:43 -0400 Message-Id: <20200805181303.7822-2-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::1041; envelope-from=robert.foley@linaro.org; helo=mail-pj1-x1041.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 change removes the implied BQL from the cpu_handle_interrupt, and cpu_handle_exception paths. This BQL acquire is being pushed down into the per arch implementation. Signed-off-by: Robert Foley --- accel/tcg/cpu-exec.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) -- 2.17.1 diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index 80d0e649b2..8e2bfd97a1 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -517,9 +517,7 @@ static inline bool cpu_handle_exception(CPUState *cpu, int *ret) #else if (replay_exception()) { CPUClass *cc = CPU_GET_CLASS(cpu); - qemu_mutex_lock_iothread(); cc->do_interrupt(cpu); - qemu_mutex_unlock_iothread(); cpu->exception_index = -1; if (unlikely(cpu->singlestep_enabled)) { @@ -558,7 +556,7 @@ static inline bool cpu_handle_interrupt(CPUState *cpu, if (unlikely(cpu_interrupt_request(cpu))) { int interrupt_request; - qemu_mutex_lock_iothread(); + cpu_mutex_lock(cpu); interrupt_request = cpu_interrupt_request(cpu); if (unlikely(cpu->singlestep_enabled & SSTEP_NOIRQ)) { /* Mask out external interrupts for this step. */ @@ -567,7 +565,7 @@ static inline bool cpu_handle_interrupt(CPUState *cpu, if (interrupt_request & CPU_INTERRUPT_DEBUG) { cpu_reset_interrupt(cpu, CPU_INTERRUPT_DEBUG); cpu->exception_index = EXCP_DEBUG; - qemu_mutex_unlock_iothread(); + cpu_mutex_unlock(cpu); return true; } if (replay_mode == REPLAY_MODE_PLAY && !replay_has_interrupt()) { @@ -577,13 +575,15 @@ static inline bool cpu_handle_interrupt(CPUState *cpu, cpu_reset_interrupt(cpu, CPU_INTERRUPT_HALT); cpu_halted_set(cpu, 1); cpu->exception_index = EXCP_HLT; - qemu_mutex_unlock_iothread(); + cpu_mutex_unlock(cpu); return true; } #if defined(TARGET_I386) else if (interrupt_request & CPU_INTERRUPT_INIT) { X86CPU *x86_cpu = X86_CPU(cpu); CPUArchState *env = &x86_cpu->env; + cpu_mutex_unlock(cpu); + qemu_mutex_lock_iothread(); replay_interrupt(); cpu_svm_check_intercept_param(env, SVM_EXIT_INIT, 0, 0); do_cpu_init(x86_cpu); @@ -595,7 +595,7 @@ static inline bool cpu_handle_interrupt(CPUState *cpu, else if (interrupt_request & CPU_INTERRUPT_RESET) { replay_interrupt(); cpu_reset(cpu); - qemu_mutex_unlock_iothread(); + cpu_mutex_unlock(cpu); return true; } #endif @@ -604,7 +604,9 @@ static inline bool cpu_handle_interrupt(CPUState *cpu, True when it is, and we should restart on a new TB, and via longjmp via cpu_loop_exit. */ else { + cpu_mutex_unlock(cpu); if (cc->cpu_exec_interrupt(cpu, interrupt_request)) { + cpu_mutex_lock(cpu); replay_interrupt(); /* * After processing the interrupt, ensure an EXCP_DEBUG is @@ -614,6 +616,8 @@ static inline bool cpu_handle_interrupt(CPUState *cpu, cpu->exception_index = (cpu->singlestep_enabled ? EXCP_DEBUG : -1); *last_tb = NULL; + } else { + cpu_mutex_lock(cpu); } /* The target hook may have updated the 'cpu->interrupt_request'; * reload the 'interrupt_request' value */ @@ -627,7 +631,7 @@ static inline bool cpu_handle_interrupt(CPUState *cpu, } /* If we exit via cpu_loop_exit/longjmp it is reset in cpu_exec */ - qemu_mutex_unlock_iothread(); + cpu_mutex_unlock(cpu); } /* Finally, check if we need to exit to the main loop. */ @@ -691,7 +695,6 @@ static inline void cpu_loop_exec_tb(CPUState *cpu, TranslationBlock *tb, } #endif } - /* main execution loop */ int cpu_exec(CPUState *cpu)