This is an automated email from the ASF dual-hosted git repository. jerpelea pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push: new 5e625b9cdb Performance optimizations in connection allocations. 5e625b9cdb is described below commit 5e625b9cdb347dabce36e9eefa287a335877a164 Author: Fotis Panagiotopoulos <f.pa...@amco.gr> AuthorDate: Tue Feb 28 12:31:21 2023 +0200 Performance optimizations in connection allocations. --- net/bluetooth/bluetooth_conn.c | 6 ++---- net/can/can_conn.c | 5 +---- net/icmp/icmp_conn.c | 5 +---- net/icmpv6/icmpv6_conn.c | 6 ++---- net/ieee802154/ieee802154_conn.c | 5 +---- net/netlink/netlink_conn.c | 5 +---- net/pkt/pkt_conn.c | 5 +---- net/udp/udp_conn.c | 5 +---- net/usrsock/usrsock_conn.c | 2 +- 9 files changed, 11 insertions(+), 33 deletions(-) diff --git a/net/bluetooth/bluetooth_conn.c b/net/bluetooth/bluetooth_conn.c index 9851710d9b..c0b11a5f9d 100644 --- a/net/bluetooth/bluetooth_conn.c +++ b/net/bluetooth/bluetooth_conn.c @@ -205,13 +205,10 @@ void bluetooth_conn_free(FAR struct bluetooth_conn_s *conn) bluetooth_container_free(container); } - /* Reset structure */ - - memset(conn, 0, sizeof(*conn)); - /* If this is a preallocated or a batch allocated connection store it in * the free connections list. Else free it. */ + #if CONFIG_NET_BLUETOOTH_ALLOC_CONNS == 1 if (conn < g_bluetooth_connections || conn >= (g_bluetooth_connections + CONFIG_NET_BLUETOOTH_PREALLOC_CONNS)) @@ -221,6 +218,7 @@ void bluetooth_conn_free(FAR struct bluetooth_conn_s *conn) else #endif { + memset(conn, 0, sizeof(*conn)); dq_addlast(&conn->bc_conn.node, &g_free_bluetooth_connections); } diff --git a/net/can/can_conn.c b/net/can/can_conn.c index 4310bc81bb..28f1a46001 100644 --- a/net/can/can_conn.c +++ b/net/can/can_conn.c @@ -182,10 +182,6 @@ void can_free(FAR struct can_conn_s *conn) dq_rem(&conn->sconn.node, &g_active_can_connections); - /* Reset structure */ - - memset(conn, 0, sizeof(*conn)); - /* If this is a preallocated or a batch allocated connection store it in * the free connections list. Else free it. */ @@ -199,6 +195,7 @@ void can_free(FAR struct can_conn_s *conn) else #endif { + memset(conn, 0, sizeof(*conn)); dq_addlast(&conn->sconn.node, &g_free_can_connections); } diff --git a/net/icmp/icmp_conn.c b/net/icmp/icmp_conn.c index 2ddcc6903d..a727ce7e1e 100644 --- a/net/icmp/icmp_conn.c +++ b/net/icmp/icmp_conn.c @@ -182,10 +182,6 @@ void icmp_free(FAR struct icmp_conn_s *conn) dq_rem(&conn->sconn.node, &g_active_icmp_connections); - /* Clear the connection structure */ - - memset(conn, 0, sizeof(*conn)); - /* If this is a preallocated or a batch allocated connection store it * in the free connections list. Else free it. */ @@ -199,6 +195,7 @@ void icmp_free(FAR struct icmp_conn_s *conn) else #endif { + memset(conn, 0, sizeof(*conn)); dq_addlast(&conn->sconn.node, &g_free_icmp_connections); } } diff --git a/net/icmpv6/icmpv6_conn.c b/net/icmpv6/icmpv6_conn.c index 4299fb62ac..ae5007a2b3 100644 --- a/net/icmpv6/icmpv6_conn.c +++ b/net/icmpv6/icmpv6_conn.c @@ -172,13 +172,10 @@ void icmpv6_free(FAR struct icmpv6_conn_s *conn) dq_rem(&conn->sconn.node, &g_active_icmpv6_connections); - /* Clear the connection structure */ - - memset(conn, 0, sizeof(*conn)); - /* If this is a preallocated or a batch allocated connection store it in * the free connections list. Else free it. */ + #if CONFIG_NET_ICMPv6_ALLOC_CONNS == 1 if (conn < g_icmpv6_connections || conn >= (g_icmpv6_connections + CONFIG_NET_ICMPv6_PREALLOC_CONNS)) @@ -188,6 +185,7 @@ void icmpv6_free(FAR struct icmpv6_conn_s *conn) else #endif { + memset(conn, 0, sizeof(*conn)); dq_addlast(&conn->sconn.node, &g_free_icmpv6_connections); } diff --git a/net/ieee802154/ieee802154_conn.c b/net/ieee802154/ieee802154_conn.c index a6133a100f..b7a5e25f81 100644 --- a/net/ieee802154/ieee802154_conn.c +++ b/net/ieee802154/ieee802154_conn.c @@ -194,10 +194,6 @@ void ieee802154_conn_free(FAR struct ieee802154_conn_s *conn) ieee802154_container_free(container); } - /* Enqueue the connection into the active list */ - - memset(conn, 0, sizeof(*conn)); - /* If this is a preallocated or a batch allocated connection store it in * the free connections list. Else free it. */ @@ -211,6 +207,7 @@ void ieee802154_conn_free(FAR struct ieee802154_conn_s *conn) else #endif { + memset(conn, 0, sizeof(*conn)); dq_addlast(&conn->sconn.node, &g_free_ieee802154_connections); } diff --git a/net/netlink/netlink_conn.c b/net/netlink/netlink_conn.c index 443e004b0b..c31eeaccc9 100644 --- a/net/netlink/netlink_conn.c +++ b/net/netlink/netlink_conn.c @@ -205,10 +205,6 @@ void netlink_free(FAR struct netlink_conn_s *conn) kmm_free(resp); } - /* Reset structure */ - - memset(conn, 0, sizeof(*conn)); - /* If this is a preallocated or a batch allocated connection store it in * the free connections list. Else free it. */ @@ -222,6 +218,7 @@ void netlink_free(FAR struct netlink_conn_s *conn) else #endif { + memset(conn, 0, sizeof(*conn)); dq_addlast(&conn->sconn.node, &g_free_netlink_connections); } diff --git a/net/pkt/pkt_conn.c b/net/pkt/pkt_conn.c index a7663a764e..6693d61571 100644 --- a/net/pkt/pkt_conn.c +++ b/net/pkt/pkt_conn.c @@ -169,10 +169,6 @@ void pkt_free(FAR struct pkt_conn_s *conn) dq_rem(&conn->sconn.node, &g_active_pkt_connections); - /* Make sure that the connection is marked as uninitialized */ - - memset(conn, 0, sizeof(*conn)); - /* If this is a preallocated or a batch allocated connection store it in * the free connections list. Else free it. */ @@ -186,6 +182,7 @@ void pkt_free(FAR struct pkt_conn_s *conn) else #endif { + memset(conn, 0, sizeof(*conn)); dq_addlast(&conn->sconn.node, &g_free_pkt_connections); } diff --git a/net/udp/udp_conn.c b/net/udp/udp_conn.c index 6b3cc628f7..48202cf622 100644 --- a/net/udp/udp_conn.c +++ b/net/udp/udp_conn.c @@ -712,10 +712,6 @@ void udp_free(FAR struct udp_conn_s *conn) #endif - /* Clear the connection structure */ - - memset(conn, 0, sizeof(*conn)); - /* Free the connection. * If this is a preallocated or a batch allocated connection store it in * the free connections list. Else free it. @@ -730,6 +726,7 @@ void udp_free(FAR struct udp_conn_s *conn) else #endif { + memset(conn, 0, sizeof(*conn)); dq_addlast(&conn->sconn.node, &g_free_udp_connections); } diff --git a/net/usrsock/usrsock_conn.c b/net/usrsock/usrsock_conn.c index 675a3ca3f7..c11cf8de95 100644 --- a/net/usrsock/usrsock_conn.c +++ b/net/usrsock/usrsock_conn.c @@ -151,7 +151,6 @@ void usrsock_free(FAR struct usrsock_conn_s *conn) /* Reset structure */ nxsem_destroy(&conn->resp.sem); - memset(conn, 0, sizeof(*conn)); /* If this is a preallocated or a batch allocated connection store it in * the free connections list. Else free it. @@ -166,6 +165,7 @@ void usrsock_free(FAR struct usrsock_conn_s *conn) else #endif { + memset(conn, 0, sizeof(*conn)); dq_addlast(&conn->sconn.node, &g_free_usrsock_connections); }