* [PATCH net-next] net: sock: do not set sk_cookie in sk_clone_lock()
@ 2019-01-17 10:01 Yafang Shao
2019-01-17 16:40 ` Eric Dumazet
0 siblings, 1 reply; 3+ messages in thread
From: Yafang Shao @ 2019-01-17 10:01 UTC (permalink / raw)
To: davem, edumazet; +Cc: netdev, shaoyafang, Yafang Shao
The only call site of sk_clone_lock is in inet_csk_clone_lock,
and sk_cookie will be set there.
So we don't need to set sk_cookie in sk_clone_lock().
That can save an atomic operation.
Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
---
net/core/sock.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/net/core/sock.c b/net/core/sock.c
index f00902c..21e2a84 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -1726,7 +1726,6 @@ struct sock *sk_clone_lock(const struct sock *sk, const gfp_t priority)
newsk->sk_err_soft = 0;
newsk->sk_priority = 0;
newsk->sk_incoming_cpu = raw_smp_processor_id();
- atomic64_set(&newsk->sk_cookie, 0);
if (likely(newsk->sk_net_refcnt))
sock_inuse_add(sock_net(newsk), 1);
--
1.8.3.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] net: sock: do not set sk_cookie in sk_clone_lock()
2019-01-17 10:01 [PATCH net-next] net: sock: do not set sk_cookie in sk_clone_lock() Yafang Shao
@ 2019-01-17 16:40 ` Eric Dumazet
2019-01-18 1:57 ` Yafang Shao
0 siblings, 1 reply; 3+ messages in thread
From: Eric Dumazet @ 2019-01-17 16:40 UTC (permalink / raw)
To: Yafang Shao; +Cc: David Miller, netdev, shaoyafang
On Thu, Jan 17, 2019 at 2:02 AM Yafang Shao <laoar.shao@gmail.com> wrote:
>
> The only call site of sk_clone_lock is in inet_csk_clone_lock,
> and sk_cookie will be set there.
> So we don't need to set sk_cookie in sk_clone_lock().
> That can save an atomic operation.
>
Patch is fine, although the wording of ' atomic operation' is a bit misleading.
atomic_set or atomic_read are plain memory writes and reads.
Real ' atomic and expensive' operations are the ones doing RMW
operations (with lock semantic on SMP)
Reviewed-by: Eric Dumazet <edumazet@google.com>
> Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
> ---
> net/core/sock.c | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/net/core/sock.c b/net/core/sock.c
> index f00902c..21e2a84 100644
> --- a/net/core/sock.c
> +++ b/net/core/sock.c
> @@ -1726,7 +1726,6 @@ struct sock *sk_clone_lock(const struct sock *sk, const gfp_t priority)
> newsk->sk_err_soft = 0;
> newsk->sk_priority = 0;
> newsk->sk_incoming_cpu = raw_smp_processor_id();
> - atomic64_set(&newsk->sk_cookie, 0);
> if (likely(newsk->sk_net_refcnt))
> sock_inuse_add(sock_net(newsk), 1);
>
> --
> 1.8.3.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] net: sock: do not set sk_cookie in sk_clone_lock()
2019-01-17 16:40 ` Eric Dumazet
@ 2019-01-18 1:57 ` Yafang Shao
0 siblings, 0 replies; 3+ messages in thread
From: Yafang Shao @ 2019-01-18 1:57 UTC (permalink / raw)
To: Eric Dumazet; +Cc: David Miller, netdev, shaoyafang
On Fri, Jan 18, 2019 at 12:40 AM Eric Dumazet <edumazet@google.com> wrote:
>
> On Thu, Jan 17, 2019 at 2:02 AM Yafang Shao <laoar.shao@gmail.com> wrote:
> >
> > The only call site of sk_clone_lock is in inet_csk_clone_lock,
> > and sk_cookie will be set there.
> > So we don't need to set sk_cookie in sk_clone_lock().
> > That can save an atomic operation.
> >
>
> Patch is fine, although the wording of ' atomic operation' is a bit misleading.
>
> atomic_set or atomic_read are plain memory writes and reads.
>
> Real ' atomic and expensive' operations are the ones doing RMW
> operations (with lock semantic on SMP)
>
> Reviewed-by: Eric Dumazet <edumazet@google.com>
>
Thanks for your correction.
Will change it and send v2.
>
> > Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
> > ---
> > net/core/sock.c | 1 -
> > 1 file changed, 1 deletion(-)
> >
> > diff --git a/net/core/sock.c b/net/core/sock.c
> > index f00902c..21e2a84 100644
> > --- a/net/core/sock.c
> > +++ b/net/core/sock.c
> > @@ -1726,7 +1726,6 @@ struct sock *sk_clone_lock(const struct sock *sk, const gfp_t priority)
> > newsk->sk_err_soft = 0;
> > newsk->sk_priority = 0;
> > newsk->sk_incoming_cpu = raw_smp_processor_id();
> > - atomic64_set(&newsk->sk_cookie, 0);
> > if (likely(newsk->sk_net_refcnt))
> > sock_inuse_add(sock_net(newsk), 1);
> >
> > --
> > 1.8.3.1
> >
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-01-18 1:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-17 10:01 [PATCH net-next] net: sock: do not set sk_cookie in sk_clone_lock() Yafang Shao
2019-01-17 16:40 ` Eric Dumazet
2019-01-18 1:57 ` Yafang Shao
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.