Checking wheter iter->desc is NULL is not worth a function call especially when we use EPT/NPT because we know it would almost always be NULL. Although using "inline" like this does not look clean, we could see measurable performance improvements: get_dirty_log for 1GB dirty memory became faster by more than 10% on my test box. Signed-off-by: Takuya Yoshikawa <yoshikawa.takuya@xxxxxxxxxxxxx> --- arch/x86/kvm/mmu.c | 38 +++++++++++++++++++++++--------------- 1 files changed, 23 insertions(+), 15 deletions(-) diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index d042087..8aa58a1 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c @@ -1016,30 +1016,38 @@ static bool rmap_get_first(unsigned long rmap, struct rmap_iterator *iter) * * Returns true if spte is found, false otherwise. */ -static bool rmap_get_next(struct rmap_iterator *iter) +static bool __rmap_get_next(struct rmap_iterator *iter) { - if (iter->desc) { - if (iter->pos < PTE_LIST_EXT - 1) { - ++iter->pos; - iter->sptep = iter->desc->sptes[iter->pos]; - if (iter->sptep) - return true; - } + if (iter->pos < PTE_LIST_EXT - 1) { + ++iter->pos; + iter->sptep = iter->desc->sptes[iter->pos]; + if (iter->sptep) + return true; + } - iter->desc = iter->desc->more; + iter->desc = iter->desc->more; - if (iter->desc) { - iter->pos = 0; - iter->sptep = iter->desc->sptes[iter->pos]; - /* desc->sptes[0] cannot be NULL */ - return true; - } + if (iter->desc) { + iter->pos = 0; + iter->sptep = iter->desc->sptes[iter->pos]; + /* desc->sptes[0] cannot be NULL */ + return true; } iter->sptep = NULL; return false; } +/* Make this trivial check alone inlined by putting inline. */ +static inline bool rmap_get_next(struct rmap_iterator *iter) +{ + if (iter->desc) + return __rmap_get_next(iter); + + iter->sptep = NULL; + return false; +} + static void drop_spte(struct kvm *kvm, u64 *sptep) { if (mmu_spte_clear_track_bits(sptep)) -- 1.7.5.4 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html