From owner-freebsd-mips@FreeBSD.ORG Sun Aug 1 11:39:42 2010 Return-Path: Delivered-To: freebsd-mips@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0E565106566C; Sun, 1 Aug 2010 11:39:42 +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 30E2C8FC1F; Sun, 1 Aug 2010 11:39:40 +0000 (UTC) Received: by fxm13 with SMTP id 13so1509038fxm.13 for ; Sun, 01 Aug 2010 04:39:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received: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=fnw9qdIrwQecteXv3BQB1BpkIWBGfuR5bnkQNph+FbY=; b=reGNYvEkkFwraBGuHLyQ8ePsMW9zekvjatX+smeKMgjeD6g/do3y4c9NvDOQ4jCszw 4FKZS/8J67qmq7Dmhxiv1JEGXVWGPhBLA+gdKWf4+k5K0TIDsnucb2r2DMRJ/E6vO9dD X1GEBJ6Ebtnx84g6MnPQlr5L8iM6DRxuGseqQ= DomainKey-Signature: a=rsa-sha1; c=nofws; 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; b=cQIAJeChN/RG9mwKCMgnEldEvz3/MBZCAz7t0AKF7YFNYBgrvozP5noaQys2oynxjy jSXsU/3Q7Lzv9MhgsGXBt0PKP+944CmTeZpv4OfWEFN0OSyG8TjqtG19t7pqCOXQo2EF GqFlaDvq0UHCvJxQzMdZsAX+KydiStaUfEpJ0= Received: by 10.223.111.206 with SMTP id t14mr4428053fap.32.1280662780013; Sun, 01 Aug 2010 04:39:40 -0700 (PDT) Received: from mavbook.mavhome.dp.ua (pc.mavhome.dp.ua [212.86.226.226]) by mx.google.com with ESMTPS id h4sm1583740faj.15.2010.08.01.04.39.38 (version=SSLv3 cipher=RC4-MD5); Sun, 01 Aug 2010 04:39:39 -0700 (PDT) Sender: Alexander Motin Message-ID: <4C555CF7.5080101@FreeBSD.org> Date: Sun, 01 Aug 2010 14:39:35 +0300 From: Alexander Motin User-Agent: Thunderbird 2.0.0.24 (X11/20100402) MIME-Version: 1.0 To: Neel Natu References: <4C41A248.8090605@FreeBSD.org> <4C41B4CF.6080409@FreeBSD.org> <4C4205CC.6080700@FreeBSD.org> <4C4ED247.80701@FreeBSD.org> In-Reply-To: X-Enigmail-Version: 0.96.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: Randall Stewart , freebsd-mips@freebsd.org, Neel Natu Subject: Re: [RFC] Event timers on MIPS X-BeenThere: freebsd-mips@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to MIPS List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 01 Aug 2010 11:39:42 -0000 Neel Natu wrote: > Here is the patch for mips/mips/tick.c to fix tick_ticker(). > > In addition to incorporating the changes made in rmi/tick.c it fixes > the following: > > - There is a race between clock_intr() and tick_ticker() updating > counter_upper and counter_lower_last. This race exists because > interrupts are enabled even though tick_ticker() executes in a > critical section. While there is indeed a possible issue, I am not sure your solution is reliable. I haven't looked how DPCPU_GET implemented on MIPS, but can't compiler reorder them? I would thought about some lock or at least some atomics with barriers. "t_upper++;" there looks a bit strange, as it is not written back. The wrapping stuff won't work if this timer interrupts were not used. > - Fix a bug in clock_intr() in how it updates counter_upper and > counter_lower_last. It updates it only once every time the COUNT > register wraps around. More interestingly it will *never* update the > cached values of 'counter_upper' and 'counter_lower_last' if the > previous value of 'counter_lower_last' happens to be '0'. Reasonable. It would be nice if both wrapping places were implemented alike or the same way. > - Get rid of the superfluous critical section in clock_intr(). There > is no reason for it because clock_intr() executes in hard interrupt > context. Seems OK. -- Alexander Motin