From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39947) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a8PY8-0005xF-23 for qemu-devel@nongnu.org; Mon, 14 Dec 2015 04:36:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a8PY4-00069Z-Po for qemu-devel@nongnu.org; Mon, 14 Dec 2015 04:36:07 -0500 Received: from mx1.redhat.com ([209.132.183.28]:43477) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a8PY4-00069P-Js for qemu-devel@nongnu.org; Mon, 14 Dec 2015 04:36:04 -0500 References: <1450082498-27109-1-git-send-email-a.rigo@virtualopensystems.com> <1450082498-27109-10-git-send-email-a.rigo@virtualopensystems.com> From: Paolo Bonzini Message-ID: <566E8D7C.9030400@redhat.com> Date: Mon, 14 Dec 2015 10:35:56 +0100 MIME-Version: 1.0 In-Reply-To: <1450082498-27109-10-git-send-email-a.rigo@virtualopensystems.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [RFC v6 09/14] softmmu: Add history of excl accesses List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alvise Rigo , qemu-devel@nongnu.org, mttcg@greensocs.com Cc: alex.bennee@linaro.org, jani.kokkonen@huawei.com, tech@virtualopensystems.com, claudio.fontana@huawei.com, rth@twiddle.net On 14/12/2015 09:41, Alvise Rigo wrote: > +static inline void excl_history_put_addr(CPUState *cpu, hwaddr addr) > +{ > + /* Avoid some overhead if the address we are about to put is equal to > + * the last one */ > + if (cpu->excl_protected_addr[cpu->excl_protected_last] != > + (addr & TARGET_PAGE_MASK)) { > + cpu->excl_protected_last = (cpu->excl_protected_last + 1) % > + EXCLUSIVE_HISTORY_LEN; Either use "&" here... > + /* Unset EXCL bit of the oldest entry */ > + if (cpu->excl_protected_addr[cpu->excl_protected_last] != > + EXCLUSIVE_RESET_ADDR) { > + cpu_physical_memory_unset_excl( > + cpu->excl_protected_addr[cpu->excl_protected_last], > + cpu->cpu_index); > + } > + > + /* Add a new address, overwriting the oldest one */ > + cpu->excl_protected_addr[cpu->excl_protected_last] = > + addr & TARGET_PAGE_MASK; > + } > +} > + > #define MMUSUFFIX _mmu > > /* Generates LoadLink/StoreConditional helpers in softmmu_template.h */ > diff --git a/include/qom/cpu.h b/include/qom/cpu.h > index 9e409ce..5f65ebf 100644 > --- a/include/qom/cpu.h > +++ b/include/qom/cpu.h > @@ -217,6 +217,7 @@ struct kvm_run; > > /* Atomic insn translation TLB support. */ > #define EXCLUSIVE_RESET_ADDR ULLONG_MAX > +#define EXCLUSIVE_HISTORY_LEN 8 > > /** > * CPUState: > @@ -343,6 +344,8 @@ struct CPUState { > * The address is set to EXCLUSIVE_RESET_ADDR if the vCPU is not. > * in the middle of a LL/SC. */ > struct Range excl_protected_range; > + hwaddr excl_protected_addr[EXCLUSIVE_HISTORY_LEN]; > + int excl_protected_last; ... or make this an "unsigned int". Otherwise the code will contain an actual (and slow) modulo operation. Paolo > /* Used to carry the SC result but also to flag a normal (legacy) > * store access made by a stcond (see softmmu_template.h). */ > int excl_succeeded;