[Devel] net: fix silly mistake with TCP cgroup memory pressure check

Submitted by Stanislav Kinsburskiy on May 26, 2017, 12:59 p.m.

Details

Message ID 20170526125947.4845.90481.stgit@localhost.localdomain
State New
Series "net: fix silly mistake with TCP cgroup memory pressure check"
Headers show

Commit Message

Stanislav Kinsburskiy May 26, 2017, 12:59 p.m.
Memmory pressure is referenced as a pointer in socket structure.
Simple check for pointer address will always return true for each socket,
allocated with enabled mem_cg.
Memory pressure value has to checked instead.

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

Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
---
 include/net/tcp.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/include/net/tcp.h b/include/net/tcp.h
index d64d30b..f2b4843 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -298,7 +298,7 @@  extern int tcp_memory_pressure;
 static inline bool tcp_under_memory_pressure(const struct sock *sk)
 {
 	if (mem_cgroup_sockets_enabled && sk->sk_cgrp)
-		return !!sk->sk_cgrp->memory_pressure;
+		return *sk->sk_cgrp->memory_pressure;
 
 	return tcp_memory_pressure;
 }

Comments

Andrey Ryabinin May 26, 2017, 1:22 p.m.
On 05/26/2017 03:59 PM, Stanislav Kinsburskiy wrote:
> Memmory pressure is referenced as a pointer in socket structure.
> Simple check for pointer address will always return true for each socket,
> allocated with enabled mem_cg.
> Memory pressure value has to checked instead.
> 
> https://jira.sw.ru/browse/PSBM-66468
> 
> Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>

Acked-by: Andrey Ryabinin <aryabinin@virtuozzo.com>

> ---
>  include/net/tcp.h |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/net/tcp.h b/include/net/tcp.h
> index d64d30b..f2b4843 100644
> --- a/include/net/tcp.h
> +++ b/include/net/tcp.h
> @@ -298,7 +298,7 @@ extern int tcp_memory_pressure;
>  static inline bool tcp_under_memory_pressure(const struct sock *sk)
>  {
>  	if (mem_cgroup_sockets_enabled && sk->sk_cgrp)
> -		return !!sk->sk_cgrp->memory_pressure;
> +		return *sk->sk_cgrp->memory_pressure;
>  
>  	return tcp_memory_pressure;
>  }
>