From owner-freebsd-arm@FreeBSD.ORG Mon Oct 12 20:35:28 2009 Return-Path: Delivered-To: freebsd-arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B7F0C106566B for ; Mon, 12 Oct 2009 20:35:28 +0000 (UTC) (envelope-from gballet@gmail.com) Received: from mail-ew0-f218.google.com (mail-ew0-f218.google.com [209.85.219.218]) by mx1.freebsd.org (Postfix) with ESMTP id 143CE8FC16 for ; Mon, 12 Oct 2009 20:35:27 +0000 (UTC) Received: by ewy18 with SMTP id 18so3136814ewy.43 for ; Mon, 12 Oct 2009 13:35:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=Roe4tf6SU0V6pi65/YZe5k/B++ptG1SUWAY8m62lwv8=; b=Ve0PnkTpSJGeUIk3UkeILQtQhcz1+ficf8vTR5e97gT+p/PufJ4ztsD93TyFX1Nz8W LhSGluI2bqjGyp2mHPp+LehpwHrUojZpvojK/9YASpK3hki5KbQ3KrQvxDSyhDRgKYBS 1kk1s+qK5hE/rwpz/mX0Hber9mE/UWoWOzdEA= 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 :content-type:content-transfer-encoding; b=beeZJSXeOpg0qRMfV6XjeaKpc6DWIckpmgMyX0PT+Sx9Uiey62yInsQjCQZyuVoE22 aDMCdEx2cBv6WB4VBe1HyIp3IE0MzIdPmOnFHml5Fw6nfEOt090Wt17Q+Tz4/t57IKFN Z2kvgHWSCIgC+R1+FdscKOfJfap8s2mAxy05o= MIME-Version: 1.0 Received: by 10.210.84.10 with SMTP id h10mr4434040ebb.70.1255379726975; Mon, 12 Oct 2009 13:35:26 -0700 (PDT) In-Reply-To: <6C1CF2D3-A473-4A73-92CB-C45BEEABCE0E@semihalf.com> References: <200910081613.n98GDt7r053539@casselton.net> <4A95E6D9-7BA5-4D8A-99A1-6BC6A7EABC18@semihalf.com> <20091012153628.9196951f.stas@deglitch.com> <4AD32D76.3090401@freebsd.org> <6C1CF2D3-A473-4A73-92CB-C45BEEABCE0E@semihalf.com> Date: Mon, 12 Oct 2009 22:35:26 +0200 Message-ID: From: Guillaume Ballet To: Nathan Whitehorn , Mark Tinguely , freebsd-arm@freebsd.org, Stanislav Sedov Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: Subject: Re: Adding members to struct cpu_functions X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Oct 2009 20:35:28 -0000 On Mon, Oct 12, 2009 at 5:07 PM, Rafal Jaworowski wrote: > > On 2009-10-12, at 15:21, Nathan Whitehorn wrote: > >>>>> I was wondering whether a separate pmap module for ARMv6-7 would not >>>>> be the best approach. After all v6-7 should be considered an entirely >>>>> new architecture variation, and we would avoid the very likely #ifdef= s >>>>> hell in case of a single pmap.c. >>>>> >>>>> >>>> Yeah, I think that would be the best solution. =A0We could conditional= ly >>>> select the right pmap.c file based on the target CPU selected (just >>>> like we do for board variations for at91/marvell). >>>> >>>> >>> >>> pmap.c is a very large file that seems to change very often. I fear >>> having several versions is going to be difficult to maintain. Granted, >>> I haven't read the whole file line after line. Yet it seems to me its >>> content can be abstracted to rely on arch-specific functions that >>> would be found in cpufuncs instead of hardcoded macros. Is there >>> something fundamentally wrong with enhancing struct cpufunc in order >>> to let the portmeisters decide what the MMU and caching bits should >>> look like? This is a blocking issue for me, since it looks like the >>> omap has some problem with backward compatibility mode. Without fixing >>> up the TLBs in my initarm function, it doesn't work. >>> >>> Speaking of #ifdef hell, why not breaking cpufuncs.c into several >>> cpufuncs_.c? That would be a good way to start that >>> reorganization Mark has been talking about in his email. >>> >> One thing that might be worth looking at while thinking about this is ho= w >> this is done on PowerPC. We have run-time selectable PMAP modules using = KOBJ >> to handle CPUs with different MMU designs, as well as a platform module >> scheme, again using KOBJ, to pick the appropriate PMAP for the board as = well >> as determine the physical memory layout and such things. One of the nice >> things about the approach is that it is easy to subclass if you have a n= ew, >> marginally different, design, and it avoids #ifdef hell as well as letti= ng >> you build a GENERIC kernel with support for multiple MMU designs and boa= rd >> types (the last less of a concern on ARM, though). > > What always concerned me was the performance cost this imposes, and it wo= uld > be a really useful exercise to measure what is the actual impact of > KOBJ-tized pmap we have in PowerPC; with an often-called interface like p= map > it might occur the penalty is not that little.. > > Rafal > > Good point. Using KOBJs this way is really cool, but the overhead is going to be a concern if it is used by an application that allocates memory very often. This is not the case of most embedded appliances I worked with, still one should not assume anything about the userland at kernel level. As a result, extending the struct cpu_functions is not a good thing either, for the same reason. The compiler can not inline a call through a function pointer. In which case, why not create a bunch of headers files with the pattern cpufunc_myarch.h, in which all functions would be declared inline? Something like: static inline l2_l_entry(vm_addr_t pa, int prot, int cache); static inline l2_s_entry(vm_addr_t pa, int prot, int cache); ... which would then be included by pmap.c and friends. One problem is that such a change affects all platforms at the same time, and therefore requires all portmeisters to implement the functions that are needed. That should not be too difficult, though, because so far it was the same macros that were used by all platforms. Another problem is that it requires some build script magic to make sure the correct header is included depending on the arch. I wonder if this is easy? Guillaume