From nobody Wed May 8 06:41:59 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1593686340; cv=none; d=zohomail.com; s=zohoarc; b=NF1W5raYTLzvGJAY3apNDXdkMnEC2X0aq9GI3NIZxHgUqAfU2XPDUc+o1gu0Ohr/wUzvkUdYGjq0vZswnwxpXUCC93WcV5L0KA7rcwjqBh5G1u21jD8Y5b9QooKvZ62xaky3jBfwRnCxWJxdqxWurOrilJB9GNODSP2OsCHXWaU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593686340; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=mEdie+sgoovn6l4efVOCgpUKqagorM8gT9QHHsKXzTk=; b=mWwFdAY8hjvMFOsf9jG/S+pZmZzDxoxwDhj4BX1xoOKTbBq0DiJbytISFSnmWpHWKCW6nU3G7Hm8n4fqHM+zyvQFErzQft4Vg7mhC4bJZyMrGvQRybBuv2jnGE9epemjPn7NyBpLfY8i/WiC1usENLwpakMB7vBb6+k5oiPyCz4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593686340642460.8722416883314; Thu, 2 Jul 2020 03:39:00 -0700 (PDT) Received: from localhost ([::1]:42046 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jqwcN-0001vV-6J for importer@patchew.org; Thu, 02 Jul 2020 06:38:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43696) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jqwbm-0001Qm-N0 for qemu-devel@nongnu.org; Thu, 02 Jul 2020 06:38:22 -0400 Received: from mail-ed1-x543.google.com ([2a00:1450:4864:20::543]:40517) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jqwbl-00063B-1r for qemu-devel@nongnu.org; Thu, 02 Jul 2020 06:38:22 -0400 Received: by mail-ed1-x543.google.com with SMTP id b15so23093970edy.7 for ; Thu, 02 Jul 2020 03:38:20 -0700 (PDT) Received: from x1w.redhat.com (1.red-83-51-162.dynamicip.rima-tde.net. [83.51.162.1]) by smtp.gmail.com with ESMTPSA id d23sm6495413eja.27.2020.07.02.03.38.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Jul 2020 03:38:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=mEdie+sgoovn6l4efVOCgpUKqagorM8gT9QHHsKXzTk=; b=VAzbGJKByjGH0Gjm8ufb9m837QgodA37JVrFQ15uBAIdGlAVVYEqzqaZ9pS1wXMTWa 4e5ML6oTpt5ywKhRVJYdrFguWZRI1Yc65RHLGhIJA/6AtYpxCELAm6W5bDPA5L2IQ2AB FT/w5Cr39MGkHSK6KKihS/C1A/JMfv7LvhttFcn6KPxnFoyAcO86cktmReicHmtHqRXr CFkzJcNX8CHvrzAV0QB95q3/KkTDYUbJ/1OuEli+HOFYldsj9fxSn1ts+e+6CkFg6PSg PZDprnXin+wrYDzz5bWPzDx2jMiqGNzVS9FdD+cvA7u595fWo8AAXcAFgo9EYI9/XsWV DHdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; bh=mEdie+sgoovn6l4efVOCgpUKqagorM8gT9QHHsKXzTk=; b=DqelCEpbsrVmeVRimzey+kS7/Aizrj7l/JNi8ArHqu4l/LB3HmreOT5aFX5o7KFOMR 6pMLEurXVKrjC4ef0EW9BHyQ6ufw3yQGc7MxqL+imKZ07+ghsiOq13ZLQz9Q48Wx5xrt d/nRM8aO2y2V6XvFzKkg9Ha9Kn0pMAzZp6q3EGJ5EA0CKgVK8tVYhKAA1jJRvv4FDKkA QZO7dUkl5Z7IMRqCaUhzU3UbkjuYsk0KODs3lYWs5xj24iHxBjI6wTYpoOrkgp4ouzTT q57m4xrTCK9p1RUP0CBPwcRdm7QY+2cNoUoIw1cldixzn1ayHJFo7y5+lBVRzqA4LY8p 6cvA== X-Gm-Message-State: AOAM531PUC4r+bCs7miNGIO+98NXRHN7wM163xNmvVwHk6g7vKkQZ0yB /nrlIiP+aalTIFUe4AMAxgSxxf1O2+o= X-Google-Smtp-Source: ABdhPJyyX6DbAB+bOG5d0NMTW668wbTs7VgnvXU3c6vFe+d0zqCg2kqculbs94Hg7K3IOHepwUq3iA== X-Received: by 2002:a50:9f8c:: with SMTP id c12mr30760386edf.149.1593686298513; Thu, 02 Jul 2020 03:38:18 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2] cpus: Move CPU code from exec.c to cpus-common.c Date: Thu, 2 Jul 2020 12:38:16 +0200 Message-Id: <20200702103816.13798-1-f4bug@amsat.org> X-Mailer: git-send-email 2.21.3 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::543; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-ed1-x543.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: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-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: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Paolo Bonzini , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Philippe Mathieu-Daud=C3=A9 This code was introduced with SMP support in commit 6a00d60127, later commit 267f685b8b moved CPU list management to common code but forgot this code. Move now and simplify ifdef'ry. Reviewed-by: Richard Henderson Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- cpus-common.c | 18 ++++++++++++++++++ exec.c | 22 ---------------------- 2 files changed, 18 insertions(+), 22 deletions(-) diff --git a/cpus-common.c b/cpus-common.c index 8f5512b3d7..34044f4e4c 100644 --- a/cpus-common.c +++ b/cpus-common.c @@ -72,6 +72,8 @@ static int cpu_get_free_index(void) return max_cpu_index; } =20 +CPUTailQ cpus =3D QTAILQ_HEAD_INITIALIZER(cpus); + void cpu_list_add(CPUState *cpu) { QEMU_LOCK_GUARD(&qemu_cpu_list_lock); @@ -96,6 +98,22 @@ void cpu_list_remove(CPUState *cpu) cpu->cpu_index =3D UNASSIGNED_CPU_INDEX; } =20 +CPUState *qemu_get_cpu(int index) +{ + CPUState *cpu; + + CPU_FOREACH(cpu) { + if (cpu->cpu_index =3D=3D index) { + return cpu; + } + } + + return NULL; +} + +/* current CPU in the current thread. It is only valid inside cpu_exec() */ +__thread CPUState *current_cpu; + struct qemu_work_item { QSIMPLEQ_ENTRY(qemu_work_item) node; run_on_cpu_func func; diff --git a/exec.c b/exec.c index 21926dc9c7..997b7db15f 100644 --- a/exec.c +++ b/exec.c @@ -98,12 +98,6 @@ AddressSpace address_space_memory; static MemoryRegion io_mem_unassigned; #endif =20 -CPUTailQ cpus =3D QTAILQ_HEAD_INITIALIZER(cpus); - -/* current CPU in the current thread. It is only valid inside - cpu_exec() */ -__thread CPUState *current_cpu; - uintptr_t qemu_host_page_size; intptr_t qemu_host_page_mask; =20 @@ -832,22 +826,6 @@ const VMStateDescription vmstate_cpu_common =3D { } }; =20 -#endif - -CPUState *qemu_get_cpu(int index) -{ - CPUState *cpu; - - CPU_FOREACH(cpu) { - if (cpu->cpu_index =3D=3D index) { - return cpu; - } - } - - return NULL; -} - -#if !defined(CONFIG_USER_ONLY) void cpu_address_space_init(CPUState *cpu, int asidx, const char *prefix, MemoryRegion *mr) { --=20 2.21.3