public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Subash Abhinov Kasiviswanathan <subashab@codeaurora•org>
To: David Miller <davem@davemloft•net>
Cc: netdev@vger•kernel.org, fengguang.wu@intel•com, dcbw@redhat•com,
	jiri@resnulli•us, stephen@networkplumber•org,
	David.Laight@aculab•com, marcel@holtmann•org, andrew@lunn•ch
Subject: Re: [PATCH net-next 3/3 v9] drivers: net: ethernet: qualcomm: rmnet: Initial implementation
Date: Mon, 28 Aug 2017 11:40:39 -0600	[thread overview]
Message-ID: <86de09154bfe0b4e13ac5fcc9090389a@codeaurora.org> (raw)
In-Reply-To: <20170825.200623.1467784779129980276.davem@davemloft.net>

> 
> In these code paths where you are the writer, you have to rely upon
> the RTNL mutex (or some other mutual exclusion mechanism) to protect
> the update operation.  RCU locking itself does not provide this.
> 
> So you should use something like rcu_dereference_rtnl() or similar.
> 
> So this would be rmnet_force_unassociate_device() and rmnet_dellink()
> 
> RCU is subtle and the writer paths have the be handled differently
> from the reader paths.  Please take some time to study how RCU should
> be applied properly in these situations rather than just slapping a
> patch together overnight.
> 
> Thank you.

Sorry about the mess David.

Can you tell me if the following design is correct -

The shared resource which needs to be protected is 
real_dev->rx_handler_data.

For the writer path, this needs to be protected using rtnl_lock() and 
rcu.
The writer paths are rmnet_newlink(), rmnet_delink() and
rmnet_force_unassociate_device(). These paths are already called with
rtnl_lock() acquired in, so we just need to acquire the rcu_read_lock(). 
To
dereference here, we will need to use rtnl_dereference().

For the reader path, the real_dev->rx_handler_data is called in the TX / 
RX
path. We only need rcu_read_lock() for these scenarios. In these cases,
the rcu_read_lock() is held in __dev_queue_xmit() and
netif_receive_skb_internal(), so readers need to use 
rcu_dereference_rtnl()
to get the relevant information.

      reply	other threads:[~2017-08-28 17:40 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-25  4:39 [PATCH net-next 0/3 v9] Add support for rmnet driver Subash Abhinov Kasiviswanathan
2017-08-25  4:39 ` [PATCH net-next 1/3 v9] net: ether: Add support for multiplexing and aggregation type Subash Abhinov Kasiviswanathan
2017-08-28 22:22   ` Dan Williams
2017-08-29  3:00     ` Subash Abhinov Kasiviswanathan
2017-08-25  4:39 ` [PATCH net-next 2/3 v9] net: arp: Add support for raw IP device Subash Abhinov Kasiviswanathan
2017-08-25  4:39 ` [PATCH net-next 3/3 v9] drivers: net: ethernet: qualcomm: rmnet: Initial implementation Subash Abhinov Kasiviswanathan
2017-08-26  3:06   ` David Miller
2017-08-28 17:40     ` Subash Abhinov Kasiviswanathan [this message]

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=86de09154bfe0b4e13ac5fcc9090389a@codeaurora.org \
    --to=subashab@codeaurora$(echo .)org \
    --cc=David.Laight@aculab$(echo .)com \
    --cc=andrew@lunn$(echo .)ch \
    --cc=davem@davemloft$(echo .)net \
    --cc=dcbw@redhat$(echo .)com \
    --cc=fengguang.wu@intel$(echo .)com \
    --cc=jiri@resnulli$(echo .)us \
    --cc=marcel@holtmann$(echo .)org \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=stephen@networkplumber$(echo .)org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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