Date: Fri, 07 Oct 2005 13:28:58 +0400 From: dima <_pppp@mail.ru> To: Gleb Smirnoff <glebius@FreeBSD.org> Cc: arch@FreeBSD.org Subject: Re[2]: [REVIEW/TEST] polling(4) changes Message-ID: <E1ENoXC-000CxD-00._pppp-mail-ru@f44.mail.ru> In-Reply-To: <20051006183413.GH14542@cell.sick.ru>
next in thread | previous in thread | raw e-mail | index | archive | help
> d> Seems to be a first considerable step regarding the ideas discussed in March :)
> d> But, my idea about the separate locking of each interface dissappeared from this implementation. mtx_poll is good to protect the pollrec array and other sensitive variables. But we could get advantage of SMP machines writing polling loops like this:
> d>
> d> for( i = 0; i < poll_handlers; ++i ) {
> d> mtx_lock( &iface_lock[i] );
> d> pr[i].handler(pr[i].ifp, POLL_ONLY, count);
> d> mtx_unlock( &iface_lock[i] );
> d> }
>
> What is the benefit here? The driver must have its own lock.
Well, consider the absense of the mtx_poll lock:
- mtx_lock( &mtx_poll );
for( i = 0; i < poll_handlers; ++i ) {
+ mtx_lock( &iface_lock[i] );
pr[i].handler( pr[i].ifp, POLL_ONLY, count );
+ mtx_unlock( &iface_lock[i] );
}
- mtx_unlock( &mtx_poll );
So, several kernel threads in an SMP machine can poll different interfaces simultaneously. And mtx_lock should only be used in ether_poll_[de]register().
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?E1ENoXC-000CxD-00._pppp-mail-ru>
