Re: [PATCH 5/5] arch: x86: use sign_extend64() for sign extension
From: George Spelvin
Date: Fri Oct 16 2015 - 17:30:31 EST
> --- a/arch/x86/kernel/cpu/perf_event_msr.c
> +++ b/arch/x86/kernel/cpu/perf_event_msr.c
> @@ -163,10 +163,9 @@ again:
> goto again;
>
> delta = now - prev;
> - if (unlikely(event->hw.event_base == MSR_SMI_COUNT)) {
> - delta <<= 32;
> - delta >>= 32; /* sign extend */
> - }
> + if (unlikely(event->hw.event_base == MSR_SMI_COUNT))
> + delta = sign_extend64(delta, 31);
> +
> local64_add(now - prev, &event->count);
> }
GCC can figure it out wither way, but wouldn't
delta = (s32)delta;
be simpler than either?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/