From patchwork Thu Mar 26 19:31:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 184927 Delivered-To: patch@linaro.org Received: by 2002:a92:de47:0:0:0:0:0 with SMTP id e7csp484249ilr; Thu, 26 Mar 2020 13:16:41 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsLPxkMCVEl1F4ogRABfWJPnt+lLEnQd7gcVQFYGawFXpHAOrpNvsh2ITilbCRG9QsLUJnG X-Received: by 2002:ad4:53a2:: with SMTP id j2mr10360143qvv.145.1585253801272; Thu, 26 Mar 2020 13:16:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585253801; cv=none; d=google.com; s=arc-20160816; b=cZI2ToONmnCA7R9TWzBQEDhBOM0i0fiRI8iHfiPhkLPDTAFAMoEqJ6oR6k4FMYa6KI jAbfflXwFAKYQMKEgwPr/xz39XPLlGMgnJmtAZGuRiAxbUsNfiFMQtRAis0Iq2vK7RzR kVAIcCxbJj04fzZeiw+dnaNgoDwQchCvwV7BMTowmCu+AORRG/qz2sUfdSw6M9m38/m0 KQxbmMYM3LJk9lXzapBqM1cMufLUNbA4dh4XRUsRygH7Duo0vPcyAAQ+mznkOrNR0iyG 5vPGn7tUt+zTkyfrra9SSwq74S9LUbGeg49U6FkbjjQb/6he7VGLZOEnxy/NZy+LPEW8 Ks7A== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=gacJZESnVEqf4qDD4ve/Hru1eX3df4yi6C7OwVt2hqI=; b=PiO+zDWQpDJ448/lVzmWm0boMXeil259VnAUiL/e9Su2lHmDi8caMPL5SmPzNzEilg oDMBLst3heomYU14lqLs/g5rn8Jxdc62kUgU9ryEq6r0qKKB5ij+6fd3Axa+lkUYL15r zhwbuliYjctq+hO4d7FJg8c51xke6PIJBVJym+E1pF8Mt2AOJK7I99xN3wZR3VunpTao 6ilj5y0TOAxo8wJvyWvzEoyqszq0wK7NDaUelXdUKaFzBWDEnGmyBva4BZO4cnrKppui vkY26JRhvoem1fk6HKFdUtvmMzX9DgmDVISJWq/Bmkoqf90WEMRL9BlBcq4RysNygpl/ CGnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=kBNhzknP; 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 n10si2036491qvx.203.2020.03.26.13.16.41 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 26 Mar 2020 13:16:41 -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=kBNhzknP; 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]:59704 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jHYvg-00078T-Rl for patch@linaro.org; Thu, 26 Mar 2020 16:16:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59316) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jHYLG-0008Nk-Ov for qemu-devel@nongnu.org; Thu, 26 Mar 2020 15:39:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jHYLF-00029Y-N9 for qemu-devel@nongnu.org; Thu, 26 Mar 2020 15:39:02 -0400 Received: from mail-qk1-x742.google.com ([2607:f8b0:4864:20::742]:45624) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jHYLF-00029N-IU for qemu-devel@nongnu.org; Thu, 26 Mar 2020 15:39:01 -0400 Received: by mail-qk1-x742.google.com with SMTP id c145so8140955qke.12 for ; Thu, 26 Mar 2020 12:39:01 -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 :mime-version:content-transfer-encoding; bh=gacJZESnVEqf4qDD4ve/Hru1eX3df4yi6C7OwVt2hqI=; b=kBNhzknPUnADBAOos+I/ZAk0539ZD0y9aBnUxRzQUffxPzh1aBireyAk8kPHdMh7Ri yVcUqo21xbeFGC5d+cYmaBTT8jTpuPp582/61fTXXDGzFzulcVAaBlERRbMNNqRAfNMA JtN2B144yFlBo6rHmsDd0ml20GVV1KdzKSHpTCBGSBidZV3uUQM7sdYsB6V+JW1lyYUP qjTofPY0hD8KEKYbU4f9JrxeGV/dcDYfvV+7tmtpq64uKqhvQWLCtFJSeQW9khciCqm9 W97sY8GbtbbONZHuPNTzvvbBGzifigWhXBX6ov5lqNB51KxO/i/FKNbBh110oS/7U0ca ozXQ== 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:mime-version:content-transfer-encoding; bh=gacJZESnVEqf4qDD4ve/Hru1eX3df4yi6C7OwVt2hqI=; b=k2y91F5bL8C3HckzHNXHAz1bhdcTf/i50c+3aCbXSmngDtUM7/MJXxzlzTVnIQ1yQq uZ5CSzzGQXNBBif81XwzKUNkotlq1LAPLOx+BXeRfUxe5LkoVPCtLQvfyIoahCdjGGj1 Fq04phRiQDlAtgRwjYk5dl5xauKLeYQ/J3O6F2hppOiDs6rm0u7xT9e/LLM9JuvvrneB RP3asucs3W82/2brEXuLdxvlfl7Tv2kHRaq0YuPXnjgjLCS7dpwsf+BzRpG4nNtWwOce +lHgX0azSqA46STiGrhDUsgO3sPnPdkmHjCcHhqithXmgx4f3RHiNf5IPxHEXzZbcU90 UmYg== X-Gm-Message-State: ANhLgQ1CA5+jkjJYKaQw/AiWTWvz+HmIyvv/uzdv386GgdSAKbd/uJ23 zrZ/YhabjuNSaDKg1x43QtCsp2NCBWcY/Q== X-Received: by 2002:a37:453:: with SMTP id 80mr10007108qke.325.1585251540096; Thu, 26 Mar 2020 12:39:00 -0700 (PDT) Received: from Rfoley-MA01.hsd1.ma.comcast.net ([2601:199:4480:60c0:fd55:4e67:1038:8302]) by smtp.gmail.com with ESMTPSA id u51sm2161916qth.46.2020.03.26.12.38.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Mar 2020 12:38:59 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v8 62/74] cpu: call .cpu_has_work with the CPU lock held Date: Thu, 26 Mar 2020 15:31:44 -0400 Message-Id: <20200326193156.4322-63-robert.foley@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200326193156.4322-1-robert.foley@linaro.org> References: <20200326193156.4322-1-robert.foley@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::742 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: richard.henderson@linaro.org, "Emilio G. Cota" , alex.bennee@linaro.org, robert.foley@linaro.org, peter.puhov@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" Reviewed-by: Richard Henderson Reviewed-by: Alex Bennée Signed-off-by: Emilio G. Cota Signed-off-by: Robert Foley --- include/hw/core/cpu.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) -- 2.17.1 diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index 1c3701b142..a01c258320 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -80,7 +80,8 @@ struct TranslationBlock; * instantiatable CPU type. * @parse_features: Callback to parse command line arguments. * @reset_dump_flags: #CPUDumpFlags to use for reset logging. - * @has_work: Callback for checking if there is work to do. + * @has_work: Callback for checking if there is work to do. Called with the + * CPU lock held. * @do_interrupt: Callback for interrupt handling. * @do_unaligned_access: Callback for unaligned access handling, if * the target defines #TARGET_ALIGNED_ONLY. @@ -799,9 +800,16 @@ const char *parse_cpu_option(const char *cpu_option); static inline bool cpu_has_work(CPUState *cpu) { CPUClass *cc = CPU_GET_CLASS(cpu); + bool ret; g_assert(cc->has_work); - return cc->has_work(cpu); + if (cpu_mutex_locked(cpu)) { + return cc->has_work(cpu); + } + cpu_mutex_lock(cpu); + ret = cc->has_work(cpu); + cpu_mutex_unlock(cpu); + return ret; } /**