From patchwork Thu May 21 16:39:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 187075 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp1739040ilb; Thu, 21 May 2020 10:19:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzc/VZKn3Lm4siy4onnU/B6sY/BKMXXNbLTET0MsR2T9qsthbEQnGFCimrKMQ7wup7M9cry X-Received: by 2002:a37:797:: with SMTP id 145mr7997041qkh.8.1590081547193; Thu, 21 May 2020 10:19:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590081547; cv=none; d=google.com; s=arc-20160816; b=GU0CXstP8QEZhzVK8+VzuwgZ/WJLTz/mAm96tPz3TZRPuz8OjmqHfJdpRK8q9f4WX0 lRd9o8EVZ8pqOm1vz6NTSiNUuLxY40QdTii1dta6BW4p28g+P0Qe1T7XTrF/bSyhSiJT ih4CNeEbQ/GQkPHWpCu7Ha8lZRFzZTFTaxHMfewsPrvsG35Y2SRfXU0TET9pBVp210tr DekCEdBurSM9iijmraTCFeatDCO8wRJS4C8+CUTRLhUQRd70igS9OrPIJRWSXvcYhjkS 9Ze0mP+uSLS9HgWACCI+3tVT2ArBxcJH92f4JwuPhrer64h5s+rBwGVA6Q3niFTWEZIH z6Jg== 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=DROR1j7T4nvT3Kb9/UW2YDjxvm1xSx4iyEWd3x/xCYw=; b=iT4QElbxhxPoQu8XNnjeJYR4c8a5Fhszjfb8oLGQ2UxqeRg5487Zhw/zhXYxL8p+y2 qx4gzrZsXkqZhbY8G2djD85c4UyaNOJ9pAmlaVVnr2G5J8PYZTzeCf9D55OLb/q7PRS5 ZIYxMVonCBWWxeb9kgLdMzCYH4FD/6xmTWMf/Xda1f/EAEKMrXfXLTWA9GZ5FqMc3c/4 CKjlaIH2AoLt8HF1zR0tvOmBhX9a7kkwl7KJt3tPlhkSqg1CjB7+OAk/FS3WYj2la6Ux k396hHb6LnXi6YwxVEgsxuyCgSdm/htPiHcqx3TRkkv/am6GQzpCGSRSYCLFYd9KA6LR dt5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Jsk7EHgC; 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 i3si3670044qvx.22.2020.05.21.10.19.07 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 May 2020 10:19:07 -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=Jsk7EHgC; 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]:40568 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jboqY-00012H-Nl for patch@linaro.org; Thu, 21 May 2020 13:19:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50174) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jboJD-0004Su-Px for qemu-devel@nongnu.org; Thu, 21 May 2020 12:44:39 -0400 Received: from mail-qk1-x741.google.com ([2607:f8b0:4864:20::741]:34330) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jboJC-0006j4-R6 for qemu-devel@nongnu.org; Thu, 21 May 2020 12:44:39 -0400 Received: by mail-qk1-x741.google.com with SMTP id 190so7917992qki.1 for ; Thu, 21 May 2020 09:44:38 -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=DROR1j7T4nvT3Kb9/UW2YDjxvm1xSx4iyEWd3x/xCYw=; b=Jsk7EHgCy0F5z0OqfBb9qvVNN1MWfkVXUS5hylU8y/EYU03wvdaRFqRXrbzaapZeq1 kW++2lZfsFYNJ0h2NR0XFTWVobJS3D01QoIsvIDMydnamlic1uhsCZpOEEPa6nSa3Dn3 9zjBSi1O9hOg422U4dl9OYNbZ28soZWNWdtSzgVLvIUZiHKhZgdCt/9cGXert1KBqj0S e8qmVFkOyFoe8RpdrlePkU2jq6GA1YeMy8FZ3/3R19xJy6Tw399OpkVLuwH5Uqv+f11Q PPN/Zgj7OOpGvnokyqjIPfk7UCddI3jA+OSqco6pwAgJP89wOME7jqZ2j2ue998aJtBQ v5Sw== 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=DROR1j7T4nvT3Kb9/UW2YDjxvm1xSx4iyEWd3x/xCYw=; b=XMWHSxuhV7Wfi3yv+90RbgMcBaD/4MqqAMYPIe1yyRWEjPVtztWuyeH/YKuyinKgCn 3uotd1nM5nWsVo69zBd6ewXUAKbzTiYM1f51HsDnSis6h6MnTxJRq7+GzBqdx/QGgpI7 hy+s5NPMGtTAEjDs/n2Y6mS7pPIJ+AZWHuym3xnfpAVUdHABMR+WOmbC3J8uo/uOQB6l KSIB+p4J4fkUDjKvyN6NoI6bFDDJ8+JnL8vUwIb1veVF16qGgm1h3+Pw9X+PH/pwvsQR GEu3cPpMpJ+mQHWyrzHEuVxcr6lPWv+ZZhhFeGbkNi1yzINKi4GLm2a0uh97ioAb0Bal znOQ== X-Gm-Message-State: AOAM531UaonHtgDZ4RpQza/0Wb4RwDtoZFb5s7PwizyRZME+gLyNLuf/ hfwrIpI5cRsWg6sOx0+UzCtafF0ZFxdadA== X-Received: by 2002:a05:620a:14ac:: with SMTP id x12mr10392691qkj.262.1590079477697; Thu, 21 May 2020 09:44:37 -0700 (PDT) Received: from Rfoley-MA01.hsd1.ma.comcast.net ([2601:199:4480:60c0:1944:c530:655c:5583]) by smtp.gmail.com with ESMTPSA id x24sm5923829qth.57.2020.05.21.09.44.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 May 2020 09:44:37 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v9 62/74] cpu: call .cpu_has_work with the CPU lock held Date: Thu, 21 May 2020 12:39:59 -0400 Message-Id: <20200521164011.638-63-robert.foley@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200521164011.638-1-robert.foley@linaro.org> References: <20200521164011.638-1-robert.foley@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::741; envelope-from=robert.foley@linaro.org; helo=mail-qk1-x741.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_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN 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: richard.henderson@linaro.org, cota@braap.org, 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 6ed806db60..7bf7700630 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; } /**