public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Toshiaki Makita <makita.toshiaki@lab•ntt.co.jp>
To: Simon Horman <simon.horman@netronome•com>
Cc: Scott Feldman <sfeldma@gmail•com>, Jiri Pirko <jiri@resnulli•us>,
	David Miller <davem@davemloft•net>,
	netdev@vger•kernel.org
Subject: Re: [PATCH v3 net-next 3/4] rocker: do not make neighbour entry changes when preparing transactions
Date: Wed, 20 May 2015 17:36:06 +0900	[thread overview]
Message-ID: <555C4776.70508@lab.ntt.co.jp> (raw)
In-Reply-To: <20150520074810.GA21934@vergenet.net>

On 2015/05/20 16:48, Simon Horman wrote:
> On Wed, May 20, 2015 at 03:15:23PM +0900, Toshiaki Makita wrote:
>> On 2015/05/20 14:48, Simon Horman wrote:
...
>>>  static void _rocker_neigh_add(struct rocker *rocker,
>>> +			      enum switchdev_trans trans,
>>>  			      struct rocker_neigh_tbl_entry *entry)
>>>  {
>>> +	if (trans == SWITCHDEV_TRANS_PREPARE)
>>> +		return;
>>>  	entry->index = rocker->neigh_tbl_next_index++;
>>
>> Isn't index needed here? It looks to be used in later function call and
>> logging.
> 
> Thanks, that does not follow the usual model of setting values
> during the PREPARE (and all other) transaction phase(s).
> 
>> How about setting index like this?
>>
>> 	entry->index = rocker->neigh_tbl_next_index;
>> 	if (trans == PREPARE)
>> 		return;
>> 	rocker->neigh_tbl_next_index++;
>> 	...
> 
> I am concerned that _rocker_neigh_add() may be called by some other
> caller while a transaction is in process and thus entry->index will
> be inconsistent across callers.
> 
> Perhaps we can convince ourselves that all the bases are covered.
> So far my testing has drawn a blank. But the logic seems difficult to
> reason about.
> 
> As we are basically allocating an index I suppose what is really needed for
> a correct implementation is a transaction aware index allocator, like we
> have for memory (rocker_port_kzalloc etc...).  But that does seem like
> overkill.
> 
> I think that we can make entry->index consistent across
> calls in the same transaction at the expense of breaking the
> rule that per-transaction data should be set during all transaction phases.
> 
> Something like this:
> 
> 
> 	if (trans != SWITCHDEV_TRANS_COMMIT)
> 		/* Avoid index being set to different values across calls
> 		 * to this function by the same caller within the same
> 		 * transaction.
> 		 */
> 		entry->index = rocker->neigh_tbl_next_index++;
> 	if (trans == SWITCHDEV_TRANS_PREPARE)
> 		return;
> 
> 

As long as it is guraded by rtnl lock, no worries about this race?  It
seems to be assumed that prepare-commit is guarded by rtnl lock,
according to commit c4f20321 ("rocker: support prepare-commit
transaction model").

But as you are concerned, it seems to be able to be called by another
caller, specifically, neigh_timer_handler() in interrupt context without
rtnl lock. IMHO, it should be fixed rather than avoiding the race here.

Thanks,
Toshiaki Makita

  reply	other threads:[~2015-05-20  8:36 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-20  5:48 [PATCH v3 net-next 0/4] rocker: transaction fixes Simon Horman
2015-05-20  5:48 ` [PATCH v3 net-next 1/4] rocker: do not delete fdb entries in rocker_port_fdb_flush() when preparing transactions Simon Horman
2015-05-20  6:01   ` Jiri Pirko
2015-05-20  5:48 ` [PATCH v3 net-next 2/4] rocker: do not modify fdb table in rocker_port_fdb() " Simon Horman
2015-05-20  6:01   ` Jiri Pirko
2015-05-20  5:48 ` [PATCH v3 net-next 3/4] rocker: do not make neighbour entry changes " Simon Horman
2015-05-20  6:01   ` Jiri Pirko
2015-05-20  6:15   ` Toshiaki Makita
2015-05-20  7:48     ` Simon Horman
2015-05-20  8:36       ` Toshiaki Makita [this message]
2015-05-20  8:46         ` Simon Horman
2015-05-20 11:17           ` Jiri Pirko
2015-05-20 12:57             ` Simon Horman
2015-05-20 17:37               ` Scott Feldman
2015-05-20 22:32                 ` Simon Horman
2015-05-20 23:59                   ` Scott Feldman
2015-05-20  5:48 ` [PATCH v3 net-next 4/4] rocker: make rocker_port_internal_vlan_id_{get,put}() non-transactional Simon Horman
2015-05-20  6:02   ` Jiri Pirko

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=555C4776.70508@lab.ntt.co.jp \
    --to=makita.toshiaki@lab$(echo .)ntt.co.jp \
    --cc=davem@davemloft$(echo .)net \
    --cc=jiri@resnulli$(echo .)us \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=sfeldma@gmail$(echo .)com \
    --cc=simon.horman@netronome$(echo .)com \
    /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