[igt-dev] [igt PATCH v2 1/1] lib: Incrementally mlock()

Caz Yokoyama Caz.Yokoyama at intel.com
Tue Feb 26 16:06:21 UTC 2019


As we discussed on the mailng list, please drop my patch.
-caz

On Fri, 2019-02-22 at 02:03 +0000, Caz Yokoyama wrote:
> As we already have the previous portion of the mmap mlocked, we only
> need to mlock() the fresh portion for testing available memory.
> 
> Address calculation on mlock is fixed.
> 
> When the parent process mlocks, i.e.,
>   igt_assert(!mlock(can_mlock, *can_mlock));
> most likely killed.
> 
> In suspend.c, OOM kills when 64MB less memory is mlocked.
> 
> This patch does not make the test faster. It runs 300-900sec.
> I recommend followings.
> 
> 1. Run patched i915_suspend at shrink only on full test(shard test ?)
> 2. add lighter test such as 1) mlock 3/4 of avail memory, 2) suspend-
> resume
> 
> 2 constantly runs less than 5 sec. However, it does not suspend-
> resume
> with exhausting all of system memory.
> 
> Signed-off-by: Caz Yokoyama <caz.yokoyama at intel.com>
> ---
>  lib/intel_os.c       | 17 +++++++++--------
>  tests/i915/suspend.c |  7 +++++--
>  2 files changed, 14 insertions(+), 10 deletions(-)
> 
> diff --git a/lib/intel_os.c b/lib/intel_os.c
> index e1e31e23..44e852ee 100644
> --- a/lib/intel_os.c
> +++ b/lib/intel_os.c
> @@ -250,22 +250,23 @@ intel_get_total_pinnable_mem(void)
>  	}
>  
>  	for (uint64_t inc = 1024 << 20; inc >= 4 << 10; inc >>= 2) {
> -		igt_debug("Testing mlock %'"PRIu64" B (%'"PRIu64"
> MiB)\n",
> -			  *can_mlock, *can_mlock >> 20);
> +		uint64_t locked = *can_mlock;
> +
> +		igt_debug("Testing mlock %'"PRIu64"B (%'"PRIu64"MiB) +
> %'"PRIu64"B\n",
> +			  locked, locked >> 20, inc);
>  
>  		igt_fork(child, 1) {
> -			for (uint64_t bytes = *can_mlock;
> -			     bytes <= pin;
> -			     bytes += inc) {
> -				if (mlock(can_mlock, bytes))
> +			uint64_t bytes = *can_mlock;
> +
> +			while (bytes <= pin) {
> +				if (mlock((void *)can_mlock + bytes,
> inc))
>  					break;
>  
> -				*can_mlock = bytes;
> +				*can_mlock = bytes += inc;
>  				__sync_synchronize();
>  			}
>  		}
>  		__igt_waitchildren();
> -		igt_assert(!mlock(can_mlock, *can_mlock));
>  	}
>  
>  out:
> diff --git a/tests/i915/suspend.c b/tests/i915/suspend.c
> index 84cb3b49..99ab68be 100644
> --- a/tests/i915/suspend.c
> +++ b/tests/i915/suspend.c
> @@ -160,6 +160,9 @@ test_sysfs_reader(bool hibernate)
>  	igt_stop_helper(&reader);
>  }
>  
> +#define MB (1 << 20)
> +#define LESS_MEM (252*MB)
> +
>  static void
>  test_shrink(int fd, unsigned int mode)
>  {
> @@ -170,8 +173,8 @@ test_shrink(int fd, unsigned int mode)
>  	intel_purge_vm_caches(fd);
>  
>  	size = intel_get_total_pinnable_mem();
> -	igt_require(size > 64 << 20);
> -	size -= 64 << 20;
> +	igt_require(size > LESS_MEM);
> +	size -= LESS_MEM;
>  
>  	mem = mmap(NULL, size, PROT_READ, MAP_SHARED | MAP_ANON, -1,
> 0);
>  



More information about the igt-dev mailing list