Re: [PATCH v6 5/5] mm: THP low utilization shrinker

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Alex,

I think it would better to have the 90% under utilization threshold for
shrinker to be defined as macro rather than hard coded?

like,

/*
 * The threshold to determine if thp is under utilized and can be
 * shrunk.
 */
#define THP_NRML_UTILIZED_BUCKET THP_UTIL_BUCKET_NR - 1

This way, it is more clear.

--skip
> +bool can_shrink_thp(struct folio *folio)
> +{
> +	int bucket, num_utilized_pages;
> +
> +	if (!folio || !folio_test_anon(folio) || !folio_test_transhuge(folio))
> +		return false;
> +
> +	num_utilized_pages = thp_number_utilized_pages(folio);
> +	bucket = thp_utilization_bucket(num_utilized_pages);
> +
> +	return bucket >= 0 && bucket < THP_UTIL_BUCKET_NR - 1;
This can be

         return bucket >= 0 && bucket < THP_NRML_UTILIZED_BUCKET;



> +}
> +
>  static void thp_scan_next_zone(void)
>  {
>  	struct timespec64 current_time;
> @@ -170,6 +183,9 @@ static void thp_util_scan(unsigned long pfn_end)
>  		if (bucket < 0)
>  			continue;
>  
> +		if (bucket < THP_UTIL_BUCKET_NR - 1)
Similarly, this one.

There might be other instances too.
> +			add_underutilized_thp(page);
> +
>  		thp_scan.buckets[bucket].nr_thps++;
>  		thp_scan.buckets[bucket].nr_zero_pages += (HPAGE_PMD_NR - num_utilized_pages);
>  	}
> -- 
> 2.30.2




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux