From patchwork Thu Jun 20 16:34:31 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takuya Yoshikawa X-Patchwork-Id: 2757171 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 90D1F9F751 for ; Thu, 20 Jun 2013 16:34:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6826420440 for ; Thu, 20 Jun 2013 16:34:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 86E402043F for ; Thu, 20 Jun 2013 16:34:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161039Ab3FTQeh (ORCPT ); Thu, 20 Jun 2013 12:34:37 -0400 Received: from mail-pb0-f47.google.com ([209.85.160.47]:59831 "EHLO mail-pb0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161031Ab3FTQeg (ORCPT ); Thu, 20 Jun 2013 12:34:36 -0400 Received: by mail-pb0-f47.google.com with SMTP id rr13so6414912pbb.34 for ; Thu, 20 Jun 2013 09:34:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:x-mailer:mime-version :content-type:content-transfer-encoding; bh=goV2BAa0Ago9/vZVuQsKw0zcnvcPp2VoJIs4yxFyynI=; b=UoAtUAyVxTjEAFKw6SPuStuTzpCJpFZcReZGo3W+o+dd/FFAof95WOpEs8w8/CHzQF LtfLONVTUrS5qzUH9SspqE8JK6j4OyVIz/KS/2oB7V44muTiRo9Bkc6eDc+SOapfGNaJ /voQ6eu5o6jBVB0o/AiOyNoldAUSxjhgdnHR11/AvlkWrVNUSoSMVZ5Fy5lZaH9rXj+j Y/8pvrvofpQO1NZZue4oTm0czOgZzWsoKGS9je06NqIljSQhA5+I6uD5sH1f5f776mG3 lrfbwhApyRqAMyiDr2/3yiNy4i4OwhBwaFkliI8A0d423QTMHdHQUJqh/YfkYW5AyvqU zrpQ== X-Received: by 10.68.75.49 with SMTP id z17mr8464071pbv.169.1371746076225; Thu, 20 Jun 2013 09:34:36 -0700 (PDT) Received: from x121e (w183160.dynamic.ppp.asahi-net.or.jp. [121.1.183.160]) by mx.google.com with ESMTPSA id vz8sm1424650pac.20.2013.06.20.09.34.33 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 20 Jun 2013 09:34:35 -0700 (PDT) Date: Fri, 21 Jun 2013 01:34:31 +0900 From: Takuya Yoshikawa To: gleb@redhat.com, pbonzini@redhat.com Cc: kvm@vger.kernel.org, xiaoguangrong@linux.vnet.ibm.com, yoshikawa_takuya_b1@lab.ntt.co.jp Subject: [PATCH v2] KVM: MMU: Inform users of mmio generation wraparound Message-Id: <20130621013431.141491d8778b89a39d117bbc@gmail.com> X-Mailer: Sylpheed 3.2.0beta5 (GTK+ 2.24.10; x86_64-pc-linux-gnu) Mime-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-8.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Takuya Yoshikawa Without this information, users will just see unexpected performance problems and there is little chance we will get good reports from them: note that mmio generation is increased even when we just start, or stop, dirty logging for some memory slot, in which case users cannot expect all shadow pages to be zapped. printk_ratelimited() is used for this taking into account the problems that we can see the information many times when we start multiple VMs and guests can trigger this by reading ROM in a loop for example. Signed-off-by: Takuya Yoshikawa --- Interestingly, I saw this information printed twice every time. Looks like current_mmio_gen can become mmio_max_gen... arch/x86/kvm/mmu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index c60c5da..54e3968 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c @@ -4385,8 +4385,10 @@ void kvm_mmu_invalidate_mmio_sptes(struct kvm *kvm) * The max value is MMIO_MAX_GEN - 1 since it is not called * when mark memslot invalid. */ - if (unlikely(kvm_current_mmio_generation(kvm) >= (MMIO_MAX_GEN - 1))) + if (unlikely(kvm_current_mmio_generation(kvm) >= (MMIO_MAX_GEN - 1))) { + printk_ratelimited(KERN_INFO "kvm: zapping shadow pages for mmio generation wraparound\n"); kvm_mmu_invalidate_zap_all_pages(kvm); + } } static int mmu_shrink(struct shrinker *shrink, struct shrink_control *sc)