Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

rocker: Avoid unnecessary scheduling of work item

The work item function ofdpa_port_fdb_learn_work() does not do anything
when 'OFDPA_OP_FLAG_LEARNED' is not set in the work item's flags.

Therefore, do not allocate and do not schedule the work item when the
flag is not set.

Suggested-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Ido Schimmel and committed by
Jakub Kicinski
42e51de9 3319dbb3

+7 -7
+7 -7
drivers/net/ethernet/rocker/rocker_ofdpa.c
··· 1821 1821 const struct ofdpa_fdb_learn_work *lw = 1822 1822 container_of(work, struct ofdpa_fdb_learn_work, work); 1823 1823 bool removing = (lw->flags & OFDPA_OP_FLAG_REMOVE); 1824 - bool learned = (lw->flags & OFDPA_OP_FLAG_LEARNED); 1825 1824 struct switchdev_notifier_fdb_info info = {}; 1825 + enum switchdev_notifier_type event; 1826 1826 1827 1827 info.addr = lw->addr; 1828 1828 info.vid = lw->vid; 1829 + event = removing ? SWITCHDEV_FDB_DEL_TO_BRIDGE : 1830 + SWITCHDEV_FDB_ADD_TO_BRIDGE; 1829 1831 1830 1832 rtnl_lock(); 1831 - if (learned && removing) 1832 - call_switchdev_notifiers(SWITCHDEV_FDB_DEL_TO_BRIDGE, 1833 - lw->ofdpa_port->dev, &info.info, NULL); 1834 - else if (learned && !removing) 1835 - call_switchdev_notifiers(SWITCHDEV_FDB_ADD_TO_BRIDGE, 1836 - lw->ofdpa_port->dev, &info.info, NULL); 1833 + call_switchdev_notifiers(event, lw->ofdpa_port->dev, &info.info, NULL); 1837 1834 rtnl_unlock(); 1838 1835 1839 1836 kfree(work); ··· 1860 1863 } 1861 1864 1862 1865 if (!ofdpa_port_is_bridged(ofdpa_port)) 1866 + return 0; 1867 + 1868 + if (!(flags & OFDPA_OP_FLAG_LEARNED)) 1863 1869 return 0; 1864 1870 1865 1871 lw = kzalloc(sizeof(*lw), GFP_ATOMIC);