[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20140820162653.GC20453@potion.brq.redhat.com>
Date: Wed, 20 Aug 2014 18:26:54 +0200
From: Radim Krčmář <rkrcmar@...hat.com>
To: Paolo Bonzini <pbonzini@...hat.com>
Cc: kvm@...r.kernel.org, linux-kernel@...r.kernel.org,
Gleb Natapov <gleb@...nel.org>,
Raghavendra KT <raghavendra.kt@...ux.vnet.ibm.com>,
Vinod Chegu <chegu_vinod@...com>, Hui-Zhi <hui-zhi.zhao@...com>
Subject: Re: [PATCH 9/9] KVM: VMX: automatic PLE window maximum
2014-08-20 18:03+0200, Paolo Bonzini:
> Il 20/08/2014 18:01, Radim Krčmář ha scritto:
> > 2014-08-20 17:34+0200, Paolo Bonzini:
> >> Il 20/08/2014 17:31, Radim Krčmář ha scritto:
> >>> Btw. without extra code, we are still going to overflow on races when
> >>> changing PW_grow, should they be covered as well?
> >>
> >> You mean because there is no spinlock or similar protecting the changes?
> >> I guess you could use a seqlock.
> >
> > Yes, for example between a modification of ple_window
> > new = min(old, PW_actual_max) * PW_grow
> > which gets compiled into something like this:
> > 1) tmp = min(old, PW_actual_max)
> > 2) new = tmp * PW_grow
> > and a write to increase PW_grow
> > 3) PW_actual_max = min(PW_max / new_PW_grow, PW_actual_max)
> > 4) PW_grow = new_PW_grow
> > 5) PW_actual_max = PW_max / new_PW_grow
> >
> > 3 and 4 can exectute between 1 and 2, which could overflow.
> >
> > I don't think they are important enough to warrant a significant
> > performance hit of locking.
>
> A seqlock just costs two memory accesses to the same (shared) cache line
> as the PW data, and a non-taken branch.
Oh, seqlock readers do not have to write to shared memory, so it is
acceptable ...
> I don't like code that is
> unsafe by design...
I wouldn't say it is unsafe, because VCPU's PW is always greater than
module's PW. We are just going to PLE exit sooner than expected.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists