From patchwork Fri Jun 14 17:11:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 166842 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2310636ilk; Fri, 14 Jun 2019 10:12:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqze0VpCXJ6zzbAVao7nWHezfoXQPfX2ALsDT2AceHvq6LCkClTHJ9KGoGDDonJfrJeK1EJG X-Received: by 2002:ac8:373b:: with SMTP id o56mr84333090qtb.133.1560532361168; Fri, 14 Jun 2019 10:12:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560532361; cv=none; d=google.com; s=arc-20160816; b=qu8WvEXtXiHyQgeXl+vfiT3nJG0ZS5oc9LoNF+8x3il3559eS5aIub4lq6iqpiAePQ Trrm67kYd7n15jr7KS0nIw/PE12KNNkZMTZX+ZTLW1/9fpYtOz9ouYD0VqEHyfMsXPTt WVd1zTdc90RwECL5Hc4RKSjzAEonm1qlMmuaibbxh37bXCZ5VEZgU2X1kngoQFTbt2WY cXKdrpWUIST6zeq4VEpgwiBSeJbslPnHXNCsu4vdgF020+H0CqfRSzQ+wOyAsuZSEuJC GsBjCIafA9DbKnbPWoYeuXC4hNPsBQ0QGb/xB2btt3UcBTxtJYtIXA6xgql3NZhpvY59 eIIg== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=bJlRK12NgWRhW3McWfNYPpf/1E3ddcXa2ZT9Jrrle8U=; b=LBYsLFFlDbNrFNkTq7NtNY03tPUa5o/RrdI0930b6Ggs87MWgZog6xZwSeOxtN0UP7 oqWp6TOW5cMh8WppJAhDNUGOoHJuZGdbEGPtP2PwbPz6sB8l1yYYPBrl9KhUIwfIIm8v IZTT7EluatJKAj+9p7xNRCyH5sujHHknE7bAn8wHciM+2N7hIwtMMUlOanBDVwX+Wpem DGNE7dqSpGjg9DdQ+1LUDM2IeuQuWuBY5amoEyFpZ+Cbyq+rS5Gqs623xp8SJldXvKJ3 QI+XAC5lKHuttwSHdW+SGHxmp0yJI8HcKIfS+5GHst7ZBZ6PlfzpEHQGCCoCorHaWV9q NqrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=liNlhIYr; 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 b20si2183393qte.321.2019.06.14.10.12.41 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Jun 2019 10:12: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=liNlhIYr; 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]:53650 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbpkm-0000Z6-Mf for patch@linaro.org; Fri, 14 Jun 2019 13:12:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55908) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbpkE-0000S1-Ug for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:12:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbpkD-0002we-EF for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:12:06 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:38190) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbpkD-0002vU-5a for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:12:05 -0400 Received: by mail-wr1-x442.google.com with SMTP id d18so3321244wrs.5 for ; Fri, 14 Jun 2019 10:12:04 -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=bJlRK12NgWRhW3McWfNYPpf/1E3ddcXa2ZT9Jrrle8U=; b=liNlhIYrR8Z2D81wKr24l4CaxT63ZZlnWOLIYKEA1hOU1+VGh8aZeU6f7EXWrBFNft 7vjeWU61sMupXH7ZrVWJ4hrgHbTYvynUf9+D15GulLp1eE1xu5vvsmfLVTVhakEt7AsQ xlRMjzIz15yKUp3wXeUnOvWVGZFiropttAWk8Qh7ud0xC3bWHgSTAN2K9P0gJ9G+5bFp HizKJLAr2DJhPu/G9cMoXOLUEKG9ftCssd6lnXVNwHTJ7rXBB586jixWQWeMt/DbjrLl EE9vFU7V4LGGWXiUqZcOxkmS3G4wtFMovfkFLwuqc41iKcsBLRnNZ35ls5Nbv9qIIWxS lSaQ== 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=bJlRK12NgWRhW3McWfNYPpf/1E3ddcXa2ZT9Jrrle8U=; b=EI6fWtJxNgJGtP9Ha+9XnM3IpYDAnZr3/pJY9CqJih0VoaAKAh+HXpaZt6wIGxp9P9 CtYUGSdqL1VXau6aYWee0g2EsZY9Fp2MWQNiMDrdFD/6n6dnzTs9gPpAxn7NEdiwvXTq d6OrariCsllR5lvBJ95dXfDI+50K7VY8W7fjVVuRuvBMO/5oiqiGhQE8KTmkYRMSOb6L 9wKbdHc3xjQc2BL2qQ6dmy5bgv9MLWWBP9UHTH5I7g7Db004AwRFrnd1J0IqKzzHk3cg gRaaP+G56Fkeod3ZbFXa9ADjRtRRlNUAkpWQaN7a8h696RcLPWTXvgaphf6D8dF3OEyt SyBw== X-Gm-Message-State: APjAAAWEF6ZiBSPIVLXOl2Hseb9mK+z+wZ7MX+YLUlZArjbWtlo9IPa9 ED8DgyMWznNFZLJLWscsKB0DXr5hgis= X-Received: by 2002:adf:f186:: with SMTP id h6mr719115wro.274.1560532323665; Fri, 14 Jun 2019 10:12:03 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id 18sm2315024wmg.43.2019.06.14.10.12.00 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 14 Jun 2019 10:12:02 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id AC1651FF90; Fri, 14 Jun 2019 18:12:00 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 14 Jun 2019 18:11:13 +0100 Message-Id: <20190614171200.21078-4-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190614171200.21078-1-alex.bennee@linaro.org> References: <20190614171200.21078-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::442 Subject: [Qemu-devel] [PATCH v3 03/50] cpu: introduce cpu_in_exclusive_work_context() 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: "Emilio G. Cota" , =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" Suggested-by: Alex Bennée Reviewed-by: Alex Bennée Signed-off-by: Emilio G. Cota --- cpus-common.c | 2 ++ include/qom/cpu.h | 13 +++++++++++++ 2 files changed, 15 insertions(+) -- 2.20.1 diff --git a/cpus-common.c b/cpus-common.c index 3ca58c64e8..960058457a 100644 --- a/cpus-common.c +++ b/cpus-common.c @@ -335,7 +335,9 @@ void process_queued_cpu_work(CPUState *cpu) */ qemu_mutex_unlock_iothread(); start_exclusive(); + cpu->in_exclusive_work_context = true; wi->func(cpu, wi->data); + cpu->in_exclusive_work_context = false; end_exclusive(); qemu_mutex_lock_iothread(); } else { diff --git a/include/qom/cpu.h b/include/qom/cpu.h index 5ee0046b62..08481ad304 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -373,6 +373,7 @@ struct CPUState { bool unplug; bool crash_occurred; bool exit_request; + bool in_exclusive_work_context; uint32_t cflags_next_tb; /* updates protected by BQL */ uint32_t interrupt_request; @@ -785,6 +786,18 @@ void async_run_on_cpu(CPUState *cpu, run_on_cpu_func func, run_on_cpu_data data) */ void async_safe_run_on_cpu(CPUState *cpu, run_on_cpu_func func, run_on_cpu_data data); +/** + * cpu_in_exclusive_work_context() + * @cpu: The vCPU to check + * + * Returns true if @cpu is an exclusive work context, which has + * previously been queued via async_safe_run_on_cpu(). + */ +static inline bool cpu_in_exclusive_work_context(const CPUState *cpu) +{ + return cpu->in_exclusive_work_context; +} + /** * qemu_get_cpu: * @index: The CPUState@cpu_index value of the CPU to obtain.