From mboxrd@z Thu Jan 1 00:00:00 1970 From: Radim =?utf-8?B?S3LEjW3DocWZ?= Subject: Re: [PATCH resend] kvm: embed vcpu id to dentry of vcpu anon inode Date: Thu, 25 Jan 2018 16:36:43 +0100 Message-ID: <20180125153643.GD19884@flask> References: <20180119190422.6591-1-yamato@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: kvm@vger.kernel.org To: Masatake YAMATO Return-path: Received: from mx1.redhat.com ([209.132.183.28]:34512 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750769AbeAYPgw (ORCPT ); Thu, 25 Jan 2018 10:36:52 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6962A1E2DD for ; Thu, 25 Jan 2018 15:36:52 +0000 (UTC) Content-Disposition: inline In-Reply-To: <20180119190422.6591-1-yamato@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: 2018-01-20 04:04+0900, Masatake YAMATO: > All d-entries for vcpu have the same, "anon_inode:kvm-vcpu". That means > it is impossible to know the mapping between fds for vcpu and vcpu > from userland. > > # LC_ALL=C ls -l /proc/617/fd | grep vcpu > lrwx------. 1 qemu qemu 64 Jan 7 16:50 18 -> anon_inode:kvm-vcpu > lrwx------. 1 qemu qemu 64 Jan 7 16:50 19 -> anon_inode:kvm-vcpu > > It is also impossible to know the mapping between vma for kvm_run > structure and vcpu from userland. > > # LC_ALL=C grep vcpu /proc/617/maps > 7f9d842d0000-7f9d842d3000 rw-s 00000000 00:0d 20393 anon_inode:kvm-vcpu > 7f9d842d3000-7f9d842d6000 rw-s 00000000 00:0d 20393 anon_inode:kvm-vcpu > > This change adds vcpu id to d-entries for vcpu. With this change > you can get the following output: > > # LC_ALL=C ls -l /proc/617/fd | grep vcpu > lrwx------. 1 qemu qemu 64 Jan 7 16:50 18 -> anon_inode:kvm-vcpu:0 > lrwx------. 1 qemu qemu 64 Jan 7 16:50 19 -> anon_inode:kvm-vcpu:1 > > # LC_ALL=C grep vcpu /proc/617/maps > 7f9d842d0000-7f9d842d3000 rw-s 00000000 00:0d 20393 anon_inode:kvm-vcpu:0 > 7f9d842d3000-7f9d842d6000 rw-s 00000000 00:0d 20393 anon_inode:kvm-vcpu:1 > > With the mappings known from the output, a tool like strace can report more details > of qemu-kvm process activities. Here is the strace output of my local prototype: > > # ./strace -KK -f -p 617 2>&1 | grep 'KVM_RUN\| K' > ... > [pid 664] ioctl(18, KVM_RUN, 0) = 0 (KVM_EXIT_MMIO) > K ready_for_interrupt_injection=1, if_flag=0, flags=0, cr8=0000000000000000, apic_base=0x000000fee00d00 > K phys_addr=0, len=1634035803, [33, 0, 0, 0, 0, 0, 0, 0], is_write=112 > [pid 664] ioctl(18, KVM_RUN, 0) = 0 (KVM_EXIT_MMIO) > K ready_for_interrupt_injection=1, if_flag=1, flags=0, cr8=0000000000000000, apic_base=0x000000fee00d00 > K phys_addr=0, len=1634035803, [33, 0, 0, 0, 0, 0, 0, 0], is_write=112 > ... > > Signed-off-by: Masatake YAMATO > --- Queued, thanks.