Re: [PATCH net 1/1] net: sock: Use double send/recv buff value to compare with max value
On Thu, 2017-02-09 at 17:08 +0800, Gao Feng wrote: > On Thu, Feb 9, 2017 at 12:00 AM, Eric Dumazetwrote: > > On Wed, 2017-02-08 at 21:07 +0800, f...@ikuai8.com wrote: > >> From: Gao Feng > >> > >> Because the value of SO_SNDBUF and SO_RCVBUF is doubled before > >> assignment, so the real value of send and recv buffer could be more > >> than the max sysctl config sysctl_wmem_max and sysctl_rmem_max. > >> > >> Now use doulbe send/recv buffer value to compare with sysctl_wmem_max > >> and sysctl_rmem_max, and it keeps consistence with SOCK_MIN_SNDBUF > >> and SOCK_MIN_RCVBUF. > >> > >> Signed-off-by: Gao Feng > >> --- > > > > Looks completely bogus, based on your comprehension of this code. > > It is a config param, user could config any value. > So why give it one bogus? > If need more, user could config it by himself. > > > > > If you need to, fix the doc, not this code. > > The current codes mean the buffer could exceed the sysctl max value. > It seems inconsistent. Well, after your patch, we end up doubling what the user requested. Say user used val = 2 val = min_t(u32, val * 2, sysctl_wmem_max); Now val is 4. sk->sk_sndbuf = max_t(int, val * 2, SOCK_MIN_SNDBUF); Now sk_sndbuf is 8, or am I missing something ? Before your patch, sk_sndbuf was 4. See the difference ? Some applications carefully tuned this, some people care about bufferbloat. This is too late now to change this behavior, especially the way you did it, breaking some applications. Unless you can show me a real application that hit an issue, I will not accept your patch.
Re: [PATCH net 1/1] net: sock: Use double send/recv buff value to compare with max value
On Thu, Feb 9, 2017 at 12:00 AM, Eric Dumazetwrote: > On Wed, 2017-02-08 at 21:07 +0800, f...@ikuai8.com wrote: >> From: Gao Feng >> >> Because the value of SO_SNDBUF and SO_RCVBUF is doubled before >> assignment, so the real value of send and recv buffer could be more >> than the max sysctl config sysctl_wmem_max and sysctl_rmem_max. >> >> Now use doulbe send/recv buffer value to compare with sysctl_wmem_max >> and sysctl_rmem_max, and it keeps consistence with SOCK_MIN_SNDBUF >> and SOCK_MIN_RCVBUF. >> >> Signed-off-by: Gao Feng >> --- > > Looks completely bogus, based on your comprehension of this code. It is a config param, user could config any value. So why give it one bogus? If need more, user could config it by himself. > > If you need to, fix the doc, not this code. The current codes mean the buffer could exceed the sysctl max value. It seems inconsistent. Regards Feng > > Unless you give more details of course, why we should take your patch. > > > >
Re: [PATCH net 1/1] net: sock: Use double send/recv buff value to compare with max value
On Wed, 2017-02-08 at 21:07 +0800, f...@ikuai8.com wrote: > From: Gao Feng> > Because the value of SO_SNDBUF and SO_RCVBUF is doubled before > assignment, so the real value of send and recv buffer could be more > than the max sysctl config sysctl_wmem_max and sysctl_rmem_max. > > Now use doulbe send/recv buffer value to compare with sysctl_wmem_max > and sysctl_rmem_max, and it keeps consistence with SOCK_MIN_SNDBUF > and SOCK_MIN_RCVBUF. > > Signed-off-by: Gao Feng > --- Looks completely bogus, based on your comprehension of this code. If you need to, fix the doc, not this code. Unless you give more details of course, why we should take your patch.
[PATCH net 1/1] net: sock: Use double send/recv buff value to compare with max value
From: Gao FengBecause the value of SO_SNDBUF and SO_RCVBUF is doubled before assignment, so the real value of send and recv buffer could be more than the max sysctl config sysctl_wmem_max and sysctl_rmem_max. Now use doulbe send/recv buffer value to compare with sysctl_wmem_max and sysctl_rmem_max, and it keeps consistence with SOCK_MIN_SNDBUF and SOCK_MIN_RCVBUF. Signed-off-by: Gao Feng --- net/core/sock.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/core/sock.c b/net/core/sock.c index 4eca27d..fa40dff 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -712,7 +712,7 @@ int sock_setsockopt(struct socket *sock, int level, int optname, * play 'guess the biggest size' games. RCVBUF/SNDBUF * are treated in BSD as hints */ - val = min_t(u32, val, sysctl_wmem_max); + val = min_t(u32, val * 2, sysctl_wmem_max); set_sndbuf: sk->sk_userlocks |= SOCK_SNDBUF_LOCK; sk->sk_sndbuf = max_t(int, val * 2, SOCK_MIN_SNDBUF); @@ -733,7 +733,7 @@ int sock_setsockopt(struct socket *sock, int level, int optname, * play 'guess the biggest size' games. RCVBUF/SNDBUF * are treated in BSD as hints */ - val = min_t(u32, val, sysctl_rmem_max); + val = min_t(u32, val * 2, sysctl_rmem_max); set_rcvbuf: sk->sk_userlocks |= SOCK_RCVBUF_LOCK; /* -- 1.9.1