From: Juergen Gross Subject: [PATCH 5/5] xen: use masking operation instead of test_bit for MCSF bits Date: Fri, 2 Oct 2015 06:40:30 +0200 Message-ID: <1443760830-29095-6-git-send-email-jgross@suse.com> References: <1443760830-29095-1-git-send-email-jgross@suse.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1443760830-29095-1-git-send-email-jgross@suse.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: keir@xen.org, jbeulich@suse.com, andrew.cooper3@citrix.com, dario.faggioli@citrix.com, george.dunlap@eu.citrix.com, xen-devel@lists.xen.org Cc: Juergen Gross List-Id: xen-devel@lists.xenproject.org Use a bit mask for testing of a set bit instead of test_bit in case no atomic operation is needed, as this will lead to smaller and more effective code. Signed-off-by: Juergen Gross --- xen/arch/x86/domain.c | 8 ++++---- xen/arch/x86/x86_64/compat/mm.c | 4 ++-- xen/common/multicall.c | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index 4e96f6c..7ca9b93 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -1750,7 +1750,7 @@ void hypercall_cancel_continuation(void) struct cpu_user_regs *regs = guest_cpu_user_regs(); struct mc_state *mcs = ¤t->mc_state; - if ( test_bit(_MCSF_in_multicall, &mcs->flags) ) + if ( mcs->flags & MCSF_in_multicall ) { __clear_bit(_MCSF_call_preempted, &mcs->flags); } @@ -1774,7 +1774,7 @@ unsigned long hypercall_create_continuation( va_start(args, format); - if ( test_bit(_MCSF_in_multicall, &mcs->flags) ) + if ( mcs->flags & MCSF_in_multicall ) { __set_bit(_MCSF_call_preempted, &mcs->flags); @@ -1852,9 +1852,9 @@ int hypercall_xlat_continuation(unsigned int *id, unsigned int nr, va_start(args, mask); - if ( test_bit(_MCSF_in_multicall, &mcs->flags) ) + if ( mcs->flags & MCSF_in_multicall ) { - if ( !test_bit(_MCSF_call_preempted, &mcs->flags) ) + if ( !(mcs->flags & MCSF_call_preempted) ) { va_end(args); return 0; diff --git a/xen/arch/x86/x86_64/compat/mm.c b/xen/arch/x86/x86_64/compat/mm.c index d034bd0..178e42d 100644 --- a/xen/arch/x86/x86_64/compat/mm.c +++ b/xen/arch/x86/x86_64/compat/mm.c @@ -324,7 +324,7 @@ int compat_mmuext_op(XEN_GUEST_HANDLE_PARAM(mmuext_op_compat_t) cmp_uops, { struct cpu_user_regs *regs = guest_cpu_user_regs(); struct mc_state *mcs = ¤t->mc_state; - unsigned int arg1 = !test_bit(_MCSF_in_multicall, &mcs->flags) + unsigned int arg1 = !(mcs->flags & MCSF_in_multicall) ? regs->ecx : mcs->call.args[1]; unsigned int left = arg1 & ~MMU_UPDATE_PREEMPTED; @@ -338,7 +338,7 @@ int compat_mmuext_op(XEN_GUEST_HANDLE_PARAM(mmuext_op_compat_t) cmp_uops, { BUG_ON(!hypercall_xlat_continuation(&left, 4, 0x01, nat_ops, cmp_uops)); - if ( !test_bit(_MCSF_in_multicall, &mcs->flags) ) + if ( !(mcs->flags & MCSF_in_multicall) ) regs->_ecx += count - i; else mcs->compat_call.args[1] += count - i; diff --git a/xen/common/multicall.c b/xen/common/multicall.c index fa9d910..21661ee 100644 --- a/xen/common/multicall.c +++ b/xen/common/multicall.c @@ -79,7 +79,7 @@ do_multicall( if ( unlikely(__copy_field_to_guest(call_list, &mcs->call, result)) ) rc = -EFAULT; - else if ( test_bit(_MCSF_call_preempted, &mcs->flags) ) + else if ( mcs->flags & MCSF_call_preempted ) { /* Translate sub-call continuation to guest layout */ xlat_multicall_entry(mcs); -- 2.1.4