From: Marcelo Tosatti <mtosatti@redhat.com>
To: kvm@vger.kernel.org, qemu-devel@nongnu.org
Cc: Dean Nelson <dnelson@redhat.com>,
Marcelo Tosatti <mtosatti@redhat.com>,
Huang Ying <ying.huang@intel.com>
Subject: [Qemu-devel] [patch 3/8] Expose thread_id in info cpus
Date: Mon, 11 Oct 2010 15:31:17 -0300 [thread overview]
Message-ID: <20101011183226.812743659@redhat.com> (raw)
In-Reply-To: 20101011183114.455477545@redhat.com
[-- Attachment #1: thread-id --]
[-- Type: text/plain, Size: 3810 bytes --]
commit ce6325ff1af34dbaee91c8d28e792277e43f1227
Author: Glauber Costa <gcosta@redhat.com>
Date: Wed Mar 5 17:01:10 2008 -0300
Augment info cpus
This patch exposes the thread id associated with each
cpu through the already well known 'info cpus' interface.
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Index: qemu/cpu-defs.h
===================================================================
--- qemu.orig/cpu-defs.h
+++ qemu/cpu-defs.h
@@ -197,6 +197,7 @@ typedef struct CPUWatchpoint {
int nr_cores; /* number of cores within this CPU package */ \
int nr_threads;/* number of threads within this CPU */ \
int running; /* Nonzero if cpu is currently running(usermode). */ \
+ int thread_id; \
/* user data */ \
void *opaque; \
\
Index: qemu/cpus.c
===================================================================
--- qemu.orig/cpus.c
+++ qemu/cpus.c
@@ -539,6 +539,7 @@ static void *kvm_cpu_thread_fn(void *arg
qemu_mutex_lock(&qemu_global_mutex);
qemu_thread_self(env->thread);
+ env->thread_id = get_thread_id();
if (kvm_enabled())
kvm_init_vcpu(env);
@@ -578,6 +579,10 @@ static void *tcg_cpu_thread_fn(void *arg
while (!qemu_system_ready)
qemu_cond_timedwait(&qemu_system_cond, &qemu_global_mutex, 100);
+ for (env = first_cpu; env != NULL; env = env->next_cpu) {
+ env->thread_id = get_thread_id();
+ }
+
while (1) {
cpu_exec_all();
qemu_tcg_wait_io_event();
Index: qemu/exec.c
===================================================================
--- qemu.orig/exec.c
+++ qemu/exec.c
@@ -637,6 +637,7 @@ void cpu_exec_init(CPUState *env)
env->numa_node = 0;
QTAILQ_INIT(&env->breakpoints);
QTAILQ_INIT(&env->watchpoints);
+ env->thread_id = get_thread_id();
*penv = env;
#if defined(CONFIG_USER_ONLY)
cpu_list_unlock();
Index: qemu/osdep.c
===================================================================
--- qemu.orig/osdep.c
+++ qemu/osdep.c
@@ -44,6 +44,10 @@
extern int madvise(caddr_t, size_t, int);
#endif
+#ifdef CONFIG_LINUX
+#include <sys/syscall.h>
+#endif
+
#ifdef CONFIG_EVENTFD
#include <sys/eventfd.h>
#endif
@@ -200,6 +204,17 @@ int qemu_create_pidfile(const char *file
return 0;
}
+int get_thread_id(void)
+{
+#if defined (_WIN32)
+ return GetCurrentThreadId();
+#elif defined (__linux__)
+ return syscall(SYS_gettid);
+#else
+ return getpid();
+#endif
+}
+
#ifdef _WIN32
/* mingw32 needs ffs for compilations without optimization. */
Index: qemu/osdep.h
===================================================================
--- qemu.orig/osdep.h
+++ qemu/osdep.h
@@ -126,6 +126,7 @@ void qemu_vfree(void *ptr);
int qemu_madvise(void *addr, size_t len, int advice);
int qemu_create_pidfile(const char *filename);
+int get_thread_id(void);
#ifdef _WIN32
int ffs(int i);
Index: qemu/monitor.c
===================================================================
--- qemu.orig/monitor.c
+++ qemu/monitor.c
@@ -878,6 +878,9 @@ static void print_cpu_iter(QObject *obj,
monitor_printf(mon, " (halted)");
}
+ monitor_printf(mon, " thread_id=%" PRId64 " ",
+ qdict_get_int(cpu, "thread_id"));
+
monitor_printf(mon, "\n");
}
@@ -922,6 +925,7 @@ static void do_info_cpus(Monitor *mon, Q
#elif defined(TARGET_MIPS)
qdict_put(cpu, "PC", qint_from_int(env->active_tc.PC));
#endif
+ qdict_put(cpu, "thread_id", qint_from_int(env->thread_id));
qlist_append(cpu_list, cpu);
}
next prev parent reply other threads:[~2010-10-11 18:38 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-04 18:54 [Qemu-devel] [patch uq/master 0/8] port qemu-kvm's MCE support Marcelo Tosatti
2010-10-04 18:54 ` [Qemu-devel] [patch uq/master 1/8] signalfd compatibility Marcelo Tosatti
2010-10-04 18:54 ` [Qemu-devel] [patch uq/master 2/8] iothread: use signalfd Marcelo Tosatti
2010-10-04 18:54 ` [Qemu-devel] [patch uq/master 3/8] Expose thread_id in info cpus Marcelo Tosatti
2010-10-04 18:54 ` [Qemu-devel] [patch uq/master 4/8] kvm: x86: add mce support Marcelo Tosatti
2010-10-04 18:54 ` [Qemu-devel] [patch uq/master 5/8] Export qemu_ram_addr_from_host Marcelo Tosatti
2010-10-05 12:57 ` [Qemu-devel] " Anthony Liguori
2010-10-05 20:13 ` Marcelo Tosatti
2010-10-05 20:48 ` Anthony Liguori
2010-10-04 18:54 ` [Qemu-devel] [patch uq/master 6/8] Add RAM -> physical addr mapping in MCE simulation Marcelo Tosatti
2010-10-04 18:54 ` [Qemu-devel] [patch uq/master 7/8] MCE: Relay UCR MCE to guest Marcelo Tosatti
2010-10-06 1:10 ` [Qemu-devel] " Hidetoshi Seto
2010-10-06 16:02 ` Marcelo Tosatti
2010-10-06 1:58 ` Hidetoshi Seto
2010-10-06 16:05 ` Marcelo Tosatti
2010-10-06 18:10 ` Dean Nelson
2010-10-07 3:41 ` Hidetoshi Seto
2010-10-07 15:23 ` Dean Nelson
2010-10-08 3:15 ` Huang Ying
2010-10-08 5:54 ` Hidetoshi Seto
2010-10-08 12:02 ` Dean Nelson
2010-10-08 2:50 ` Huang Ying
2010-10-04 18:54 ` [Qemu-devel] [patch uq/master 8/8] Add savevm/loadvm support for MCE Marcelo Tosatti
2010-10-05 16:31 ` [Qemu-devel] [patch uq/master 0/8] port qemu-kvm's MCE support Andreas Färber
2010-10-05 18:58 ` Chris Wright
2010-10-05 20:24 ` Marcelo Tosatti
2010-10-06 17:34 ` [Qemu-devel] [patch uq/master 0/8] port qemu-kvm's MCE support (v2) Marcelo Tosatti
2010-10-06 17:34 ` [Qemu-devel] [patch uq/master 1/8] signalfd compatibility Marcelo Tosatti
2010-10-06 17:34 ` [Qemu-devel] [patch uq/master 2/8] iothread: use signalfd Marcelo Tosatti
2010-10-06 17:34 ` [Qemu-devel] [patch uq/master 3/8] Expose thread_id in info cpus Marcelo Tosatti
2010-10-06 17:34 ` [Qemu-devel] [patch uq/master 4/8] kvm: x86: add mce support Marcelo Tosatti
2010-10-06 19:32 ` [Qemu-devel] " Anthony Liguori
2010-10-06 17:34 ` [Qemu-devel] [patch uq/master 5/8] Export qemu_ram_addr_from_host Marcelo Tosatti
2010-10-06 17:34 ` [Qemu-devel] [patch uq/master 6/8] Add RAM -> physical addr mapping in MCE simulation Marcelo Tosatti
2010-10-06 17:34 ` [Qemu-devel] [patch uq/master 7/8] MCE: Relay UCR MCE to guest Marcelo Tosatti
2010-10-06 17:34 ` [Qemu-devel] [patch uq/master 8/8] Add savevm/loadvm support for MCE Marcelo Tosatti
2010-10-11 18:31 ` [Qemu-devel] [patch 0/8] port qemu-kvm's MCE support (v3) Marcelo Tosatti
2010-10-11 18:31 ` [Qemu-devel] [patch 1/8] signalfd compatibility Marcelo Tosatti
2010-10-11 18:31 ` [Qemu-devel] [patch 2/8] iothread: use signalfd Marcelo Tosatti
2010-10-11 18:31 ` Marcelo Tosatti [this message]
2010-10-11 18:31 ` [Qemu-devel] [patch 4/8] kvm: x86: add mce support Marcelo Tosatti
2010-10-11 18:31 ` [Qemu-devel] [patch 5/8] Export qemu_ram_addr_from_host Marcelo Tosatti
2010-10-11 18:31 ` [Qemu-devel] [patch 6/8] Add RAM -> physical addr mapping in MCE simulation Marcelo Tosatti
2010-10-11 18:31 ` [Qemu-devel] [patch 7/8] MCE: Relay UCR MCE to guest Marcelo Tosatti
2010-10-11 18:31 ` [Qemu-devel] [patch 8/8] Add savevm/loadvm support for MCE Marcelo Tosatti
2010-10-14 10:25 ` [Qemu-devel] Re: [patch 0/8] port qemu-kvm's MCE support (v3) Avi Kivity
2010-10-14 16:21 ` Marcelo Tosatti
2010-10-17 9:32 ` [Qemu-devel] Re: [patch 0/8] port qemu-kvm's MCE support (v3 resend) Avi Kivity
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20101011183226.812743659@redhat.com \
--to=mtosatti@redhat.com \
--cc=dnelson@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=qemu-devel@nongnu.org \
--cc=ying.huang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).