From owner-freebsd-arch@FreeBSD.ORG Fri Oct 7 09:29:02 2005 Return-Path: X-Original-To: arch@FreeBSD.org Delivered-To: freebsd-arch@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 38F2016A420; Fri, 7 Oct 2005 09:29:02 +0000 (GMT) (envelope-from _pppp@mail.ru) Received: from f44.mail.ru (f44.mail.ru [194.67.57.82]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2294343D66; Fri, 7 Oct 2005 09:28:59 +0000 (GMT) (envelope-from _pppp@mail.ru) Received: from mail by f44.mail.ru with local id 1ENoXC-000CxD-00; Fri, 07 Oct 2005 13:28:58 +0400 Received: from [212.5.170.174] by win.mail.ru with HTTP; Fri, 07 Oct 2005 13:28:58 +0400 From: dima <_pppp@mail.ru> To: Gleb Smirnoff Mime-Version: 1.0 X-Mailer: mPOP Web-Mail 2.19 X-Originating-IP: [212.5.170.174] Date: Fri, 07 Oct 2005 13:28:58 +0400 In-Reply-To: <20051006183413.GH14542@cell.sick.ru> Content-Type: text/plain; charset=koi8-r Content-Transfer-Encoding: 8bit Message-Id: Cc: arch@FreeBSD.org Subject: Re[2]: [REVIEW/TEST] polling(4) changes X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: dima <_pppp@mail.ru> List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Oct 2005 09:29:02 -0000 > 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().