[igt-dev] [PATCH i-g-t v2 1/2] lib: Extract mlock probing

Chris Wilson chris at chris-wilson.co.uk
Tue Jun 12 11:52:42 UTC 2018


Quoting Michał Winiarski (2018-06-12 12:26:34)
> We already have the routine we need in drv_suspend. Let's move it to lib and
> use it in the mlocking tests. We can also make it a bit faster if we tweak the
> initial step and initial amount.
> (I think it's safe to assume assume that we should be able to lock 3/4 of RAM,
> this cuts the probe time on my 32G SKL - from ~530s to ~180s)
> 
> v2: Use available mem, amend step, also lock outside of fork,
>     early exit if the assumption is wrong (Chris)
>     Update the function name in doc (Ewelina)
> 
> Signed-off-by: Michał Winiarski <michal.winiarski at intel.com>
> Cc: Chris Wilson <chris at chris-wilson.co.uk>
> Cc: Ewelina Musial <ewelina.musial at intel.com>
> ---
>  lib/igt_aux.h       |  1 +
>  lib/intel_os.c      | 56 +++++++++++++++++++++++++++++++++++++++++++++
>  tests/drv_suspend.c | 44 +++++++++--------------------------
>  3 files changed, 68 insertions(+), 33 deletions(-)
> 
> diff --git a/lib/igt_aux.h b/lib/igt_aux.h
> index 0eb96e44..9a962881 100644
> --- a/lib/igt_aux.h
> +++ b/lib/igt_aux.h
> @@ -209,6 +209,7 @@ void intel_purge_vm_caches(int fd);
>  uint64_t intel_get_avail_ram_mb(void);
>  uint64_t intel_get_total_ram_mb(void);
>  uint64_t intel_get_total_swap_mb(void);
> +size_t intel_get_total_pinnable_mem(void);
>  
>  int __intel_check_memory(uint64_t count, uint64_t size, unsigned mode,
>                          uint64_t *out_required, uint64_t *out_total);
> diff --git a/lib/intel_os.c b/lib/intel_os.c
> index f7ad05ac..8d096edf 100644
> --- a/lib/intel_os.c
> +++ b/lib/intel_os.c
> @@ -183,6 +183,62 @@ intel_get_total_swap_mb(void)
>         return retval / (1024*1024);
>  }
>  
> +/**
> + * intel_get_total_pinnable_mem:
> + *
> + * Compute the amount of memory that we're able to safely lock.
> + * Note that in order to achieve this, we're attempting to repeatedly lock more
> + * and more memory, which is a time consuming process.
> + *
> + * Returns: Amount of memory that can be safely pinned, in bytes.
> + */
> +size_t
> +intel_get_total_pinnable_mem(void)
> +{
> +       uint64_t *can_mlock, pin;
> +       size_t ret;
> +
> +       pin = (intel_get_avail_ram_mb() + 1) << 20;
> +
> +       can_mlock = mmap(NULL, pin, PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
> +       igt_require(can_mlock != MAP_FAILED);
> +
> +       /*
> +        * We can reasonably assume that we should be able to lock at
> +        * least 3/4 of available RAM
> +        */
> +       *can_mlock = (pin >> 1) + (pin >> 2);

We want to use avail as the starting value, but keep total as the target
value, imho.

Other than that,
Reviewed-by: Chris Wilson <chris at chris-wilson.co.uk>

Still not sure why your 32G machine is so slow, I did a few trial runs
on 32G kbl if memory serves. But just curiosity.
-Chris


More information about the igt-dev mailing list