From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965646AbbEEQbF (ORCPT ); Tue, 5 May 2015 12:31:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36037 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1761243AbbEEQaD (ORCPT ); Tue, 5 May 2015 12:30:03 -0400 Date: Tue, 5 May 2015 18:29:55 +0200 From: Radim =?utf-8?B?S3LEjW3DocWZ?= To: Bandan Das Cc: Paolo Bonzini , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, guangrong.xiao@linux.intel.com, Yang Zhang , wanpeng.li@linux.intel.com Subject: Re: [PATCH 02/13] KVM: reuse memslot in kvm_write_guest_page Message-ID: <20150505162954.GA17198@potion.brq.redhat.com> References: <1430393772-27208-1-git-send-email-pbonzini@redhat.com> <1430393772-27208-3-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 2015-05-05 11:03-0400, Bandan Das: > Paolo Bonzini writes: > >> From: Radim Krčmář >> >> Saves one O(log N) search. > > It really doesn't hurt to change this to: > "Caching memslot value helps us avoid another O(log N) search > later when calling mark_page_dirty_in_slot()." > > Sorry I am not a fan of commit messages less than 75 characters :) Sure, I just couldn't find a message that would be easier to understand than the code and not misleading at the same time ... what came out was a teaser for people who care about performance :) In verbose mode, I'd write it like this: gfn_to_hva() and mark_page_dirty() both call gfn_to_memslot(). We can store a result of gfn_to_memslot() (memslot) and unwrap gfn_to_hva() and mark_page_dirty() to directly call functions that accept a memslot. gfn_to_memslot() does a binary search, so it also saves some cycles.