All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] memcg: Account for pages in the per-cpu cache
@ 2023-10-04 12:11 Richard Palethorpe via ltp
  2023-10-05  9:00 ` Petr Vorel
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Palethorpe via ltp @ 2023-10-04 12:11 UTC (permalink / raw)
  To: ltp; +Cc: Richard Palethorpe

PAGESIZES is one greater than the batch size for charging pages from
the per CPU cache. So with MEM_TO_ALLOC=2*PAGESIZES we have two pages
that are below the threshold for being charged.

Sometimes something triggers a flush and the pages get charged to the
global counter anyway and the test passes. We have seen cases where
the test times out waiting for this to happen.

So this patch sets a lower bound to allow those cases to pass. It'll
probably speed the test up as well.

Signed-off-by: Richard Palethorpe <rpalethorpe@suse.com>
---
 .../controllers/memcg/functional/memcg_subgroup_charge.sh    | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/testcases/kernel/controllers/memcg/functional/memcg_subgroup_charge.sh b/testcases/kernel/controllers/memcg/functional/memcg_subgroup_charge.sh
index 9bcc01258..3b7311422 100755
--- a/testcases/kernel/controllers/memcg/functional/memcg_subgroup_charge.sh
+++ b/testcases/kernel/controllers/memcg/functional/memcg_subgroup_charge.sh
@@ -33,8 +33,8 @@ test_subgroup()
 	fi
 
 	echo $MEMCG_PROCESS_PID > tasks
-	signal_memcg_process $MEM_TO_ALLOC
-	check_mem_stat "rss" $MEM_TO_ALLOC
+	signal_memcg_process $MIN_CHARGED
+	check_mem_stat "rss" $MIN_CHARGED $MEM_TO_ALLOC
 
 	cd subgroup
 	echo $MEMCG_PROCESS_PID > tasks
@@ -66,5 +66,6 @@ test3()
 
 # Allocate memory bigger than per-cpu kernel memory
 MEM_TO_ALLOC=$((PAGESIZES * 2))
+MIN_CHARGED=$((2 * (PAGESIZES - 1)))
 
 tst_run
-- 
2.40.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [LTP] [PATCH] memcg: Account for pages in the per-cpu cache
  2023-10-04 12:11 [LTP] [PATCH] memcg: Account for pages in the per-cpu cache Richard Palethorpe via ltp
@ 2023-10-05  9:00 ` Petr Vorel
  2023-10-12  9:09   ` Richard Palethorpe
  0 siblings, 1 reply; 3+ messages in thread
From: Petr Vorel @ 2023-10-05  9:00 UTC (permalink / raw)
  To: Richard Palethorpe; +Cc: ltp

Hi Richie,

[ Cc Li ]

> PAGESIZES is one greater than the batch size for charging pages from
> the per CPU cache. So with MEM_TO_ALLOC=2*PAGESIZES we have two pages
> that are below the threshold for being charged.

> Sometimes something triggers a flush and the pages get charged to the
> global counter anyway and the test passes. We have seen cases where
> the test times out waiting for this to happen.

> So this patch sets a lower bound to allow those cases to pass. It'll
> probably speed the test up as well.

LGTM.
Reviewed-by: Petr Vorel <pvorel@suse.cz>

Kind regards,
Petr

> Signed-off-by: Richard Palethorpe <rpalethorpe@suse.com>
> ---
>  .../controllers/memcg/functional/memcg_subgroup_charge.sh    | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)

> diff --git a/testcases/kernel/controllers/memcg/functional/memcg_subgroup_charge.sh b/testcases/kernel/controllers/memcg/functional/memcg_subgroup_charge.sh
> index 9bcc01258..3b7311422 100755
> --- a/testcases/kernel/controllers/memcg/functional/memcg_subgroup_charge.sh
> +++ b/testcases/kernel/controllers/memcg/functional/memcg_subgroup_charge.sh
> @@ -33,8 +33,8 @@ test_subgroup()
>  	fi

>  	echo $MEMCG_PROCESS_PID > tasks
> -	signal_memcg_process $MEM_TO_ALLOC
> -	check_mem_stat "rss" $MEM_TO_ALLOC
> +	signal_memcg_process $MIN_CHARGED
> +	check_mem_stat "rss" $MIN_CHARGED $MEM_TO_ALLOC

>  	cd subgroup
>  	echo $MEMCG_PROCESS_PID > tasks
> @@ -66,5 +66,6 @@ test3()

>  # Allocate memory bigger than per-cpu kernel memory
>  MEM_TO_ALLOC=$((PAGESIZES * 2))
> +MIN_CHARGED=$((2 * (PAGESIZES - 1)))

>  tst_run

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [LTP] [PATCH] memcg: Account for pages in the per-cpu cache
  2023-10-05  9:00 ` Petr Vorel
