From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42594) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UoFLV-0007SD-Li for qemu-devel@nongnu.org; Sun, 16 Jun 2013 11:58:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UoFLU-00079Z-1h for qemu-devel@nongnu.org; Sun, 16 Jun 2013 11:58:25 -0400 Received: from cantor2.suse.de ([195.135.220.15]:60042 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UoFLT-00078a-O1 for qemu-devel@nongnu.org; Sun, 16 Jun 2013 11:58:23 -0400 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Sun, 16 Jun 2013 17:57:44 +0200 Message-Id: <1371398269-6213-25-git-send-email-afaerber@suse.de> In-Reply-To: <1371398269-6213-1-git-send-email-afaerber@suse.de> References: <1371398269-6213-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH qom-cpu v2 24/29] cpu: Drop qemu_for_each_cpu() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Andreas=20F=C3=A4rber?= , "Michael S. Tsirkin" Revert commit d6b9e0d60cc511eca210834428bb74508cff3d33 (cpu: Add qemu_for_each_cpu()) and its usage in favor of open-coding CPU loops, now that they are based on CPUState. Suggested-by: Markus Armbruster Signed-off-by: Andreas F=C3=A4rber --- cpus.c | 11 ++++------- exec.c | 11 ----------- hw/acpi/piix4.c | 20 +++++++++----------- include/qom/cpu.h | 9 --------- qom/cpu.c | 30 +++++++++--------------------- 5 files changed, 22 insertions(+), 59 deletions(-) diff --git a/cpus.c b/cpus.c index ec38644..691c435 100644 --- a/cpus.c +++ b/cpus.c @@ -803,12 +803,6 @@ static void *qemu_dummy_cpu_thread_fn(void *arg) =20 static void tcg_exec_all(void); =20 -static void tcg_signal_cpu_creation(CPUState *cpu, void *data) -{ - cpu->thread_id =3D qemu_get_thread_id(); - cpu->created =3D true; -} - static void *qemu_tcg_cpu_thread_fn(void *arg) { CPUState *cpu =3D arg; @@ -817,7 +811,10 @@ static void *qemu_tcg_cpu_thread_fn(void *arg) qemu_thread_get_self(cpu->thread); =20 qemu_mutex_lock(&qemu_global_mutex); - qemu_for_each_cpu(tcg_signal_cpu_creation, NULL); + for (cpu =3D first_cpu; cpu !=3D NULL; cpu =3D cpu->next_cpu) { + cpu->thread_id =3D qemu_get_thread_id(); + cpu->created =3D true; + } qemu_cond_signal(&qemu_cpu_cond); =20 /* wait for initial kick-off after machine start */ diff --git a/exec.c b/exec.c index 191eb4e..5f3aba1 100644 --- a/exec.c +++ b/exec.c @@ -276,17 +276,6 @@ CPUState *qemu_get_cpu(int index) return cpu; } =20 -void qemu_for_each_cpu(void (*func)(CPUState *cpu, void *data), void *da= ta) -{ - CPUState *cpu; - - cpu =3D first_cpu; - while (cpu) { - func(cpu, data); - cpu =3D cpu->next_cpu; - } -} - void cpu_exec_init(CPUArchState *env) { CPUState *cpu =3D ENV_GET_CPU(env); diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c index 756df3b..3234452 100644 --- a/hw/acpi/piix4.c +++ b/hw/acpi/piix4.c @@ -654,22 +654,14 @@ static void piix4_cpu_added_req(Notifier *n, void *= opaque) piix4_cpu_hotplug_req(s, CPU(opaque), PLUG); } =20 -static void piix4_init_cpu_status(CPUState *cpu, void *data) -{ - CPUStatus *g =3D (CPUStatus *)data; - CPUClass *k =3D CPU_GET_CLASS(cpu); - int64_t id =3D k->get_arch_id(cpu); - - g_assert((id / 8) < PIIX4_PROC_LEN); - g->sts[id / 8] |=3D (1 << (id % 8)); -} - static int piix4_device_hotplug(DeviceState *qdev, PCIDevice *dev, PCIHotplugState state); =20 static void piix4_acpi_system_hot_add_init(MemoryRegion *parent, PCIBus *bus, PIIX4PMState *s) { + CPUState *cpu; + memory_region_init_io(&s->io_gpe, &piix4_gpe_ops, s, "apci-gpe0", GPE_LEN); memory_region_add_subregion(parent, GPE_BASE, &s->io_gpe); @@ -680,7 +672,13 @@ static void piix4_acpi_system_hot_add_init(MemoryReg= ion *parent, &s->io_pci); pci_bus_hotplug(bus, piix4_device_hotplug, &s->dev.qdev); =20 - qemu_for_each_cpu(piix4_init_cpu_status, &s->gpe_cpu); + for (cpu =3D first_cpu; cpu !=3D NULL; cpu =3D cpu->next_cpu) { + CPUClass *cc =3D CPU_GET_CLASS(cpu); + int64_t id =3D cc->get_arch_id(cpu); + + g_assert((id / 8) < PIIX4_PROC_LEN); + s->gpe_cpu.sts[id / 8] |=3D (1 << (id % 8)); + } memory_region_init_io(&s->io_cpu, &cpu_hotplug_ops, s, "apci-cpu-hot= plug", PIIX4_PROC_LEN); memory_region_add_subregion(parent, PIIX4_PROC_BASE, &s->io_cpu); diff --git a/include/qom/cpu.h b/include/qom/cpu.h index 2a64af2..467896c 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -356,15 +356,6 @@ bool cpu_is_stopped(CPUState *cpu); void run_on_cpu(CPUState *cpu, void (*func)(void *data), void *data); =20 /** - * qemu_for_each_cpu: - * @func: The function to be executed. - * @data: Data to pass to the function. - * - * Executes @func for each CPU. - */ -void qemu_for_each_cpu(void (*func)(CPUState *cpu, void *data), void *da= ta); - -/** * qemu_get_cpu: * @index: The CPUState@cpu_index value of the CPU to obtain. * diff --git a/qom/cpu.c b/qom/cpu.c index ee8f632..94fa2b8 100644 --- a/qom/cpu.c +++ b/qom/cpu.c @@ -24,30 +24,18 @@ #include "qemu/notify.h" #include "sysemu/sysemu.h" =20 -typedef struct CPUExistsArgs { - int64_t id; - bool found; -} CPUExistsArgs; - -static void cpu_exist_cb(CPUState *cpu, void *data) -{ - CPUClass *klass =3D CPU_GET_CLASS(cpu); - CPUExistsArgs *arg =3D data; - - if (klass->get_arch_id(cpu) =3D=3D arg->id) { - arg->found =3D true; - } -} - bool cpu_exists(int64_t id) { - CPUExistsArgs data =3D { - .id =3D id, - .found =3D false, - }; + CPUState *cpu; + + for (cpu =3D first_cpu; cpu !=3D NULL; cpu =3D cpu->next_cpu) { + CPUClass *cc =3D CPU_GET_CLASS(cpu); =20 - qemu_for_each_cpu(cpu_exist_cb, &data); - return data.found; + if (cc->get_arch_id(cpu) =3D=3D id) { + return true; + } + } + return false; } =20 bool cpu_paging_enabled(const CPUState *cpu) --=20 1.8.1.4