lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20120911112237.13852.1095.stgit@srivatsabhat.in.ibm.com>
Date:	Tue, 11 Sep 2012 16:52:37 +0530
From:	"Srivatsa S. Bhat" <srivatsa.bhat@...ux.vnet.ibm.com>
To:	davem@...emloft.net, nhorman@...driver.com
Cc:	john.r.fastabend@...el.com, gaofeng@...fujitsu.com,
	eric.dumazet@...il.com, mark.d.rustad@...el.com,
	lizefan@...wei.com, netdev@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	"Srivatsa S. Bhat" <srivatsa.bhat@...ux.vnet.ibm.com>
Subject: [PATCH 2/2] netprio_cgroup: Optimize the priomap copy loop slightly

* Check for non-NULL old_priomap outside the loop, since its
  not going to change.
* Copy the old_priomap's length to a local variable and use
  that for loop control, instead of costly pointer-dereferences.

Signed-off-by: Srivatsa S. Bhat <srivatsa.bhat@...ux.vnet.ibm.com>
---

 net/core/netprio_cgroup.c |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/net/core/netprio_cgroup.c b/net/core/netprio_cgroup.c
index fd339bb0..0775bc9 100644
--- a/net/core/netprio_cgroup.c
+++ b/net/core/netprio_cgroup.c
@@ -73,7 +73,7 @@ static int extend_netdev_table(struct net_device *dev, u32 new_len)
 			   ((sizeof(u32) * new_len));
 	struct netprio_map *new_priomap = kzalloc(new_size, GFP_KERNEL);
 	struct netprio_map *old_priomap;
-	int i;
+	int i, old_len;
 
 	old_priomap  = rtnl_dereference(dev->priomap);
 
@@ -82,10 +82,12 @@ static int extend_netdev_table(struct net_device *dev, u32 new_len)
 		return -ENOMEM;
 	}
 
-	for (i = 0;
-	     old_priomap && (i < old_priomap->priomap_len);
-	     i++)
-		new_priomap->priomap[i] = old_priomap->priomap[i];
+	if (old_priomap) {
+		old_len = old_priomap->priomap_len;
+
+		for (i = 0; i < old_len; i++)
+			new_priomap->priomap[i] = old_priomap->priomap[i];
+	}
 
 	new_priomap->priomap_len = new_len;
 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