From nobody Thu Nov 6 10:38:35 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1540489615905820.2441023611963; Thu, 25 Oct 2018 10:46:55 -0700 (PDT) Received: from localhost ([::1]:56142 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gFjig-0005ho-ME for importer@patchew.org; Thu, 25 Oct 2018 13:46:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40359) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gFjKm-0006hv-Kh for qemu-devel@nongnu.org; Thu, 25 Oct 2018 13:22:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gFjJk-0008Ol-OO for qemu-devel@nongnu.org; Thu, 25 Oct 2018 13:21:11 -0400 Received: from out3-smtp.messagingengine.com ([66.111.4.27]:51189) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gFjJk-0008Nz-Er for qemu-devel@nongnu.org; Thu, 25 Oct 2018 13:21:08 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id E9FF222145; Thu, 25 Oct 2018 13:21:07 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Thu, 25 Oct 2018 13:21:07 -0400 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id 985ABE4074; Thu, 25 Oct 2018 13:21:06 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h= from:to:cc:subject:date:message-id:in-reply-to:references; s= mesmtp; bh=Ie8oCK8Hqrp4QCcb5EiWjVyTCD230QzoRU0Yp4AVUdU=; b=GNK76 ez7MiPXL7UYuxj4k4kWwVjZ5K0d13lYnlMuPIHPR7iF2M3+1ZzCKp2Vs4upn1v1Q AXUV4nlnFgnNFbqwYlP9B6FogJSi9B6Vn9i1Qx8Ix28U1MV+HyhW5cazk7OVpIl4 Jl8UbZPOisybadIIAt9dDIaKY6gCAQAn6SeyfU= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=Ie8oCK8Hqrp4QCcb5EiWjVyTCD230 QzoRU0Yp4AVUdU=; b=oSe3ESJNvP2aDMQsNxDM9EV4Xwm9x5zx4BB5gjGvDZ6H4 QwYunhW/MtcPNix8VcM8IiDl/nkYVfiU7TUbzylY9YjpNWWihAbQ5Jizt0YyKZMn sPj7fPSaakwpLLKf9DRz/xO6GJ/MQ+idpDm6ih25r96OLSNKwGNRIkXSd5auA3+f JGu7+ydzkEUGtUcZpWFjzBnoki0rFKfAYDRZe81Ebui9xSV7nPqQjRQxV++jWNMZ XrtF92QYjOXJNkiN+hmG+eN5Zi/562A+l2vz/K68SHqAtIiSw/JHchPoyNOrLHWH VlDXsGZGOncOjcKnwqE7v7lggol9oRlaAP/CLObbg== X-ME-Sender: X-ME-Proxy: From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Thu, 25 Oct 2018 13:20:10 -0400 Message-Id: <20181025172057.20414-2-cota@braap.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181025172057.20414-1-cota@braap.org> References: <20181025172057.20414-1-cota@braap.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 66.111.4.27 Subject: [Qemu-devel] [RFC 01/48] cpu: introduce run_on_cpu_no_bql X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Llu=C3=ADs=20Vilanova?= , Pavel Dovgalyuk , Stefan Hajnoczi Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This allows us to queue synchronous CPU work without the BQL. Will gain a user soon. Signed-off-by: Emilio G. Cota Reviewed-by: Alex Benn=C3=A9e --- include/qom/cpu.h | 13 +++++++++++++ cpus-common.c | 28 ++++++++++++++++++++++------ 2 files changed, 35 insertions(+), 6 deletions(-) diff --git a/include/qom/cpu.h b/include/qom/cpu.h index 204bc94056..863aa2bff1 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -877,6 +877,19 @@ bool cpu_is_stopped(CPUState *cpu); */ void run_on_cpu(CPUState *cpu, run_on_cpu_func func, run_on_cpu_data data); =20 +/** + * run_on_cpu_no_bql + * @cpu: The vCPU to run on. + * @func: The function to be executed. + * @data: Data to pass to the function. + * + * Schedules the function @func for execution on the vCPU @cpu. + * This function is run outside the BQL. + * See also: run_on_cpu() + */ +void run_on_cpu_no_bql(CPUState *cpu, run_on_cpu_func func, + run_on_cpu_data data); + /** * async_run_on_cpu: * @cpu: The vCPU to run on. diff --git a/cpus-common.c b/cpus-common.c index cffb2b71ac..b478fc8741 100644 --- a/cpus-common.c +++ b/cpus-common.c @@ -144,7 +144,8 @@ static void queue_work_on_cpu(CPUState *cpu, struct qem= u_work_item *wi) cpu_mutex_unlock(cpu); } =20 -void run_on_cpu(CPUState *cpu, run_on_cpu_func func, run_on_cpu_data data) +static void do_run_on_cpu(CPUState *cpu, run_on_cpu_func func, + run_on_cpu_data data, bool bql) { struct qemu_work_item wi; bool has_bql =3D qemu_mutex_iothread_locked(); @@ -152,12 +153,16 @@ void run_on_cpu(CPUState *cpu, run_on_cpu_func func, = run_on_cpu_data data) g_assert(no_cpu_mutex_locked()); =20 if (qemu_cpu_is_self(cpu)) { - if (has_bql) { - func(cpu, data); + if (bql) { + if (has_bql) { + func(cpu, data); + } else { + qemu_mutex_lock_iothread(); + func(cpu, data); + qemu_mutex_unlock_iothread(); + } } else { - qemu_mutex_lock_iothread(); func(cpu, data); - qemu_mutex_unlock_iothread(); } return; } @@ -172,7 +177,7 @@ void run_on_cpu(CPUState *cpu, run_on_cpu_func func, ru= n_on_cpu_data data) wi.done =3D false; wi.free =3D false; wi.exclusive =3D false; - wi.bql =3D true; + wi.bql =3D bql; =20 cpu_mutex_lock(cpu); queue_work_on_cpu_locked(cpu, &wi); @@ -189,6 +194,17 @@ void run_on_cpu(CPUState *cpu, run_on_cpu_func func, r= un_on_cpu_data data) } } =20 +void run_on_cpu(CPUState *cpu, run_on_cpu_func func, run_on_cpu_data data) +{ + do_run_on_cpu(cpu, func, data, true); +} + +void +run_on_cpu_no_bql(CPUState *cpu, run_on_cpu_func func, run_on_cpu_data dat= a) +{ + do_run_on_cpu(cpu, func, data, false); +} + void async_run_on_cpu(CPUState *cpu, run_on_cpu_func func, run_on_cpu_data= data) { struct qemu_work_item *wi; --=20 2.17.1