From: Jason Wang <jasowang@redhat.com>
To: Eric Dumazet <edumazet@google.com>,
"David S . Miller" <davem@davemloft.net>
Cc: netdev <netdev@vger.kernel.org>,
Eric Dumazet <eric.dumazet@gmail.com>,
Jakub Kicinski <jakub.kicinski@netronome.com>,
Zhang Yu <zhangyu31@baidu.com>, Wang Li <wangli39@baidu.com>,
Li RongQing <lirongqing@baidu.com>
Subject: Re: [PATCH net] tun: remove possible false sharing in tun_flow_update()
Date: Thu, 10 Oct 2019 11:59:29 +0800 [thread overview]
Message-ID: <7c390fda-f892-9c44-3976-60d1d3035ebb@redhat.com> (raw)
In-Reply-To: <20191009162002.19360-1-edumazet@google.com>
On 2019/10/10 上午12:20, Eric Dumazet wrote:
> As mentioned in https://github.com/google/ktsan/wiki/READ_ONCE-and-WRITE_ONCE#it-may-improve-performance
> a C compiler can legally transform
>
> if (e->queue_index != queue_index)
> e->queue_index = queue_index;
>
> to :
>
> e->queue_index = queue_index;
>
> Note that the code using jiffies has no issue, since jiffies
> has volatile attribute.
>
> if (e->updated != jiffies)
> e->updated = jiffies;
>
> Fixes: 83b1bc122cab ("tun: align write-heavy flow entry members to a cache line")
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Cc: Zhang Yu <zhangyu31@baidu.com>
> Cc: Wang Li <wangli39@baidu.com>
> Cc: Li RongQing <lirongqing@baidu.com>
> Cc: Jason Wang <jasowang@redhat.com>
> ---
> drivers/net/tun.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/tun.c b/drivers/net/tun.c
> index 812dc3a65efbb9d1ee2724e73978dbc4803ec171..a8d3141582a53caf407dc9aff61c452998de068f 100644
> --- a/drivers/net/tun.c
> +++ b/drivers/net/tun.c
> @@ -526,8 +526,8 @@ static void tun_flow_update(struct tun_struct *tun, u32 rxhash,
> e = tun_flow_find(head, rxhash);
> if (likely(e)) {
> /* TODO: keep queueing to old queue until it's empty? */
> - if (e->queue_index != queue_index)
> - e->queue_index = queue_index;
> + if (READ_ONCE(e->queue_index) != queue_index)
> + WRITE_ONCE(e->queue_index, queue_index);
> if (e->updated != jiffies)
> e->updated = jiffies;
> sock_rps_record_flow_hash(e->rps_rxhash);
Acked-by: Jason Wang <jasowang@redhat.com>
next prev parent reply other threads:[~2019-10-10 3:59 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-09 16:20 [PATCH net] tun: remove possible false sharing in tun_flow_update() Eric Dumazet
2019-10-10 3:59 ` Jason Wang [this message]
2019-10-10 4:29 ` Jakub Kicinski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7c390fda-f892-9c44-3976-60d1d3035ebb@redhat.com \
--to=jasowang@redhat.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=eric.dumazet@gmail.com \
--cc=jakub.kicinski@netronome.com \
--cc=lirongqing@baidu.com \
--cc=netdev@vger.kernel.org \
--cc=wangli39@baidu.com \
--cc=zhangyu31@baidu.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).