netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 0/9] bonding: remove bond_next_slave()
@ 2013-09-27 14:11 Veaceslav Falico
  2013-09-27 14:11 ` [PATCH net-next 1/9] bonding: remove __get_next_port() Veaceslav Falico
                   ` (9 more replies)
  0 siblings, 10 replies; 14+ messages in thread
From: Veaceslav Falico @ 2013-09-27 14:11 UTC (permalink / raw)
  To: netdev; +Cc: nikolay, bhutchings, Jay Vosburgh, Andy Gospodarek,
	Veaceslav Falico

(on top of "[PATCH net-next 0/2] bonding: fix 3ad slave (de)init" - the
patchset is essential)

Hi,

As Ben Hutchings and Nikolay Aleksandrov correctly noted -
bond_next_slave() already is not O(1), but rather O(n), so it's only useful
for one-off operations and shouldn't be used widely - for example, for list
traversal, which will take O(n^2) time, which will be disastrous for any
hot path with a large number of slaves.

Currently, bond_next_slave() is used several times in 802.3ad and for
seq_read - bond_info_seq_next().

The 802.3ad part uses it only in constructs like:

for (X = __get_first_X(); X; X = __get_next_X()) {

where __get_next_X() uses bond_next_slave().

This for can (and should) actually be replaced by the standard

bond_for_each_slave(bond, slave, iter) {
	X = __get_X_by_slave(slave);

it's faster, easier to read, debug and maintain. Also, removes a lot of
code lines.

After replacing it, the only user of bond_next_slave() is
bond_info_seq_next() - which can, actually, implement it by itself, and not
call another function.

So, that way, we can completely remove the bond_next_slave(), cleanup and
optimize a bit.

p.s. the 802.3ad code is horrible, both style-wise and from the logical
point of view - so I've decided to *not* change anything except that what
this patch is intended to provide. The cleanup and some refactoring should
be done in another patchset, which I've began to work on already.

Thank you!

CC: Jay Vosburgh <fubar@us.ibm.com>
CC: Andy Gospodarek <andy@greyhouse.net>
Signed-off-by: Veaceslav Falico <vfalico@redhat.com>

---
 drivers/net/bonding/bond_3ad.c    | 137 ++++++++++++++------------------------
 drivers/net/bonding/bond_main.c   |   2 +-
 drivers/net/bonding/bond_procfs.c |  16 +++--
 drivers/net/bonding/bonding.h     |  31 ---------
 4 files changed, 62 insertions(+), 124 deletions(-)

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2013-09-28 22:22 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-27 14:11 [PATCH net-next 0/9] bonding: remove bond_next_slave() Veaceslav Falico
2013-09-27 14:11 ` [PATCH net-next 1/9] bonding: remove __get_next_port() Veaceslav Falico
2013-09-27 14:11 ` [PATCH net-next 2/9] bonding: remove __get_first_port() Veaceslav Falico
2013-09-27 14:50   ` David Laight
2013-09-27 14:58     ` Veaceslav Falico
2013-09-27 15:05       ` Veaceslav Falico
2013-09-27 14:11 ` [PATCH net-next 3/9] bonding: make ad_port_selection_logic() use bond_for_each_slave() Veaceslav Falico
2013-09-27 14:12 ` [PATCH net-next 4/9] bonding: make __get_active_agg() " Veaceslav Falico
2013-09-27 14:12 ` [PATCH net-next 5/9] bonding: make ad_agg_selection_logic() " Veaceslav Falico
2013-09-27 14:12 ` [PATCH net-next 6/9] bonding: make bond_3ad_unbind_slave() " Veaceslav Falico
2013-09-27 14:12 ` [PATCH net-next 7/9] bonding: remove unused __get_next_agg() Veaceslav Falico
2013-09-27 14:12 ` [PATCH net-next 8/9] bonding: don't use bond_next_slave() in bond_info_seq_next() Veaceslav Falico
2013-09-27 14:12 ` [PATCH net-next 9/9] bonding: remove bond_next_slave() Veaceslav Falico
2013-09-28 22:29 ` [PATCH net-next 0/9] " David Miller

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).