From: Marcelo Tosatti <mtosatti@redhat.com> To: Anthony Liguori <aliguori@us.ibm.com> Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org, Marcelo Tosatti <mtosatti@redhat.com>, Avi Kivity <avi@redhat.com> Subject: [PATCH 05/10] Expose thread_id in info cpus Date: Tue, 19 Oct 2010 08:40:31 -0200 [thread overview] Message-ID: <20e1976aaa36d15c8aef01f7fbd422403e64fa89.1287484836.git.mtosatti@redhat.com> (raw) In-Reply-To: <cover.1287484836.git.mtosatti@redhat.com> 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> Signed-off-by: Avi Kivity <avi@redhat.com> --- cpu-defs.h | 1 + cpus.c | 5 +++++ exec.c | 1 + monitor.c | 4 ++++ osdep.c | 15 +++++++++++++++ osdep.h | 1 + 6 files changed, 27 insertions(+), 0 deletions(-) diff --git a/cpu-defs.h b/cpu-defs.h index 8d4bf86..eaed43e 100644 --- a/cpu-defs.h +++ b/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; \ \ diff --git a/cpus.c b/cpus.c index 3875657..429993a 100644 --- a/cpus.c +++ b/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(); diff --git a/exec.c b/exec.c index 1fbe91c..c09051d 100644 --- a/exec.c +++ b/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(); diff --git a/monitor.c b/monitor.c index 260cc02..709d0fd 100644 --- a/monitor.c +++ b/monitor.c @@ -849,6 +849,9 @@ static void print_cpu_iter(QObject *obj, void *opaque) monitor_printf(mon, " (halted)"); } + monitor_printf(mon, " thread_id=%" PRId64 " ", + qdict_get_int(cpu, "thread_id")); + monitor_printf(mon, "\n"); } @@ -893,6 +896,7 @@ static void do_info_cpus(Monitor *mon, QObject **ret_data) #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); } diff --git a/osdep.c b/osdep.c index 2e05b21..dda0f43 100644 --- a/osdep.c +++ b/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 *filename) 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. */ diff --git a/osdep.h b/osdep.h index 6716281..9b3bc2e 100644 --- a/osdep.h +++ b/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); -- 1.7.2.1
WARNING: multiple messages have this Message-ID (diff)
From: Marcelo Tosatti <mtosatti@redhat.com> To: Anthony Liguori <aliguori@us.ibm.com> Cc: Marcelo Tosatti <mtosatti@redhat.com>, qemu-devel@nongnu.org, kvm@vger.kernel.org, Avi Kivity <avi@redhat.com> Subject: [Qemu-devel] [PATCH 05/10] Expose thread_id in info cpus Date: Tue, 19 Oct 2010 08:40:31 -0200 [thread overview] Message-ID: <20e1976aaa36d15c8aef01f7fbd422403e64fa89.1287484836.git.mtosatti@redhat.com> (raw) In-Reply-To: <cover.1287484836.git.mtosatti@redhat.com> 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> Signed-off-by: Avi Kivity <avi@redhat.com> --- cpu-defs.h | 1 + cpus.c | 5 +++++ exec.c | 1 + monitor.c | 4 ++++ osdep.c | 15 +++++++++++++++ osdep.h | 1 + 6 files changed, 27 insertions(+), 0 deletions(-) diff --git a/cpu-defs.h b/cpu-defs.h index 8d4bf86..eaed43e 100644 --- a/cpu-defs.h +++ b/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; \ \ diff --git a/cpus.c b/cpus.c index 3875657..429993a 100644 --- a/cpus.c +++ b/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(); diff --git a/exec.c b/exec.c index 1fbe91c..c09051d 100644 --- a/exec.c +++ b/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(); diff --git a/monitor.c b/monitor.c index 260cc02..709d0fd 100644 --- a/monitor.c +++ b/monitor.c @@ -849,6 +849,9 @@ static void print_cpu_iter(QObject *obj, void *opaque) monitor_printf(mon, " (halted)"); } + monitor_printf(mon, " thread_id=%" PRId64 " ", + qdict_get_int(cpu, "thread_id")); + monitor_printf(mon, "\n"); } @@ -893,6 +896,7 @@ static void do_info_cpus(Monitor *mon, QObject **ret_data) #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); } diff --git a/osdep.c b/osdep.c index 2e05b21..dda0f43 100644 --- a/osdep.c +++ b/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 *filename) 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. */ diff --git a/osdep.h b/osdep.h index 6716281..9b3bc2e 100644 --- a/osdep.h +++ b/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); -- 1.7.2.1
next prev parent reply other threads:[~2010-10-19 10:41 UTC|newest] Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top 2010-10-19 10:40 [PATCH 00/10] [PULL] qemu-kvm.git uq/master queue Marcelo Tosatti 2010-10-19 10:40 ` [Qemu-devel] " Marcelo Tosatti 2010-10-19 10:40 ` [PATCH 01/10] Set cpuid definition to 0 before initializing it Marcelo Tosatti 2010-10-19 10:40 ` [Qemu-devel] " Marcelo Tosatti 2010-10-19 10:40 ` [PATCH 02/10] Add svm cpuid features Marcelo Tosatti 2010-10-19 10:40 ` [Qemu-devel] " Marcelo Tosatti 2010-10-19 10:40 ` [PATCH 03/10] signalfd compatibility Marcelo Tosatti 2010-10-19 10:40 ` [Qemu-devel] " Marcelo Tosatti 2010-10-19 10:40 ` [PATCH 04/10] iothread: use signalfd Marcelo Tosatti 2010-10-19 10:40 ` [Qemu-devel] " Marcelo Tosatti 2010-10-19 10:40 ` Marcelo Tosatti [this message] 2010-10-19 10:40 ` [Qemu-devel] [PATCH 05/10] Expose thread_id in info cpus Marcelo Tosatti 2010-10-19 10:40 ` [PATCH 06/10] kvm: x86: add mce support Marcelo Tosatti 2010-10-19 10:40 ` [Qemu-devel] " Marcelo Tosatti 2010-10-19 10:40 ` [PATCH 07/10] Export qemu_ram_addr_from_host Marcelo Tosatti 2010-10-19 10:40 ` [Qemu-devel] " Marcelo Tosatti 2010-10-19 10:40 ` [PATCH 08/10] Add RAM -> physical addr mapping in MCE simulation Marcelo Tosatti 2010-10-19 10:40 ` [Qemu-devel] " Marcelo Tosatti 2010-10-19 10:40 ` [PATCH 09/10] MCE: Relay UCR MCE to guest Marcelo Tosatti 2010-10-19 10:40 ` [Qemu-devel] " Marcelo Tosatti 2010-10-19 14:35 ` [PATCH 09/10] MCE: Relay UCR MCE to guest (v2) Marcelo Tosatti 2010-10-19 14:35 ` [Qemu-devel] " Marcelo Tosatti 2010-10-19 10:40 ` [PATCH 10/10] Add savevm/loadvm support for MCE Marcelo Tosatti 2010-10-19 10:40 ` [Qemu-devel] " Marcelo Tosatti 2010-10-19 13:40 ` [Qemu-devel] [PATCH 00/10] [PULL] qemu-kvm.git uq/master queue Anthony Liguori
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=20e1976aaa36d15c8aef01f7fbd422403e64fa89.1287484836.git.mtosatti@redhat.com \ --to=mtosatti@redhat.com \ --cc=aliguori@us.ibm.com \ --cc=avi@redhat.com \ --cc=kvm@vger.kernel.org \ --cc=qemu-devel@nongnu.org \ /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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.