Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 27 Nov 2017 15:29:51 +1100 (EST)
From:      Bruce Evans <brde@optusnet.com.au>
To:        Andrew Turner <andrew@freebsd.org>
Cc:        src-committers@freebsd.org, svn-src-all@freebsd.org,  svn-src-head@freebsd.org
Subject:   Re: svn commit: r326225 - head/sys/arm64/arm64
Message-ID:  <20171127143528.J1162@besplex.bde.org>
In-Reply-To: <201711260929.vAQ9TYpk047843@repo.freebsd.org>
References:  <201711260929.vAQ9TYpk047843@repo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, 26 Nov 2017, Andrew Turner wrote:

> Log:
>  Make the arm64 pmap_invalidate functions static inline. This fixes building
>  with DIAGNOSTIC.

This is fairly broken on x86 too.

> Modified: head/sys/arm64/arm64/pmap.c
> ==============================================================================
> --- head/sys/arm64/arm64/pmap.c	Sun Nov 26 06:31:34 2017	(r326224)
> +++ head/sys/arm64/arm64/pmap.c	Sun Nov 26 09:29:34 2017	(r326225)
> @@ -896,7 +896,7 @@ SYSCTL_ULONG(_vm_pmap_l2, OID_AUTO, promotions, CTLFLA
> /*
>  * Invalidate a single TLB entry.
>  */
> -PMAP_INLINE void
> +static __inline void
> pmap_invalidate_page(pmap_t pmap, vm_offset_t va)

PMAP_INLINE is now only used once on arm64 (for pmap_kremove).  It gives
a small optimization or pessimization by inlining, but is fragile and
broken in some cases.

In the DIAGNOSTIC case, it is usually or always defined as empty.  This is
silly.  It does nothing except insignificantly simplify debugging and
expose the 2 bugs fixed in this commit.  These bugs are:
- on arm64, the pmap_invalidate*() functions are not declared in a header
   file or used outside of pmap.c, but they were declared as gnu
   [implicit-extern] inline for the reachable !DIAGNOSTIC case.
- complier bug: compilers don't detect the error that extern functions
   are not prototyped before they are defined in the gnu [implicit-extern]
   inline case
The bugs are exposed by the DIAGNOSTIC case.  Then the functions are
plain implicit-extern.

There is also an unreachable !DIAGNOSTIC case for non-gcc compatible
compilers.  On x86 and arm64, this uses explicit-extern inline.  This
gives C99 extern inline, which is confusing and probably doesn't worked.
If it worked, then it might be used instead of forcing gnu implicit-extern
inline if possible.

Plain arm is quite different:

arm/pmap-v4.c defines PMAP_INLINE as plain implicit-extern __inline in the
!PMAP_DEBUG case.  But this macro is completely different than the one of
the same name in most other pmap files.  It is only used when preceded by
'static', and thus is just for debugging, while its normal use is for
inlining public functions.  Some static functions are inlined without this
obfuscation.  i386 had the same obfuscation and more in FreeBSD-4 (it also
used PMAP_INLINE for extern functions).

arm/pmap-v6.c is more like arm64/pmap.c.  It ifdefs on DIAGNOSTIC but gives
plain implicit-extern C99 __inline only for extern functions where arm64
gives gnu implicit-extern non-C99 inline.

There are also style bugs.  Most places use __inline, but arm64 uses inline.
amd64/pmap.c uses __inline except twice for PMAP_INLINE and once for
pmap_unwire_ptp().

Bruce



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20171127143528.J1162>