From owner-freebsd-current@FreeBSD.ORG Tue Sep 27 15:56:20 2011 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5F3C1106566C; Tue, 27 Sep 2011 15:56:20 +0000 (UTC) (envelope-from mavbsd@gmail.com) Received: from mail-fx0-f54.google.com (mail-fx0-f54.google.com [209.85.161.54]) by mx1.freebsd.org (Postfix) with ESMTP id 91EB08FC0A; Tue, 27 Sep 2011 15:56:19 +0000 (UTC) Received: by fxg9 with SMTP id 9so9429080fxg.13 for ; Tue, 27 Sep 2011 08:56:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=sender:message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:x-enigmail-version:content-type :content-transfer-encoding; bh=5TROv52EMxWKAXHk1yt+36xrofT7aHwka/46pN2+0tA=; b=rQXzFPJmh+aHON8vVsrIT2sdX7cvtnHGonVoGCA6S6LlYRM/M4IHbIKd77n7utN+AZ d7YIkAHQoCipkj9zZFAwC+zutEbE23u0G4yAWCBWyvJWum9L0lMKa1166bD+za6u5YD2 sXD60It5KSBsgSEwm/2crpyohAE43V5Tb6yKw= Received: by 10.223.76.201 with SMTP id d9mr12556769fak.119.1317138978542; Tue, 27 Sep 2011 08:56:18 -0700 (PDT) Received: from mavbook2.mavhome.dp.ua (pc.mavhome.dp.ua. [212.86.226.226]) by mx.google.com with ESMTPS id v17sm24010231fai.18.2011.09.27.08.56.17 (version=SSLv3 cipher=OTHER); Tue, 27 Sep 2011 08:56:17 -0700 (PDT) Sender: Alexander Motin Message-ID: <4E81F21D.7000209@FreeBSD.org> Date: Tue, 27 Sep 2011 18:56:13 +0300 From: Alexander Motin User-Agent: Thunderbird 2.0.0.23 (X11/20091212) MIME-Version: 1.0 To: Adrian Chadd References: <201109261053.30410.jhb@freebsd.org> <201109261305.57602.jhb@freebsd.org> <4E81E4A1.3070301@FreeBSD.org> In-Reply-To: <4E81E4A1.3070301@FreeBSD.org> X-Enigmail-Version: 0.96.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: freebsd-current@freebsd.org Subject: Re: ath / 802.11n performance issues and timer code X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Sep 2011 15:56:20 -0000 Alexander Motin wrote: > Adrian Chadd wrote: >> .. erm, sys/mips/mips/machdep.c: >> >> /* >> * call platform specific code to halt (until next interrupt) for the idle loop >> */ >> void >> cpu_idle(int busy) >> { >> KASSERT((mips_rd_status() & MIPS_SR_INT_IE) != 0, >> ("interrupts disabled in idle process.")); >> KASSERT((mips_rd_status() & MIPS_INT_MASK) != 0, >> ("all interrupts masked in idle process.")); >> >> if (!busy) { >> critical_enter(); >> cpu_idleclock(); >> } >> __asm __volatile ("wait"); >> if (!busy) { >> cpu_activeclock(); >> critical_exit(); >> } >> } >> >> .. does that look right? > > Yes it does. x86 does the same, but with more details. The general idea > of the critical section is to block context switch out of idle thread > until missed time events will be handled inside cpu_activeclock(). I was wrong. That's not good. I have no idea about mips wait instruction semantics, related to disabling interrupts. In x86 semantics proper solution is: disable_intr(); if (sched_runnable()) enable_intr(); else __asm __volatile("sti; hlt"); It makes interrupts enabled atomically with entering sleep state, that closes race window and prevents entering into sleep after receiving interrupt. -- Alexander Motin