From patchwork Tue Sep 13 10:16:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Punit Agrawal X-Patchwork-Id: 669284 Return-Path: X-Original-To: incoming-imx@patchwork.ozlabs.org Delivered-To: patchwork-incoming-imx@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2001:1868:205::9]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3sYLKY50fZz9sf6 for ; Tue, 13 Sep 2016 20:20:33 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bjkna-0007hc-A7; Tue, 13 Sep 2016 10:18:42 +0000 Received: from fw-tnat.cambridge.arm.com ([217.140.96.140] helo=cam-smtp0.cambridge.arm.com) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bjkmQ-0006vt-7k for linux-arm-kernel@lists.infradead.org; Tue, 13 Sep 2016 10:17:31 +0000 Received: from e105922-lin.cambridge.arm.com (e105922-lin.cambridge.arm.com [10.1.194.52]) by cam-smtp0.cambridge.arm.com (8.13.8/8.13.8) with SMTP id u8DAGjau009438; Tue, 13 Sep 2016 11:16:45 +0100 Received: by e105922-lin.cambridge.arm.com (sSMTP sendmail emulation); Tue, 13 Sep 2016 11:16:45 +0100 From: Punit Agrawal To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Subject: [PATCH 2/7] KVM: Track the pid of the VM process Date: Tue, 13 Sep 2016 11:16:04 +0100 Message-Id: <1473761769-30572-3-git-send-email-punit.agrawal@arm.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1473761769-30572-1-git-send-email-punit.agrawal@arm.com> References: <1473761769-30572-1-git-send-email-punit.agrawal@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160913_031730_747424_306CEA20 X-CRM114-Status: UNSURE ( 9.63 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -5.6 (-----) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-5.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [217.140.96.140 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.4 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Marc Zyngier , Punit Agrawal , Will Deacon , Steven Rostedt , Ingo Molnar , Paolo Bonzini , Christoffer Dall Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org List-Id: linux-imx-kernel.lists.patchwork.ozlabs.org Userspace tools such as perf can be used to profile individual processes. Track the PID of the virtual machine process to match profiling requests targeted at it. This can be used to take appropriate action to enable the requested profiling operations for the VMs of interest. Signed-off-by: Punit Agrawal Cc: Paolo Bonzini Cc: "Radim Krčmář" Cc: Christoffer Dall Cc: Marc Zyngier --- include/linux/kvm_host.h | 1 + virt/kvm/kvm_main.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index 9c28b4d..7c42c94 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -374,6 +374,7 @@ struct kvm_memslots { struct kvm { spinlock_t mmu_lock; struct mutex slots_lock; + struct pid *pid; struct mm_struct *mm; /* userspace tied to this vm */ struct kvm_memslots *memslots[KVM_ADDRESS_SPACE_NUM]; struct srcu_struct srcu; diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 1950782..d87231a 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -613,6 +613,7 @@ static struct kvm *kvm_create_vm(unsigned long type) spin_lock_init(&kvm->mmu_lock); atomic_inc(¤t->mm->mm_count); kvm->mm = current->mm; + kvm->pid = get_task_pid(current->group_leader, PIDTYPE_PID); kvm_eventfd_init(kvm); mutex_init(&kvm->lock); mutex_init(&kvm->irq_lock); @@ -712,6 +713,7 @@ static void kvm_destroy_vm(struct kvm *kvm) int i; struct mm_struct *mm = kvm->mm; + put_pid(kvm->pid); kvm_destroy_vm_debugfs(kvm); kvm_arch_sync_events(kvm); spin_lock(&kvm_lock);