@ 2023-10-12  9:09   ` Richard Palethorpe
  0 siblings, 0 replies; 3+ messages in thread
From: Richard Palethorpe @ 2023-10-12  9:09 UTC (permalink / raw)
  To: Petr Vorel; +Cc: Martin Doucha, ltp

Hello,

Merged, thanks!

As discussed on bz, it may be better to drain the stocks
instead. However there is no direct way to do it.

My idea would be to find the batch size emperically, but it requires a
rewrite of the test IMO. So let's see if this works for now.

Petr Vorel <pvorel@suse.cz> writes:

> Hi Richie,
>
> [ Cc Li ]
>
>> PAGESIZES is one greater than the batch size for charging pages from
>> the per CPU cache. So with MEM_TO_ALLOC=2*PAGESIZES we have two pages
>> that are below the threshold for being charged.
>
>> Sometimes something triggers a flush and the pages get charged to the
>> global counter anyway and the test passes. We have seen cases where
>> the test times out waiting for this to happen.
>
>> So this patch sets a lower bound to allow those cases to pass. It'll
>> probably speed the test up as well.
>
> LGTM.
> Reviewed-by: Petr Vorel <pvorel@suse.cz>
>
> Kind regards,
> Petr
>
>> Signed-off-by: Richard Palethorpe <rpalethorpe@suse.com>
>> ---
>>  .../controllers/memcg/functional/memcg_subgroup_charge.sh    | 5 +++--
>>  1 file changed, 3 insertions(+), 2 deletions(-)
>
>> diff --git a/testcases/kernel/controllers/memcg/functional/memcg_subgroup_charge.sh b/testcases/kernel/controllers/memcg/functional/memcg_subgroup_charge.sh
>> index 9bcc01258..3b7311422 100755
>> --- a/testcases/kernel/controllers/memcg/functional/memcg_subgroup_charge.sh
>> +++ b/testcases/kernel/controllers/memcg/functional/memcg_subgroup_charge.sh
>> @@ -33,8 +33,8 @@ test_subgroup()
>>  	fi
>
>>  	echo $MEMCG_PROCESS_PID > tasks
>> -	signal_memcg_process $MEM_TO_ALLOC
>> -	check_mem_stat "rss" $MEM_TO_ALLOC
>> +	signal_memcg_process $MIN_CHARGED
>> +	check_mem_stat "rss" $MIN_CHARGED $MEM_TO_ALLOC
>
>>  	cd subgroup
>>  	echo $MEMCG_PROCESS_PID > tasks
>> @@ -66,5 +66,6 @@ test3()
>
>>  # Allocate memory bigger than per-cpu kernel memory
>>  MEM_TO_ALLOC=$((PAGESIZES * 2))
>> +MIN_CHARGED=$((2 * (PAGESIZES - 1)))
>
>>  tst_run


-- 
Thank you,
Richard.

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-10-12  9:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-04 12:11 [LTP] [PATCH] memcg: Account for pages in the per-cpu cache Richard Palethorpe via ltp
2023-10-05  9:00 ` Petr Vorel
2023-10-12  9:09   ` Richard Palethorpe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.