[FFmpeg-devel] [PATCH 1/3] checkasm: use perf API on Linux ARM*

Michael Niedermayer michael at niedermayer.cc
Mon Sep 4 00:31:29 EEST 2017


On Sat, Sep 02, 2017 at 08:17:38PM +0200, Clément Bœsch wrote:
> From: Clément Bœsch <cboesch at gopro.com>
> 
> On ARM platforms, accessing the PMU registers requires special user
> access permissions. Since there is no other way to get accurate timers,
> the current implementation of timers in FFmpeg is using these registers.
> Unfortunately, enabling user access to these registers on Linux is not
> trivial, and generally involve compiling a random and unreliable github
> kernel module, or patching somehow your kernel.
> 
> Such module is very unlikely to reach the upstream anytime soon. Quoting
> Robin Murphin from ARM:
> 
> > Say you do give userspace direct access to the PMU; now run two or more
> > programs at once that believe they can use the counters for their own
> > "minimal-overhead" profiling. Have fun interpreting those results...
> >
> > And that's not even getting into the implications of scheduling across
> > different CPUs, CPUidle, etc. where the PMU state is completely beyond
> > userspace's control. In general, the plan to provide userspace with
> > something which might happen to just about work in a few corner cases,
> > but is meaningless, misleading or downright broken in all others, is to
> > never do so.
> 
> As a result, the alternative is to use the Performance Monitoring Linux
> API which makes use of these registers internally (assuming the PMU of
> your ARM board is supported in the kernel, which is definitely not a
> given...).
> 
> While the Linux API is obviously cross platform, it does have a
> significant overhead which needs to be taken into account. As a result,
> that mode is only weakly enabled on ARM platforms exclusively.
> 
> Note on the non flexibility of the implementation: the timers (native
> FFmpeg vs Linux API) are selected at compilation time to prevent the
> need of function calls, which would result in a negative impact on the
> cycle counters.
> ---
>  configure                 |   3 ++
>  tests/checkasm/checkasm.c | 107 +++++++++++++++++++++++++++++++++++++---------
>  tests/checkasm/checkasm.h |  47 +++++++++++++++++---
>  3 files changed, 132 insertions(+), 25 deletions(-)
> 
> diff --git a/configure b/configure
> index 445d953e4f..dc65adfde0 100755
> --- a/configure
> +++ b/configure
> @@ -448,6 +448,7 @@ Developer options (useful when working on FFmpeg itself):
>    --libfuzzer=PATH         path to libfuzzer
>    --ignore-tests=TESTS     comma-separated list (without "fate-" prefix
>                             in the name) of tests whose result is ignored
> +  --enable-linux-perf      enable Linux Performance Monitor API
>  
>  NOTE: Object files are built at the place where configure is launched.
>  EOF
> @@ -1694,6 +1695,7 @@ CONFIG_LIST="
>      $SUBSYSTEM_LIST
>      autodetect
>      fontconfig
> +    linux_perf
>      memory_poisoning
>      neon_clobber_test
>      ossfuzz
> @@ -5013,6 +5015,7 @@ case $target_os in
>      linux)
>          enable dv1394
>          enable section_data_rel_ro
> +        enabled_any arm aarch64 && enable_weak linux_perf
>          ;;
>      irix*)
>          target_os=irix
> diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c
> index 9173ed19d9..bc5193c6e3 100644
> --- a/tests/checkasm/checkasm.c
> +++ b/tests/checkasm/checkasm.c
> @@ -20,6 +20,14 @@
>   * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
>   */
>  
> +#include "config.h"
> +

> +#ifdef CONFIG_LINUX_PERF

is this and others intended to be #ifdef instead of #if ?


[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

"I am not trying to be anyone's saviour, I'm trying to think about the
 future and not be sad" - Elon Musk

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20170903/ebaf4ec8/attachment.sig>


More information about the ffmpeg-devel mailing list