The patch titled Subject: kvm: don't call mmu_shrinker w/o used_mmu_pages has been added to the -mm tree. Its filename is kvm-dont-call-mmu_shrinker-w-o-used_mmu_pages.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/SubmitChecklist when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Ying Han <yinghan@xxxxxxxxxx> Subject: kvm: don't call mmu_shrinker w/o used_mmu_pages mmu_shrink() is heavy by itself by iterating all kvms and holding the kvm_lock. spotted the code w/ Rik during LSF, and it turns out we don't need to call the shrinker if nothing to shrink. Signed-off-by: Ying Han <yinghan@xxxxxxxxxx> Cc: Michal Hocko <mhocko@xxxxxxx> Cc: Johannes Weiner <hannes@xxxxxxxxxxx> Cc: Mel Gorman <mel@xxxxxxxxx> Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@xxxxxxxxxxxxxx> Cc: Rik van Riel <riel@xxxxxxxxxx> Cc: Hillf Danton <dhillf@xxxxxxxxx> Cc: Hugh Dickins <hughd@xxxxxxxxxx> Cc: Dan Magenheimer <dan.magenheimer@xxxxxxxxxx> Cc: xAvi Kivity <avi@xxxxxxxxxx> Cc: Marcelo Tosatti <mtosatti@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- arch/x86/kvm/mmu.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff -puN arch/x86/kvm/mmu.c~kvm-dont-call-mmu_shrinker-w-o-used_mmu_pages arch/x86/kvm/mmu.c --- a/arch/x86/kvm/mmu.c~kvm-dont-call-mmu_shrinker-w-o-used_mmu_pages +++ a/arch/x86/kvm/mmu.c @@ -189,6 +189,11 @@ static u64 __read_mostly shadow_mmio_mas static void mmu_spte_set(u64 *sptep, u64 spte); +static inline int get_kvm_total_used_mmu_pages() +{ + return percpu_counter_read_positive(&kvm_total_used_mmu_pages); +} + void kvm_mmu_set_mmio_spte_mask(u64 mmio_mask) { shadow_mmio_mask = mmio_mask; @@ -3964,6 +3969,9 @@ static int mmu_shrink(struct shrinker *s if (nr_to_scan == 0) goto out; + if (!get_kvm_total_used_mmu_pages()) + return 0; + raw_spin_lock(&kvm_lock); list_for_each_entry(kvm, &vm_list, vm_list) { @@ -3990,7 +3998,7 @@ static int mmu_shrink(struct shrinker *s raw_spin_unlock(&kvm_lock); out: - return percpu_counter_read_positive(&kvm_total_used_mmu_pages); + return get_kvm_total_used_mmu_pages(); } static struct shrinker mmu_shrinker = { _ Subject: Subject: kvm: don't call mmu_shrinker w/o used_mmu_pages Patches currently in -mm which might be from yinghan@xxxxxxxxxx are mm-fix-up-the-vmscan-stat-in-vmstat.patch kvm-dont-call-mmu_shrinker-w-o-used_mmu_pages.patch mm-vmscan-remove-lumpy-reclaim.patch mm-vmscan-do-not-stall-on-writeback-during-memory-compaction.patch mm-vmscan-remove-reclaim_mode_t.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html