From owner-freebsd-net@FreeBSD.ORG Thu Mar 3 23:25:01 2005 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 19E2616A4CE; Thu, 3 Mar 2005 23:25:01 +0000 (GMT) Received: from darkness.comp.waw.pl (darkness.comp.waw.pl [195.117.238.136]) by mx1.FreeBSD.org (Postfix) with ESMTP id 931F643D2F; Thu, 3 Mar 2005 23:25:00 +0000 (GMT) (envelope-from pjd@darkness.comp.waw.pl) Received: by darkness.comp.waw.pl (Postfix, from userid 1009) id 76585AC956; Fri, 4 Mar 2005 00:24:58 +0100 (CET) Date: Fri, 4 Mar 2005 00:24:58 +0100 From: Pawel Jakub Dawidek To: Luigi Rizzo Message-ID: <20050303232458.GO9291@darkness.comp.waw.pl> References: <20050217161031.A46700@xorpc.icir.org> <200503011642.48813.jhb@FreeBSD.org> <20050301162949.A64187@xorpc.icir.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="QKFUq+IbM9AW97yF" Content-Disposition: inline In-Reply-To: <20050301162949.A64187@xorpc.icir.org> User-Agent: Mutt/1.4.2i X-PGP-Key-URL: http://people.freebsd.org/~pjd/pjd.asc X-OS: FreeBSD 5.2.1-RC2 i386 cc: dima <_pppp@mail.ru> cc: John Baldwin cc: net@FreeBSD.org Subject: Re: Giant-free polling [PATCH] X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Mar 2005 23:25:01 -0000 --QKFUq+IbM9AW97yF Content-Type: text/plain; charset=iso-8859-2 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Mar 01, 2005 at 04:29:49PM -0800, Luigi Rizzo wrote: +> [cc-ing net@freebsd.org to get more opinions] +>=20 +> On Tue, Mar 01, 2005 at 04:42:48PM -0500, John Baldwin wrote: +> > On Thursday 17 February 2005 07:10 pm, Luigi Rizzo wrote: +> > > i am no expert about the locking but i see places where +> > > you grab polling_lock followed by ifnet_lock, and others where +> > > you use the opposite order. This seems prone to deadlock... +> >=20 +> > Yes, it basically seems that the polling_lock should be removed and ju= st the=20 +> > ifnet_lock used because the the ifnet_lock is already always held when= the=20 +> > polling_lock is locked. Yeah, but we cannot grap ifnet_lock in polling code, because this is internal mutex, not visible from outside. I was thinking about moving ifnet_lock into ifnet structure... +> this said, if the lock requests are blocking, you basically end +> up with the polling loops always contending for the locks, with only one +> doing actual work and the other one always busy-waiting. +>=20 +> Assuming the primitive exists, I think the correct way to implement +> SMP polling is to use non-blocking locks, something like this +> (in pseudocode) +>=20 +> poll_loop() { +> have_polling_lock =3D try_get_lock(polling_lock) +> foreach(ifp in polled_interfaces) { +> if (have_polling_lock) +> have_ifp_lock =3D get_lock(ifp) // returns true +> else +> have_ifp_lock =3D try_get_lock(ifp) +> if (have_ifp_lock) { +> ifp->poll(); +> release_lock(ifp) +> } +> } +> if (have_polling_lock) +> release_lock(polling_lock); +> } +>=20 +> so additional polling processes after the first one will not +> block on busy interfaces and move forward instead. +> This should remove a bit of contention, and let separate processes actua= lly +> work on different interfaces. I think we should just implement per-interface idlepoll threads, so we can run polling code on many CPUs for many interfaces. --=20 Pawel Jakub Dawidek http://www.wheel.pl pjd@FreeBSD.org http://www.FreeBSD.org FreeBSD committer Am I Evil? Yes, I Am! --QKFUq+IbM9AW97yF Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (FreeBSD) iD8DBQFCJ5zKForvXbEpPzQRAi2lAKC2NdMRuUkUm/0YQuu8bJo6fEM/HwCg0OZy axqDwvGKiDlorK9INal9ask= =wq7q -----END PGP SIGNATURE----- --QKFUq+IbM9AW97yF--