Commit 2a80d892 authored by David S. Miller's avatar David S. Miller
Browse files

Merge branch 'net-improve-multicast-group-join-performance'



Jonas Rebmann says:

====================
improve multicast join group performance

This series seeks to improve performance on updating igmp group
memberships such as with IP_ADD_MEMBERSHIP or MCAST_JOIN_SOURCE_GROUP.

Our use case was to add 2000 multicast memberships on a TQMLS1046A which
took about 3.6 seconds for the membership additions alone. Our userspace
reproducer tool was instrumented to log runtimes of the individual
setsockopt invocations which clearly indicated quadratic complexity of
setting up the membership with regard to the total number of multicast
groups to be joined. We used perf to locate the hotspots and
subsequently optimized the most costly sections of code.

This series includes a patch to Linux igmp handling as well as a patch
to the DPAA/Freescale driver. With both patches applied, our memberships can
be set up in only about 87 miliseconds, which corresponds to a speedup
of around 40.

While we have acheived practically linear run-time complexity on the
kernel side, a small quadratic factor remains in parts of the freescale
driver code which we haven't yet optimized. We have by now payed little
attention to the optimization potential in dropping group memberships,
yet the dpaa patch applies to joining and leaving groups alike.

Overall, this patch series brings great improvements in use cases
involving large numbers of multicast groups, particularly when using the
fsl_dpa driver, without noteworthy drawbacks in other scenarios.
====================

Signed-off-by: default avatarJonas Rebmann <jre@pengutronix.de>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 20503272 298f70b3
Loading
Loading
Loading
Loading
+18 −2
Original line number Diff line number Diff line
@@ -463,6 +463,22 @@ static int dpaa_set_mac_address(struct net_device *net_dev, void *addr)
	return 0;
}

static int dpaa_addr_sync(struct net_device *net_dev, const u8 *addr)
{
	const struct dpaa_priv *priv = netdev_priv(net_dev);

	return priv->mac_dev->add_hash_mac_addr(priv->mac_dev->fman_mac,
						(enet_addr_t *)addr);
}

static int dpaa_addr_unsync(struct net_device *net_dev, const u8 *addr)
{
	const struct dpaa_priv *priv = netdev_priv(net_dev);

	return priv->mac_dev->remove_hash_mac_addr(priv->mac_dev->fman_mac,
						   (enet_addr_t *)addr);
}

static void dpaa_set_rx_mode(struct net_device *net_dev)
{
	const struct dpaa_priv	*priv;
@@ -490,9 +506,9 @@ static void dpaa_set_rx_mode(struct net_device *net_dev)
				  err);
	}

	err = priv->mac_dev->set_multi(net_dev, priv->mac_dev);
	err = __dev_mc_sync(net_dev, dpaa_addr_sync, dpaa_addr_unsync);
	if (err < 0)
		netif_err(priv, drv, net_dev, "mac_dev->set_multi() = %d\n",
		netif_err(priv, drv, net_dev, "dpaa_addr_sync() = %d\n",
			  err);
}

+0 −1
Original line number Diff line number Diff line
@@ -1415,7 +1415,6 @@ int dtsec_initialization(struct mac_device *mac_dev,
	mac_dev->set_exception		= dtsec_set_exception;
	mac_dev->set_allmulti		= dtsec_set_allmulti;
	mac_dev->set_tstamp		= dtsec_set_tstamp;
	mac_dev->set_multi		= fman_set_multi;
	mac_dev->enable			= dtsec_enable;
	mac_dev->disable		= dtsec_disable;

+0 −1
Original line number Diff line number Diff line
@@ -1087,7 +1087,6 @@ int memac_initialization(struct mac_device *mac_dev,
	mac_dev->set_exception		= memac_set_exception;
	mac_dev->set_allmulti		= memac_set_allmulti;
	mac_dev->set_tstamp		= memac_set_tstamp;
	mac_dev->set_multi		= fman_set_multi;
	mac_dev->enable			= memac_enable;
	mac_dev->disable		= memac_disable;

+0 −1
Original line number Diff line number Diff line
@@ -771,7 +771,6 @@ int tgec_initialization(struct mac_device *mac_dev,
	mac_dev->set_exception		= tgec_set_exception;
	mac_dev->set_allmulti		= tgec_set_allmulti;
	mac_dev->set_tstamp		= tgec_set_tstamp;
	mac_dev->set_multi		= fman_set_multi;
	mac_dev->enable			= tgec_enable;
	mac_dev->disable		= tgec_disable;

+0 −42
Original line number Diff line number Diff line
@@ -32,8 +32,6 @@ MODULE_DESCRIPTION("FSL FMan MAC API based driver");
struct mac_priv_s {
	u8				cell_index;
	struct fman			*fman;
	/* List of multicast addresses */
	struct list_head		mc_addr_list;
	struct platform_device		*eth_dev;
	u16				speed;
};
@@ -57,44 +55,6 @@ static void mac_exception(struct mac_device *mac_dev,
		__func__, ex);
}

int fman_set_multi(struct net_device *net_dev, struct mac_device *mac_dev)
{
	struct mac_priv_s	*priv;
	struct mac_address	*old_addr, *tmp;
	struct netdev_hw_addr	*ha;
	int			err;
	enet_addr_t		*addr;

	priv = mac_dev->priv;

	/* Clear previous address list */
	list_for_each_entry_safe(old_addr, tmp, &priv->mc_addr_list, list) {
		addr = (enet_addr_t *)old_addr->addr;
		err = mac_dev->remove_hash_mac_addr(mac_dev->fman_mac, addr);
		if (err < 0)
			return err;

		list_del(&old_addr->list);
		kfree(old_addr);
	}

	/* Add all the addresses from the new list */
	netdev_for_each_mc_addr(ha, net_dev) {
		addr = (enet_addr_t *)ha->addr;
		err = mac_dev->add_hash_mac_addr(mac_dev->fman_mac, addr);
		if (err < 0)
			return err;

		tmp = kmalloc(sizeof(*tmp), GFP_ATOMIC);
		if (!tmp)
			return -ENOMEM;

		ether_addr_copy(tmp->addr, ha->addr);
		list_add(&tmp->list, &priv->mc_addr_list);
	}
	return 0;
}

static DEFINE_MUTEX(eth_lock);

static struct platform_device *dpaa_eth_add_device(int fman_id,
@@ -181,8 +141,6 @@ static int mac_probe(struct platform_device *_of_dev)
	mac_dev->priv = priv;
	mac_dev->dev = dev;

	INIT_LIST_HEAD(&priv->mc_addr_list);

	/* Get the FM node */
	dev_node = of_get_parent(mac_node);
	if (!dev_node) {
Loading