net/tls: unref frags in order
authorJakub Kicinski <jakub.kicinski@netronome.com>
Sat, 7 Sep 2019 05:29:57 +0000 (22:29 -0700)
committerDavid S. Miller <davem@davemloft.net>
Sat, 7 Sep 2019 16:10:34 +0000 (18:10 +0200)
It's generally more cache friendly to walk arrays in order,
especially those which are likely not in cache.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Dirk van der Merwe <dirk.vandermerwe@netronome.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/tls/tls_device.c

index 41c106e45f0170857e96b3838601ae1e95d24811..285c9f9e94e4ce20e7cd84896b2ed3276733d96b 100644 (file)
@@ -122,13 +122,10 @@ static struct net_device *get_netdev_for_sock(struct sock *sk)
 
 static void destroy_record(struct tls_record_info *record)
 {
-       int nr_frags = record->num_frags;
-       skb_frag_t *frag;
+       int i;
 
-       while (nr_frags-- > 0) {
-               frag = &record->frags[nr_frags];
-               __skb_frag_unref(frag);
-       }
+       for (i = 0; i < record->num_frags; i++)
+               __skb_frag_unref(&record->frags[i]);
        kfree(record);
 }