[RH7,1/2] memcg, bc/vm_pages.c: allow Container to report lot of total RAM/SWAP

Submitted by Konstantin Khorenko on July 16, 2020, 12:37 p.m.

Details

Message ID 20200716123717.9402-1-khorenko@virtuozzo.com
State New
Series "Series without cover letter"
Headers show

Commit Message

Konstantin Khorenko July 16, 2020, 12:37 p.m.
We used a Container can be configured some SWAP and RAM and expect the
Container reports those total SWAP/RAM values from its configuration
despite the actual ammount of available SWAP/RAM on the Hardware Node.

This assumption has been broken recently, so resurrect the original
behavior.

Fixes: 770906b27920d ("memcg, bc/vm_pages.c: account some swapped memory
as used in CT in /proc/meminfo")

https://jira.sw.ru/browse/PSBM-105529

Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
---
 mm/memcontrol.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

Patch hide | download patch | download mbox

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index c2713cfd99753..8cd925d0b2078 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -4659,19 +4659,18 @@  void mem_cgroup_fill_meminfo(struct mem_cgroup *memcg, struct meminfo *mi)
 
 void mem_cgroup_fill_sysinfo(struct mem_cgroup *memcg, struct sysinfo *si)
 {
-	unsigned long totalram, totalswap;
 	unsigned long swaped, used;
 
-	totalram = si->totalram;
-	totalswap = si->totalswap;
-
 	memset(si, 0, sizeof(*si));
 
 	used = page_counter_read(&memcg->memory);
-	si->totalram = min(totalram, memcg->memory.limit);
+	/* CT can report totalram > RAM available on Host */
+	si->totalram = memcg->memory.limit;
 
-	swaped = page_counter_read(&memcg->memsw) - page_counter_read(&memcg->memory);
-	si->totalswap = min(totalswap, memcg->memsw.limit - memcg->memory.limit);
+	swaped = page_counter_read(&memcg->memsw) -
+		 page_counter_read(&memcg->memory);
+	/* CT can report totalswap > SWAP available on Host */
+	si->totalswap = memcg->memsw.limit - memcg->memory.limit;
 
 	used = page_counter_read(&memcg->memory);
 

Comments

Konstantin Khorenko July 16, 2020, 12:37 p.m.
please, ignore

--
Best regards,

Konstantin Khorenko,
Virtuozzo Linux Kernel Team

On 07/16/2020 03:37 PM, Konstantin Khorenko wrote:
> We used a Container can be configured some SWAP and RAM and expect the
> Container reports those total SWAP/RAM values from its configuration
> despite the actual ammount of available SWAP/RAM on the Hardware Node.
>
> This assumption has been broken recently, so resurrect the original
> behavior.
>
> Fixes: 770906b27920d ("memcg, bc/vm_pages.c: account some swapped memory
> as used in CT in /proc/meminfo")
>
> https://jira.sw.ru/browse/PSBM-105529
>
> Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
> ---
>  mm/memcontrol.c | 13 ++++++-------
>  1 file changed, 6 insertions(+), 7 deletions(-)
>
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index c2713cfd99753..8cd925d0b2078 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -4659,19 +4659,18 @@ void mem_cgroup_fill_meminfo(struct mem_cgroup *memcg, struct meminfo *mi)
>
>  void mem_cgroup_fill_sysinfo(struct mem_cgroup *memcg, struct sysinfo *si)
>  {
> -	unsigned long totalram, totalswap;
>  	unsigned long swaped, used;
>
> -	totalram = si->totalram;
> -	totalswap = si->totalswap;
> -
>  	memset(si, 0, sizeof(*si));
>
>  	used = page_counter_read(&memcg->memory);
> -	si->totalram = min(totalram, memcg->memory.limit);
> +	/* CT can report totalram > RAM available on Host */
> +	si->totalram = memcg->memory.limit;
>
> -	swaped = page_counter_read(&memcg->memsw) - page_counter_read(&memcg->memory);
> -	si->totalswap = min(totalswap, memcg->memsw.limit - memcg->memory.limit);
> +	swaped = page_counter_read(&memcg->memsw) -
> +		 page_counter_read(&memcg->memory);
> +	/* CT can report totalswap > SWAP available on Host */
> +	si->totalswap = memcg->memsw.limit - memcg->memory.limit;
>
>  	used = page_counter_read(&memcg->memory);
>
>