[LTP] [PATCH] perf_event_open: improve the memory leak detection

Cyril Hrubis chrubis@suse.cz
Wed Jul 17 10:31:19 CEST 2024


Hi!
> +		/*
> +		 * Every 1200000 iterations, calculate the difference in memory
> +		 * availability. If the difference is greater than 10 * 1024 (10MB),
> +		 * increment the sample counter and log the event.
> +		 */
> +		if ((i % 1200000) == 0) {
> +			mem_avail = SAFE_READ_MEMINFO("MemAvailable:");
> +			diff = mem_avail_prev - mem_avail;
> +			diff_total += diff;
> +
> +			if (diff > 20 * 1024) {

Shouldn't this be 10 * 1024 or possibly slightly less than 10 * 1024?

> +				sample++;
> +				tst_res(TINFO, "MemAvailable decreased by %ld kB at iteration %d", diff, i);
> +			}
> +
> +			mem_avail_prev = mem_avail;
> +		}
> +	}
>  
> -	if (diff > 50 * 1024)
> -		tst_res(TFAIL, "Likely kernel memory leak detected");
> +	if ((sample > 5) || (diff_total > 100 * 1024))

Maybe this can rather be if ((sample > 5) && (diff_total > 100 * 1024))

That means that the available memory has been eaten by something and
that it happened more or less in a linear fashion when the program was
running.

> +		tst_res(TFAIL, "Likely kernel memory leak detected, total decrease: %ld kB", diff_total);
>  	else
>  		tst_res(TPASS, "No memory leak found");
>  }
> -- 
> 2.45.2
> 

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list