From owner-freebsd-current Mon Feb 25 19:19:44 2002 Delivered-To: freebsd-current@freebsd.org Received: from apollo.backplane.com (apollo.backplane.com [216.240.41.2]) by hub.freebsd.org (Postfix) with ESMTP id A166B37B435; Mon, 25 Feb 2002 19:19:26 -0800 (PST) Received: (from dillon@localhost) by apollo.backplane.com (8.11.6/8.9.1) id g1Q3JMf55372; Mon, 25 Feb 2002 19:19:22 -0800 (PST) (envelope-from dillon) Date: Mon, 25 Feb 2002 19:19:22 -0800 (PST) From: Matthew Dillon Message-Id: <200202260319.g1Q3JMf55372@apollo.backplane.com> To: Bruce Evans Cc: Terry Lambert , Alfred Perlstein , Bosko Milekic , Seigo Tanimura , , John Baldwin Subject: Re: Patch for critical_enter()/critical_exit() & interrupt assembly revamp, please review! References: <20020226121245.F42820-100000@gamplex.bde.org> Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG It kinda sounds like the interrupt/trap code that calls into kern/subr_trap.c should be responsible for placing us in a critical section. kern/subr_trap.c has no business making assumptions in regards to cpu_critical_enter()/cpu_critical_exit() (for the same reason that fork_exit() has no business making those kinds of assumptions). For the moment I'm not going to worry about it. I'll just keep the cpu_critical_*() API intact for i386 for now. -Matt Matthew Dillon :The use of cpu_critical*() in subr_trap.c is a bit trickier/kludgier. :We need to return from the interrupt handler atomically with clearing :the lazy-masking flag. The hardware interrupt enable flag must be :used for this on i386's. The code for this is logically: : :In ast: : /* Prevent changes to flags while we are deciding if they are set. */ : critical_enter(); : : while ((ke->ke_flags & (KEF_ASTPENDING | KEF_NEEDRESCHED)) != 0) { : critical_exit(); : ... : /* As above. */ : critical_enter(); : } : :In doreti: : /* : * Must use MD code to prevent race window after critical_exit(). : * We switch from lazy sofware masking using td_critnest (or : * whatever critical_enter() uses) to hardware masking using cli. : */ : cli(); : critical_exit(); : ... : iretd(); : :but this is optimized in -current by using cpu_critical*() instead of :critical_enter*() in ast() and not doing the cli() and critical_exit() :in doreti. This depends on cpu_critical_enter() being precisely cli(). : :Bruce : To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message