From owner-freebsd-mips@FreeBSD.ORG Sun Jul 25 11:30:51 2010 Return-Path: Delivered-To: mips@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 177BE1065677 for ; Sun, 25 Jul 2010 11:30:51 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (bsdimp.com [199.45.160.85]) by mx1.freebsd.org (Postfix) with ESMTP id EFEFF8FC22 for ; Sun, 25 Jul 2010 11:30:50 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by harmony.bsdimp.com (8.14.3/8.14.1) with ESMTP id o6PBPqcZ040239; Sun, 25 Jul 2010 05:25:53 -0600 (MDT) (envelope-from imp@bsdimp.com) Date: Sun, 25 Jul 2010 05:26:29 -0600 (MDT) Message-Id: <20100725.052629.160100930644600654.imp@bsdimp.com> To: c.jayachandran@gmail.com From: "M. Warner Losh" In-Reply-To: References: <201007250419.o6P4J50q033283@svn.freebsd.org> <4C4BC213.5060001@cs.rice.edu> X-Mailer: Mew version 6.3 on Emacs 22.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Cc: mips@freebsd.org, alc@cs.rice.edu Subject: Re: svn commit: r210460 - head/sys/mips/include 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, 25 Jul 2010 11:30:51 -0000 In message: "Jayachandran C." writes: : On Sun, Jul 25, 2010 at 10:18 AM, Alan Cox wrote: : > Warner Losh wrote: : >> : >> Author: imp : >> Date: Sun Jul 25 04:19:05 2010 : >> New Revision: 210460 : >> URL: http://svn.freebsd.org/changeset/base/210460 : >> : >> Log: : >> =A0Get N64 building by defining VM_FREELIST_DIRECT to be : >> =A0VM_FREELIST_DEFAULT. =A0I believe this is correct, since KX is = set in : >> =A0n64, and thus all RAM can be direct mapped. : = : Thanks, this is something I missed in my MIPS page table changes. : = : > : > Yes, it is. : = : In MIPS 64bit, whole physical memory is direct mapped thru a XKPHYS : region. We can use vm_page_alloc() for pmap_alloc_pte_page() and : VM_WAIT for pmap_grow_pte_page_cache(), is this something we should : consider? Likely. Any idea what kind of performance difference this would buy us? Warner From owner-freebsd-mips@FreeBSD.ORG Mon Jul 26 07:57:16 2010 Return-Path: Delivered-To: mips@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 018F5106567B for ; Mon, 26 Jul 2010 07:57:16 +0000 (UTC) (envelope-from c.jayachandran@gmail.com) Received: from mail-vw0-f54.google.com (mail-vw0-f54.google.com [209.85.212.54]) by mx1.freebsd.org (Postfix) with ESMTP id B52D18FC21 for ; Mon, 26 Jul 2010 07:57:15 +0000 (UTC) Received: by vws7 with SMTP id 7so2636730vws.13 for ; Mon, 26 Jul 2010 00:57:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=xq4+lbO0EGggB9rVOWpktepR+xLODBm63t3F4klUQEs=; b=bl1TtEMPx5V/r5eHDCrWcDRC551wvIR8eC/Qdx2altljUkqy8SaMYQj+4ugdII2EP5 7koQPylPOjgK7n7LpodBrIsUgYHvu6Soyzm66rdFdUTPx55en2j4VauySJpoF6BlPakr cXWuEsCjfdDvIlrs3t9kofgrGS2m1XlNbsjLI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=sQ28oQwmnaKivNu04I0oyv7FOzLnnefYIQBdXqQO2U/iCl1YMTHzNI7VYlKVtDMkmK 5Q/kpSLNzIgfhH91ulnb5kfP844XyH5eXJai0/cotDxkdTlvnXYyXFCyJznWCT1fsHMT fHuNjp9CJLpy/qMhoWU/icX6XHkLTIq2iqLpo= MIME-Version: 1.0 Received: by 10.220.62.136 with SMTP id x8mr3843085vch.175.1280131034832; Mon, 26 Jul 2010 00:57:14 -0700 (PDT) Received: by 10.220.195.11 with HTTP; Mon, 26 Jul 2010 00:57:14 -0700 (PDT) In-Reply-To: <4C4D3AC1.8080201@cs.rice.edu> References: <201007250419.o6P4J50q033283@svn.freebsd.org> <4C4BC213.5060001@cs.rice.edu> <20100725.052629.160100930644600654.imp@bsdimp.com> <4C4D3AC1.8080201@cs.rice.edu> Date: Mon, 26 Jul 2010 13:27:14 +0530 Message-ID: From: "Jayachandran C." To: Alan Cox Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: mips@freebsd.org Subject: Re: svn commit: r210460 - head/sys/mips/include 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: Mon, 26 Jul 2010 07:57:16 -0000 On Mon, Jul 26, 2010 at 1:05 PM, Alan Cox wrote: > M. Warner Losh wrote: >> >> In message: >> =A0 =A0 =A0 =A0 =A0 =A0"Jayachandran C." writ= es: >> : On Sun, Jul 25, 2010 at 10:18 AM, Alan Cox wrote: >> : > Warner Losh wrote: >> : >> >> : >> Author: imp >> : >> Date: Sun Jul 25 04:19:05 2010 >> : >> New Revision: 210460 >> : >> URL: http://svn.freebsd.org/changeset/base/210460 >> : >> >> : >> Log: >> : >> =A0Get N64 building by defining VM_FREELIST_DIRECT to be >> : >> =A0VM_FREELIST_DEFAULT. =A0I believe this is correct, since KX is s= et in >> : >> =A0n64, and thus all RAM can be direct mapped. >> : : Thanks, this is something I missed in my MIPS page table changes. >> : : > >> : > Yes, it is. >> : : In MIPS 64bit, whole physical memory is direct mapped thru a XKPHYS >> : region. We can use vm_page_alloc() for pmap_alloc_pte_page() and >> : VM_WAIT for pmap_grow_pte_page_cache(), is this something we should >> : consider? >> >> Likely. =A0Any idea what kind of performance difference this would buy >> us? >> > > As long as n64 has a single free list, there is no point in changing > pmap_alloc_pte_page() to use vm_page_alloc(). =A0There may, however, be s= ome > point to using VM_WAIT in pmap_grow_pte_page_cache(), because > vm_contig_grow_cache() is far more aggressive about paging out dirty page= s > than VM_WAIT is, and VM_WAIT would suffice. Thanks - the 64 bit is the HEAD is still in early development, so I was just trying to understand this better. > For what it's worth, fixing pmap_change_wiring() and > pmap_page_wired_mappings() is almost certainly more important. I had seen the mail on this, but thought I will look at this after the 64 bit support work (if it is not fixed by then). JC. From owner-freebsd-mips@FreeBSD.ORG Mon Jul 26 08:06:58 2010 Return-Path: Delivered-To: mips@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 818C4106566B for ; Mon, 26 Jul 2010 08:06:57 +0000 (UTC) (envelope-from alc@cs.rice.edu) Received: from mail.cs.rice.edu (mail.cs.rice.edu [128.42.1.31]) by mx1.freebsd.org (Postfix) with ESMTP id 5CED78FC0A for ; Mon, 26 Jul 2010 08:06:57 +0000 (UTC) Received: from mail.cs.rice.edu (localhost.localdomain [127.0.0.1]) by mail.cs.rice.edu (Postfix) with ESMTP id DFDA12C2B58; Mon, 26 Jul 2010 02:35:39 -0500 (CDT) X-Virus-Scanned: by amavis-2.4.0 at mail.cs.rice.edu Received: from mail.cs.rice.edu ([127.0.0.1]) by mail.cs.rice.edu (mail.cs.rice.edu [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 8YY1B+Yu2FbI; Mon, 26 Jul 2010 02:35:32 -0500 (CDT) Received: from adsl-216-63-78-18.dsl.hstntx.swbell.net (adsl-216-63-78-18.dsl.hstntx.swbell.net [216.63.78.18]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.cs.rice.edu (Postfix) with ESMTP id F007A2C2C56; Mon, 26 Jul 2010 02:35:31 -0500 (CDT) Message-ID: <4C4D3AC1.8080201@cs.rice.edu> Date: Mon, 26 Jul 2010 02:35:29 -0500 From: Alan Cox User-Agent: Thunderbird 2.0.0.24 (X11/20100501) MIME-Version: 1.0 To: "M. Warner Losh" References: <201007250419.o6P4J50q033283@svn.freebsd.org> <4C4BC213.5060001@cs.rice.edu> <20100725.052629.160100930644600654.imp@bsdimp.com> In-Reply-To: <20100725.052629.160100930644600654.imp@bsdimp.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: mips@freebsd.org Subject: Re: svn commit: r210460 - head/sys/mips/include 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: Mon, 26 Jul 2010 08:06:58 -0000 M. Warner Losh wrote: > In message: > "Jayachandran C." writes: > : On Sun, Jul 25, 2010 at 10:18 AM, Alan Cox wrote: > : > Warner Losh wrote: > : >> > : >> Author: imp > : >> Date: Sun Jul 25 04:19:05 2010 > : >> New Revision: 210460 > : >> URL: http://svn.freebsd.org/changeset/base/210460 > : >> > : >> Log: > : >> Get N64 building by defining VM_FREELIST_DIRECT to be > : >> VM_FREELIST_DEFAULT. I believe this is correct, since KX is set in > : >> n64, and thus all RAM can be direct mapped. > : > : Thanks, this is something I missed in my MIPS page table changes. > : > : > > : > Yes, it is. > : > : In MIPS 64bit, whole physical memory is direct mapped thru a XKPHYS > : region. We can use vm_page_alloc() for pmap_alloc_pte_page() and > : VM_WAIT for pmap_grow_pte_page_cache(), is this something we should > : consider? > > Likely. Any idea what kind of performance difference this would buy > us? > As long as n64 has a single free list, there is no point in changing pmap_alloc_pte_page() to use vm_page_alloc(). There may, however, be some point to using VM_WAIT in pmap_grow_pte_page_cache(), because vm_contig_grow_cache() is far more aggressive about paging out dirty pages than VM_WAIT is, and VM_WAIT would suffice. For what it's worth, fixing pmap_change_wiring() and pmap_page_wired_mappings() is almost certainly more important. Alan From owner-freebsd-mips@FreeBSD.ORG Mon Jul 26 10:33:06 2010 Return-Path: Delivered-To: mips@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 03BDC106566C for ; Mon, 26 Jul 2010 10:33:06 +0000 (UTC) (envelope-from ray@dlink.ua) Received: from dlink.ua (smtp.dlink.ua [193.138.187.146]) by mx1.freebsd.org (Postfix) with ESMTP id 881028FC1D for ; Mon, 26 Jul 2010 10:33:05 +0000 (UTC) Received: from gw ([192.168.10.10] helo=terran) by dlink.ua with esmtpsa (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.63) (envelope-from ) id 1OdKcf-0002tY-5n; Mon, 26 Jul 2010 13:09:25 +0300 Date: Mon, 26 Jul 2010 13:09:20 +0300 From: Alexandr Rybalko To: "M. Warner Losh" Message-Id: <20100726130920.faeafa58.ray@dlink.ua> In-Reply-To: <20100725.052629.160100930644600654.imp@bsdimp.com> References: <201007250419.o6P4J50q033283@svn.freebsd.org> <4C4BC213.5060001@cs.rice.edu> <20100725.052629.160100930644600654.imp@bsdimp.com> Organization: D-Link X-Mailer: Sylpheed 2.7.1 (GTK+ 2.20.1; i386-portbld-freebsd8.0) Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: alc@cs.rice.edu, mips@freebsd.org Subject: Re: svn commit: r210460 - head/sys/mips/include 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: Mon, 26 Jul 2010 10:33:06 -0000 On Sun, 25 Jul 2010 05:26:29 -0600 (MDT) "M. Warner Losh" wrote: >> In message: >> "Jayachandran C." writes: >> : On Sun, Jul 25, 2010 at 10:18 AM, Alan Cox wrote: >> : > Warner Losh wrote: >> : >> >> : >> Author: imp >> : >> Date: Sun Jul 25 04:19:05 2010 >> : >> New Revision: 210460 >> : >> URL: http://svn.freebsd.org/changeset/base/210460 >> : >> >> : >> Log: >> : >>  Get N64 building by defining VM_FREELIST_DIRECT to be >> : >>  VM_FREELIST_DEFAULT.  I believe this is correct, since KX is set in >> : >>  n64, and thus all RAM can be direct mapped. >> : >> : Thanks, this is something I missed in my MIPS page table changes. >> : >> : > >> : > Yes, it is. >> : >> : In MIPS 64bit, whole physical memory is direct mapped thru a XKPHYS >> : region. We can use vm_page_alloc() for pmap_alloc_pte_page() and >> : VM_WAIT for pmap_grow_pte_page_cache(), is this something we should >> : consider? >> >> Likely. Any idea what kind of performance difference this would buy >> us? >> >> Warner >> >> >> _______________________________________________ >> freebsd-mips@freebsd.org mailing list >> http://lists.freebsd.org/mailman/listinfo/freebsd-mips >> To unsubscribe, send any mail to "freebsd-mips-unsubscribe@freebsd.org" Hi, Today I try to make MIPS kernel, and get this error: cc -c -O2 -pipe -fno-strict-aliasing -march=mips32 -std=c99 -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual -Wundef -Wno-pointer-sign -fformat-extensions -nostdinc -I. -I/usr/1/MIPS_FreeBSD/HEAD/head/sys -I/usr/1/MIPS_FreeBSD/HEAD/head/sys/contrib/altq -D_KERNEL -DHAVE_KERNEL_OPTION_HEADERS -include opt_global.h -fno-common -finline-limit=768 --param inline-unit-growth=1000 --param large-function-growth=100000 -EL -fno-pic -mno-abicalls -G0 -EL -march=mips32 -msoft-float -ffreestanding -Werror /usr/1/MIPS_FreeBSD/HEAD/head/sys/mips/mips/pmap.c cc1: warnings being treated as errors /usr/1/MIPS_FreeBSD/HEAD/head/sys/mips/mips/pmap.c: In function 'pmap_grow_pte_page_cache': /usr/1/MIPS_FreeBSD/HEAD/head/sys/mips/mips/pmap.c:941: warning: implicit declaration of function 'vm_contig_grow_cache' /usr/1/MIPS_FreeBSD/HEAD/head/sys/mips/mips/pmap.c:941: warning: nested extern declaration of 'vm_contig_grow_cache' *** Error code 1 Where is vm_contig_grow_cache(3, 0, MIPS_KSEG0_LARGEST_PHYS) defined? I found vm_contig_grow_cache in sys/vm/vm_contig.c, but they wont only one argument. WBW -- Alexandr Rybalko aka Alex RAY From owner-freebsd-mips@FreeBSD.ORG Mon Jul 26 11:07:06 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 568C11065676 for ; Mon, 26 Jul 2010 11:07:06 +0000 (UTC) (envelope-from owner-bugmaster@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 1C8CE8FC21 for ; Mon, 26 Jul 2010 11:07:06 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id o6QB75FY080736 for ; Mon, 26 Jul 2010 11:07:05 GMT (envelope-from owner-bugmaster@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id o6QB75Xm080734 for freebsd-mips@FreeBSD.org; Mon, 26 Jul 2010 11:07:05 GMT (envelope-from owner-bugmaster@FreeBSD.org) Date: Mon, 26 Jul 2010 11:07:05 GMT Message-Id: <201007261107.o6QB75Xm080734@freefall.freebsd.org> X-Authentication-Warning: freefall.freebsd.org: gnats set sender to owner-bugmaster@FreeBSD.org using -f From: FreeBSD bugmaster To: freebsd-mips@FreeBSD.org Cc: Subject: Current problem reports assigned to freebsd-mips@FreeBSD.org 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: Mon, 26 Jul 2010 11:07:06 -0000 Note: to view an individual PR, use: http://www.freebsd.org/cgi/query-pr.cgi?pr=(number). The following is a listing of current problems submitted by FreeBSD users. These represent problem reports covering all versions including experimental development code and obsolete releases. S Tracker Resp. Description -------------------------------------------------------------------------------- o misc/147471 mips [headers] [patch] whitespace discrepancy in sys/mips/i 1 problem total. From owner-freebsd-mips@FreeBSD.ORG Mon Jul 26 12:30:27 2010 Return-Path: Delivered-To: mips@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 48ED31065670 for ; Mon, 26 Jul 2010 12:30:27 +0000 (UTC) (envelope-from c.jayachandran@gmail.com) Received: from mail-vw0-f54.google.com (mail-vw0-f54.google.com [209.85.212.54]) by mx1.freebsd.org (Postfix) with ESMTP id ECE678FC12 for ; Mon, 26 Jul 2010 12:30:26 +0000 (UTC) Received: by vws7 with SMTP id 7so2825982vws.13 for ; Mon, 26 Jul 2010 05:30:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=/qbxN3ExhZHpPX2EpZbtj64rB+X7Uu1dmuqJuWeK2Tk=; b=n9sVScq1Jy2GVQMOYGLl2C93JlDjjH5OJ117APBlkMN41IzgKOcyezDf6og/igPzcc 6M+i07qejUQkeK+U7DnZuI4YYnQKrSCtQKmZF3bMmIOAJGzG9UfrQbJsXXIMl4s7oJbL pRogn4bXH4rxDtXuTDtGFRrpya94I76DJB2zk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=tpoIIebYkkgkGKaRs8jZJikqN25Khe7+0chinA1YX01z+jLG/LVm0RxtcOyMp5gRej A/zqElmYhWJpG2B40np+PGLfC8bpocS+5hineX2dj3KZ18R3S/ZT20Iey/oa8se99Kej djxgEDMM6GAJ3/GjtJ/oJRTQJ/83bHNDmcFcg= MIME-Version: 1.0 Received: by 10.220.48.90 with SMTP id q26mr4116159vcf.88.1280147425953; Mon, 26 Jul 2010 05:30:25 -0700 (PDT) Received: by 10.220.195.11 with HTTP; Mon, 26 Jul 2010 05:30:25 -0700 (PDT) In-Reply-To: <20100726130920.faeafa58.ray@dlink.ua> References: <201007250419.o6P4J50q033283@svn.freebsd.org> <4C4BC213.5060001@cs.rice.edu> <20100725.052629.160100930644600654.imp@bsdimp.com> <20100726130920.faeafa58.ray@dlink.ua> Date: Mon, 26 Jul 2010 18:00:25 +0530 Message-ID: From: "Jayachandran C." To: Alexandr Rybalko Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: alc@cs.rice.edu, mips@freebsd.org Subject: Re: svn commit: r210460 - head/sys/mips/include 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: Mon, 26 Jul 2010 12:30:27 -0000 On Mon, Jul 26, 2010 at 3:39 PM, Alexandr Rybalko wrote: > On Sun, 25 Jul 2010 05:26:29 -0600 (MDT) > Hi, > > Today I try to make MIPS kernel, and get this error: > > cc -c -O2 -pipe -fno-strict-aliasing -march=3Dmips32 -std=3Dc99 =A0-Wall = -Wredundant-decls -Wnested-externs -Wstrict-prototypes > -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual =A0-Wundef -Wno= -pointer-sign -fformat-extensions -nostdinc =A0-I. > -I/usr/1/MIPS_FreeBSD/HEAD/head/sys -I/usr/1/MIPS_FreeBSD/HEAD/head/sys/c= ontrib/altq -D_KERNEL -DHAVE_KERNEL_OPTION_HEADERS > -include opt_global.h -fno-common -finline-limit=3D768 --param inline-uni= t-growth=3D1000 --param large-function-growth=3D100000 =A0-EL > -fno-pic -mno-abicalls -G0 -EL -march=3Dmips32 -msoft-float -ffreestandin= g > -Werror =A0/usr/1/MIPS_FreeBSD/HEAD/head/sys/mips/mips/pmap.c cc1: warnin= gs being treated as > errors /usr/1/MIPS_FreeBSD/HEAD/head/sys/mips/mips/pmap.c: In function > 'pmap_grow_pte_page_cache': /usr/1/MIPS_FreeBSD/HEAD/head/sys/mips/mips/p= map.c:941: warning: implicit declaration of function > 'vm_contig_grow_cache' /usr/1/MIPS_FreeBSD/HEAD/head/sys/mips/mips/pmap.c= :941: warning: nested extern declaration of > 'vm_contig_grow_cache' *** Error code 1 > > Where is vm_contig_grow_cache(3, 0, MIPS_KSEG0_LARGEST_PHYS) defined? > > I found vm_contig_grow_cache in sys/vm/vm_contig.c, but they wont only on= e argument. Are you building from HEAD? The head seems to have the correct version (http://svn.freebsd.org/viewvc/base/head/sys/vm/vm_contig.c?view=3Dmarkup) JC. From owner-freebsd-mips@FreeBSD.ORG Mon Jul 26 13:26:36 2010 Return-Path: Delivered-To: mips@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A20A01065679 for ; Mon, 26 Jul 2010 13:26:36 +0000 (UTC) (envelope-from ray@dlink.ua) Received: from dlink.ua (smtp.dlink.ua [193.138.187.146]) by mx1.freebsd.org (Postfix) with ESMTP id 2AA028FC2A for ; Mon, 26 Jul 2010 13:26:35 +0000 (UTC) Received: from gw ([192.168.10.10] helo=terran) by dlink.ua with esmtpsa (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.63) (envelope-from ) id 1OdNhO-0004hp-BZ; Mon, 26 Jul 2010 16:26:30 +0300 Date: Mon, 26 Jul 2010 16:26:25 +0300 From: Alexandr Rybalko To: "Jayachandran C." Message-Id: <20100726162625.f7300c62.ray@dlink.ua> In-Reply-To: References: <201007250419.o6P4J50q033283@svn.freebsd.org> <4C4BC213.5060001@cs.rice.edu> <20100725.052629.160100930644600654.imp@bsdimp.com> <20100726130920.faeafa58.ray@dlink.ua> Organization: D-Link X-Mailer: Sylpheed 2.7.1 (GTK+ 2.20.1; i386-portbld-freebsd8.0) Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: alc@cs.rice.edu, mips@freebsd.org Subject: Re: svn commit: r210460 - head/sys/mips/include 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: Mon, 26 Jul 2010 13:26:36 -0000 On Mon, 26 Jul 2010 18:00:25 +0530 "Jayachandran C." wrote: >> On Mon, Jul 26, 2010 at 3:39 PM, Alexandr Rybalko wrote: >> > On Sun, 25 Jul 2010 05:26:29 -0600 (MDT) >> > Hi, >> > >> > Today I try to make MIPS kernel, and get this error: >> > >> > cc -c -O2 -pipe -fno-strict-aliasing -march=mips32 -std=c99  -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes >> > -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual  -Wundef -Wno-pointer-sign -fformat-extensions -nostdinc  -I. >> > -I/usr/1/MIPS_FreeBSD/HEAD/head/sys -I/usr/1/MIPS_FreeBSD/HEAD/head/sys/contrib/altq -D_KERNEL -DHAVE_KERNEL_OPTION_HEADERS >> > -include opt_global.h -fno-common -finline-limit=768 --param inline-unit-growth=1000 --param large-function-growth=100000 >> >  -EL -fno-pic -mno-abicalls -G0 -EL -march=mips32 -msoft-float -ffreestanding >> > -Werror  /usr/1/MIPS_FreeBSD/HEAD/head/sys/mips/mips/pmap.c cc1: warnings being treated as >> > errors /usr/1/MIPS_FreeBSD/HEAD/head/sys/mips/mips/pmap.c: In function >> > 'pmap_grow_pte_page_cache': /usr/1/MIPS_FreeBSD/HEAD/head/sys/mips/mips/pmap.c:941: warning: implicit declaration of function >> > 'vm_contig_grow_cache' /usr/1/MIPS_FreeBSD/HEAD/head/sys/mips/mips/pmap.c:941: warning: nested extern declaration of >> > 'vm_contig_grow_cache' *** Error code 1 >> > >> > Where is vm_contig_grow_cache(3, 0, MIPS_KSEG0_LARGEST_PHYS) defined? >> > >> > I found vm_contig_grow_cache in sys/vm/vm_contig.c, but they wont only one argument. >> >> Are you building from HEAD? The head seems to have the correct version >> (http://svn.freebsd.org/viewvc/base/head/sys/vm/vm_contig.c?view=markup) >> >> JC. Yes, you're right, for my mistake, not all files are updated on svn update. Sorry for wasting time. -- Alexandr Rybalko aka Alex RAY From owner-freebsd-mips@FreeBSD.ORG Mon Jul 26 14:29:30 2010 Return-Path: Delivered-To: mips@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E33C8106566B for ; Mon, 26 Jul 2010 14:29:30 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (bsdimp.com [199.45.160.85]) by mx1.freebsd.org (Postfix) with ESMTP id A42448FC08 for ; Mon, 26 Jul 2010 14:29:30 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by harmony.bsdimp.com (8.14.3/8.14.1) with ESMTP id o6QEO63Y064883; Mon, 26 Jul 2010 08:24:07 -0600 (MDT) (envelope-from imp@bsdimp.com) Date: Mon, 26 Jul 2010 08:24:44 -0600 (MDT) Message-Id: <20100726.082444.792475653697373753.imp@bsdimp.com> To: alc@cs.rice.edu From: "M. Warner Losh" In-Reply-To: <4C4D3AC1.8080201@cs.rice.edu> References: <20100725.052629.160100930644600654.imp@bsdimp.com> <4C4D3AC1.8080201@cs.rice.edu> X-Mailer: Mew version 6.3 on Emacs 22.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cc: mips@FreeBSD.org Subject: Re: svn commit: r210460 - head/sys/mips/include 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: Mon, 26 Jul 2010 14:29:31 -0000 In message: <4C4D3AC1.8080201@cs.rice.edu> Alan Cox writes: : M. Warner Losh wrote: : > In message: : > : > "Jayachandran C." writes: : > : On Sun, Jul 25, 2010 at 10:18 AM, Alan Cox wrote: : > : > Warner Losh wrote: : > : >> : > : >> Author: imp : > : >> Date: Sun Jul 25 04:19:05 2010 : > : >> New Revision: 210460 : > : >> URL: http://svn.freebsd.org/changeset/base/210460 : > : >> : > : >> Log: : > : >> Get N64 building by defining VM_FREELIST_DIRECT to be : > : >> VM_FREELIST_DEFAULT. I believe this is correct, since KX is set : > in : > : >> n64, and thus all RAM can be direct mapped. : > : : Thanks, this is something I missed in my MIPS page table changes. : > : : > : > : > Yes, it is. : > : : In MIPS 64bit, whole physical memory is direct mapped thru a : > XKPHYS : > : region. We can use vm_page_alloc() for pmap_alloc_pte_page() and : > : VM_WAIT for pmap_grow_pte_page_cache(), is this something we should : > : consider? : > : > Likely. Any idea what kind of performance difference this would buy : > us? : > : : As long as n64 has a single free list, there is no point in changing : pmap_alloc_pte_page() to use vm_page_alloc(). There may, however, be : some point to using VM_WAIT in pmap_grow_pte_page_cache(), because : vm_contig_grow_cache() is far more aggressive about paging out dirty : pages than VM_WAIT is, and VM_WAIT would suffice. : : For what it's worth, fixing pmap_change_wiring() and : pmap_page_wired_mappings() is almost certainly more important. what's broken with them now? Warner From owner-freebsd-mips@FreeBSD.ORG Mon Jul 26 18:06:11 2010 Return-Path: Delivered-To: mips@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3C320106566C for ; Mon, 26 Jul 2010 18:06:11 +0000 (UTC) (envelope-from alc@cs.rice.edu) Received: from mail.cs.rice.edu (mail.cs.rice.edu [128.42.1.31]) by mx1.freebsd.org (Postfix) with ESMTP id 077428FC17 for ; Mon, 26 Jul 2010 18:06:10 +0000 (UTC) Received: from mail.cs.rice.edu (localhost.localdomain [127.0.0.1]) by mail.cs.rice.edu (Postfix) with ESMTP id 831262C2AEB; Mon, 26 Jul 2010 13:06:10 -0500 (CDT) X-Virus-Scanned: by amavis-2.4.0 at mail.cs.rice.edu Received: from mail.cs.rice.edu ([127.0.0.1]) by mail.cs.rice.edu (mail.cs.rice.edu [127.0.0.1]) (amavisd-new, port 10024) with LMTP id PB1Mvg3STet4; Mon, 26 Jul 2010 13:06:02 -0500 (CDT) Received: from adsl-216-63-78-18.dsl.hstntx.swbell.net (adsl-216-63-78-18.dsl.hstntx.swbell.net [216.63.78.18]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.cs.rice.edu (Postfix) with ESMTP id 7B5862C2B02; Mon, 26 Jul 2010 13:06:02 -0500 (CDT) Message-ID: <4C4DCE89.6070301@cs.rice.edu> Date: Mon, 26 Jul 2010 13:06:01 -0500 From: Alan Cox User-Agent: Thunderbird 2.0.0.24 (X11/20100501) MIME-Version: 1.0 To: "M. Warner Losh" References: <20100725.052629.160100930644600654.imp@bsdimp.com> <4C4D3AC1.8080201@cs.rice.edu> <20100726.082444.792475653697373753.imp@bsdimp.com> In-Reply-To: <20100726.082444.792475653697373753.imp@bsdimp.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Alan Cox , mips@FreeBSD.org Subject: Re: svn commit: r210460 - head/sys/mips/include 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: Mon, 26 Jul 2010 18:06:11 -0000 M. Warner Losh wrote: > In message: <4C4D3AC1.8080201@cs.rice.edu> > Alan Cox writes: > : M. Warner Losh wrote: > : > In message: > : > > : > "Jayachandran C." writes: > : > : On Sun, Jul 25, 2010 at 10:18 AM, Alan Cox wrote: > : > : > Warner Losh wrote: > : > : >> > : > : >> Author: imp > : > : >> Date: Sun Jul 25 04:19:05 2010 > : > : >> New Revision: 210460 > : > : >> URL: http://svn.freebsd.org/changeset/base/210460 > : > : >> > : > : >> Log: > : > : >> Get N64 building by defining VM_FREELIST_DIRECT to be > : > : >> VM_FREELIST_DEFAULT. I believe this is correct, since KX is set > : > in > : > : >> n64, and thus all RAM can be direct mapped. > : > : : Thanks, this is something I missed in my MIPS page table changes. > : > : : > > : > : > Yes, it is. > : > : : In MIPS 64bit, whole physical memory is direct mapped thru a > : > XKPHYS > : > : region. We can use vm_page_alloc() for pmap_alloc_pte_page() and > : > : VM_WAIT for pmap_grow_pte_page_cache(), is this something we should > : > : consider? > : > > : > Likely. Any idea what kind of performance difference this would buy > : > us? > : > > : > : As long as n64 has a single free list, there is no point in changing > : pmap_alloc_pte_page() to use vm_page_alloc(). There may, however, be > : some point to using VM_WAIT in pmap_grow_pte_page_cache(), because > : vm_contig_grow_cache() is far more aggressive about paging out dirty > : pages than VM_WAIT is, and VM_WAIT would suffice. > : > : For what it's worth, fixing pmap_change_wiring() and > : pmap_page_wired_mappings() is almost certainly more important. > > what's broken with them now? > pmap_page_wired_mappings() counts the number of pv entries for the specified page that have the pv entry wired flag set to TRUE. pmap_enter() correctly initializes this flag. However, pmap_change_wiring() doesn't update the corresponding pv entry flag, only the PTE. So, the count returned by pmap_page_wired_mappings() will sometimes be wrong. In other words, that a particular mapping is wired is being redundantly stored in two places, the PTE and the pv entry, but these two places are not being consistently maintained. In the short term, the best fix would be to eliminate the pv entry flag and use only the PTE. That flag is wasting non-trivial memory. However, in the long run, the use of a PTE bit on a wired flag was probably a suboptimal choice for MIPS given the scarcity of bits available to software. For example, spending that bit on a PTE_MANAGED flag would save a fair number of cycles, especially now that MIPS is configured as VM_PHYSSEG_SPARSE. That said, in closing, I would reiterate that the best fix for the foreseeable future is to eliminate the redundant pv entry flag. Alan From owner-freebsd-mips@FreeBSD.ORG Tue Jul 27 09:24:11 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 65899106567E; Tue, 27 Jul 2010 09:24:11 +0000 (UTC) (envelope-from c.jayachandran@gmail.com) Received: from mail-vw0-f54.google.com (mail-vw0-f54.google.com [209.85.212.54]) by mx1.freebsd.org (Postfix) with ESMTP id BAD218FC23; Tue, 27 Jul 2010 09:24:10 +0000 (UTC) Received: by vws7 with SMTP id 7so4038150vws.13 for ; Tue, 27 Jul 2010 02:24:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=T+wbIPQERPn7LzHvLknNSDzpU+ibs83d25iNpOiZEMw=; b=fLuAyBDOOxjuMlaB7PrwUx+IISobf/CQoK2nHnbVJn/VRfGzEf2S58AWB9MXtgfy3C eayiQT4aJM4QzUWbVOE3tISspuO84iRrfw/D1GsQqJmZkqqZ+JWzgPOTH9HDw7rYr8MC 6+tCycRd7QHKW+VP41KyCpCeHnH+aFHke/Zik= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=m4k3lsb4AwsTBAcqsFQkD0mFEIMdxWy+kwvNibLlJ8gHBCqOa99eY9a9csPHnLYJg6 VvXgAC2JoWnRYScHZxRQZNuXbotcINlAXpcla5LBIoYSteb9SIbyUENYuT/AFa8496zo meOTbB5iR+/0DcWpf8pe8akybyOeuj8Z1Cd5E= MIME-Version: 1.0 Received: by 10.220.62.136 with SMTP id x8mr4912621vch.10.1280222649705; Tue, 27 Jul 2010 02:24:09 -0700 (PDT) Received: by 10.220.195.11 with HTTP; Tue, 27 Jul 2010 02:24:09 -0700 (PDT) In-Reply-To: <4C4205CC.6080700@FreeBSD.org> References: <4C41A248.8090605@FreeBSD.org> <4C41B4CF.6080409@FreeBSD.org> <4C4205CC.6080700@FreeBSD.org> Date: Tue, 27 Jul 2010 14:54:09 +0530 Message-ID: From: "Jayachandran C." To: Alexander Motin Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: Randall Stewart , Neel Natu , freebsd-mips@freebsd.org 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: Tue, 27 Jul 2010 09:24:11 -0000 On Sun, Jul 18, 2010 at 1:04 AM, Alexander Motin wrote: > Jayachandran C. wrote: >> On XLR we would like to use the count/compare which is faster but less >> accurate on all cpus - we can have upto 32 cpus now. =A0We also have a >> PIC which can provide a better timestamp and timer interrupts. =A0This >> PIC timestamp can be read from all CPUs but the timer interrupt can be >> delivered to just one CPU at a time. =A0I think this is how we ended up >> with the current implementation, but any suggestions on how to improve >> this is welcome. As a first step, I have copied the count /compare code from mips with minor modifications into mips/rmi, this lets me boot up (checked in as r210528). I would like to add the PIC based clock next. > I would prefer to not mix the things. > > I think: > =A0- PIC timestamp looks like the best candidate for system timecounter. > =A0- per-CPU counters could be registered as per-CPU timecounters with > set_cputicker() - the main criteria there is a speed. > =A0- if per-CPU counters are synchronized between CPUs - they could be > registered as alternative timecounter for people who wish fastest > timecounting; if they are not - they are useless in that role. > =A0- both PIC timer and per-CPU comparators should be independently > registered as eventtimers - it is better to have two of them to from > accounting correctness PoV, and it will allow user to experiment which > one he likes more. > =A0- if there is any other timer hardware - it also should be registered = - > it will give additional flexibility. The per-cpu count/compare counters are not synchronized on XLR. So your suggestion would be to add a PIC based clock which calls tc_init() and et_register(), and to leave the set_cputicker() to be the count/compare? Also, with just the count/compare, I get these print on early mutiuser boot= up. --- calcru: runtime went backwards from 85936878 usec to 236488 usec for pid 1286 (rpcbind) calcru: runtime went backwards from 7158742 usec to 19700 usec for pid 1285 (nfsiod 0) calcru: runtime went backwards from 111005442 usec to 305474 usec for pid 1257 (syslogd) calcru: runtime went backwards from 10740196 usec to 29555 usec for pid 1048 (devd) -- Did not get much time to investigate, any idea what the cause can be? Thanks, JC. From owner-freebsd-mips@FreeBSD.ORG Tue Jul 27 12:35:36 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 B18C61065677; Tue, 27 Jul 2010 12:35:36 +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 1548E8FC13; Tue, 27 Jul 2010 12:35:35 +0000 (UTC) Received: by fxm13 with SMTP id 13so593612fxm.13 for ; Tue, 27 Jul 2010 05:35:34 -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=50WwlFyByheXnakUGs2H8Ib4y6ChtRlDSL1rNrSXm98=; b=qE9DtJZwuibEaXm65o2rgSQOSlRz7meTyZBw2aqYELm2GRXk6DSapMkffSUaFpD8cl asDYmgJh9IQozPPhmkbvJ/4CSCSklnwxqxi0OXzbRBzUPe3Och5+WViQGFgYS5xICmzt 1QkGZOg82smM+gPcWdQtl2LsRotSGXRNAoazA= 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=tNHPN1BcUPbSpkm84vO6dCrtwdSZi4vqPabCtnAoSI/Kyn4iLGNpoxoxtUmo3Dle6I 3BSJPNAWlj/cyS+fzXUk59Lx5Y1ajKxJ+5vY1I+2g11LXxmAJodlTdOmA7blY6a6EDFU s2wZKggV/NGLG14y84wkTH4Z7MX6BqICjgXAg= Received: by 10.223.119.136 with SMTP id z8mr7972963faq.63.1280234133696; Tue, 27 Jul 2010 05:35:33 -0700 (PDT) Received: from mavbook2.mavhome.dp.ua (pc.mavhome.dp.ua [212.86.226.226]) by mx.google.com with ESMTPS id b36sm1883314faq.35.2010.07.27.05.35.31 (version=SSLv3 cipher=RC4-MD5); Tue, 27 Jul 2010 05:35:32 -0700 (PDT) Sender: Alexander Motin Message-ID: <4C4ED247.80701@FreeBSD.org> Date: Tue, 27 Jul 2010 15:34:15 +0300 From: Alexander Motin User-Agent: Thunderbird 2.0.0.23 (X11/20091212) MIME-Version: 1.0 To: "Jayachandran C." References: <4C41A248.8090605@FreeBSD.org> <4C41B4CF.6080409@FreeBSD.org> <4C4205CC.6080700@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 , Neel Natu , freebsd-mips@freebsd.org 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: Tue, 27 Jul 2010 12:35:36 -0000 Jayachandran C. wrote: > On Sun, Jul 18, 2010 at 1:04 AM, Alexander Motin wrote: >> Jayachandran C. wrote: >>> On XLR we would like to use the count/compare which is faster but less >>> accurate on all cpus - we can have upto 32 cpus now. We also have a >>> PIC which can provide a better timestamp and timer interrupts. This >>> PIC timestamp can be read from all CPUs but the timer interrupt can be >>> delivered to just one CPU at a time. I think this is how we ended up >>> with the current implementation, but any suggestions on how to improve >>> this is welcome. > > As a first step, I have copied the count /compare code from mips with > minor modifications into mips/rmi, this lets me boot up (checked in as > r210528). > > I would like to add the PIC based clock next. Thanks. >> I would prefer to not mix the things. >> >> I think: >> - PIC timestamp looks like the best candidate for system timecounter. >> - per-CPU counters could be registered as per-CPU timecounters with >> set_cputicker() - the main criteria there is a speed. >> - if per-CPU counters are synchronized between CPUs - they could be >> registered as alternative timecounter for people who wish fastest >> timecounting; if they are not - they are useless in that role. >> - both PIC timer and per-CPU comparators should be independently >> registered as eventtimers - it is better to have two of them to from >> accounting correctness PoV, and it will allow user to experiment which >> one he likes more. >> - if there is any other timer hardware - it also should be registered - >> it will give additional flexibility. > > The per-cpu count/compare counters are not synchronized on XLR. Then tick_ticker() function looks broken. counter_lower_last and counter_upper should be tracked per-CPU. Otherwise you will have huge forward jumps due to false overflows. > So your suggestion would be to add a PIC based clock which calls > tc_init() and et_register(), and to leave the set_cputicker() to be > the count/compare? Yes. And I would leave count/compare also calling tc_init() and et_register() as it is now. It won't hurt. > Also, with just the count/compare, I get these print on early mutiuser bootup. > --- > calcru: runtime went backwards from 85936878 usec to 236488 usec for > pid 1286 (rpcbind) > calcru: runtime went backwards from 7158742 usec to 19700 usec for pid > 1285 (nfsiod 0) > calcru: runtime went backwards from 111005442 usec to 305474 usec for > pid 1257 (syslogd) > calcru: runtime went backwards from 10740196 usec to 29555 usec for > pid 1048 (devd) > -- > Did not get much time to investigate, any idea what the cause can be? I think it can easily be result of broken tick_ticker(). -- Alexander Motin From owner-freebsd-mips@FreeBSD.ORG Tue Jul 27 14:43:32 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 C05451065673; Tue, 27 Jul 2010 14:43:32 +0000 (UTC) (envelope-from c.jayachandran@gmail.com) Received: from mail-vw0-f54.google.com (mail-vw0-f54.google.com [209.85.212.54]) by mx1.freebsd.org (Postfix) with ESMTP id 1C4188FC15; Tue, 27 Jul 2010 14:43:31 +0000 (UTC) Received: by vws7 with SMTP id 7so4356150vws.13 for ; Tue, 27 Jul 2010 07:43:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type; bh=qF2ZIuysJvnJRKyDicd0BdfFC3VXaP7U6u5djvCF68M=; b=FbwK/Uc6XE6rZ1TaLe23chvs0n3la1LmeCy1Me9gYfhtPK1CKWWCp1sftsNOVkVcAC BCA45LdmjeJdCql2kXkhFhgxMgyGcRMeI66Sa9n4YlNaVls8gQp7/SD2kJwYWCKt1jXY OeAiVrAsAdiAuXY9ngZ8zaRCfQaqgF5zMxrTw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=GUSE9osr0ToBybmXfcBOxra8V9PyjbYdw8qMR1OQk9gpPHAKsqL8qLBxjJ06PsnVmy 9CyFGOz05GPWx1CZFU2uG8xjvGhiK7yrwc7zdTlqZpILm/XXr3EJch4NYeTJVD4lZE7S FNTuszO8tlsgvxZ5wxuUs+/SRX/B6vBri0EbE= MIME-Version: 1.0 Received: by 10.220.89.68 with SMTP id d4mr5146552vcm.98.1280241810782; Tue, 27 Jul 2010 07:43:30 -0700 (PDT) Received: by 10.220.195.11 with HTTP; Tue, 27 Jul 2010 07:43:30 -0700 (PDT) In-Reply-To: <4C4ED247.80701@FreeBSD.org> References: <4C41A248.8090605@FreeBSD.org> <4C41B4CF.6080409@FreeBSD.org> <4C4205CC.6080700@FreeBSD.org> <4C4ED247.80701@FreeBSD.org> Date: Tue, 27 Jul 2010 20:13:30 +0530 Message-ID: From: "Jayachandran C." To: Alexander Motin Content-Type: multipart/mixed; boundary=0016364ed2685bb957048c5f86b6 Cc: Randall Stewart , Neel Natu , freebsd-mips@freebsd.org 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: Tue, 27 Jul 2010 14:43:32 -0000 --0016364ed2685bb957048c5f86b6 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On Tue, Jul 27, 2010 at 6:04 PM, Alexander Motin wrote: > Jayachandran C. wrote: >> On Sun, Jul 18, 2010 at 1:04 AM, Alexander Motin wrote= : >>> Jayachandran C. wrote: >>>> On XLR we would like to use the count/compare which is faster but less >>>> accurate on all cpus - we can have upto 32 cpus now. =A0We also have a >>>> PIC which can provide a better timestamp and timer interrupts. =A0This >>>> PIC timestamp can be read from all CPUs but the timer interrupt can be >>>> delivered to just one CPU at a time. =A0I think this is how we ended u= p >>>> with the current implementation, but any suggestions on how to improve >>>> this is welcome. >> >> As a first step, I have copied the count /compare code from mips with >> minor modifications into mips/rmi, this lets me boot up (checked in as >> r210528). >> >> I would like to add the PIC based clock next. > > Thanks. > >>> I would prefer to not mix the things. >>> >>> I think: >>> =A0- PIC timestamp looks like the best candidate for system timecounter= . >>> =A0- per-CPU counters could be registered as per-CPU timecounters with >>> set_cputicker() - the main criteria there is a speed. >>> =A0- if per-CPU counters are synchronized between CPUs - they could be >>> registered as alternative timecounter for people who wish fastest >>> timecounting; if they are not - they are useless in that role. >>> =A0- both PIC timer and per-CPU comparators should be independently >>> registered as eventtimers - it is better to have two of them to from >>> accounting correctness PoV, and it will allow user to experiment which >>> one he likes more. >>> =A0- if there is any other timer hardware - it also should be registere= d - >>> it will give additional flexibility. >> >> The per-cpu count/compare counters are not synchronized on XLR. > > Then tick_ticker() function looks broken. counter_lower_last and > counter_upper should be tracked per-CPU. Otherwise you will have huge > forward jumps due to false overflows. > >> So your suggestion would be to add a PIC based clock which calls >> tc_init() and et_register(), and to leave the set_cputicker() to be >> the count/compare? > > Yes. And I would leave count/compare also calling tc_init() and > et_register() as it is now. It won't hurt. > >> Also, with just the count/compare, I get these print on early mutiuser b= ootup. >> --- >> calcru: runtime went backwards from 85936878 usec to 236488 usec for >> pid 1286 (rpcbind) >> calcru: runtime went backwards from 7158742 usec to 19700 usec for pid >> 1285 (nfsiod 0) >> calcru: runtime went backwards from 111005442 usec to 305474 usec for >> pid 1257 (syslogd) >> calcru: runtime went backwards from 10740196 usec to 29555 usec for >> pid 1048 (devd) >> -- >> Did not get much time to investigate, any idea what the cause =A0can be? > > I think it can easily be result of broken tick_ticker(). I'm planning to check-in the attached patch for mips/rmi, I think mips/mips would need something similar. JC. --0016364ed2685bb957048c5f86b6 Content-Type: text/x-patch; charset=US-ASCII; name="ticker.patch" Content-Disposition: attachment; filename="ticker.patch" Content-Transfer-Encoding: base64 X-Attachment-Id: f_gc4uytwl0 SW5kZXg6IHN5cy9taXBzL3JtaS90aWNrLmMKPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQotLS0gc3lzL21pcHMvcm1pL3Rp Y2suYwkocmV2aXNpb24gMjEwNTM0KQorKysgc3lzL21pcHMvcm1pL3RpY2suYwkod29ya2luZyBj b3B5KQpAQCAtNjIsOSArNjIsOCBAQAogc3RhdGljIERQQ1BVX0RFRklORSh1aW50MzJfdCwgY3lj bGVzX3Blcl90aWNrKTsKIHN0YXRpYyB1aW50MzJfdCBjeWNsZXNfcGVyX3VzZWM7CiAKLXN0YXRp YyB1X2ludDMyX3QgY291bnRlcl91cHBlciA9IDA7Ci1zdGF0aWMgdV9pbnQzMl90IGNvdW50ZXJf bG93ZXJfbGFzdCA9IDA7Ci0KK3N0YXRpYyBEUENQVV9ERUZJTkUodWludDMyX3QsIGNvdW50ZXJf dXBwZXIpOworc3RhdGljIERQQ1BVX0RFRklORSh1aW50MzJfdCwgY291bnRlcl9sb3dlcl9sYXN0 KTsKIHN0YXRpYyBEUENQVV9ERUZJTkUodWludDMyX3Qs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Sw5IEBACiAJCW1pcHNf d3JfY29tcGFyZSgweGZmZmZmZmZmKTsKIAogCWNyaXRpY2FsX2VudGVyKCk7Ci0JaWYgKGNvdW50 IDwgY291bnRlcl9sb3dlcl9sYXN0KSB7Ci0JCWNvdW50ZXJfdXBwZXIrKzsKLQkJY291bnRlcl9s b3dlcl9sYXN0ID0gY291bnQ7CisJaWYgKGNvdW50IDwgRFBDUFVfR0VUKGNvdW50ZXJfbG93ZXJf bGFzdCkpIHsKKwkJRFBDUFVfU0VUKGNvdW50ZXJfdXBwZXIsIERQQ1BVX0dFVChjb3VudGVyX3Vw cGVyKSArIDEpOworCQlEUENQVV9TRVQoY291bnRlcl9sb3dlcl9sYXN0LCBjb3VudCk7CiAJfQog CiAJaWYgKGN5Y2xlc19wZXJfdGljayA+IDApIHsK --0016364ed2685bb957048c5f86b6-- From owner-freebsd-mips@FreeBSD.ORG Tue Jul 27 14:46:19 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 746AA1065673; Tue, 27 Jul 2010 14:46:19 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (bsdimp.com [199.45.160.85]) by mx1.freebsd.org (Postfix) with ESMTP id 13CC88FC0C; Tue, 27 Jul 2010 14:46:18 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by harmony.bsdimp.com (8.14.3/8.14.1) with ESMTP id o6REZ3pf078053; Tue, 27 Jul 2010 08:35:04 -0600 (MDT) (envelope-from imp@bsdimp.com) Date: Tue, 27 Jul 2010 08:35:43 -0600 (MDT) Message-Id: <20100727.083543.653774248293717664.imp@bsdimp.com> To: c.jayachandran@gmail.com From: "M. Warner Losh" In-Reply-To: References: <4C4205CC.6080700@FreeBSD.org> X-Mailer: Mew version 6.3 on Emacs 22.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Cc: rrs@FreeBSD.org, mav@FreeBSD.org, neel@FreeBSD.org, freebsd-mips@FreeBSD.org 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: Tue, 27 Jul 2010 14:46:19 -0000 In message: "Jayachandran C." writes: : > I would prefer to not mix the things. : > : > I think: : > =A0- PIC timestamp looks like the best candidate for system timecou= nter. : > =A0- per-CPU counters could be registered as per-CPU timecounters w= ith : > set_cputicker() - the main criteria there is a speed. : > =A0- if per-CPU counters are synchronized between CPUs - they could= be : > registered as alternative timecounter for people who wish fastest : > timecounting; if they are not - they are useless in that role. : > =A0- both PIC timer and per-CPU comparators should be independently= : > registered as eventtimers - it is better to have two of them to fro= m : > accounting correctness PoV, and it will allow user to experiment wh= ich : > one he likes more. : > =A0- if there is any other timer hardware - it also should be regis= tered - : > it will give additional flexibility. : = : The per-cpu count/compare counters are not synchronized on XLR. The Octeon processors have a register to force them to be synchronized. Once synchronized, except for some weird debug scenarios, they stay synchronized. Does the XLR advanced the count counters at the same rate on all the core at the same time? : So your suggestion would be to add a PIC based clock which calls : tc_init() and et_register(), and to leave the set_cputicker() to be : the count/compare? : = : Also, with just the count/compare, I get these print on early mutiuse= r bootup. : --- : calcru: runtime went backwards from 85936878 usec to 236488 usec for : pid 1286 (rpcbind) : calcru: runtime went backwards from 7158742 usec to 19700 usec for pi= d : 1285 (nfsiod 0) : calcru: runtime went backwards from 111005442 usec to 305474 usec for= : pid 1257 (syslogd) : calcru: runtime went backwards from 10740196 usec to 29555 usec for : pid 1048 (devd) : -- : Did not get much time to investigate, any idea what the cause can be= ? Is this multicore? Warner From owner-freebsd-mips@FreeBSD.ORG Tue Jul 27 14:56:30 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 8CF7D1065673; Tue, 27 Jul 2010 14:56:30 +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 B91138FC12; Tue, 27 Jul 2010 14:56:29 +0000 (UTC) Received: by fxm13 with SMTP id 13so679790fxm.13 for ; Tue, 27 Jul 2010 07:56:28 -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=Mtjb1Armyt4QscoMMK/CWrJJQBLkL38+0Wf+ko0EAOk=; b=Mc3lMOqYRoo5doy7g7DkDtunhhg/J1roqu8EB4PEXqcT5y920FkZedbdERl/WMO6n8 UXQ0YJPE8UWgAtDFoA5QioF/LDun4ocmJb1yk/sxUDMCefcckRLrU7SXU3Dk3qkcDPuD C5dbWzZGGijurzL0Qv0Fshe6KMBGkJRWsyzT8= 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=IFmwEq3Cln0ycUp2YQxUR9unyFGnwP1lFhmJnxL3Zi9C9TJFRhowTdveTRdfrxuikO kLjoW650+WA1Qyiz53wlWVNr5Hu8nIDEnTMTGqkTbBq9r1p7HelSuWi8Hq+NWsOSQ3cK CrSHOOV3/kc3t8v2vns6ixb+dgwdD5Jf42sdg= Received: by 10.223.125.196 with SMTP id z4mr8154214far.80.1280242588553; Tue, 27 Jul 2010 07:56:28 -0700 (PDT) Received: from mavbook.mavhome.dp.ua (pc.mavhome.dp.ua [212.86.226.226]) by mx.google.com with ESMTPS id r5sm1952423faq.32.2010.07.27.07.56.26 (version=SSLv3 cipher=RC4-MD5); Tue, 27 Jul 2010 07:56:27 -0700 (PDT) Sender: Alexander Motin Message-ID: <4C4EF398.1050507@FreeBSD.org> Date: Tue, 27 Jul 2010 17:56:24 +0300 From: Alexander Motin User-Agent: Thunderbird 2.0.0.24 (X11/20100402) MIME-Version: 1.0 To: "Jayachandran C." 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 , Neel Natu , freebsd-mips@freebsd.org 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: Tue, 27 Jul 2010 14:56:30 -0000 Jayachandran C. wrote: > On Tue, Jul 27, 2010 at 6:04 PM, Alexander Motin wrote: >> Jayachandran C. wrote: >>> Also, with just the count/compare, I get these print on early mutiuser bootup. >>> --- >>> calcru: runtime went backwards from 85936878 usec to 236488 usec for >>> pid 1286 (rpcbind) >>> calcru: runtime went backwards from 7158742 usec to 19700 usec for pid >>> 1285 (nfsiod 0) >>> calcru: runtime went backwards from 111005442 usec to 305474 usec for >>> pid 1257 (syslogd) >>> calcru: runtime went backwards from 10740196 usec to 29555 usec for >>> pid 1048 (devd) >>> -- >>> Did not get much time to investigate, any idea what the cause can be? >> I think it can easily be result of broken tick_ticker(). > > I'm planning to check-in the attached patch for mips/rmi, I think > mips/mips would need something similar. Looks fine. Does it help? -- Alexander Motin From owner-freebsd-mips@FreeBSD.ORG Tue Jul 27 15:06:35 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 D0E8E1065672; Tue, 27 Jul 2010 15:06:35 +0000 (UTC) (envelope-from c.jayachandran@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 D41608FC19; Tue, 27 Jul 2010 15:06:34 +0000 (UTC) Received: by fxm13 with SMTP id 13so689961fxm.13 for ; Tue, 27 Jul 2010 08:06:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=gOgY2bO44C2F9eDB5jtCu3Nu7G4Tj0uWd8CQCEs1vDU=; b=g9MYhuRveqWmJGslyUwnSy6mOFvWkPl70W075j8NF3mdqEh8w9h8eDx6S1c9vYRuuA UE69uICAzWuPAYkzymbOlRoE9DeSQxNi0jSoYJWABwiLmNVSvWM1/PMJTye54xFcnWWI BlNEoj7ei+lHHl6xtEwlxiRfIcnPKdALdRPIo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=jpgwMQF7DLpUqEonncuDai4byQAODQwMWuAUOg8+gT+K3Ff6JB7RVRmps/Dd5Mwcms RRg6wkHyigTxgonUy0HeupY+i87+sbL60raJRmJqO1QfIdixcYs/VJ/0ybjCVpJrqe5/ reLmZwYmmstXDyRlteLMR4bUExA+u95FLB5d0= MIME-Version: 1.0 Received: by 10.103.218.19 with SMTP id v19mr1163722muq.11.1280243193649; Tue, 27 Jul 2010 08:06:33 -0700 (PDT) Received: by 10.220.195.11 with HTTP; Tue, 27 Jul 2010 08:06:33 -0700 (PDT) In-Reply-To: <20100727.083543.653774248293717664.imp@bsdimp.com> References: <4C4205CC.6080700@FreeBSD.org> <20100727.083543.653774248293717664.imp@bsdimp.com> Date: Tue, 27 Jul 2010 20:36:33 +0530 Message-ID: From: "Jayachandran C." To: "M. Warner Losh" Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: rrs@freebsd.org, mav@freebsd.org, neel@freebsd.org, freebsd-mips@freebsd.org 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: Tue, 27 Jul 2010 15:06:36 -0000 On Tue, Jul 27, 2010 at 8:05 PM, M. Warner Losh wrote: > In message: > =A0 =A0 =A0 =A0 =A0 =A0"Jayachandran C." write= s: > : > I would prefer to not mix the things. > : > > : > I think: > : > =A0- PIC timestamp looks like the best candidate for system timecount= er. > : > =A0- per-CPU counters could be registered as per-CPU timecounters wit= h > : > set_cputicker() - the main criteria there is a speed. > : > =A0- if per-CPU counters are synchronized between CPUs - they could b= e > : > registered as alternative timecounter for people who wish fastest > : > timecounting; if they are not - they are useless in that role. > : > =A0- both PIC timer and per-CPU comparators should be independently > : > registered as eventtimers - it is better to have two of them to from > : > accounting correctness PoV, and it will allow user to experiment whic= h > : > one he likes more. > : > =A0- if there is any other timer hardware - it also should be registe= red - > : > it will give additional flexibility. > : > : The per-cpu count/compare counters are not synchronized on XLR. > > The Octeon processors have a register to force them to be > synchronized. =A0Once synchronized, except for some weird debug > scenarios, they stay synchronized. > > Does the XLR advanced the count counters at the same rate on all the > core at the same time? They are incremented at the same rate, but can set to different values on different cpus. The clocks are not hardware synchronized across cores, so they probably can drift over time, even though I'm not completely sure if this is significant. > : So your suggestion would be to add a PIC based clock which calls > : tc_init() and et_register(), and to leave the set_cputicker() to be > : the count/compare? > : > : Also, with just the count/compare, I get these print on early mutiuser = bootup. > : --- > : calcru: runtime went backwards from 85936878 usec to 236488 usec for > : pid 1286 (rpcbind) > : calcru: runtime went backwards from 7158742 usec to 19700 usec for pid > : 1285 (nfsiod 0) > : calcru: runtime went backwards from 111005442 usec to 305474 usec for > : pid 1257 (syslogd) > : calcru: runtime went backwards from 10740196 usec to 29555 usec for > : pid 1048 (devd) > : -- > : Did not get much time to investigate, any idea what the cause =A0can be= ? > > Is this multicore? yes - the changes suggested by mav@ seems to fixed it. JC. From owner-freebsd-mips@FreeBSD.ORG Tue Jul 27 15:16:25 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 3B832106566B; Tue, 27 Jul 2010 15:16:25 +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 62EE38FC1E; Tue, 27 Jul 2010 15:16:24 +0000 (UTC) Received: by fxm13 with SMTP id 13so699415fxm.13 for ; Tue, 27 Jul 2010 08:16:23 -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=b+TzLLoLKmn80tdk1lPv+N3fcuO5qpAokbRD9D58zCc=; b=fjZDdQ9xy24ufTZoj4xkLv1qtUbuQvbO4Ii68uy7MgxUlP+wcAYrdIxhB9zw7lizZj z5lcIdFmx1WRiB0OxBhWiHSOQXQDdwTslYM0Y/FXfb4pZsSCLlwXLds/f7HBMf9cuH4h wlPUgzwx0KZbLvPknm+7BlBGJfOPgUUKArpTc= 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=NgEDDnDNmKpzWrAIN4Ly+j7OnW2b1Ac07nSMKKyQXxJ57cBGRFOY3ioLBNudXFIeKq LRfVfaX2uqcbKqLnGn/c/wB41iGbr0ENjEJBoPhH2AgFI9Am1Q6mlz1JShfW1uuNPYrE OvzinOL7jNkY0moeL1aCv4gdoaWxIoc70Zjck= Received: by 10.223.104.7 with SMTP id m7mr8282973fao.8.1280243783348; Tue, 27 Jul 2010 08:16:23 -0700 (PDT) Received: from mavbook.mavhome.dp.ua (pc.mavhome.dp.ua [212.86.226.226]) by mx.google.com with ESMTPS id r8sm1967032faq.34.2010.07.27.08.16.21 (version=SSLv3 cipher=RC4-MD5); Tue, 27 Jul 2010 08:16:22 -0700 (PDT) Sender: Alexander Motin Message-ID: <4C4EF842.5020103@FreeBSD.org> Date: Tue, 27 Jul 2010 18:16:18 +0300 From: Alexander Motin User-Agent: Thunderbird 2.0.0.24 (X11/20100402) MIME-Version: 1.0 To: "Jayachandran C." References: <4C41A248.8090605@FreeBSD.org> <4C41B4CF.6080409@FreeBSD.org> <4C4205CC.6080700@FreeBSD.org> <4C4ED247.80701@FreeBSD.org> <4C4EF398.1050507@FreeBSD.org> In-Reply-To: <4C4EF398.1050507@FreeBSD.org> X-Enigmail-Version: 0.96.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: Randall Stewart , Neel Natu , freebsd-mips@freebsd.org 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: Tue, 27 Jul 2010 15:16:25 -0000 Alexander Motin wrote: > Jayachandran C. wrote: >> On Tue, Jul 27, 2010 at 6:04 PM, Alexander Motin wrote: >>> Jayachandran C. wrote: >>>> Also, with just the count/compare, I get these print on early mutiuser bootup. >>>> --- >>>> calcru: runtime went backwards from 85936878 usec to 236488 usec for >>>> pid 1286 (rpcbind) >>>> calcru: runtime went backwards from 7158742 usec to 19700 usec for pid >>>> 1285 (nfsiod 0) >>>> calcru: runtime went backwards from 111005442 usec to 305474 usec for >>>> pid 1257 (syslogd) >>>> calcru: runtime went backwards from 10740196 usec to 29555 usec for >>>> pid 1048 (devd) >>>> -- >>>> Did not get much time to investigate, any idea what the cause can be? >>> I think it can easily be result of broken tick_ticker(). >> I'm planning to check-in the attached patch for mips/rmi, I think >> mips/mips would need something similar. > > Looks fine. Does it help? Sorry, after looked again, I've got one question. Why this: + DPCPU_SET(counter_upper, t_upper); + DPCPU_SET(counter_lower_last, t_lower_last); was moved out of the critical section? Due to the per-CPU nature of this function it probably always called inside critical section, so there is no problem I think. But IMHO either critical section calls there are unneeded, or above sets and mips_rd_count() worth moving inside of it. -- Alexander Motin From owner-freebsd-mips@FreeBSD.ORG Tue Jul 27 15:40: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 95B391065678; Tue, 27 Jul 2010 15:40:42 +0000 (UTC) (envelope-from c.jayachandran@gmail.com) Received: from mail-pw0-f54.google.com (mail-pw0-f54.google.com [209.85.160.54]) by mx1.freebsd.org (Postfix) with ESMTP id 4AD028FC12; Tue, 27 Jul 2010 15:40:42 +0000 (UTC) Received: by pwj9 with SMTP id 9so596621pwj.13 for ; Tue, 27 Jul 2010 08:40:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=U/ufVlYPHTmUuRU7pVDjdSr0HyjcPh/pGjQsrg/WC7c=; b=uIFCh+nXPhrylfILS5CrGhbDam8m3UpETo8N2CPviqi9Tf6ZGJ0zBZ2tvHBRiF+aOb A4PdRUM9F6sIHGGtGrDdU6vB63bNf39Y4MXqPgS4RihQOe8UF5FrnNi29U5wR4uVHEIi 4y3sju4ad3s+BhnONjZjXfnYZfDgozmIeEA04= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=qIMhco8U4TFay5e0iMzc13ede0wQ2dUsIREOqlGq4kaH2XdkAniXKl1Wo27QSQiWB7 qTGxES47uYv0+oERcE0WtaOD4WXw6+4c2VSnI3jzTNa7f8b1TaDzZuDY0ya5gGY0W5DM XDhYybRGGMsCESlaWgrJjMXpBDarb4OkD8yBY= MIME-Version: 1.0 Received: by 10.142.246.20 with SMTP id t20mr4715508wfh.199.1280245241557; Tue, 27 Jul 2010 08:40:41 -0700 (PDT) Received: by 10.220.195.11 with HTTP; Tue, 27 Jul 2010 08:40:41 -0700 (PDT) In-Reply-To: <4C4EF842.5020103@FreeBSD.org> References: <4C41A248.8090605@FreeBSD.org> <4C41B4CF.6080409@FreeBSD.org> <4C4205CC.6080700@FreeBSD.org> <4C4ED247.80701@FreeBSD.org> <4C4EF398.1050507@FreeBSD.org> <4C4EF842.5020103@FreeBSD.org> Date: Tue, 27 Jul 2010 21:10:41 +0530 Message-ID: From: "Jayachandran C." To: Alexander Motin Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: Randall Stewart , Neel Natu , freebsd-mips@freebsd.org 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: Tue, 27 Jul 2010 15:40:42 -0000 On Tue, Jul 27, 2010 at 8:46 PM, Alexander Motin wrote: > Alexander Motin wrote: >> Jayachandran C. wrote: >>> On Tue, Jul 27, 2010 at 6:04 PM, Alexander Motin wrot= e: >>>> Jayachandran C. wrote: >>>>> Also, with just the count/compare, I get these print on early mutiuse= r bootup. >>>>> --- >>>>> calcru: runtime went backwards from 85936878 usec to 236488 usec for >>>>> pid 1286 (rpcbind) >>>>> calcru: runtime went backwards from 7158742 usec to 19700 usec for pi= d >>>>> 1285 (nfsiod 0) >>>>> calcru: runtime went backwards from 111005442 usec to 305474 usec for >>>>> pid 1257 (syslogd) >>>>> calcru: runtime went backwards from 10740196 usec to 29555 usec for >>>>> pid 1048 (devd) >>>>> -- >>>>> Did not get much time to investigate, any idea what the cause =A0can = be? >>>> I think it can easily be result of broken tick_ticker(). >>> I'm planning to check-in the attached patch for mips/rmi, I think >>> mips/mips would need something similar. >> >> Looks fine. Does it help? > > Sorry, after looked again, I've got one question. Why this: > > + =A0 =A0 =A0 DPCPU_SET(counter_upper, t_upper); > + =A0 =A0 =A0 DPCPU_SET(counter_lower_last, t_lower_last); > > was moved out of the critical section? Due to the per-CPU nature of this > function it probably always called inside critical section, so there is > no problem I think. But IMHO either critical section calls there are > unneeded, or above sets and mips_rd_count() worth moving inside of it. I missed the critical section, I will move the DPCPU_SET and into the critical section, since it is an obvious mistake I introduced. There is a critical_enter/exit in cpu_intr too, with mips_rd_count() outsid= e.. Thanks, JC. From owner-freebsd-mips@FreeBSD.ORG Tue Jul 27 20:34:20 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 659861065672; Tue, 27 Jul 2010 20:34:20 +0000 (UTC) (envelope-from c.jayachandran@gmail.com) Received: from mail-vw0-f54.google.com (mail-vw0-f54.google.com [209.85.212.54]) by mx1.freebsd.org (Postfix) with ESMTP id 964958FC0A; Tue, 27 Jul 2010 20:34:19 +0000 (UTC) Received: by vws7 with SMTP id 7so4544317vws.13 for ; Tue, 27 Jul 2010 13:34:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:date:message-id :subject:from:to:cc:content-type; bh=QtQf8gydh5xRdLBk3AjqRjlzmfvUnLp9wgE6N69s9sE=; b=as6ozdaQEOcprRFvVuoyP5LD39Z9a52GWfhdOrzCE00lNjrl3g+jy6hRh2m4Z0MbHE mOhzGsZZUfidYcDKoqW7NR8T+smeqjOqv6Ol50ZZjtKGLtLJn+XcSWrjTgNJl5Nsw6cN XxlmT6byGVtMxsqcGPOlBUcLXFz4DT5DHNyDk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:cc:content-type; b=UqA2s94JV3N22qNPeS1UmDWehKQ6PTq4BmM97VOUQHJcfvbK58odMjFcBT8VdT9/N5 PHoC6et9s/r7TYam+MFk7GdN441ii80dIBkp+tYtEGxNdqiY3S9eLRj+KXVPxPETjAvr rktNTv1zotHSay7zvGjR9p14ujngC3t2Xdv4M= MIME-Version: 1.0 Received: by 10.220.71.136 with SMTP id h8mr5486412vcj.275.1280262857389; Tue, 27 Jul 2010 13:34:17 -0700 (PDT) Received: by 10.220.195.11 with HTTP; Tue, 27 Jul 2010 13:34:14 -0700 (PDT) Date: Wed, 28 Jul 2010 02:04:14 +0530 Message-ID: From: "Jayachandran C." To: freebsd-mips@freebsd.org Content-Type: multipart/mixed; boundary=0016e64757dcd58fd3048c646c04 Cc: Subject: Support for 64bit userspace. 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: Tue, 27 Jul 2010 20:34:20 -0000 --0016e64757dcd58fd3048c646c04 Content-Type: text/plain; charset=ISO-8859-1 Here's my initial work to get 64bit user space. With this set of changes, I can boot to the single user shell with n64 /sbin/init and /bin/sh. There are still issues to fix, and the dynamic loader is still not working, but I think this would be a good time to get some initial feedback. The changes mainly add a 3 level page table for both userspace and kernel. The PTE entries are 32bit still (this will be changed to 64bit once I get the current code more stable) and the PDE entries are 64 bit, which would give us 40bit (9+9+10+12) virtual address space. Managing a both 32bit and 64 bit pagetables in one pmap.c was tough, so I have moved all the 64bit pmap code to a new file pmap64.c, and added a config option for 64bit. But otherwise the 32bit code is almost completely untouched. But once things are stable, we can see if some part of pmap.c and pmap64.c can be move to a common file. The changes have been grouped into (files are also at http://people.freebsd.org/~jchandra/mips-n64/ ) mips-n64-other.patch - header file and other minor changes - param.h - add PDRSHIFT/MASK for mid-level, rename SEGOFSET to SEGMASK for consistency. - _stdint.h/profile.h - 64 bit defs I missed in the last pass - vm_machdep.c/pm_machdep.c - add UX bit to status register where needed. mips-n64-asm.patch - changes for assembly files - exception.S - add second level page table lookup - excption.S/locore.S - enable UX in status - exception.S - the kernel stack is in XKSEG, so we need to set KX before saving registers - support.S - fuword should be 64bit in n64 - swtch.S kstack in XKSEG mips-n64-pmap.patch - move 64bit code to pmap64.c - revert the 64bit additions to pmap.c - create pmap64.c which will be used in 64 bit compilation, (this has some debugging code still in there, and there are still a few issues I'm looking at) mips-n64-config.patch - add config option for 64bit compile, so that we pick pmap.c in 32bit and pmap64.c in 64bit compile. I'm not sure if there is a better way to do this,. - options.mips, mips/conf/DEFAULTS - adds options KERNEL_32 and KERNEL_64, make KERNEL_32 default option - files.mips - use pmap.c or pmap64.c depending on kernel_32 or kernel_64 rmi-n64-rge.patch - support for 64 bit in RMI gmac driver. Let me know your comments (buildworld needs -DWITHOUT_DYNAMICROOT -DWITHOUT_CDDL -DWITHOUT_USB -DWITHOUT_BLUETOOTH, for now) Thanks, JC. --0016e64757dcd58fd3048c646c04 Content-Type: application/octet-stream; name="mips-n64-other.patch" Content-Disposition: attachment; filename="mips-n64-other.patch" Content-Transfer-Encoding: base64 X-Attachment-Id: f_gc55slvs0 SW5kZXg6IHN5cy9taXBzL2luY2x1ZGUvcGFyYW0uaAo9PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0tLSBzeXMvbWlwcy9p bmNsdWRlL3BhcmFtLmgJKHJldmlzaW9uIDIxMDUzNCkKKysrIHN5cy9taXBzL2luY2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RlZmluZWQoX19TVERD X0NPTlNUQU5UX01BQ1JPUykgKi8KIApJbmRleDogc3lzL21pcHMvaW5jbHVkZS9wcm9maWxlLmgK PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PQotLS0gc3lzL21pcHMvaW5jbHVkZS9wcm9maWxlLmgJKHJldmlzaW9uIDIxMDUz NCkKKysrIHN5cy9taXBzL2luY2x1ZGUvcHJvZmlsZS5oCSh3b3JraW5nIGNvcHkpCkBAIC0xMTUs NyArMTE1LDExIEBACiAKICNkZWZpbmUJRlVOQ1RJT05fQUxJR05NRU5UCTQKIAorI2lmZGVmIF9f bWlwc19uNjQKK3R5cGVkZWYgdW5zaWduZWQgbG9uZwl1aW50ZnB0cl90OworI2Vsc2UKIHR5cGVk ZWYgdW5zaWduZWQgaW50CXVpbnRmcHRyX3Q7CisjZW5kaWYKIAogI2VuZGlmIC8qIF9LRVJORUwg Ki8KIApAQCAtMTIzLDcgKzEyNywxMSBAQAogICogQW4gdW5zaWduZWQgaW50ZWdyYWwgdHlwZSB0 aGF0IGNhbiBob2xkIG5vbi1uZWdhdGl2ZSBkaWZmZXJlbmNlIGJldHdlZW4KICAqIGZ1bmN0aW9u IHBvaW50ZXJzLgogICovCisjaWZkZWYgX19taXBzX242NAordHlwZWRlZiB1X2xvbmcJZnB0cmRp ZmZfdDsKKyNlbHNlCiB0eXBlZGVmIHVfaW50CWZwdHJkaWZmX3Q7CisjZW5kaWYKIAogI2lmZGVm IF9LRVJORUwKIApJbmRleDogc3lzL21pcHMvaW5jbHVkZS9ydW5xLmgKPT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQotLS0g c3lzL21pcHMvaW5jbHVkZS9ydW5xLmgJKHJldmlzaW9uIDIxMDUzNCkKKysrIHN5cy9taXBzL2lu Y2x1ZGUvcnVucS5oCSh3b3JraW5nIGNvcHkpCkB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Npb24gMjEwNTM0KQorKysgc3lzL21pcHMvbWlwcy9wbV9tYWNo ZGVwLmMJKHdvcmtpbmcgY29weSkKQEAgLTQ4Niw4ICs0ODYsMTAgQEAKIAl0ZC0+dGRfZnJhbWUt PnQ5ID0gaW1ncC0+ZW50cnlfYWRkciAmIH4zOyAvKiBhYmljYWxsIHJlcSAqLwogCXRkLT50ZF9m cmFtZS0+c3IgPSBNSVBTX1NSX0tTVV9VU0VSIHwgTUlQU19TUl9FWEwgfCBNSVBTX1NSX0lOVF9J RSB8CiAJICAgIChtaXBzX3JkX3N0YXR1cygpICYgTUlQU19TUl9JTlRfTUFTSyk7Ci0jaWYgZGVm aW5lZChfX21pcHNfbjMyKSB8fCBkZWZpbmVkKF9fbWlwc19uNjQpCisjaWYgZGVmaW5lZChfX21p cHNfbjMyKSAKIAl0ZC0+dGRfZnJhbWUtPnNyIHw9IE1JUFNfU1JfUFg7CisjZWxpZiAgZGVmaW5l ZChfX21pcHNfbjY0KQorCXRkLT50ZF9mcmFtZS0+c3IgfD0gTUlQU19TUl9QWCB8IE1JUFNfU1Jf VVg7CiAjZW5kaWYKICNpZmRlZiBDUFVfQ05NSVBTCiAJdGQtPnRkX2ZyYW1lLT5zciB8PSBNSVBT X1NSX0NPUF8yX0JJVCB8IE1JUFNfU1JfUFggfCBNSVBTX1NSX1VYIHwK --0016e64757dcd58fd3048c646c04 Content-Type: application/octet-stream; name="mips-n64-asm.patch" Content-Disposition: attachment; filename="mips-n64-asm.patch" Content-Transfer-Encoding: base64 X-Attachment-Id: f_gc572v7t1 SW5kZXg6IHN5cy9taXBzL21pcHMvZXhjZXB0aW9uLlMKPT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQotLS0gc3lzL21pcHMv bWlwcy9leGNlcHRpb24uUwkocmV2aXNpb24gMjEwNTM0KQorKysgc3lzL21pcHMvbWlwcy9leGNl cHRpb24uUwkod29ya2luZyBjb3B5K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WIgb2Zmc2V0CiAJUFRS X0FERFUJazEsIGsxLCBrMAkJCSMgazE9cHRlIGFkZHJlc3MKSW5kZXg6IHN5cy9taXBzL21pcHMv Z2VuYXNzeW0uYwo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09Ci0tLSBzeXMvbWlwcy9taXBzL2dlbmFzc3ltLmMJKHJldmlz aW9uIDIxMDUzNCkKKysrIHN5cy9taXBzL21pcHMvZ2VuYXNzeW0uYwkod29ya2luZyBjb3B5KQpA QCAtOTQsNiArOTQsNyBAQAogQVNTWU0oUEFHRV9TSVpFLCBQQUdFX1NJWkUpOwogQVNTWU0oUEFH RV9NQVNLLCBQQUdFX01BU0spOwogQVNTWU0oU0VHU0hJRlQsIFNFR1NISUZUKTsKK0FTU1lNKFBE UlNISUZULCBQRFJTSElGVCk7CiBBU1NZTShOUFRFUEcsIE5QVEVQRyk7CiBBU1NZTShUREZfTkVF RFJFU0NIRUQsIFRERl9ORUVEUkVTQ0hFRCk7CiBBU1NZTShUREZfQVNUUEVORElORywgVERGX0FT VFBFTkRJTkcpOwpAQCAtMTAzLDMgKzEwNCw0IEBACiBBU1NZTShNSVBTX0tTRUcwX1NUQVJULCBN SVBTX0tTRUcwX1NUQVJUKTsKIEFTU1lNKE1JUFNfS1NFRzFfU1RBUlQsIE1JUFNfS1NFRzFfU1RB UlQpOwogQVNTWU0oTUlQU19LU0VHMl9TVEFSVCwgTUlQU19LU0VHMl9TVEFSVCk7CitBU1NZTShN SVBTX1hLU0VHX1NUQVJULCBNSVBTX1hLU0VHX1NUQVJUKTsKSW5kZXg6IHN5cy9taXBzL21pcHMv bG9jb3JlLlMKPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PQotLS0gc3lzL21pcHMvbWlwcy9sb2NvcmUuUwkocmV2aXNpb24g MjEwNTM0KQorKysgc3lzL21pcHMvbW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MChh MCkJCSMgZmV0Y2ggd29yZAorCWoJcmEKKwlQVFJfUwl6ZXJvLCBVX1BDQl9PTkZBVUxUKHYxKQor RU5EKGZ1d29yZDY0KQorI2VuZGlmCisKK0xFQUYoZnV3b3JkMzIpCisjaWYgIWRlZmluZWQoX19t aXBzX242NCkKK0FMRUFGKGZ1d29yZCkKKyNlbmRpZgorCVBUUl9MQQl2MCwgZnN3YmVycgorCWJs dAlhMCwgemVybywgZnN3YmVycgkjIG1ha2Ugc3VyZSBhZGRyZXNzIGlzIGluIHVzZXIgc3BhY2UK Kwlub3AKKwlHRVRfQ1BVX1BDUFUodjEpCisJUFRSX0wJdjEsIFBDX0NVUlBDQih2MSkKKwlQVFJf Uwl2MCwgVV9QQ0JfT05GQVVMVCh2MSkKIAlsdwl2MCwgMChhMCkJCSMgZmV0Y2ggd29yZAogCWoJ cmEKIAlQVFJfUwl6ZXJvLCBVX1BDQl9PTkZBVUxUKHYxKQotRU5EKGZ1d29yZCkKK0VORChmdXdv cmQzMikKIAogTEVBRihmdXN3b3JkKQogQUxFQUYoZnVpc3dvcmQpCg== --0016e64757dcd58fd3048c646c04 Content-Type: application/octet-stream; name="mips-n64-pmap.patch" Content-Disposition: attachment; filename="mips-n64-pmap.patch" Content-Transfer-Encoding: base64 X-Attachment-Id: f_gc572w172 SW5kZXg6IHN5cy9taXBzL21pcHMvcG1hcDY0LmMKPT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQotLS0gc3lzL21pcHMvbWlw cy9wbWFwNjQuYwkocmV2aXNpb24gMCkKKysrIHN5cy9taXBzL21pcHMvcG1hcDY0LmMJKHJldmlz aW9uIDApCkBAIC0wLDAgKzEsMzAwOCBAQAorLyoKKyAqIENvcHlyaWdodCAoYykgMTk5MSBSZWdl bnRzIG9mIHRoZSBVbml2ZXJzaXR5IG9mIENhbGlmb3JuaWEuCisgKiBBbGwgcmlnaHRzIHJlc2Vy dmVk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l2ZW4gbWFwL3ZpcnR1YWxfYWRkcmVzcyBwYWlyLgorICovCitwdF9lbnRyeV90ICoK K3BtYXBfcHRlKHBtYXBfdCBwbWFwLCB2bV9vZmZzZXRfdCB2YSkKK3sKKwlwZF9lbnRyeV90ICpw ZGU7CisJcHRfZW50cnlfdCAqcHRlOworCisJcGRlID0gcG1hcF9wZGUocG1hcCwgdmEpOworCWlm IChwZGUgPT0gTlVMTCB8fCAqcGRlID09IE5VTEwpCisJCXJldHVybiAoTlVMTCk7CisKKwlwdGUg PSAocHRfZW50cnlfdCAqKSpwZGU7CisJcmV0dXJuICgmcHRlW3BtYXBfcHRlX2luZGV4KHZhKV0p OworfQorCisKK3ZtX29mZnNldF90CitwbWFwX3N0ZWFsX21lbW9yeSh2bV9zaXplX3Qgc2l6ZSkK K3sKKwl2bV9zaXplX3QgYmFua19zaXplOworCXZtX29mZnNldF90IHBhLCB2YTsKKworCXNpemUg PSByb3VuZF9wYWdlKHNpemUpOworCisJYmFua19zaXplID0gcGh5c19hdmFpbFsxXSAtIHBoeXNf YXZhaWxbMF07CisJd2hpbGUgKHNpemUgPiBiYW5rX3NpemUpIHsKKwkJaW50IGk7CisKKwkJZm9y IChpID0gMDsgcGh5c19hdmFpbFtpICsgMl07IGkgKz0gMikgeworCQkJcGh5c19hdmFpbFtpXSA9 IHBoeXNfYXZhaWxbaSArIDJdOworCQkJcGh5c19hdmFpbFtpICsgMV0gPSBwaHlzX2F2YWlsW2kg KyAzXTsKKwkJfQorCQlwaHlzX2F2YWlsW2ldID0gMDsKKwkJcGh5c19hdmFpbFtpICsgMV0gPSAw OworCQlpZiAoIXBoeXNfYXZhaWxbMF0pCisJCQlwYW5pYygicG1hcF9zdGVhbF9tZW1vcnk6IG91 dCBvZiBtZW1vcnkiKTsKKwkJYmFua19zaXplID0gcGh5c19hdmFpbFsxXSAtIHBoeXNfYXZhaWxb MF07CisJfQorCisJcGEgPSBwaHlzX2F2YWlsWzBdOworCXBoeXNfYXZhaWxbM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wgVU1BX1pPTkVfVk0gfCBVTUFfWk9ORV9OT0ZSRUUpOworCXB2X2VudHJ5X21heCA9 IFBNQVBfU0hQR1BFUlBST0MgKiBtYXhwcm9jICsgY250LnZfcGFnZV9jb3VudDsKKwlwdl9lbnRy eV9oaWdoX3dhdGVyID0gOSAqIChwdl9lbnRyeV9tYXggLyAxMCk7CisJdW1hX3pvbmVfc2V0X29i aihwdnpvbmUsICZwdnpvbmVfb2JqLCBwdl9lbnRyeV9tYXgpOworfQorCisvKioqKioqKioqKioq KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisgKiBMb3cgbGV2ZWwgaGVs cGVyIHJvdXRpbmVzLi4uLi4KKyAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq KioqKioqKioqKioqKiovCisKKyNpZiBkZWZpbmVkKFBNQVBfRElBR05PU1RJQykKKworLyoKKyAq IFRoaXMgY29kZSBjaGVja3MgZm9yIG5vbi13cml0ZWFibGUvbW9kaWZpZWQgcGFnZXMuCisgKiBU aGlzIHNob3VsZCBiZSBhbiBpbnZhbGlkIGNvbmRpdGlvbi4KKyAqLworc3RhdGljIGludAorcG1h cF9ud19tb2RpZmllZChwdF9lbnRyeV90IHB0ZSkKK3sKKwlpZiAoKHB0ZSAmIChQVEVfRCB8IFBU RV9STykpID09IChQVEVfRCB8IFBURV9STykpCisJCXJldHVybiAoMSk7CisJZWxzZQorCQlyZXR1 cm4gKDApOworfQorCisjZW5kaWYKKworc3RhdGljIHZvaWQKK3BtYXBfaW52YWxpZGF0ZV9hbGwo cG1hcF90IHBtYXApCit7CisjaWZkZWYgU01QCisJc21wX3JlbmRlenZvdXMoMCwgcG1hcF9pbnZh bGlkYXRlX2FsbF9hY3Rpb24sIDAsICh2b2lkICopcG1hcCk7Cit9CisKK3N0YXRpYyB2b2lkCitw bWFwX2ludmFsaWRhdGVfYWxsX2FjdGlvbih2b2lkICphcmcpCit7CisJcG1hcF90IHBtYXAgPSAo cG1hcF90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JfQorfQorCisvKioqKioqKioqKioq KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisgKiBQYWdlIHRhYmxlIHBh Z2UgbWFuYWdlbWVudCByb3V0aW5lcy4uLi4uCisgKioqKioqKioqKioqKioqKioqKioqKioqKioq KioqKioqKioqKioqKioqKioqKioqKioqLworCisvKiAgUmV2aXNpb24gMS41MDcKKyAqCisgKiBT aW1wbGlmeSB0aGUgcmVmZXJlbmNlIGNvdW50aW5nIG9mIHBhZ2UgdGFibGUgcGFnZXMuCSBTcGVj aWZpY2FsbHksIHVzZQorICogdGhlIHBhZ2UgdGFibGUgcGFnZSdzIHdpcmVkIGNvdW50IHJhdGhl ciB0aGFuIGl0cyBob2xkIGNvdW50IHRvIGNvbnRhaW4KKyAqIHRoZSByZWZlcmVuY2UgY291bnQu CisgKi8KKworLyoKKyAqIFRoaXMgcm91dGluZSB1bmhvbGRzIHBhZ2UgdGFibGUgcGFnZXMsIGFu ZCBpZiB0aGUgaG9sZCBjb3VudAorICogZHJvcHMgdG8gemVybywgdGhlbiBpdCBkZWNyZW1lbnRz IHRoZSB3aXJlIGNvdW50LgorICovCitzdGF0aWMgUE1BUF9JTkxJTkUgaW50CitwbWFwX3Vud2ly ZV9wdGVfaG9sZChwbWFwX3QgcG1hcCwgdm1fb2Zmc2V0X3QgdmEsIHZtX3BhZ2VfdCBtKQorewor CS0tbS0+d2lyZV9jb3VudDsKKwlpZiAobS0+d2lyZV9jb3VudCA9PSAwKQorCQlyZXR1cm4gKF9w bWFwX3Vud2lyZV9wdGVfaG9sZChwbWFwLCB2YSwgbSkpOworCWVsc2UKKwkJcmV0dXJuICgwKTsK K30KKworc3RhdGljIGludAorX3BtYXBfdW53aXJlX3B0ZV9ob2xkKHBtYXBfdCBwbWFwLCB2bV9v ZmZzZXRfdCB2YSwgdm1fcGFnZV90IG0pCit7CisJcGRfZW50cnlfdCAqcGRlLCAqcGRwOworCXZt X3BhZ2VfdCBwZHBnOworCisgICAgICA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gdm1fcHJvdF90 IHByb3QpCit7CisJcHRfZW50cnlfdCAqcHRwYWRkciwgKnB0ZTsKKwlwZF9lbnRyeV90ICpwZHBl LCAqcGRlOworCXZtX29mZnNldF90IHZhX25leHQ7CisKKwlpZiAocG1hcCA9PSBOVUxMKQorCQly ZXR1cm47CisKKwlwcmludGYoIlBNQVAgcHJvdCBzdmEgJXAgZXZhICVwICV4XG4iLCh2b2lkICop c3ZhLCh2b2lkICopZXZhLCAoaW50KXByb3QpOworCWlmICgocHJvdCAmIFZNX1BST1RfUkVBRCkg PT0gVk1fUFJPVF9OT05FKSB7CisJCXBtYXBfcmVtb3ZlKHBtYXAsIHN2YSwgZXZhKTsKKwkJcmV0 dXJuOworCX0KKwlpZiAocHJvdCAmIFZNX1BST1RfV1JJVEUpCisJCXJldHVybjsKKworCXZtX3Bh Z2VfbG9ja19xdWV1ZXMoKTsKKwlQTUFQX0xPQ0socG1hcCk7CisJd2hpbGUgKHN2YSA8IGV2YSkg eworCQkvKgorCQkgKiBJZiBzZWdtZW50IHRhYmxlIGVudHJ5IGlzIGVtcHR5LCBza2lwIHRoaXMg c2VnbWVudC4KKwkJICovCisJCXBkcGUgPSBwbWFwX3NlZ21hcChwbWFwLCBzdmEpOworCQlpZiAo KnBkcGUgPT0gMCkgeworCQkJdmFfbmV4dCA9IChzdmEgKyBOQlNFRykgJiB+U0VHTUFTSzsKKwkJ CWlmICh2YV9uZXh0IDwgc3ZhKQorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YV9u ZXh0ID0gZXZhOworCQkJY29udGludWU7CisJCX0KKworCQl2YV9uZXh0ID0gKHN2YSArIE5CUERS KSAmIH5QRFJNQVNLOworICAgICAgICAgICAgICAgIGlmICh2YV9uZXh0IDwgc3ZhKQorICAgICAg ICAgICAgICAgICAgICAgICAgdmFfbmV4dCA9IGV2YTsKKworICAgICAgICAgICAgICAgIHBkZSA9 IHBtYXBfcGRwZV90b19wZGUocGRwZSwgc3ZhKTsKKyAgICAgICAgICAgICAgICBwdHBhZGRyID0g KnBkZTsKKworCQkvKgorICAgICAgICAgICAgICAgICAqIFdlZWQgb3V0IGludmFsaWQgbWFwcGlu Z3MuCisJCSAqLworICAgICAgICAgICAgICAgIGlmIChwdHBhZGRyID09IDApCisJCQljb250aW51 ZTsKKworICAgICAgICAgICAgICAgIGlmICh2YV9uZXh0ID4gZXZhKQorICAgICAgICAgICAgICAg ICAgICAgICAgdmFfbmV4dCA9IGV2YTsKKworICAgICAgICAgICAgICAgIGZvciAocHRlID0gcHRw YWRkcjsgc3ZhICE9IHZhX25leHQ7IHB0ZSsrLAorCQkJICAgICBzdmEgKz0gUEFHRV9TSVpFKSB7 CisgICAgICAgICAgICAgICAgICAgICAgICBwdF9lbnRyeV90IG9iaXRzLCBwYml0czsKKyAgICAg ICAgICAgICAgICAgICAgICAgIHZtX3BhZ2VfdCBtOworCQkJdm1fcGFkZHJfdCBwYTsKKwkJCQor cmV0cnk6CisJCW9iaXRzID0gcGJpdHMgPSAqcHRlOworCQlwYSA9IFRMQkxPX1BURV9UT19QQShw Yml0cyk7CisKKwkJaWYgKHBhZ2VfaXNfbWFuYWdlZChwYSkgJiYgcHRlX3Rlc3QoJnBiaXRzLCBQ VEVfRCkpIHsKKwkJCW0gPSBQSFlTX1RPX1ZNX1BBR0UocGEpOworCQkJdm1fcGFnZV9kaXJ0eSht KTsKKwkJCW0tPm1kLnB2X2ZsYWdzICY9IH5QVl9UQUJMRV9NT0Q7CisJCX0KKwkJcHRlX2NsZWFy KCZwYml0cywgUFRFX0QpOworCQlwdGVfc2V0KCZwYml0cywgUFRFX1JPKTsKKworCQlpZiAocGJp dHMgIT0gKnB0ZSkgeworCQkJaWYgKCFhdG9taWNfY21wc2V0X2ludCgodV9pbnQgKilwdGUsIG9i aXRzLCBwYml0cykpCisJCQkJZ290byByZXRyeTsKKwkJCXBtYXBfdXBkYXRlX3BhZ2UocG1hcCwg c3ZhLCBwYml0cyk7CisJCX0KKwkJfQorCX0KKwl2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YgKDApIHBy aW50ZigicG1hcF9lbnRlcl9xdWljazogbSAlcCBpbmRleCAleCB2YTogJXAgXG4iLCBtLCAoaW50 KXB0ZXBpbmRleCwgKHZvaWQgKil2YSk7CisJCWlmIChtcHRlICYmIChtcHRlLT5waW5kZXggPT0g cHRlcGluZGV4KSkgeworCQkJbXB0ZS0+d2lyZV9jb3VudCsrOworCQl9IGVsc2UgeworCQkJLyoK KwkJCSAqIEdldCB0aGUgcGFnZSBkaXJlY3RvcnkgZW50cnkKKwkJCSAqLworCQkJcGRlID0gcG1h cF9wZGUocG1hcCwgdmEpOworCisJCQkvKgorCQkJICogSWYgdGhlIHBhZ2UgdGFibGUgcGFnZSBp cyBtYXBwZWQsIHdlIGp1c3QKKwkJCSAqIGluY3JlbWVudCB0aGUgaG9sZCBjb3VudCwgYW5kIGFj dGl2YXRlIGl0LgorCQkJICovCisJCQlpZiAocGRlICYmICpwZGUgIT0gMCkgeworCQkJCWlmIChw bWFwLT5wbV9wdHBoaW50ICYmCisJCQkJICAgIChwbWFwLT5wbV9wdHBoaW50LT5waW5kZXggPT0g cHRlcGluZGV4KSkgeworCQkJCQltcHRlID0gcG1hcC0+cG1fcHRwaGludDsKKwkJCQl9IGVsc2Ug eworCQkJCQltcHRlID0gUEhZU19UT19WTV9QQUdFKAorCQkJCQkJTUlQU19LU0VHMF9UT19QSFlT KCpwZGUpKTsKKwkJCQkJcG1hcC0+cG1fcHRwaGludCA9IG1wdGU7CisJCQkJfQorCQkJCW1wdGUt PndpcmVfY291bnQrKzsKKwkJCX0gZWxzZSB7CisJCQkJbXB0ZSA9IF9wbWFwX2FsbG9jcHRlKHBt YXAsIHB0ZXBpbmRleCwKKwkJCQkgICAgTV9OT1dBSVQpOworCQkJCWlmIChtcHRlID09IE5VTEwp CisJCQkJCXJldHVybiAobXB0ZSk7CisJCQl9CisJCX0KKwl9IGVsc2UgeworCQltcHRlID0gTlVM TDsKKwl9CisKKwlwdGUgPSBwbWFwX3B0ZShwbWFwLCB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CBwbWFwIGluaXRpYWxpemVkPyAqLworCQlpZiAo a2VybmVsX3BtYXAtPnBtX2FjdGl2ZSkgeworCQkJLyogSXQncyBpbnNpZGUgdGhlIHZpcnR1YWwg YWRkcmVzcyByYW5nZSAqLworCQkJcHRlcCA9IHBtYXBfcHRlKGtlcm5lbF9wbWFwLCB2YSk7CisJ CQlpZiAocHRlcCkgeworCQkJCXJldHVybiAoVExCTE9fUFRFX1RPX1BBKCpwdGVwKSB8CisJCQkJ ICAgICh2YSAmIFBBR0VfTUFTSykpOworCQkJfQorCQl9CisJCXJldHVybiAoMCk7CisJfQorCisJ cGFuaWMoIiVzIGZvciB1bmtub3duIGFkZHJlc3Mgc3BhY2UgJXAuIiwgX19mdW5jX18sICh2b2lk ICopdmEpOworfQorCisKK3ZvaWQgCitwbWFwX2ZsdXNoX3B2Y2FjaGUodm1fcGFnZV90IG0pCit7 CisJcHZfZW50cnlfdCBwdjsKKworCWlmIChtICE9IE5VTEwpIHsKKwkJZm9yIChwdiA9IFRBSUxR X0ZJUlNUKCZtLT5tZC5wdl9saXN0KTsgcHY7CisJICAgIAkgICAgcHYgPSBUQUlMUV9ORVhUKHB2 LCBwdl9saXN0KSkgeworCQkJbWlwc19kY2FjaGVfd2JpbnZfcmFuZ2VfaW5kZXgocHYtPnB2X3Zh LCBQQUdFX1NJWkUpOworCQl9CisJfQorfQpJbmRleDogc3lzL21pcHMvbWlwcy9wbWFwLmMKPT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PQotLS0gc3lzL21pcHMvbWlwcy9wbWFwLmMJKHJldmlzaW9uIDIxMDUzNCkKKysrIHN5 cy9taXBzL21pcHMvcG1hcC5jCSh3b3JraW5nIGNvcHkpCkBAIC0xMjgsMTIgKzEyOCw4IEBACiAj ZGVmaW5lCXBtYXBfc2Vnc2hpZnQodikJKCgodikgPj4gU0VHU0hJRlQpICYgKE5QREVQRyAtIDEp KQogI2RlZ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lmIGRlZmluZWQo X19taXBzX242NCkKLQltYXBwZWQgPSBtYXBwZWQgfHwgKHZhID49IE1JUFNfWEtTRUdfU1RBUlQg fHwgdmEgPCBNSVBTX1hLU0VHX0VORCk7Ci0jZW5kaWYgCiAJLyoKIAkgKiBLZXJuZWwgdmlydHVh bC4KIAkgKi8K --0016e64757dcd58fd3048c646c04 Content-Type: application/octet-stream; name="mips-n64-config.patch" Content-Disposition: attachment; filename="mips-n64-config.patch" Content-Transfer-Encoding: base64 X-Attachment-Id: f_gc572wx23 SW5kZXg6IHN5cy9jb25mL29wdGlvbnMubWlwcwo9PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0tLSBzeXMvY29uZi9vcHRp b25zLm1pcHMJKHJldmlzaW9uIDIxMDUzNCkKKysrIHN5cy9jb25mL29wdGlvbnMubWlwcwkod29y a2luZyBjb3B5KQpAQCAtNTMsNiArNTMsOSBAQAogVEFSR0VUX0VNVUxBVE9SCW9wdF9kZGIuaAog VEFSR0VUX1hMUl9YTFMgIG9wdF9nbG9iYWwuaAogCitLRVJORUxfNjQJb3B0X2dsb2JhbC5oCitL RVJORUxfMzIJb3B0X2dsb2JhbC5oCisKIFRJQ0tfVVNFX1lBTU9OX0ZSRVEJb3B0X2dsb2JhbC5o CiBUSUNLX1VTRV9NQUxUQV9SVEMJb3B0X2dsb2JhbC5oCiAKSW5kZXg6IHN5cy9jb25mL2ZpbGVz Lm1pcHMKPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PQotLS0gc3lzL2NvbmYvZmlsZXMubWlwcwkocmV2aXNpb24gMjEwNTM0 KQorKysgc3lzL2NvbmYvZmlsZXMubWlwcwkod29ya2luZyBjb3B5KQpAQCAtMzIsNyArMzIsOCBA QAogbWlwcy9taXBzL2V4Y2VwdGlvbi5TCQlzdGFuZGFyZAogbWlwcy9taXBzL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cy9jb25mL0RFRkFVTFRTCShyZXZpc2lvbiAyMTA1MzQpCisrKyBzeXMvbWlw cy9jb25mL0RFRkFVTFRTCSh3b3JraW5nIGNvcHkpCkBAIC0xMSwzICsxMSw0IEBACiAKIG9wdGlv bnMgCUdFT01fUEFSVF9CU0QKIG9wdGlvbnMgCUdFT01fUEFSVF9NQlIKK29wdGlvbnMJCUtFUk5F TF8zMgo= --0016e64757dcd58fd3048c646c04 Content-Type: application/octet-stream; name="rmi-n64-rge.patch" Content-Disposition: attachment; filename="rmi-n64-rge.patch" Content-Transfer-Encoding: base64 X-Attachment-Id: f_gc572xjt4 SW5kZXg6IHN5cy9taXBzL3JtaS9kZXYveGxyL3JnZS5jCj09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLS0tIHN5cy9taXBz L3JtaS9kZXYveGxyL3JnZS5jCShyZXZpc2lvbiAyMTA1MzQpCisrKyBzeXMvbWlwcy9ybWkvZGV2 L3hsci9yZ2UuYwkod29ya2luZyBjb3B5KQpAQCAtNTY3LDggKzU2Nyw4IEBACiAJcGFkZHIgPSB2 dG9waHlzKCh2bV9vZmZzZXRfdCl0eF9kZXNjKTsKIAl0eF9kZXNjLT5mcmFnW25mcmFnXSA9ICgx VUxMIDw8IDYzKSB8IChmcl9zdGlkIDw8IDU0KSB8IHBhZGRyOwogCW5mcmFnKys7Ci0JdHhfZGVz Yy0+ZnJhZ1tYTFJfTUFYX1RYX0ZSQUdTXSA9ICh1aW50NjRfdCkgKHZtX29mZnNldF90KXR4X2Rl c2M7Ci0JdHhfZGVzYy0+ZnJhZ1tYTFJfTUFYX1RYX0ZSQUdTICsgMV0gPSAodWludDY0X3QpICh2 bV9vZmZzZXRfdCltX2hlYWQ7CisJdHhfZGVzYy0+ZnJhZ1tYTFJfTUFYX1RYX0ZSQUdTXSA9ICh1 aW50NjRfdCkoaW50cHRyX3QpdHhfZGVzYzsKKwl0eF9kZXNjL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gZWxzZSBwYWNrZXQgRXJyb3IgLSBGSVhNRSBpbiBpbnRpYWxpemF0aW9u ICovCi0JCXByaW50ZigiY3B1ICVkOiAqRVJST1IqIE5vdCBteSBwYWNrZXQgcGFkZHIgJXBcbiIs IHhscl9jcHVfaWQoKSwgKHZvaWQgKilwYWRkcik7CisJCXByaW50ZigiY3B1ICVkOiAqRVJST1Iq IE5vdCBteSBwYWNrZXQgcGFkZHIgJXBcbiIsCisJCSAgICB4bHJfY3B1X2lkKCksICh2b2lkICop cGFkZHIpOwogCQlyZXR1cm47CiAJfQogCS8qIGFsaWduIHRoZSBkYXRhICovCg== --0016e64757dcd58fd3048c646c04-- From owner-freebsd-mips@FreeBSD.ORG Wed Jul 28 23:32:49 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 63760106567B; Wed, 28 Jul 2010 23:32:49 +0000 (UTC) (envelope-from c.jayachandran@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 AB23F8FC0A; Wed, 28 Jul 2010 23:32:45 +0000 (UTC) Received: by fxm13 with SMTP id 13so1579336fxm.13 for ; Wed, 28 Jul 2010 16:32:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type; bh=CHlPZxxqC0njIcWBcfb7Gv6TmJ2LvR5ndEcogKoRxPk=; b=s3BbHtilpNPcEVFMie+zQWQYbIt4cn4+FiUhti7miNyVAoTH6jJ5QRjwXW2YZUuEZq JWy42TNEULxWi2hnliOpawc1+Otpmuiu3e5nKUPSeF/wrzwYPbjtLO+KcNpJ35sxZ35+ NsLa6zRNlvfWiOkTNy6nZIBQpe30gesk7OhkI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=k16veON6m71Up42nevM0DPjQAVbGxHW6lX9bHilzCEUHmqoMzRbSNC9QsqoNEEWpga Vw1rbgs1HqGBf1yVBruxAoM8Q9L/HeyayjBBjTmQYRXi/dSvDYxgysg7rzh+xQuzBKBR AV7KhsJF2Hgya83ScCd+ovItOdsMXypFp0Yy0= MIME-Version: 1.0 Received: by 10.103.197.5 with SMTP id z5mr1431035mup.107.1280359965006; Wed, 28 Jul 2010 16:32:45 -0700 (PDT) Received: by 10.102.228.12 with HTTP; Wed, 28 Jul 2010 16:32:44 -0700 (PDT) In-Reply-To: References: Date: Thu, 29 Jul 2010 05:02:44 +0530 Message-ID: From: "Jayachandran C." To: freebsd-mips@freebsd.org Content-Type: multipart/mixed; boundary=0016e659f21ae61e11048c7b08e9 Cc: Subject: Re: Support for 64bit userspace. 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: Wed, 28 Jul 2010 23:32:49 -0000 --0016e659f21ae61e11048c7b08e9 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On Wed, Jul 28, 2010 at 2:04 AM, Jayachandran C. wrote: > Here's my initial work to get 64bit user space. =A0With this set of > changes, I can boot to the single user shell with n64 /sbin/init and > /bin/sh. =A0There are still issues to fix, and the dynamic loader is > still not working, but I think this would be a good time to get some > initial feedback. The dynamic loader seems to work after some straight-forward changes. The only change is that the got[1] entry needs to be 64-bit. The changes are attached. There is still an occasional kernel panic in n64, which I need to track down - but I think the changes other than pmap.c/pmap64.c are ready for check in. I would like some feedback on pmap64.c I can clean it up for check in. Thanks, JC. --0016e659f21ae61e11048c7b08e9 Content-Type: application/octet-stream; name="mips-n64-rtld.patch" Content-Disposition: attachment; filename="mips-n64-rtld.patch" Content-Transfer-Encoding: base64 X-Attachment-Id: f_gc6svn7q5 SW5kZXg6IGxpYmV4ZWMvcnRsZC1lbGYvbWlwcy9ydGxkX3N0YXJ0LlMKPT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQotLS0g bGliZXhlYy9ydGxkLWVsZi9taXBzL3J0bGRfc3RhcnQuUwkocmV2aXNpb24gMjEwNTM0KQorKysg bGliZXhlYy9ydGxkLWVsZi9taXBzL3J0bGRfc3RhcnQuUwkod29ya2luZyBjb3B5KQpAQCAtMTMw LDExICsxMzAsMTIgQEAKIAkJCQkJLyogLmdvdCA9ICRncCAtIDB4N2ZmMAkJKi8KIAkJCQkJLyog U2ltcGxlIG1hdGggYXMgeW91IGNhbiBzZWUuCSovCiAjaWYgZGVmaW5lZChfX21pcHNfbjY0KQot CWxkCWEwLCA4KGEwKQkJLyogb2JqZWN0ID0gcGx0Z290WzFdICYgMHg3ZmZmZmZmZiAqLworCWxk CWEwLCA4KGEwKQkJLyogb2JqZWN0ID0gcGx0Z290WzFdICovCisJYW5kCWEwLCBhMCwgMHg3ZmZm ZmZmZmZmZmZmZmZmCiAjZWxzZQogCWx3CWEwLCA0KGEwKQkJLyogb2JqZWN0ID0gcGx0Z290WzFd ICYgMHg3ZmZmZmZmZiAqLworCWFuZAlhMCwgYTAsIDB4N2ZmZmZmZmYKICNlbmRpZgotCWFuZAlh MCwgYTAsIDB4N2ZmZmZmZmYKIAltb3ZlCWExLCB0OAkJCS8qIHN5bWJvbCBpbmRleCAqLwogCiAJ UFRSX0xBCXQ5LCBfQ19MQUJFTChfbWlwc19ydGxkX2JpbmQpCkluZGV4OiBsaWJleGVjL3J0bGQt ZWxmL21pcHMvcmVsb2MuYwo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0tLSBsaWJleGVjL3J0bGQtZWxmL21pcHMvcmVs b2MuY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kID0gbG9hZF9wdHIod2hlcmUsIHJs ZW4pOwogCQkJRWxmX1N4d29yZCB2YWwgPSBvbGQ7Ci0jaWYgRUxGU0laRSA9PSA2NAorI2lmIGRl ZmluZWQoX19taXBzX242NCkKIAkJCWFzc2VydChyX3R5cGUgPT0gUl9UWVBFKFJFTDMyKQogCQkJ ICAgIHx8IHJfdHlwZSA9PSAoUl9UWVBFKFJFTDMyKXwoUl9UWVBFKDY0KSA8PCA4KSkpOwogI2Vu ZGlmCkBAIC0yNzIsNyArMjc5LDcgQEAKIAlkYmcoIiVzOiBicm9rZW49JWQiLCBvYmotPnBhdGgs IGJyb2tlbik7CiAjZW5kaWYKIAotCWkgPSAoZ290WzFdICYgMHg4MDAwMDAwMCkgPyAyIDogMTsK KwlpID0gKGdvdFsxXSAmIEdPVDFfTUFTSykgPyAyIDogMTsKIAogCS8qIFJlbG9jYXRlIHRoZSBs b2NhbCBHT1QgZW50cmllcyAqLwogCWdvdCArPSBpOwo= --0016e659f21ae61e11048c7b08e9-- From owner-freebsd-mips@FreeBSD.ORG Wed Jul 28 23:42:17 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 0DA611065672 for ; Wed, 28 Jul 2010 23:42:17 +0000 (UTC) (envelope-from juli@clockworksquid.com) Received: from mail-iw0-f182.google.com (mail-iw0-f182.google.com [209.85.214.182]) by mx1.freebsd.org (Postfix) with ESMTP id D1F6B8FC21 for ; Wed, 28 Jul 2010 23:42:16 +0000 (UTC) Received: by iwn35 with SMTP id 35so6307759iwn.13 for ; Wed, 28 Jul 2010 16:42:15 -0700 (PDT) Received: by 10.42.9.73 with SMTP id l9mr3588404icl.74.1280360535216; Wed, 28 Jul 2010 16:42:15 -0700 (PDT) MIME-Version: 1.0 Sender: juli@clockworksquid.com Received: by 10.42.4.66 with HTTP; Wed, 28 Jul 2010 16:41:55 -0700 (PDT) In-Reply-To: References: From: Juli Mallett Date: Wed, 28 Jul 2010 16:41:55 -0700 X-Google-Sender-Auth: qw4nEV-4OZf2M0XtkIqdjPxDG7Q Message-ID: To: "Jayachandran C." Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: freebsd-mips@freebsd.org Subject: Re: Support for 64bit userspace. 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: Wed, 28 Jul 2010 23:42:17 -0000 Hi JC, On Wed, Jul 28, 2010 at 16:32, Jayachandran C. w= rote: > On Wed, Jul 28, 2010 at 2:04 AM, Jayachandran C. > wrote: >> Here's my initial work to get 64bit user space. =A0With this set of >> changes, I can boot to the single user shell with n64 /sbin/init and >> /bin/sh. =A0There are still issues to fix, and the dynamic loader is >> still not working, but I think this would be a good time to get some >> initial feedback. > > The dynamic loader seems to work after some straight-forward changes. > The only change is that the got[1] entry needs to be 64-bit. =A0The > changes are attached. > > There is still an occasional kernel panic in n64, which I need to > track down - but I think the changes other than pmap.c/pmap64.c are > ready for check in. =A0I would like some feedback on pmap64.c I can > clean it up for check in. I'm uncomfortable with pmap.c and pmap64.c. I don't get the impression that the ifdefs required to do both in the same file are really a great burden, but obviously my efforts are incomplete compared to yours. It seems like there are very few operations that should care about how deep the page tables are and that macros and ifdefed inline functions are the way to go. If you check it in as two files, I'll probably just go through and ifdef the deltas that can't be eliminated. What do you think are the problem areas that justify having two different files? Thanks, Juli. From owner-freebsd-mips@FreeBSD.ORG Wed Jul 28 23:49:30 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 54E16106564A; Wed, 28 Jul 2010 23:49:30 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (bsdimp.com [199.45.160.85]) by mx1.freebsd.org (Postfix) with ESMTP id 10D898FC0A; Wed, 28 Jul 2010 23:49:29 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by harmony.bsdimp.com (8.14.3/8.14.1) with ESMTP id o6SNkWrg001399; Wed, 28 Jul 2010 17:46:33 -0600 (MDT) (envelope-from imp@bsdimp.com) Date: Wed, 28 Jul 2010 17:46:53 -0600 (MDT) Message-Id: <20100728.174653.956847443285364686.imp@bsdimp.com> To: jmallett@freebsd.org From: "M. Warner Losh" In-Reply-To: References: X-Mailer: Mew version 6.3 on Emacs 22.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Cc: freebsd-mips@freebsd.org Subject: Re: Support for 64bit userspace. 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: Wed, 28 Jul 2010 23:49:30 -0000 In message: Juli Mallett writes: : Hi JC, : = : On Wed, Jul 28, 2010 at 16:32, Jayachandran C. wrote: : > On Wed, Jul 28, 2010 at 2:04 AM, Jayachandran C. : > wrote: : >> Here's my initial work to get 64bit user space. =A0With this set o= f : >> changes, I can boot to the single user shell with n64 /sbin/init a= nd : >> /bin/sh. =A0There are still issues to fix, and the dynamic loader = is : >> still not working, but I think this would be a good time to get so= me : >> initial feedback. : > : > The dynamic loader seems to work after some straight-forward change= s. : > The only change is that the got[1] entry needs to be 64-bit. =A0The= : > changes are attached. : > : > There is still an occasional kernel panic in n64, which I need to : > track down - but I think the changes other than pmap.c/pmap64.c are= : > ready for check in. =A0I would like some feedback on pmap64.c I can= : > clean it up for check in. : = : I'm uncomfortable with pmap.c and pmap64.c. I don't get the : impression that the ifdefs required to do both in the same file are : really a great burden, but obviously my efforts are incomplete : compared to yours. It seems like there are very few operations that : should care about how deep the page tables are and that macros and : ifdefed inline functions are the way to go. If you check it in as tw= o : files, I'll probably just go through and ifdef the deltas that can't : be eliminated. What do you think are the problem areas that justify : having two different files? Eventually, and by no means should this hold things up today, I'd like to be able to run 32-bit and 64-bit programs on the same system... Warner From owner-freebsd-mips@FreeBSD.ORG Wed Jul 28 23:51:55 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 0526D1065674 for ; Wed, 28 Jul 2010 23:51:55 +0000 (UTC) (envelope-from juli@clockworksquid.com) Received: from mail-iw0-f182.google.com (mail-iw0-f182.google.com [209.85.214.182]) by mx1.freebsd.org (Postfix) with ESMTP id C7A9B8FC14 for ; Wed, 28 Jul 2010 23:51:54 +0000 (UTC) Received: by iwn35 with SMTP id 35so6318777iwn.13 for ; Wed, 28 Jul 2010 16:51:54 -0700 (PDT) Received: by 10.42.9.73 with SMTP id l9mr3591731icl.74.1280361114150; Wed, 28 Jul 2010 16:51:54 -0700 (PDT) MIME-Version: 1.0 Sender: juli@clockworksquid.com Received: by 10.42.4.66 with HTTP; Wed, 28 Jul 2010 16:51:34 -0700 (PDT) In-Reply-To: <20100728.174653.956847443285364686.imp@bsdimp.com> References: <20100728.174653.956847443285364686.imp@bsdimp.com> From: Juli Mallett Date: Wed, 28 Jul 2010 16:51:34 -0700 X-Google-Sender-Auth: JtIoqac8wQQHYl-q7KeqePKl_l0 Message-ID: To: "M. Warner Losh" Content-Type: text/plain; charset=ISO-8859-1 Cc: freebsd-mips@freebsd.org Subject: Re: Support for 64bit userspace. 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: Wed, 28 Jul 2010 23:51:55 -0000 On Wed, Jul 28, 2010 at 16:46, M. Warner Losh wrote: > Eventually, and by no means should this hold things up today, I'd like > to be able to run 32-bit and 64-bit programs on the same system... That isn't impacted by the pmap changes at all. Being able to support a larger user address space causes no problems with supporting programs which only use 0x00000000-0x7fffffff. It's only the normal freebsd32 compatibility that is required. Juli. From owner-freebsd-mips@FreeBSD.ORG Thu Jul 29 08:15:51 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 2B6881065670; Thu, 29 Jul 2010 08:15:51 +0000 (UTC) (envelope-from c.jayachandran@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 85E888FC14; Thu, 29 Jul 2010 08:15:50 +0000 (UTC) Received: by fxm13 with SMTP id 13so40416fxm.13 for ; Thu, 29 Jul 2010 01:15:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type; bh=Yh/CCNQYASKFaasQ67nEVl0vF+cgmQBUQGFBC24mIT0=; b=lfVBjwwxGAdeIz7y+//7rHxW+O8TKRdchD8zAAYEqx9qbKW23mDYNZ4J6iLpctbJvl PNUBxCBfX9M8V99tqL6LPxNUSmVJi1qDFUF1AED6Hazst3a4ugK/9wdgWo4lZSv/HGN+ d8AJKOesu+nYpNMSGqp4p6CF6Di4gqlZh0ncY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=i47eYBeojJhD2Wm8CcuqWRpTlBtXPGH+lqKCWgV8XONbmR6qeLnR1Aqcn/pcDur03W c3nMw523p0GbLYB//cWF1FkkNqX75k6AREmXP0vW2i3siZpepCy7TA8THJdDl0iw/Uxl DZsGDOgBrfTLV28n9C5XWdc7nGJe+WT0zYBZo= MIME-Version: 1.0 Received: by 10.103.121.6 with SMTP id y6mr1454613mum.58.1280391349398; Thu, 29 Jul 2010 01:15:49 -0700 (PDT) Received: by 10.102.228.12 with HTTP; Thu, 29 Jul 2010 01:15:49 -0700 (PDT) In-Reply-To: References: Date: Thu, 29 Jul 2010 13:45:49 +0530 Message-ID: From: "Jayachandran C." To: Juli Mallett Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: freebsd-mips@freebsd.org Subject: Re: Support for 64bit userspace. 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: Thu, 29 Jul 2010 08:15:51 -0000 On Thu, Jul 29, 2010 at 5:11 AM, Juli Mallett wrote: > Hi JC, > > On Wed, Jul 28, 2010 at 16:32, Jayachandran C. > wrote: > > On Wed, Jul 28, 2010 at 2:04 AM, Jayachandran C. > > wrote: > >> Here's my initial work to get 64bit user space. With this set of > >> changes, I can boot to the single user shell with n64 /sbin/init and > >> /bin/sh. There are still issues to fix, and the dynamic loader is > >> still not working, but I think this would be a good time to get some > >> initial feedback. > > > > The dynamic loader seems to work after some straight-forward changes. > > The only change is that the got[1] entry needs to be 64-bit. The > > changes are attached. > > > > There is still an occasional kernel panic in n64, which I need to > > track down - but I think the changes other than pmap.c/pmap64.c are > > ready for check in. I would like some feedback on pmap64.c I can > > clean it up for check in. > > I'm uncomfortable with pmap.c and pmap64.c. I don't get the > impression that the ifdefs required to do both in the same file are > really a great burden, but obviously my efforts are incomplete > compared to yours. It seems like there are very few operations that > should care about how deep the page tables are and that macros and > ifdefed inline functions are the way to go. If you check it in as two > files, I'll probably just go through and ifdef the deltas that can't > be eliminated. What do you think are the problem areas that justify > having two different files? > I kept the 32 bit pmap.c code untouched so that I don't have to deal with the breakage there during the early 64bit changes. I will check in the other changes now, and will do another round of work on pmap.c/pmap64.c to see if it can be merged (and eliminate the config option). Thanks, JC. From owner-freebsd-mips@FreeBSD.ORG Thu Jul 29 08:19:27 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 8D9A1106564A for ; Thu, 29 Jul 2010 08:19:27 +0000 (UTC) (envelope-from juli@clockworksquid.com) Received: from mail-gw0-f54.google.com (mail-gw0-f54.google.com [74.125.83.54]) by mx1.freebsd.org (Postfix) with ESMTP id 51FCA8FC1D for ; Thu, 29 Jul 2010 08:19:27 +0000 (UTC) Received: by gwj23 with SMTP id 23so40995gwj.13 for ; Thu, 29 Jul 2010 01:19:26 -0700 (PDT) Received: by 10.151.42.18 with SMTP id u18mr609249ybj.382.1280391566275; Thu, 29 Jul 2010 01:19:26 -0700 (PDT) MIME-Version: 1.0 Sender: juli@clockworksquid.com Received: by 10.42.4.66 with HTTP; Thu, 29 Jul 2010 01:19:06 -0700 (PDT) In-Reply-To: References: From: Juli Mallett Date: Thu, 29 Jul 2010 01:19:06 -0700 X-Google-Sender-Auth: N1o4v3mbLfzjgVOW1ABJu1PL0Eo Message-ID: To: "Jayachandran C." Content-Type: text/plain; charset=ISO-8859-1 Cc: freebsd-mips@freebsd.org Subject: Re: Support for 64bit userspace. 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: Thu, 29 Jul 2010 08:19:27 -0000 On Thu, Jul 29, 2010 at 01:15, Jayachandran C. wrote: > I kept the 32 bit pmap.c code untouched so that I don't have to deal with > the breakage there during the early 64bit changes. > I will check in the other changes now, and will do another round of work on > pmap.c/pmap64.c to see if it can be merged (and eliminate the config > option). Hmm, hopefully the changes will be well-isolated and any abstractions will be right for 32-bit and 64-bit both. One of the problems with two files is that when they are merged, which it sounds like you think is inevitable, we lose the change history for that file. And if they're in the same file, you don't need an option, just __mips_n64. From owner-freebsd-mips@FreeBSD.ORG Thu Jul 29 19:18:52 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 C72E91065674; Thu, 29 Jul 2010 19:18:52 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (bsdimp.com [199.45.160.85]) by mx1.freebsd.org (Postfix) with ESMTP id 86CE38FC0C; Thu, 29 Jul 2010 19:18:52 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by harmony.bsdimp.com (8.14.3/8.14.1) with ESMTP id o6TJBPCV012997; Thu, 29 Jul 2010 13:11:25 -0600 (MDT) (envelope-from imp@bsdimp.com) Date: Thu, 29 Jul 2010 13:11:34 -0600 (MDT) Message-Id: <20100729.131134.4959786895411328.imp@bsdimp.com> To: jmallett@FreeBSD.org From: "M. Warner Losh" In-Reply-To: References: X-Mailer: Mew version 6.3 on Emacs 22.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cc: freebsd-mips@FreeBSD.org Subject: Re: Support for 64bit userspace. 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: Thu, 29 Jul 2010 19:18:52 -0000 In message: Juli Mallett writes: : On Thu, Jul 29, 2010 at 01:15, Jayachandran C. wrote: : > I kept the 32 bit pmap.c code untouched so that I don't have to deal with : > the breakage there during the early 64bit changes. : > I will check in the other changes now, and will do another round of work on : > pmap.c/pmap64.c to see if it can be merged (and eliminate the config : > option). : : Hmm, hopefully the changes will be well-isolated and any abstractions : will be right for 32-bit and 64-bit both. One of the problems with : two files is that when they are merged, which it sounds like you think : is inevitable, we lose the change history for that file. And if : they're in the same file, you don't need an option, just __mips_n64. I'd prefer one file as well... Warner From owner-freebsd-mips@FreeBSD.ORG Fri Jul 30 08:15:57 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 2D0021065670; Fri, 30 Jul 2010 08:15:57 +0000 (UTC) (envelope-from c.jayachandran@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 764BD8FC14; Fri, 30 Jul 2010 08:15:56 +0000 (UTC) Received: by fxm13 with SMTP id 13so756968fxm.13 for ; Fri, 30 Jul 2010 01:15:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=RRWOWHcVx7nPxmIm0phGzoASTTbhFSG8IA9KBg3Y2+g=; b=E0OvwaLn0meEQN23IGCjXFwxvN0byZZ2dFB/sQifF5vLaG7ve89WbyjuerTPE9XEk/ LAYKL9mOwi3ZyXwTn8QaeG6y3DxmjbVTNzE/5ird0TVEDS35P9GwW6F6ror3tN0ljwS+ 7Jh0xIocw1edsDqBZmy4S+oJXW2Xnsj9/eQcU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=c+u4Qd1otaMT1dpJsDwxHArTDv/1EBHp/oNZ0CBgaw9xrJxDkc88yYcLYzrB3KxU/w VEQcKLJhZsvW8oeFDYtAtgz9DDSzTxSbLlogJPYwNCOVcvr06ShTaSi2neryj67msrwb F/yNVamoE78Y5X9JS0jXdO1wylgBdOferV2xk= MIME-Version: 1.0 Received: by 10.103.239.14 with SMTP id q14mr393911mur.15.1280477754418; Fri, 30 Jul 2010 01:15:54 -0700 (PDT) Received: by 10.102.228.12 with HTTP; Fri, 30 Jul 2010 01:15:54 -0700 (PDT) In-Reply-To: <20100729.131134.4959786895411328.imp@bsdimp.com> References: <20100729.131134.4959786895411328.imp@bsdimp.com> Date: Fri, 30 Jul 2010 13:45:54 +0530 Message-ID: From: "Jayachandran C." To: "M. Warner Losh" , jmallett@freebsd.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: freebsd-mips@freebsd.org Subject: Re: Support for 64bit userspace. 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: Fri, 30 Jul 2010 08:15:57 -0000 On Fri, Jul 30, 2010 at 12:41 AM, M. Warner Losh wrote: > In message: > =A0 =A0 =A0 =A0 =A0 =A0Juli Mallett writes: > : On Thu, Jul 29, 2010 at 01:15, Jayachandran C. wrote: > : > I kept the 32 bit pmap.c code untouched so that I don't have to deal = with > : > the breakage there during the early 64bit changes. > : > I will check in the other changes now, and will do another round of w= ork on > : > pmap.c/pmap64.c to see if it can be merged (and eliminate the config > : > option). > : > : Hmm, hopefully the changes will be well-isolated and any abstractions > : will be right for 32-bit and 64-bit both. =A0One of the problems with > : two files is that when they are merged, which it sounds like you think > : is inevitable, we lose the change history for that file. =A0And if > : they're in the same file, you don't need an option, just __mips_n64. > > I'd prefer one file as well... I will look at merging them without too many ifdefs. Another possibility is to have a pmap.c, pmap32.c and pmap64.c, so that the common code is not duplicated, but that too (as far as I can see) will require a config option. Also, I've been checking in the other pieces of 64 bit support that I had posted here. I've broken down the patches further so that they are be obvious (and easy to revert if it affects anything). I am not planning to check-in the pmap changes for 3 level page tables now, will post it again for review once I see what level of merge can be done. JC. From owner-freebsd-mips@FreeBSD.ORG Fri Jul 30 08:38:09 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 1866F106566B for ; Fri, 30 Jul 2010 08:38:09 +0000 (UTC) (envelope-from juli@clockworksquid.com) Received: from mail-ww0-f42.google.com (mail-ww0-f42.google.com [74.125.82.42]) by mx1.freebsd.org (Postfix) with ESMTP id ABB7E8FC17 for ; Fri, 30 Jul 2010 08:38:08 +0000 (UTC) Received: by wwf26 with SMTP id 26so7079823wwf.1 for ; Fri, 30 Jul 2010 01:38:07 -0700 (PDT) Received: by 10.216.1.77 with SMTP id 55mr1309367wec.72.1280479087636; Fri, 30 Jul 2010 01:38:07 -0700 (PDT) MIME-Version: 1.0 Sender: juli@clockworksquid.com Received: by 10.216.5.5 with HTTP; Fri, 30 Jul 2010 01:37:46 -0700 (PDT) In-Reply-To: References: <20100729.131134.4959786895411328.imp@bsdimp.com> From: Juli Mallett Date: Fri, 30 Jul 2010 01:37:46 -0700 X-Google-Sender-Auth: kx7cN0cnJDSUC-ivmqjyDifl7Fk Message-ID: To: "Jayachandran C." Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Cc: freebsd-mips@freebsd.org Subject: Re: Support for 64bit userspace. 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: Fri, 30 Jul 2010 08:38:09 -0000 On Fri, Jul 30, 2010 at 01:15, Jayachandran C. w= rote: > I will look at merging them without too many ifdefs. Another > possibility is to have a pmap.c, pmap32.c and pmap64.c, so that the > common code is not duplicated, but that too (as far as I can see) will > require a config option. I'm not really sure what the aversion to ifdefs is =97 they kind of come with the territory and this is exactly the part of the system where you expect to have them to conditionalize exactly this kind of behavior. If you were going to split out some subroutines for 32-bit and 64-bit, there are two ways you can do it without a config option (and I agree with you that avoiding one is very desirable =97 we already use too many knobs to get the right ABI in kernel configs). You could do: #ifndef __mips_n64 #include "pmap32.c" #else #include "pmap64.c" #endif Or you could wrap the whole 32/64 files (modulo a "struct __hack;" or whatever to avoid an empty translation unit) with ifdefs. Personally, I find having two implementations of a function a lot harder to read and keep track of than a single implementation with ifdefs in the body =97 there's very few places in the kernel where we do the former. If you do split out functions into separate files I would beg you to only split out the really big functions that are actually doing things based on different levels of page tables and then it's obvious why those things have two implementations and what needs to be abstracted to merge them. Having two copies of trivial functions or non-trivial functions that are mostly identical is a bad thing. You're doing the work, so at some point it's kind of your call, but I feel like you're making style changes to things that I cleaned up and tried to unify in pmap.c and that the way that they're done is pretty significant given how intimidating people find pmap. If we were going to support different kinds of MMUs (e.g. adding support for BAT-based MMUs) I'd be in favor of splitting things up, but then I'd want to follow PowerPC's lead. For now I think the appropriate thing to do is to follow the lead of my 64-bit work in the MIPS pmap and the PAE work in the i386 pmap and to use ifdefs and to try to abstract out the page-table differences. I'm really thrilled with the work you're doing and can't wait for it to be in head =97 I'm quite eager to move everything on Octeon to n64 :) Thanks, Juli. From owner-freebsd-mips@FreeBSD.ORG Fri Jul 30 16:24:42 2010 Return-Path: Delivered-To: mips@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D2F931065673; Fri, 30 Jul 2010 16:24:42 +0000 (UTC) (envelope-from tinderbox@freebsd.org) Received: from freebsd-current.sentex.ca (freebsd-current.sentex.ca [64.7.128.98]) by mx1.freebsd.org (Postfix) with ESMTP id 714658FC0A; Fri, 30 Jul 2010 16:24:42 +0000 (UTC) Received: from freebsd-current.sentex.ca (localhost [127.0.0.1]) by freebsd-current.sentex.ca (8.14.4/8.14.3) with ESMTP id o6UGOf4p012167; Fri, 30 Jul 2010 12:24:41 -0400 (EDT) (envelope-from tinderbox@freebsd.org) Received: (from tinderbox@localhost) by freebsd-current.sentex.ca (8.14.4/8.14.3/Submit) id o6UGOfSb012165; Fri, 30 Jul 2010 16:24:41 GMT (envelope-from tinderbox@freebsd.org) Date: Fri, 30 Jul 2010 16:24:41 GMT Message-Id: <201007301624.o6UGOfSb012165@freebsd-current.sentex.ca> X-Authentication-Warning: freebsd-current.sentex.ca: tinderbox set sender to FreeBSD Tinderbox using -f Sender: FreeBSD Tinderbox From: FreeBSD Tinderbox To: FreeBSD Tinderbox , , Precedence: bulk Cc: Subject: [head tinderbox] failure on mips/mips X-BeenThere: freebsd-mips@freebsd.org X-Mailman-Version: 2.1.5 List-Id: Porting FreeBSD to MIPS List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 30 Jul 2010 16:24:42 -0000 TB --- 2010-07-30 16:21:39 - tinderbox 2.6 running on freebsd-current.sentex.ca TB --- 2010-07-30 16:21:39 - starting HEAD tinderbox run for mips/mips TB --- 2010-07-30 16:21:39 - cleaning the object tree TB --- 2010-07-30 16:21:49 - cvsupping the source tree TB --- 2010-07-30 16:21:49 - /usr/bin/csup -z -r 3 -g -L 1 -h cvsup.sentex.ca /tinderbox/HEAD/mips/mips/supfile TB --- 2010-07-30 16:22:14 - building world TB --- 2010-07-30 16:22:14 - MAKEOBJDIRPREFIX=/obj TB --- 2010-07-30 16:22:14 - PATH=/usr/bin:/usr/sbin:/bin:/sbin TB --- 2010-07-30 16:22:14 - TARGET=mips TB --- 2010-07-30 16:22:14 - TARGET_ARCH=mips TB --- 2010-07-30 16:22:14 - TZ=UTC TB --- 2010-07-30 16:22:14 - __MAKE_CONF=/dev/null TB --- 2010-07-30 16:22:14 - cd /src TB --- 2010-07-30 16:22:14 - /usr/bin/make -B buildworld >>> World build started on Fri Jul 30 16:22:14 UTC 2010 >>> Rebuilding the temporary build tree >>> stage 1.1: legacy release compatibility shims >>> stage 1.2: bootstrap tools [...] ===> games/fortune/strfile (obj,depend,all,install) /obj/mips.mips/src/tmp/src/games/fortune/strfile created for /src/games/fortune/strfile rm -f .depend mkdep -f .depend -a -I/obj/mips.mips/src/tmp/legacy/usr/include /src/games/fortune/strfile/strfile.c echo strfile: /usr/lib/libc.a /obj/mips.mips/src/tmp/legacy/usr/lib/libegacy.a >> .depend cc -O2 -pipe -std=gnu99 -I/obj/mips.mips/src/tmp/legacy/usr/include -c /src/games/fortune/strfile/strfile.c cc -O2 -pipe -std=gnu99 -I/obj/mips.mips/src/tmp/legacy/usr/include -static -L/obj/mips.mips/src/tmp/legacy/usr/lib -o strfile strfile.o -legacy Syntax error: end of file unexpected (expecting ")") *** Error code 2 Stop in /src/games/fortune/strfile. *** Error code 1 Stop in /src. *** Error code 1 Stop in /src. *** Error code 1 Stop in /src. TB --- 2010-07-30 16:24:41 - WARNING: /usr/bin/make returned exit code 1 TB --- 2010-07-30 16:24:41 - ERROR: failed to build world TB --- 2010-07-30 16:24:41 - 134.42 user 23.75 system 181.80 real http://tinderbox.freebsd.org/tinderbox-head-HEAD-mips-mips.full From owner-freebsd-mips@FreeBSD.ORG Fri Jul 30 23:47:39 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 8CFF4106564A; Fri, 30 Jul 2010 23:47:39 +0000 (UTC) (envelope-from c.jayachandran@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 4820B8FC1A; Fri, 30 Jul 2010 23:47:37 +0000 (UTC) Received: by fxm13 with SMTP id 13so1233830fxm.13 for ; Fri, 30 Jul 2010 16:47:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type; bh=QLZeiYE1OJzm74q/AJrN0XqX0tjKRGzbYqg9uAl6Pb0=; b=r/2Ftdo8jq9xWAjgsLFyWXN2595WKHfqySQNjBFhmRNGUMmv+Sk7i39iZMfFCkEp/+ n9YHpCY6e0ov8Z2XpgIEMCx40o5h+qvpYhU9H1j4PBYurx5O2Z3yl7ngvjIZwTNyPVY2 663u55uCsGOv4Jyd/hXsZMWPSB8ByzhN4s5nI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=kE757HAipdUk/nJ4z13KHK4ZjOjrZlQEzF0CQHH98mpQyI0iPdMkEne6xtsEQeVf0m AlOu4dwa3v3g7Mk9u8qOm7bDdO7uO2s2aiKvsjT8P30n8TNaayUmxShZlS3dpITmXSOD 9UkkM9eHHUUqEVMhBEMjjGJzgRgSVrgWBEG+o= MIME-Version: 1.0 Received: by 10.102.253.3 with SMTP id a3mr706736mui.49.1280533656979; Fri, 30 Jul 2010 16:47:36 -0700 (PDT) Received: by 10.103.249.16 with HTTP; Fri, 30 Jul 2010 16:47:36 -0700 (PDT) In-Reply-To: References: <20100729.131134.4959786895411328.imp@bsdimp.com> Date: Sat, 31 Jul 2010 05:17:36 +0530 Message-ID: From: "Jayachandran C." To: Juli Mallett Content-Type: multipart/mixed; boundary=0016364166e9bf4987048ca37966 X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: freebsd-mips@freebsd.org Subject: Re: Support for 64bit userspace. 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: Fri, 30 Jul 2010 23:47:39 -0000 --0016364166e9bf4987048ca37966 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable On Fri, Jul 30, 2010 at 2:07 PM, Juli Mallett wrote: > On Fri, Jul 30, 2010 at 01:15, Jayachandran C. > wrote: > > I will look at merging them without too many ifdefs. Another > > possibility is to have a pmap.c, pmap32.c and pmap64.c, so that the > > common code is not duplicated, but that too (as far as I can see) will > > require a config option. > > I'm not really sure what the aversion to ifdefs is =97 they kind of come > with the territory and this is exactly the part of the system where > you expect to have them to conditionalize exactly this kind of > behavior. If you were going to split out some subroutines for 32-bit > and 64-bit, there are two ways you can do it without a config option > (and I agree with you that avoiding one is very desirable =97 we already > use too many knobs to get the right ABI in kernel configs). You could > do: > > #ifndef __mips_n64 > #include "pmap32.c" > #else > #include "pmap64.c" > #endif > > Or you could wrap the whole 32/64 files (modulo a "struct __hack;" or > whatever to avoid an empty translation unit) with ifdefs. > > Personally, I find having two implementations of a function a lot > harder to read and keep track of than a single implementation with > ifdefs in the body =97 there's very few places in the kernel where we do > the former. If you do split out functions into separate files I would > beg you to only split out the really big functions that are actually > doing things based on different levels of page tables and then it's > obvious why those things have two implementations and what needs to be > abstracted to merge them. Having two copies of trivial functions or > non-trivial functions that are mostly identical is a bad thing. > > You're doing the work, so at some point it's kind of your call, but I > feel like you're making style changes to things that I cleaned up and > tried to unify in pmap.c and that the way that they're done is pretty > significant given how intimidating people find pmap. If we were going > to support different kinds of MMUs (e.g. adding support for BAT-based > MMUs) I'd be in favor of splitting things up, but then I'd want to > follow PowerPC's lead. For now I think the appropriate thing to do is > to follow the lead of my 64-bit work in the MIPS pmap and the PAE work > in the i386 pmap and to use ifdefs and to try to abstract out the > page-table differences. > I had not looked at merging the files so far (mostly because it was easier to do it this way), so I will see how best this can be done. I'm really thrilled with the work you're doing and can't wait for it > to be in head =97 I'm quite eager to move everything on Octeon to n64 :) > I have checked in everything except the page table implementation code. If you like to try the current code, the attached patch has the rest of the changes. This has a few more issues fixed, n64 mostly works for me, except a csh crash I'm looking at. I'll have a look at merging pmap.c with pmap64.c, and have another look at the PAE. JC. --0016364166e9bf4987048ca37966 Content-Type: application/octet-stream; name="mips-3lvl-pt.patch" Content-Disposition: attachment; filename="mips-3lvl-pt.patch" Content-Transfer-Encoding: base64 X-Attachment-Id: f_gc9o4ist0 SW5kZXg6IHN5cy9jb25mL29wdGlvbnMubWlwcwo9PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09P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hZ2Ugc2l6ZXMgKi8KSW5kZXg6IHN5cy9taXBzL2NvbmYvWExSNjQKPT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PQotLS0gc3lzL21pcHMvY29uZi9YTFI2NAkocmV2aXNpb24gMjEwNjAxKQorKysgc3lz L21pcHMvY29uZi9YTFI2NAkod29ya2luZyBjb3B5KQpAQCAtMjUsNiArMjUsOCBAQAogbWFrZW9w dGlvbnMgICAgIFRBUkdFVF9CSUdfRU5ESUFOCiAKIGluY2x1ZGUJCSIuLi9ybWkvc3RkLnhsciIK K25vb3B0aW9uCUtFUk5FTF8zMgorb3B0aW9ucwkJS0VSTkVMXzY0CiAKIG1ha2VvcHRpb25zCURF QlVHPS1nCQkjIEJ1aWxkIGtlcm5lbCB3aXRoIGdkYigxKSBkZWJ1ZyBzeW1ib2xzCiBtYWtlb3B0 aW9ucwlBUkNIX0ZMQUdTPSItbWFyY2g9bWlwczY0IC1tYWJpPTY0IgpJbmRleDogc3lzL21pcHMv Y29uZi9ERUZBVUxUUwo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09Ci0tLSBzeXMvbWlwcy9jb25mL0RFRkFVTFRTCShyZXZp c2lvbiAyMTA2MDEpCisrKyBzeXMvbWlwcy9jb25mL0RFRkFVTFRTCSh3b3JraW5nIGNvcHkpCkBA IC0xMSwzICsxMSw0IEBACiAKIG9wdGlvbnMgCUdFT01fUEFSVF9CU0QKIG9wdGlvbnMgCUdFT01f UEFSVF9NQlIKK29wdGlvbnMJCUtFUk5FTF8zMgpJbmRleDogc3lzL21pcHMvbWlwcy9wbWFwNjQu Ywo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09Ci0tLSBzeXMvbWlwcy9taXBzL3BtYXA2NC5jCShyZXZpc2lvbiAwKQorKys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uCisJICovCisJcHZ6b25lID0gdW1hX3pjcmVhdGUoIlBWIEVOVFJZIiwgc2l6ZW9mKHN0cnVj dCBwdl9lbnRyeSksIE5VTEwsIE5VTEwsCisJICAgIE5VTEwsIE5VTEwsIFVNQV9BTElHTl9QVFIs IFVNQV9aT05FX1ZNIHwgVU1BX1pPTkVfTk9GUkVFKTsKKwlwdl9lbnRyeV9tYXggPSBQTUFQX1NI UEdQRVJQUk9DICogbWF4cHJvYyArIGNudC52X3BhZ2VfY291bnQ7CisJcHZfZW50cnlfaGlnaF93 YXRlciA9IDkgKiAocHZfZW50cnlfbWF4IC8gMTApOworCXVtYV96b25lX3NldF9vYmoocHZ6b25l LCAmcHZ6b25lX29iaiwgcHZfZW50cnlfbWF4KTsKK30KKworLyoqKioqKioqKioqKioqKioqKioq KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgorICogTG93IGxldmVsIGhlbHBlciByb3V0 aW5lcy4uLi4uCisgKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq KioqKioqLworCisjaWYgZGVmaW5lZChQTUFQX0RJQUdOT1NUSUMpCisKKy8qCisgKiBUaGlzIGNv ZGUgY2hlY2tzIGZvciBub24td3JpdGVhYmxlL21vZGlmaWVkIHBhZ2VzLgorICogVGhpcyBzaG91 bGQgYmUgYW4gaW52YWxpZCBjb25kaXRpb24uCisgKi8KK3N0YXRpYyBpbnQKK3BtYXBfbndfbW9k aWZpZWQocHRfZW50cnlfdCBwdGUpCit7CisJaWYgKChwdGUgJiAoUFRFX0QgfCBQVEVfUk8pKSA9 PSAoUFRFX0QgfCBQVEVfUk8pKQorCQlyZXR1cm4gKDEpOworCWVsc2UKKwkJcmV0dXJuICgwKTsK K30KKworI2VuZGlmCisKK3N0YXRpYyB2b2lkCitwbWFwX2ludmFsaWRhdGVfYWxsKHBtYXBfdCBw bWFwKQoreworI2lmZGVmIFNNUAorCXNtcF9yZW5kZXp2b3VzKDAsIHBtYXBfaW52YWxpZG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rcmVtb3ZlIHdpbGwgZG8g aXQgZm9yIHVzCisJICovCisKKwl3aGlsZSAoY291bnQtLSA+IDApIHsKKwkJcG1hcF9rcmVtb3Zl KHZhKTsKKwkJdmEgKz0gUEFHRV9TSVpFOworCX0KK30KKworLyoqKioqKioqKioqKioqKioqKioq KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgorICogUGFnZSB0YWJsZSBwYWdlIG1hbmFn ZW1lbnQgcm91dGluZXMuLi4uLgorICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq KioqKioqKioqKioqKioqKi8KKworLyogIFJldmlzaW9uIDEuNTA3CisgKgorICogU2ltcGxpZnkg dGhlIHJlZmVyZW5jZSBjb3VudGluZyBvZiBwYWdlIHRhYmxlIHBhZ2VzLgkgU3BlY2lmaWNhbGx5 LCB1c2UKKyAqIHRoZSBwYWdlIHRhYmxlIHBhZ2UncyB3aXJlZCBjb3VudCByYXRoZXIgdGhhbiBp dHMgaG9sZCBjb3VudCB0byBjb250YWluCisgKiB0aGUgcmVmZXJlbmNlIGNvdW50LgorICovCisK Ky8qCisgKiBUaGlzIHJvdXRpbmUgdW5ob2xkcyBwYWdlIHRhYmxlIHBhZ2VzLCBhbmQgaWYgdGhl IGhvbGQgY291bnQKKyAqIGRyb3BzIHRvIHplcm8sIHRoZW4gaXQgZGVjcmVtZW50cyB0aGUgd2ly ZSBjb3VudC4KKyAqLworc3RhdGljIFBNQVBfSU5MSU5FIGludAorcG1hcF91bndpcmVfcHRlX2hv bGQocG1hcF90IHBtYXAsIHZtX29mZnNldF90IHZhLCB2bV9wYWdlX3QgbSkKK3sKKwktLW0tPndp cmVfY291bnQ7CisJaWYgKG0tPndpcmVfY291bnQgPT0gMCkKKwkJcmV0dXJuIChfcG1hcF91bndp cmVfcHRlX2hvbGQocG1hcCwgdmEsIG0pKTsKKwllbHNlCisJCXJldHVybiAoMCk7Cit9CisKK3N0 YXRpYyBpbnQKK19wbWFwX3Vud2lyZV9wdGVfaG9s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VsX21hcC0+bWF4X29mZnNldDsKKwkJCWJyZWFrOworCQl9CisJfQor fQorCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq CisqIHBhZ2UgbWFuYWdlbWVudCByb3V0aW5lcy4KKyAqKioqKioqKioqKioqKioqKioqKioqKioq KioqKioqKioqKioqKioqKioqKioqKioqKiovCisKKy8qCisgKiBmcmVlIHRoZSBwdl9lbnRyeSBi YWNrIHRvIHRoZSBmcmVlIGxpc3QKKyAqLworc3RhdGljIFBNQVBfSU5MSU5FIHZvaWQKK2ZyZWVf cHZfZW50cnkocHZfZW50cnlfdCBwdikKK3sKKworCXB2X2VudHJ5X2NvdW50LS07CisJdW1hX3pm cmVlKHB2em9uZSwgcHYpOworfQorCisvKgorICogZ2V0IGEgbmV3IHB2X2VudHJ5LCBhbGxvY2F0 aW5nIGEgYmxvY2sgZnJvbSB0aGUgc3lzdGVtCisgKiB3aGVuIG5lZWRlZC4KKyAqIHRoZSBtZW1v cnkgYWxsb2NhdGlvbiBpcyBwZXJmb3JtZWQgYnlwYXNzaW5nIHRoZSBtYWxsb2MgY29kZQorICog YmVjYXVzZSBvZiB0aGUgcG9zc2liaWxpdHkgb2YgYWxsb2NhdGlvbnMgYXQgaW50ZXJydXB0IHRp bWUuCisgKi8KK3N0YXRpYyBwdl9lbnRyeV90CitnZXRfcHZfZW50cnkocG1hcF90IGxvY2tlZF9w bWFwKQoreworCXN0YXRpYyBjb25zdCBzdHJ1Y3QgdGltZXZhbCBwcmludGludGVydmFsID0geyA2 MCwgMCB9OworCXN0YXRpYyBzdHJ1Y3QgdGltZXZhbCBsYXN0cHJpbnQ7CisJc3RydWN0IHZwZ3F1 ZXVlcyAqdnBxOworCXB0X2VudHJ5X3QgKnB0ZSwgb2xkcHRlOworCXBtYXBfdCBwbWFwOworCXB2 X2VudHJ5X3QgYWxsb2NhdGVkX3B2LCBuZXh0X3B2LCBwdjsKKwl2bV9vZmZzZXRfdCB2YTs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QgcG1hcCwgdm1fb2Zmc2V0X3Qg c3ZhLCB2bV9vZmZzZXRfdCBldmEsIHZtX3Byb3RfdCBwcm90KQoreworCXB0X2VudHJ5X3QgKnB0 ZTsKKwlwZF9lbnRyeV90ICpwZHBlLCAqcGRlOworCXZtX29mZnNldF90IHZhX25leHQ7CisKKwlp ZiAocG1hcCA9PSBOVUxMKQorCQlyZXR1cm47CisKKwlpZiAoKHByb3QgJiBWTV9QUk9UX1JFQUQp ID09IFZNX1BST1RfTk9ORSkgeworCQlwbWFwX3JlbW92ZShwbWFwLCBzdmEsIGV2YSk7CisJCXJl dHVybjsKKwl9CisJaWYgKDApIHByaW50ZigiUE1BUCBwcm90ICVwIC0gJXAgJWRcbiIsICh2b2lk ICopc3ZhLCAodm9pZCAqKWV2YSwgKGludClwcm90KTsKKwlpZiAocHJvdCAmIFZNX1BST1RfV1JJ VEUpCisJCXJldHVybjsKKworCXZtX3BhZ2VfbG9ja19xdWV1ZXMoKTsKKwlQTUFQX0xPQ0socG1h cCk7CisJZm9yICg7IHN2YSA8IGV2YTsgc3ZhID0gdmFfbmV4dCkgeworCQlwZHBlID0gcG1hcF9z ZWdtYXAocG1hcCwgc3ZhKTsKKwkJaWYgKCpwZHBlID09IDApIHsKKwkJCXZhX25leHQgPSAoc3Zh ICsgTkJTRUcpICYgflNFR01BU0s7CisJCQlpZiAodmFfbmV4dCA8IHN2YSkKKyAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgdmFfbmV4dCA9IGV2YTsKKwkJCWNvbnRpbnVlOworCQl9CisK KwkJdmFfbmV4dCA9IChzdmEgKyBOQlBEUikgJiB+UERSTUFTSzsKKyAgICAgICAgICAgICAgICBp ZiAodmFfbmV4dCA8IHN2YSkKKyAgICAgICAgICAgICAgICAgICAgICAgIHZhX25leHQgPSBldmE7 CisKKyAgICAgICAgICAgICAgICBwZGUgPSBwbWFwX3BkcGVfdG9fcGRlKHBkcGUsIHN2YSk7CisJ CS8qCisgICAgICAgICAgICAgICAgICogV2VlZCBvdXQgaW52YWxpZCBtYXBwaW5ncy4KKwkJICov CisgICAgICAgICAgICAgICAgaWYgKCpwZGUgPT0gMCkKKwkJCWNvbnRpbnVlOworCisgICAgICAg ICAgICAgICAgaWYgKHZhX25leHQgPiBldmEpCisgICAgICAgICAgICAgICAgICAgICAgICB2YV9u ZXh0ID0gZXZhOworCisgICAgICAgICAgICAgICAgZm9yIChwdGUgPSBwbWFwX3BkZV90b19wdGUo cGRlLCBzdmEpOyBzdmEgIT0gdmFfbmV4dDsgcHRlKyssCisJCQkgICAgIHN2YSArPSBQQUdFX1NJ WkUpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIHB0X2VudHJ5X3Qgb2JpdHMsIHBiaXRzOwor ICAgICAgICAgICAgICAgICAgICAgICAgdm1fcGFnZV90IG07CisJCQl2bV9wYWRkcl90IHBhOwor CityZXRyeToKKwkJCWlmICghcHRlX3Rlc3QocHRlLCBQVEVfVikpCisJCQkJY29udGludWU7CisK KwkJCW9iaXRzID0gcGJpdHMgPSAqcHRlOworCQkJcGEgPSBUTEJMT19QVEVfVE9fUEEocGJpdHMp OworCisJCQlpZiAocGFnZV9pc19tYW5hZ2VkKHBhKSAmJiBwdGVfdGVzdCgmcGJpdHMsIFBURV9E KSkgeworCQkJCW0gPSBQSFlTX1RPX1ZNX1BBR0UocGEpOworCQkJCXZtX3BhZ2VfZGlydHkobSk7 CisJCQkJbS0+bWQucHZfZmxhZ3MgJj0gflBWX1RBQkxFX01PRDsKKwkJCX0KKwkJCXB0ZV9jbGVh cigmcGJpdHMsIFBURV9EKTsKKwkJCXB0ZV9zZXQoJnBiaXRzLCBQVEVfUk8pOworCisJCQlpZiAo cGJpdHMgIT0gKnB0ZSkgeworCQkJCWlmICghYXRvbWljX2NtcHNldF9pbnQoKHVfaW50ICopcHRl LCBvYml0cywgcGJpdHMpKQorCQkJCQlnb3RvIHJldHJ5OworCQkJCXBtYXBfdXBkYXRlX3BhZ2Uo cG1hcCwgc3Z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OCiAJYW5kaQkJazAsIGswLCAweGZmOAkJCSMgazA9cGFn ZSB0YWIgb2Zmc2V0CiAJUFRSX0FERFUJazEsIGsxLCBrMAkJCSMgazE9cHRlIGFkZHJlc3MKSW5k ZXg6IHN5cy9taXBzL21pcHMvZ2VuYXNzeW0uYwo9PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0tLSBzeXMvbWlwcy9taXBz L2dlbmFzc3ltLmMJKHJldmlzaW9uIDIxMDYzOCkKKysrIHN5cy9taXBzL21pcHMvZ2VuYXNzeW0u Ywkod29ya2luZyBjb3B5KQpAQCAtOTMsNiArOTMsNyBAQAogQVNTWU0oUEFHRV9TSElGVCwgUEFH RV9TSElGVCk7CiBBU1NZTShQQUdFX1NJWkUsIFBBR0VfU0laRSk7CiBBU1NZTShQQUdFX01BU0ss IFBBR0VfTUFTSyk7CitBU1NZTShQRFJTSElGVCwgUERSU0hJRlQpOwogQVNTWU0oU0VHU0hJRlQs IFNFR1NISUZUKTsKIEFTU1lNKE5QVEVQRywgTlBURVBHKTsKIEFTU1lNKFRERl9ORUVEUkVTQ0hF RCwgVERGX05FRURSRVNDSEVEKTsK --0016364166e9bf4987048ca37966-- From owner-freebsd-mips@FreeBSD.ORG Sat Jul 31 00:47:58 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 CB853106566C; Sat, 31 Jul 2010 00:47:58 +0000 (UTC) (envelope-from neelnatu@gmail.com) Received: from mail-qw0-f54.google.com (mail-qw0-f54.google.com [209.85.216.54]) by mx1.freebsd.org (Postfix) with ESMTP id 486498FC13; Sat, 31 Jul 2010 00:47:58 +0000 (UTC) Received: by qwk3 with SMTP id 3so506079qwk.13 for ; Fri, 30 Jul 2010 17:47:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=Zy3tsS/Hh/9MtD0Rsol9Isu57my1lGp2cNoEi/UtdWU=; b=PjVptfbwt4Ncclj5k+iTWlJnEhLRfh0/l3a/aKlumA7lEsgjqLB1LxFCAES25DM4Nk KBYREeppfMGDS8++BAdbVwA2hT2su4NURVbltGY+LIiKNDSNxFy1PEOGQSrdcylSBJS4 Z8t24VDp0GNwdyEHmQhbVmDJoPLodN25jqgKo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=kvUbcNbNKG2QdBrr4b8PSEkK1ZOgZHkPw5xvl9bi+ACqLxdRqAi0okPHcAxdlQSAEb NNygamUYqleKxsmTpf8gW8hxRznLZdd3BOxmt8NPN6wi8EM3WCn904abwMClEIJ7Ypah hNJD9FXRjMBjtvSFa9oEbUn1TRMI/VgVcgLe0= MIME-Version: 1.0 Received: by 10.224.66.23 with SMTP id l23mr544853qai.152.1280537277169; Fri, 30 Jul 2010 17:47:57 -0700 (PDT) Received: by 10.224.36.201 with HTTP; Fri, 30 Jul 2010 17:47:56 -0700 (PDT) In-Reply-To: References: <4C41A248.8090605@FreeBSD.org> <4C41B4CF.6080409@FreeBSD.org> <4C4205CC.6080700@FreeBSD.org> <4C4ED247.80701@FreeBSD.org> Date: Fri, 30 Jul 2010 17:47:56 -0700 Message-ID: From: Neel Natu To: "Jayachandran C." Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: Randall Stewart , Alexander Motin , Neel Natu , freebsd-mips@freebsd.org 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: Sat, 31 Jul 2010 00:47:58 -0000 Hi, On Tue, Jul 27, 2010 at 7:43 AM, Jayachandran C. wrote: > On Tue, Jul 27, 2010 at 6:04 PM, Alexander Motin wrote: >> Jayachandran C. wrote: >>> On Sun, Jul 18, 2010 at 1:04 AM, Alexander Motin wrot= e: >>>> Jayachandran C. wrote: >>>>> On XLR we would like to use the count/compare which is faster but les= s >>>>> accurate on all cpus - we can have upto 32 cpus now. =A0We also have = a >>>>> PIC which can provide a better timestamp and timer interrupts. =A0Thi= s >>>>> PIC timestamp can be read from all CPUs but the timer interrupt can b= e >>>>> delivered to just one CPU at a time. =A0I think this is how we ended = up >>>>> with the current implementation, but any suggestions on how to improv= e >>>>> this is welcome. >>> >>> As a first step, I have copied the count /compare code from mips with >>> minor modifications into mips/rmi, this lets me boot up (checked in as >>> r210528). >>> >>> I would like to add the PIC based clock next. >> >> Thanks. >> >>>> I would prefer to not mix the things. >>>> >>>> I think: >>>> =A0- PIC timestamp looks like the best candidate for system timecounte= r. >>>> =A0- per-CPU counters could be registered as per-CPU timecounters with >>>> set_cputicker() - the main criteria there is a speed. >>>> =A0- if per-CPU counters are synchronized between CPUs - they could be >>>> registered as alternative timecounter for people who wish fastest >>>> timecounting; if they are not - they are useless in that role. >>>> =A0- both PIC timer and per-CPU comparators should be independently >>>> registered as eventtimers - it is better to have two of them to from >>>> accounting correctness PoV, and it will allow user to experiment which >>>> one he likes more. >>>> =A0- if there is any other timer hardware - it also should be register= ed - >>>> it will give additional flexibility. >>> >>> The per-cpu count/compare counters are not synchronized on XLR. >> >> Then tick_ticker() function looks broken. counter_lower_last and >> counter_upper should be tracked per-CPU. Otherwise you will have huge >> forward jumps due to false overflows. >> >>> So your suggestion would be to add a PIC based clock which calls >>> tc_init() and et_register(), and to leave the set_cputicker() to be >>> the count/compare? >> >> Yes. And I would leave count/compare also calling tc_init() and >> et_register() as it is now. It won't hurt. >> >>> Also, with just the count/compare, I get these print on early mutiuser = bootup. >>> --- >>> calcru: runtime went backwards from 85936878 usec to 236488 usec for >>> pid 1286 (rpcbind) >>> calcru: runtime went backwards from 7158742 usec to 19700 usec for pid >>> 1285 (nfsiod 0) >>> calcru: runtime went backwards from 111005442 usec to 305474 usec for >>> pid 1257 (syslogd) >>> calcru: runtime went backwards from 10740196 usec to 29555 usec for >>> pid 1048 (devd) >>> -- >>> Did not get much time to investigate, any idea what the cause =A0can be= ? >> >> I think it can easily be result of broken tick_ticker(). > > I'm planning to check-in the attached patch for mips/rmi, I think > mips/mips would need something similar. > 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. - 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'. - Get rid of the superfluous critical section in clock_intr(). There is no reason for it because clock_intr() executes in hard interrupt context. Comments? best Neel Index: sys/mips/sibyte/sb_machdep.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sys/mips/sibyte/sb_machdep.c (revision 210664) +++ sys/mips/sibyte/sb_machdep.c (working copy) @@ -454,6 +454,4 @@ mips_init(); mips_timer_init_params(sb_cpu_speed(), 0); - - set_cputicker(sb_zbbus_cycle_count, sb_cpu_speed() / 2, 1); } Index: sys/mips/mips/tick.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sys/mips/mips/tick.c (revision 210664) +++ sys/mips/mips/tick.c (working copy) @@ -60,9 +60,8 @@ static DPCPU_DEFINE(uint32_t, cycles_per_tick); static uint32_t cycles_per_usec; -static u_int32_t counter_upper =3D 0; -static u_int32_t counter_lower_last =3D 0; - +static DPCPU_DEFINE(uint32_t, counter_upper); +static DPCPU_DEFINE(uint32_t, counter_lower_last); static DPCPU_DEFINE(uint32_t, compare_ticks); static DPCPU_DEFINE(uint32_t, lost_ticks); @@ -104,21 +103,32 @@ { uint64_t ret; uint32_t ticktock; + uint32_t t_lower_last, t_upper; /* - * XXX: MIPS64 platforms can read 64-bits of counter directly. - * Also: the tc code is supposed to cope with things wrapping - * from the time counter, so I'm not sure why all these hoops - * are even necessary. + * Disable preemption because we are working with cpu specific data. */ + critical_enter(); + + /* + * Note that even though preemption is disabled, interrupts are + * still enabled. In particular there is a race with clock_intr() + * reading the values of 'counter_upper' and 'counter_lower_last'. + */ + do { + t_upper =3D DPCPU_GET(counter_upper); + t_lower_last =3D DPCPU_GET(counter_lower_last); + } while (t_upper !=3D DPCPU_GET(counter_upper)); + ticktock =3D mips_rd_count(); - critical_enter(); - if (ticktock < counter_lower_last) - counter_upper++; - counter_lower_last =3D ticktock; + critical_exit(); - ret =3D ((uint64_t) counter_upper << 32) | counter_lower_last; + /* COUNT register wrapped around */ + if (ticktock < t_lower_last) + t_upper++; + + ret =3D ((uint64_t)t_upper << 32) | ticktock; return (ret); } @@ -262,11 +272,11 @@ } else /* In one-shot mode timer should be stopped after the event. */ mips_wr_compare(0xffffffff); - critical_enter(); - if (count < counter_lower_last) { - counter_upper++; - counter_lower_last =3D count; + /* COUNT register wrapped around */ + if (count < DPCPU_GET(counter_lower_last)) { + DPCPU_SET(counter_upper, DPCPU_GET(counter_upper) + 1); } + DPCPU_SET(counter_lower_last, count); if (cycles_per_tick > 0) { @@ -296,7 +306,6 @@ } if (sc->et.et_active) sc->et.et_event_cb(&sc->et, sc->et.et_arg); - critical_exit(); return (FILTER_HANDLED); } > JC. >