kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Is KVM_GET_SREGS safe from other threads?
@ 2011-05-08  8:24 Pekka Enberg
  2011-05-08  8:50 ` Avi Kivity
  0 siblings, 1 reply; 3+ messages in thread
From: Pekka Enberg @ 2011-05-08  8:24 UTC (permalink / raw)
  To: KVM General, Avi Kivity, Ingo Molnar, Cyrill Gorcunov

Hi!

We've noticed that sometimes KVM_GET_SREGS from a signal handler
hangs. We use it like this:

static void handle_sigquit(int sig)
{
         int i;

         for (i = 0; i < nrcpus; i++) {
                 struct kvm_cpu *cpu = kvm_cpus[i];

                 kvm_cpu__show_registers(cpu); <-- here
                 kvm_cpu__show_code(cpu);
                 kvm_cpu__show_page_tables(cpu);
         }

and

void kvm_cpu__show_registers(struct kvm_cpu *self)
{
[...]
	if (ioctl(self->vcpu_fd, KVM_GET_SREGS, &sregs) < 0)
		die("KVM_GET_REGS failed");

is it not OK to call KVM_GET_SREGS from other threads than the one
that's doing KVM_RUN?

                        Pekka

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Is KVM_GET_SREGS safe from other threads?
  2011-05-08  8:24 Is KVM_GET_SREGS safe from other threads? Pekka Enberg
@ 2011-05-08  8:50 ` Avi Kivity
  2011-05-08  9:07   ` Pekka Enberg
  0 siblings, 1 reply; 3+ messages in thread
From: Avi Kivity @ 2011-05-08  8:50 UTC (permalink / raw)
  To: Pekka Enberg; +Cc: KVM General, Ingo Molnar, Cyrill Gorcunov

On 05/08/2011 11:24 AM, Pekka Enberg wrote:
> Hi!
>
> We've noticed that sometimes KVM_GET_SREGS from a signal handler
> hangs. We use it like this:
>
> static void handle_sigquit(int sig)
> {
>           int i;
>
>           for (i = 0; i<  nrcpus; i++) {
>                   struct kvm_cpu *cpu = kvm_cpus[i];
>
>                   kvm_cpu__show_registers(cpu);<-- here
>                   kvm_cpu__show_code(cpu);
>                   kvm_cpu__show_page_tables(cpu);
>           }
>
> and
>
> void kvm_cpu__show_registers(struct kvm_cpu *self)
> {
> [...]
> 	if (ioctl(self->vcpu_fd, KVM_GET_SREGS,&sregs)<  0)
> 		die("KVM_GET_REGS failed");
>
> is it not OK to call KVM_GET_SREGS from other threads than the one
> that's doing KVM_RUN?

 From Documentation/kvm/api.txt:

  - vcpu ioctls: These query and set attributes that control the operation
    of a single virtual cpu.

    Only run vcpu ioctls from the same thread that was used to create the
    vcpu.


So no, it is not okay (nor is it meaningful, you get a register snapshot 
that is disconnected from all other vcpu state).

-- 
error compiling committee.c: too many arguments to function


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Is KVM_GET_SREGS safe from other threads?
  2011-05-08  8:50 ` Avi Kivity
@ 2011-05-08  9:07   ` Pekka Enberg
  0 siblings, 0 replies; 3+ messages in thread
From: Pekka Enberg @ 2011-05-08  9:07 UTC (permalink / raw)
  To: Avi Kivity; +Cc: KVM General, Ingo Molnar, Cyrill Gorcunov

On Sun, May 8, 2011 at 11:50 AM, Avi Kivity <avi@redhat.com> wrote:
> On 05/08/2011 11:24 AM, Pekka Enberg wrote:
>>
>> Hi!
>>
>> We've noticed that sometimes KVM_GET_SREGS from a signal handler
>> hangs. We use it like this:
>>
>> static void handle_sigquit(int sig)
>> {
>>          int i;
>>
>>          for (i = 0; i<  nrcpus; i++) {
>>                  struct kvm_cpu *cpu = kvm_cpus[i];
>>
>>                  kvm_cpu__show_registers(cpu);<-- here
>>                  kvm_cpu__show_code(cpu);
>>                  kvm_cpu__show_page_tables(cpu);
>>          }
>>
>> and
>>
>> void kvm_cpu__show_registers(struct kvm_cpu *self)
>> {
>> [...]
>>        if (ioctl(self->vcpu_fd, KVM_GET_SREGS,&sregs)<  0)
>>                die("KVM_GET_REGS failed");
>>
>> is it not OK to call KVM_GET_SREGS from other threads than the one
>> that's doing KVM_RUN?
>
> From Documentation/kvm/api.txt:
>
>  - vcpu ioctls: These query and set attributes that control the operation
>   of a single virtual cpu.
>
>   Only run vcpu ioctls from the same thread that was used to create the
>   vcpu.
>
>
> So no, it is not okay (nor is it meaningful, you get a register snapshot
> that is disconnected from all other vcpu state).

Aah, I've read that part at some point but forgot all about it. Thanks, Avi!

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-05-08  9:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-08  8:24 Is KVM_GET_SREGS safe from other threads? Pekka Enberg
2011-05-08  8:50 ` Avi Kivity
2011-05-08  9:07   ` Pekka Enberg

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).