From patchwork Thu Apr 30 11:36:01 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 6302341 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0BB379F326 for ; Thu, 30 Apr 2015 11:40:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 27028201EC for ; Thu, 30 Apr 2015 11:40:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4D99820123 for ; Thu, 30 Apr 2015 11:40:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751894AbbD3LkQ (ORCPT ); Thu, 30 Apr 2015 07:40:16 -0400 Received: from mail-wi0-f170.google.com ([209.85.212.170]:35227 "EHLO mail-wi0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750947AbbD3Lge (ORCPT ); Thu, 30 Apr 2015 07:36:34 -0400 Received: by widdi4 with SMTP id di4so15634424wid.0; Thu, 30 Apr 2015 04:36:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=jcEG7FMGpsPSVkhDadIzC5kY3nhcTOzzQsE6rAzcQ9o=; b=nUJpNalBEwbqvPG0xtM9msHDpp2OPpQ0vRy0DPF2DMXlSRDp/YEV/2XLr+VYfTU8a5 KW3xpkvTdSGmMcsATiQhleh+e9rxBJQyDwLd0Dmexk2pjoeEk8PFfV6UZMZgQPXSqLJH Y5IZxqUbBMzwHMGZw+bX8hRWexhptdRne2Gj1s3LEn0KTIKAYLjNlaN7g1nJDsRYhQ87 J+bhiCbP9OkWbxMw2lvIPGoxzMl4HxeHz+1+QksysNKWgBvIoQPpH4L0k353VJ2GS036 10Nikx8TZ7tAey3wnZeYOzNAnU/lAJhfXbd9kx2k9c8ku73DCpJYBAhdYUjM3tpyvYUe UU/g== X-Received: by 10.194.90.106 with SMTP id bv10mr7968769wjb.122.1430393793735; Thu, 30 Apr 2015 04:36:33 -0700 (PDT) Received: from 640k.localdomain (dynamic-adsl-94-39-185-241.clienti.tiscali.it. [94.39.185.241]) by mx.google.com with ESMTPSA id v3sm2064527wix.8.2015.04.30.04.36.31 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Apr 2015 04:36:32 -0700 (PDT) From: Paolo Bonzini To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: rkrcmar@redhat.com, bsd@redhat.com, guangrong.xiao@linux.intel.com, Yang Zhang , wanpeng.li@linux.intel.com Subject: [PATCH 02/13] KVM: reuse memslot in kvm_write_guest_page Date: Thu, 30 Apr 2015 13:36:01 +0200 Message-Id: <1430393772-27208-3-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1430393772-27208-1-git-send-email-pbonzini@redhat.com> References: <1430393772-27208-1-git-send-email-pbonzini@redhat.com> 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=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD,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: Radim Kr?má? Saves one O(log N) search. Signed-off-by: Radim Kr?má? Message-Id: <1428695247-27603-1-git-send-email-rkrcmar@redhat.com> Signed-off-by: Paolo Bonzini --- virt/kvm/kvm_main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 90977418aeb6..b6d415156283 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -1590,15 +1590,17 @@ int kvm_write_guest_page(struct kvm *kvm, gfn_t gfn, const void *data, int offset, int len) { int r; + struct kvm_memory_slot *memslot; unsigned long addr; - addr = gfn_to_hva(kvm, gfn); + memslot = gfn_to_memslot(kvm, gfn); + addr = gfn_to_hva_memslot(memslot, gfn); if (kvm_is_error_hva(addr)) return -EFAULT; r = __copy_to_user((void __user *)addr + offset, data, len); if (r) return -EFAULT; - mark_page_dirty(kvm, gfn); + mark_page_dirty_in_slot(kvm, memslot, gfn); return 0; } EXPORT_SYMBOL_GPL(kvm_write_guest_page);