Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 6 Jul 2018 23:18:31 +0200
From:      Oliver Pinter <oliver.pinter@hardenedbsd.org>
To:        "rgrimes@freebsd.org" <rgrimes@freebsd.org>
Cc:        Hans Petter Selasky <hselasky@freebsd.org>,  "svn-src-head@freebsd.org" <svn-src-head@freebsd.org>,  "svn-src-all@freebsd.org" <svn-src-all@freebsd.org>,  "src-committers@freebsd.org" <src-committers@freebsd.org>
Subject:   Re: svn commit: r336025 - in head/sys: amd64/include i386/include
Message-ID:  <CAPQ4fft2U52DicPpoEZMjZimBQ738sBpJ_HxXpGF3hV5cmgBFg@mail.gmail.com>
In-Reply-To: <201807061532.w66FWPEN052842@pdx.rh.CN85.dnsmgr.net>
References:  <201807061013.w66ADgbJ087546@repo.freebsd.org> <201807061532.w66FWPEN052842@pdx.rh.CN85.dnsmgr.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Friday, July 6, 2018, Rodney W. Grimes <freebsd@pdx.rh.cn85.dnsmgr.net>
wrote:

> > Author: hselasky
> > Date: Fri Jul  6 10:13:42 2018
> > New Revision: 336025
> > URL: https://svnweb.freebsd.org/changeset/base/336025
> >
> > Log:
> >   Make sure kernel modules built by default are portable between UP and
> >   SMP systems by extending defined(SMP) to include defined(KLD_MODULE).
> >
> >   This is a regression issue after r335873 .
> >
> >   Discussed with:             mmacy@
> >   Sponsored by:               Mellanox Technologies
>
> Though this fixes the issue, it also means that now when
> anyone intentionally builds a UP kernel with modules
> they are getting SMP support in the modules and I am
> not sure they would want that.  I know I don't.
>
>
On linux case the lock instructions are runtime patchable. They have so
called altinstruction facility, which able to detect specific conditions -
in this case up vs smp - and in up case the locks are replaced with simple
nops or one multi word nop when the instruction longer than 1 byte.



> > Modified:
> >   head/sys/amd64/include/atomic.h
> >   head/sys/i386/include/atomic.h
> >
> > Modified: head/sys/amd64/include/atomic.h
> > ============================================================
> ==================
> > --- head/sys/amd64/include/atomic.h   Fri Jul  6 10:10:00 2018
> (r336024)
> > +++ head/sys/amd64/include/atomic.h   Fri Jul  6 10:13:42 2018
> (r336025)
> > @@ -132,7 +132,7 @@ void              atomic_store_rel_##TYPE(volatile
> u_##TYPE *p, u_
> >   * For userland, always use lock prefixes so that the binaries will run
> >   * on both SMP and !SMP systems.
> >   */
> > -#if defined(SMP) || !defined(_KERNEL)
> > +#if defined(SMP) || !defined(_KERNEL) || defined(KLD_MODULE)
> >  #define      MPLOCKED        "lock ; "
> >  #else
> >  #define      MPLOCKED
> > @@ -354,7 +354,7 @@ atomic_testandclear_long(volatile u_long *p, u_int
> v)
> >   */
> >  #define      OFFSETOF_MONITORBUF     0x100
> >
> > -#if defined(SMP)
> > +#if defined(SMP) || defined(KLD_MODULE)
> >  static __inline void
> >  __storeload_barrier(void)
> >  {
> >
> > Modified: head/sys/i386/include/atomic.h
> > ============================================================
> ==================
> > --- head/sys/i386/include/atomic.h    Fri Jul  6 10:10:00 2018
> (r336024)
> > +++ head/sys/i386/include/atomic.h    Fri Jul  6 10:13:42 2018
> (r336025)
> > @@ -143,7 +143,7 @@ void              atomic_subtract_64(volatile
> uint64_t *, uint64_t
> >   * For userland, always use lock prefixes so that the binaries will run
> >   * on both SMP and !SMP systems.
> >   */
> > -#if defined(SMP) || !defined(_KERNEL)
> > +#if defined(SMP) || !defined(_KERNEL) || defined(KLD_MODULE)
> >  #define      MPLOCKED        "lock ; "
> >  #else
> >  #define      MPLOCKED
> > @@ -302,7 +302,7 @@ atomic_testandclear_int(volatile u_int *p, u_int v)
> >   */
> >
> >  #if defined(_KERNEL)
> > -#if defined(SMP)
> > +#if defined(SMP) || defined(KLD_MODULE)
> >  #define      __storeload_barrier()   __mbk()
> >  #else /* _KERNEL && UP */
> >  #define      __storeload_barrier()   __compiler_membar()
> >
> >
>
> --
> Rod Grimes
> rgrimes@freebsd.org
> _______________________________________________
> svn-src-head@freebsd.org mailing list
> https://lists.freebsd.org/mailman/listinfo/svn-src-head
> To unsubscribe, send any mail to "svn-src-head-unsubscribe@freebsd.org"
>



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