From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 77AEC5A026D for ; Sun, 7 Jan 2024 05:28:56 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202312; t=1704601731; bh=ECrp7Wp0NeMq/vuQ2HuVgRs+g5dfznk5pGJo/ELp3WE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=kSSg4rkvd9HrKgmeOXHJyIpL8q7qJ4sX6pOHi9Qmpbf2l3deWVJPF2lWacI2H4tCq EiwvmgrS6ALXRKu5LUlluEvAegjNLmAbilByrSDWuEOmEIJyAAm4Ypna5IYUuvFWSj ztExgDN6lmcCE5AkSjhVaA8rZOcjJYZq4NOwfsudx6ftHi6JtScGJpeb9+J6UdFEml 4o9aCMLixGw6gq6ETePQxelCa/DON3iwjZklmh6gOJrhVg9KtVUXEsAgn+7S4ISiNy kW2aXliA7oETq6QRgjhqZ8j50VtZY+FTVOIAE/SC7vTqBDcNm4/3cj2e5tQa8cu7Od KkePyyW9n3dlw== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4T742W5m2Yz4wd5; Sun, 7 Jan 2024 15:28:51 +1100 (AEDT) Date: Sun, 7 Jan 2024 11:41:12 +1100 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH v2 07/12] icmp: Simplify socket expiry scanning Message-ID: References: <20231221065327.1307827-1-david@gibson.dropbear.id.au> <20231221065327.1307827-8-david@gibson.dropbear.id.au> <20240106165953.639cb7aa@elisabeth> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="eF/AwWCEqI/hSoEh" Content-Disposition: inline In-Reply-To: <20240106165953.639cb7aa@elisabeth> Message-ID-Hash: DIYRVLQQF5ESKR4RILMORQ5M3GFV544I X-Message-ID-Hash: DIYRVLQQF5ESKR4RILMORQ5M3GFV544I X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: passt-dev@passt.top X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: --eF/AwWCEqI/hSoEh Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Jan 06, 2024 at 04:59:53PM +0100, Stefano Brivio wrote: > On Thu, 21 Dec 2023 17:53:22 +1100 > David Gibson wrote: >=20 > > Currently we use icmp_act[] to scan for ICMP ids which might have an op= en > > socket which could time out. However icmp_act[] contains no information > > that's not already in icmp_id_map[] - it's just an "index" which allows > > scanning for relevant entries with less cache footprint. > >=20 > > We only scan for ICMP socket expiry every 1s, though, so it's not clear > > that cache footprint really matters. Furthermore, there's no strong re= ason > > we need to scan even that often - the timeout is fairly arbitrary and > > approximate. > >=20 > > So, eliminate icmp_act[] in favour of directly scanning icmp_id_map[] a= nd > > compensate for the cache impact by reducing the scan frequency to once > > every 10s. > >=20 > > Signed-off-by: David Gibson > > --- > > icmp.c | 34 ++++++---------------------------- > > icmp.h | 2 +- > > 2 files changed, 7 insertions(+), 29 deletions(-) > >=20 > > diff --git a/icmp.c b/icmp.c > > index dd98c7f..02739b9 100644 > > --- a/icmp.c > > +++ b/icmp.c > > @@ -56,9 +56,6 @@ struct icmp_id_sock { > > /* Indexed by ICMP echo identifier */ > > static struct icmp_id_sock icmp_id_map[IP_VERSIONS][ICMP_NUM_IDS]; > > =20 > > -/* Bitmaps, activity monitoring needed for identifier */ > > -static uint8_t icmp_act[IP_VERSIONS][DIV_ROUND_UP(ICMP_NUM_IDS, 8)]; > > - > > /** > > * icmp_sock_handler() - Handle new data from IPv4 ICMP socket > > * @c: Execution context > > @@ -194,7 +191,6 @@ int icmp_tap_handler(const struct ctx *c, uint8_t p= if, int af, > > debug("ICMP: new socket %i for echo ID %i", s, id); > > } > > icmp_id_map[V4][id].ts =3D now->tv_sec; > > - bitmap_set(icmp_act[V4], id); > > =20 > > sa.sin_addr =3D *(struct in_addr *)daddr; > > if (sendto(s, ih, sizeof(*ih) + plen, MSG_NOSIGNAL, > > @@ -237,7 +233,6 @@ int icmp_tap_handler(const struct ctx *c, uint8_t p= if, int af, > > debug("ICMPv6: new socket %i for echo ID %i", s, id); > > } > > icmp_id_map[V6][id].ts =3D now->tv_sec; > > - bitmap_set(icmp_act[V6], id); > > =20 > > sa.sin6_addr =3D *(struct in6_addr *)daddr; > > if (sendto(s, ih, sizeof(*ih) + plen, MSG_NOSIGNAL, > > @@ -261,20 +256,15 @@ fail_sock: > > /** > > * icmp_timer_one() - Handler for timed events related to a given iden= tifier > > * @c: Execution context > > - * @v6: Set for IPv6 echo identifier bindings > > - * @id: Echo identifier, host order > > + * @id_map: id socket information to check timers for >=20 > It took me a few readings to understand this... what about: >=20 > * @id_sock: Socket number and activity timestamp >=20 > ? Works for me. Updated. --=20 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --eF/AwWCEqI/hSoEh Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmWZ8xkACgkQzQJF27ox 2GcHpg/9GaeU4NInPm5j7gxbK6sIcw6j2fV6ZAulfmJ3V97INulIyocOxeEGXcvO SlHJpxwBPYb3omInIjYjIZzLplNI/lIZKEkT6HyCevQIR3Zo/DNyPR79A96f3nLE iewYMqb0qAgmm66jUVnfTOJodTdMM0SPVbxmqrM/Ygkc+N4fnBuvciIWZS3k8nGr Kr6vPlinLnT87iVMRkoOvduNM6NTOru7ml1MdCXTLloMm2jGE054nJ+KdJBn+ArT wPP5S3iST08ntYtclw+iOb4S/tPSA1B54eXwIDz+qkCWAjtKOwKFerMomWPfs7gz RSqpv3LCECq6jB1h/BZYDLTw5sCUMlE3qq7pPt/tVVKRamZlXU5wNfTDj+OQTJZA uyvvl7WhlSs8NndhDeU6kYiI5ELtqThmWqwLdLopoTD9I1/eTOGGHkwyTFtmE+Nr GcCAzj6AeBT+Y6aDlG+6dUBLQHHqVeEMhoK+890PRzFuAmAEiezAg9NhvSmF9n5V grurEZy7V2V4DbztQXRSER5SwKkySEzVntr4vgMm5P2DLX3q1HuDjzUwc6T+TFmD ULG28tZt1qN/iolm87ScMR4AwQ/jWT86TxcKAEBKb+ncDsCDfMLRSCDlCm/2vdmu eEhb301iUXp4doAGJAStVekYd103H0VpAqgKRudQitxJJ2BWhRg= =S7SP -----END PGP SIGNATURE----- --eF/AwWCEqI/hSoEh--