From: Ying Han <yinghan@google.com>
To: Hillf Danton <dhillf@gmail.com>
Cc: Michal Hocko <mhocko@suse.cz>,
Johannes Weiner <hannes@cmpxchg.org>, Mel Gorman <mel@csn.ul.ie>,
KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
Rik van Riel <riel@redhat.com>, Hugh Dickins <hughd@google.com>,
Dan Magenheimer <dan.magenheimer@oracle.com>,
Andrew Morton <akpm@linux-foundation.org>,
linux-mm@kvack.org
Subject: Re: [PATCH] kvm: don't call mmu_shrinker w/o used_mmu_pages
Date: Mon, 16 Apr 2012 09:43:53 -0700 [thread overview]
Message-ID: <CALWz4iw879XbRSGK5VPM64DOR8Rx4KjdFdumvn1ppMJuUoXhvw@mail.gmail.com> (raw)
In-Reply-To: <CAJd=RBCNDaHeFakcQGGA5jop8-9YtZtG7B4pdPyyYvgnOoiRKA@mail.gmail.com>
On Sat, Apr 14, 2012 at 4:44 AM, Hillf Danton <dhillf@gmail.com> wrote:
> On Sat, Apr 14, 2012 at 6:38 AM, Ying Han <yinghan@google.com> wrote:
>> The 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@google.com>
>> ---
>> arch/x86/kvm/mmu.c | 10 +++++++++-
>> 1 files changed, 9 insertions(+), 1 deletions(-)
>>
>> diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
>> index 4cb1642..7025736 100644
>> --- a/arch/x86/kvm/mmu.c
>> +++ b/arch/x86/kvm/mmu.c
>> @@ -188,6 +188,11 @@ static u64 __read_mostly shadow_mmio_mask;
>>
>> 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;
>> @@ -3900,6 +3905,9 @@ static int mmu_shrink(struct shrinker *shrink, struct shrink_control *sc)
>> 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) {
>> @@ -3926,7 +3934,7 @@ static int mmu_shrink(struct shrinker *shrink, struct shrink_control *sc)
>> raw_spin_unlock(&kvm_lock);
>>
>> out:
>> - return percpu_counter_read_positive(&kvm_total_used_mmu_pages);
>> + return get_kvm_total_used_mmu_pages();
>> }
>>
> Just nitpick.
> If new helper not created, there is only one hunk needed.
Hmm, thought it looks nicer with the helpful function instead of long
percpu_counter_read_positive() in the if block.
>
> btw, make sense to check nr_to_scan while scanning vm_list, and bail out
> if it hits zero?
Not totally understand the nr_to_scan in that function, but we could
do a separate patch if that is needed.
--Ying
>
> Good Weekend
> -hd
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2012-04-16 16:43 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-13 22:38 Ying Han
2012-04-14 11:44 ` Hillf Danton
2012-04-16 16:43 ` Ying Han [this message]
2012-04-20 22:11 ` Andrew Morton
2012-04-20 22:53 ` Rik van Riel
2012-04-20 23:07 ` Ying Han
2012-04-21 1:56 ` Takuya Yoshikawa
2012-04-21 2:15 ` Mike Waychison
2012-04-21 2:29 ` Takuya Yoshikawa
2012-04-21 2:48 ` Mike Waychison
2012-04-22 9:16 ` Avi Kivity
2012-04-22 19:05 ` Eric Northup
2012-04-23 8:37 ` Avi Kivity
2012-04-22 9:04 ` Avi Kivity
2012-04-22 9:35 ` Avi Kivity
2012-04-23 16:40 ` Ying Han
2012-04-23 16:48 ` Rik van Riel
2012-04-23 16:57 ` Avi Kivity
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CALWz4iw879XbRSGK5VPM64DOR8Rx4KjdFdumvn1ppMJuUoXhvw@mail.gmail.com \
--to=yinghan@google.com \
--cc=akpm@linux-foundation.org \
--cc=dan.magenheimer@oracle.com \
--cc=dhillf@gmail.com \
--cc=hannes@cmpxchg.org \
--cc=hughd@google.com \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--cc=linux-mm@kvack.org \
--cc=mel@csn.ul.ie \
--cc=mhocko@suse.cz \
--cc=riel@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox