lkml.org 
[lkml]   [2022]   [Jul]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH v2 net 09/12] net: Fix data-races around sysctl_mem.
From
Hello,

On 07/07/2022 01:40, Kuniyuki Iwashima wrote:
> While reading .sysctl_mem, it can be changed concurrently.
> So, we need to add READ_ONCE() to avoid data-races.

FYI, we got a small conflict when merging -net in net-next in the MPTCP
tree due to this patch applied in -net:

310731e2f161 ("net: Fix data-races around sysctl_mem.")

and this one from net-next:

e70f3c701276 ("Revert "net: set SK_MEM_QUANTUM to 4096"")

The conflict has been resolved on our side[1] and the resolution we
suggest is attached to this email.

I'm sharing this thinking it can help others but if it only creates
noise, please tell me! :)

Cheers,
Matt

[1] https://github.com/multipath-tcp/mptcp_net-next/commit/b01bda9d0fe6
--
Tessares | Belgium | Hybrid Access Solutions
www.tessares.netdiff --cc include/net/sock.h
index 0dd43c3df49b,9fa54762e077..f7ad1a7705e9
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@@ -1541,10 -1521,22 +1541,10 @@@ void __sk_mem_reclaim(struct sock *sk,
#define SK_MEM_SEND 0
#define SK_MEM_RECV 1

-/* sysctl_mem values are in pages, we convert them in SK_MEM_QUANTUM units */
+/* sysctl_mem values are in pages */
static inline long sk_prot_mem_limits(const struct sock *sk, int index)
{
- return sk->sk_prot->sysctl_mem[index];
- long val = READ_ONCE(sk->sk_prot->sysctl_mem[index]);
-
-#if PAGE_SIZE > SK_MEM_QUANTUM
- val <<= PAGE_SHIFT - SK_MEM_QUANTUM_SHIFT;
-#elif PAGE_SIZE < SK_MEM_QUANTUM
- val >>= SK_MEM_QUANTUM_SHIFT - PAGE_SHIFT;
-#endif
- return val;
++ return READ_ONCE(sk->sk_prot->sysctl_mem[index]);
}

static inline int sk_mem_pages(int amt)
\
 
 \ /
  Last update: 2022-07-09 11:13    [W:0.374 / U:0.400 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site