Re: svn commit: r335879 - in head/sys: conf kern sys

2018-07-08 Thread Matthew Macy
On Sun, Jul 8, 2018 at 7:22 AM, Mark Johnston  wrote:
> On Tue, Jul 03, 2018 at 01:55:10AM +, Matt Macy wrote:
>> Author: mmacy
>> Date: Tue Jul  3 01:55:09 2018
>> New Revision: 335879
>> URL: https://svnweb.freebsd.org/changeset/base/335879
>>
>> Log:
>>   make critical_{enter, exit} inline
>>
>>   Avoid pulling in all of the  dependencies by
>>   automatically generating a stripped down thread_lite exporting
>>   only the fields of interest. The field declarations are type checked
>>   against the original and the offsets of the generated result is
>>   automatically checked.
>>
>>   kib has expressed disagreement and would have preferred to simply
>>   use genassym style offsets (which loses type check enforcement).
>>   jhb has expressed dislike of it due to header pollution and a
>>   duplicate structure. He would have preferred to just have defined
>>   thread in _thread.h. Nonetheless, he admits that this is the only
>>   viable solution at the moment.
>>
>>   The impetus for this came from mjg's D15331:
>>   "Inline critical_enter/exit for amd64"
>>
>>   Reviewed by: jeff
>>   Differential Revision: https://reviews.freebsd.org/D16078
>>
>> [...]
>> +#if defined(KLD_MODULE) || defined(KTR_CRITICAL) || !defined(_KERNEL) || 
>> defined(GENOFFSET)
>> +#define critical_enter() critical_enter_KBI()
>> +#define critical_exit() critical_exit_KBI()
>> +#else
>> +static __inline void
>> +critical_enter(void)
>> +{
>> + struct thread_lite *td;
>> +
>> + td = (struct thread_lite *)curthread;
>> + td->td_critnest++;
>
> Don't we need a compiler barrier here?
>

We definitely do. Not sure how that got lost :( Will fix.
-M
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r335879 - in head/sys: conf kern sys

2018-07-08 Thread Mark Johnston
On Tue, Jul 03, 2018 at 01:55:10AM +, Matt Macy wrote:
> Author: mmacy
> Date: Tue Jul  3 01:55:09 2018
> New Revision: 335879
> URL: https://svnweb.freebsd.org/changeset/base/335879
> 
> Log:
>   make critical_{enter, exit} inline
>   
>   Avoid pulling in all of the  dependencies by
>   automatically generating a stripped down thread_lite exporting
>   only the fields of interest. The field declarations are type checked
>   against the original and the offsets of the generated result is
>   automatically checked.
>   
>   kib has expressed disagreement and would have preferred to simply
>   use genassym style offsets (which loses type check enforcement).
>   jhb has expressed dislike of it due to header pollution and a
>   duplicate structure. He would have preferred to just have defined
>   thread in _thread.h. Nonetheless, he admits that this is the only
>   viable solution at the moment.
>   
>   The impetus for this came from mjg's D15331:
>   "Inline critical_enter/exit for amd64"
>   
>   Reviewed by: jeff
>   Differential Revision: https://reviews.freebsd.org/D16078
> 
> [...]
> +#if defined(KLD_MODULE) || defined(KTR_CRITICAL) || !defined(_KERNEL) || 
> defined(GENOFFSET)
> +#define critical_enter() critical_enter_KBI()
> +#define critical_exit() critical_exit_KBI()
> +#else
> +static __inline void
> +critical_enter(void)
> +{
> + struct thread_lite *td;
> +
> + td = (struct thread_lite *)curthread;
> + td->td_critnest++;

Don't we need a compiler barrier here?

> +}
> +
> +static __inline void
> +critical_exit(void)
> +{
> + struct thread_lite *td;
> +
> + td = (struct thread_lite *)curthread;
> + KASSERT(td->td_critnest != 0,
> + ("critical_exit: td_critnest == 0"));
> + td->td_critnest--;
> + __compiler_membar();
> + if (__predict_false(td->td_owepreempt))
> + critical_exit_preempt();
> +
> +}
> +#endif
> +
> +
>  #ifdef  EARLY_PRINTF
>  typedef void early_putc_t(int ch);
>  extern early_putc_t *early_putc;
> 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r335879 - in head/sys: conf kern sys

2018-07-03 Thread Matthew Macy
genoffset_test tests that the offsets match up

On Tue, Jul 3, 2018 at 11:02 AM, Bryan Drewery  wrote:
> On 7/2/2018 6:55 PM, Matt Macy wrote:
>> Author: mmacy
>> Date: Tue Jul  3 01:55:09 2018
>> New Revision: 335879
>> URL: https://svnweb.freebsd.org/changeset/base/335879
>>
>> Log:
>>   make critical_{enter, exit} inline
>>
>>   Avoid pulling in all of the  dependencies by
>>   automatically generating a stripped down thread_lite exporting
>>   only the fields of interest. The field declarations are type checked
>>   against the original and the offsets of the generated result is
>>   automatically checked.
>>
>>   kib has expressed disagreement and would have preferred to simply
>>   use genassym style offsets (which loses type check enforcement).
>>   jhb has expressed dislike of it due to header pollution and a
>>   duplicate structure. He would have preferred to just have defined
>>   thread in _thread.h. Nonetheless, he admits that this is the only
>>   viable solution at the moment.
>>
>>   The impetus for this came from mjg's D15331:
>>   "Inline critical_enter/exit for amd64"
>>
>>   Reviewed by: jeff
>>   Differential Revision: https://reviews.freebsd.org/D16078
>>
>> Added:
>>   head/sys/kern/genoffset.c   (contents, props changed)
>>   head/sys/kern/genoffset.sh   (contents, props changed)
>>   head/sys/sys/kpilite.h   (contents, props changed)
>> Modified:
>>   head/sys/conf/kern.post.mk
>>   head/sys/conf/kern.pre.mk
>>   head/sys/kern/kern_switch.c
>>   head/sys/sys/assym.h
>>   head/sys/sys/systm.h
>>
>> Modified: head/sys/conf/kern.post.mk
>> ==
>> --- head/sys/conf/kern.post.mkMon Jul  2 22:59:29 2018
>> (r335878)
>> +++ head/sys/conf/kern.post.mkTue Jul  3 01:55:09 2018
>> (r335879)
>> @@ -185,13 +185,25 @@ hack.pico: Makefile
>>   ${CC} ${HACK_EXTRA_FLAGS} -nostdlib hack.c -o hack.pico
>>   rm -f hack.c
>>
>> -assym.inc: $S/kern/genassym.sh genassym.o
>> +offset.inc: $S/kern/genoffset.sh genoffset.o
>> + NM='${NM}' NMFLAGS='${NMFLAGS}' sh $S/kern/genoffset.sh genoffset.o > 
>> ${.TARGET}
>> +
>> +genoffset.o: $S/kern/genoffset.c
>> + ${CC} -c ${CFLAGS:N-flto:N-fno-common} $S/kern/genoffset.c
>> +
>> +genoffset_test.c: $S/kern/genoffset.c
>> + cp $S/kern/genoffset.c genoffset_test.c
>> +
>> +genoffset_test.o: genoffset_test.c offset.inc
>> + ${CC} -c ${CFLAGS:N-flto:N-fno-common} -DOFFSET_TEST genoffset_test.c
>> +
>> +assym.inc: $S/kern/genassym.sh genassym.o genoffset_test.o
>>   NM='${NM}' NMFLAGS='${NMFLAGS}' sh $S/kern/genassym.sh genassym.o > 
>> ${.TARGET}
>
> What's genoffset_test? Nothing seems to use it.
>
> --
> Regards,
> Bryan Drewery
>
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r335879 - in head/sys: conf kern sys

2018-07-03 Thread Bryan Drewery
On 7/2/2018 6:55 PM, Matt Macy wrote:
> Author: mmacy
> Date: Tue Jul  3 01:55:09 2018
> New Revision: 335879
> URL: https://svnweb.freebsd.org/changeset/base/335879
> 
> Log:
>   make critical_{enter, exit} inline
>   
>   Avoid pulling in all of the  dependencies by
>   automatically generating a stripped down thread_lite exporting
>   only the fields of interest. The field declarations are type checked
>   against the original and the offsets of the generated result is
>   automatically checked.
>   
>   kib has expressed disagreement and would have preferred to simply
>   use genassym style offsets (which loses type check enforcement).
>   jhb has expressed dislike of it due to header pollution and a
>   duplicate structure. He would have preferred to just have defined
>   thread in _thread.h. Nonetheless, he admits that this is the only
>   viable solution at the moment.
>   
>   The impetus for this came from mjg's D15331:
>   "Inline critical_enter/exit for amd64"
>   
>   Reviewed by: jeff
>   Differential Revision: https://reviews.freebsd.org/D16078
> 
> Added:
>   head/sys/kern/genoffset.c   (contents, props changed)
>   head/sys/kern/genoffset.sh   (contents, props changed)
>   head/sys/sys/kpilite.h   (contents, props changed)
> Modified:
>   head/sys/conf/kern.post.mk
>   head/sys/conf/kern.pre.mk
>   head/sys/kern/kern_switch.c
>   head/sys/sys/assym.h
>   head/sys/sys/systm.h
> 
> Modified: head/sys/conf/kern.post.mk
> ==
> --- head/sys/conf/kern.post.mkMon Jul  2 22:59:29 2018
> (r335878)
> +++ head/sys/conf/kern.post.mkTue Jul  3 01:55:09 2018
> (r335879)
> @@ -185,13 +185,25 @@ hack.pico: Makefile
>   ${CC} ${HACK_EXTRA_FLAGS} -nostdlib hack.c -o hack.pico
>   rm -f hack.c
>  
> -assym.inc: $S/kern/genassym.sh genassym.o
> +offset.inc: $S/kern/genoffset.sh genoffset.o
> + NM='${NM}' NMFLAGS='${NMFLAGS}' sh $S/kern/genoffset.sh genoffset.o > 
> ${.TARGET}
> +
> +genoffset.o: $S/kern/genoffset.c
> + ${CC} -c ${CFLAGS:N-flto:N-fno-common} $S/kern/genoffset.c
> +
> +genoffset_test.c: $S/kern/genoffset.c
> + cp $S/kern/genoffset.c genoffset_test.c
> +
> +genoffset_test.o: genoffset_test.c offset.inc
> + ${CC} -c ${CFLAGS:N-flto:N-fno-common} -DOFFSET_TEST genoffset_test.c
> +
> +assym.inc: $S/kern/genassym.sh genassym.o genoffset_test.o
>   NM='${NM}' NMFLAGS='${NMFLAGS}' sh $S/kern/genassym.sh genassym.o > 
> ${.TARGET}

What's genoffset_test? Nothing seems to use it.

-- 
Regards,
Bryan Drewery



signature.asc
Description: OpenPGP digital signature


svn commit: r335879 - in head/sys: conf kern sys

2018-07-02 Thread Matt Macy
Author: mmacy
Date: Tue Jul  3 01:55:09 2018
New Revision: 335879
URL: https://svnweb.freebsd.org/changeset/base/335879

Log:
  make critical_{enter, exit} inline
  
  Avoid pulling in all of the  dependencies by
  automatically generating a stripped down thread_lite exporting
  only the fields of interest. The field declarations are type checked
  against the original and the offsets of the generated result is
  automatically checked.
  
  kib has expressed disagreement and would have preferred to simply
  use genassym style offsets (which loses type check enforcement).
  jhb has expressed dislike of it due to header pollution and a
  duplicate structure. He would have preferred to just have defined
  thread in _thread.h. Nonetheless, he admits that this is the only
  viable solution at the moment.
  
  The impetus for this came from mjg's D15331:
  "Inline critical_enter/exit for amd64"
  
  Reviewed by: jeff
  Differential Revision: https://reviews.freebsd.org/D16078

Added:
  head/sys/kern/genoffset.c   (contents, props changed)
  head/sys/kern/genoffset.sh   (contents, props changed)
  head/sys/sys/kpilite.h   (contents, props changed)
Modified:
  head/sys/conf/kern.post.mk
  head/sys/conf/kern.pre.mk
  head/sys/kern/kern_switch.c
  head/sys/sys/assym.h
  head/sys/sys/systm.h

Modified: head/sys/conf/kern.post.mk
==
--- head/sys/conf/kern.post.mk  Mon Jul  2 22:59:29 2018(r335878)
+++ head/sys/conf/kern.post.mk  Tue Jul  3 01:55:09 2018(r335879)
@@ -185,13 +185,25 @@ hack.pico: Makefile
${CC} ${HACK_EXTRA_FLAGS} -nostdlib hack.c -o hack.pico
rm -f hack.c
 
-assym.inc: $S/kern/genassym.sh genassym.o
+offset.inc: $S/kern/genoffset.sh genoffset.o
+   NM='${NM}' NMFLAGS='${NMFLAGS}' sh $S/kern/genoffset.sh genoffset.o > 
${.TARGET}
+
+genoffset.o: $S/kern/genoffset.c
+   ${CC} -c ${CFLAGS:N-flto:N-fno-common} $S/kern/genoffset.c
+
+genoffset_test.c: $S/kern/genoffset.c
+   cp $S/kern/genoffset.c genoffset_test.c
+
+genoffset_test.o: genoffset_test.c offset.inc
+   ${CC} -c ${CFLAGS:N-flto:N-fno-common} -DOFFSET_TEST genoffset_test.c
+
+assym.inc: $S/kern/genassym.sh genassym.o genoffset_test.o
NM='${NM}' NMFLAGS='${NMFLAGS}' sh $S/kern/genassym.sh genassym.o > 
${.TARGET}
 
-genassym.o: $S/$M/$M/genassym.c
+genassym.o: $S/$M/$M/genassym.c  offset.inc
${CC} -c ${CFLAGS:N-flto:N-fno-common} $S/$M/$M/genassym.c
 
-${SYSTEM_OBJS} genassym.o vers.o: opt_global.h
+${SYSTEM_OBJS} genoffset.o genassym.o vers.o: opt_global.h
 
 .if !empty(.MAKE.MODE:Unormal:Mmeta) && empty(.MAKE.MODE:Unormal:Mnofilemon)
 _meta_filemon= 1
@@ -213,10 +225,10 @@ _SKIP_DEPEND= 1
 .endif
 
 kernel-depend: .depend
-SRCS=  assym.inc vnode_if.h ${BEFORE_DEPEND} ${CFILES} \
+SRCS=  assym.inc offset.inc vnode_if.h ${BEFORE_DEPEND} ${CFILES} \
${SYSTEM_CFILES} ${GEN_CFILES} ${SFILES} \
${MFILES:T:S/.m$/.h/}
-DEPENDOBJS+=   ${SYSTEM_OBJS} genassym.o
+DEPENDOBJS+=   ${SYSTEM_OBJS} genassym.o genoffset.o
 DEPENDFILES=   ${DEPENDOBJS:O:u:C/^/.depend./}
 .if ${MAKE_VERSION} < 20160220
 DEPEND_MP?=-MP

Modified: head/sys/conf/kern.pre.mk
==
--- head/sys/conf/kern.pre.mk   Mon Jul  2 22:59:29 2018(r335878)
+++ head/sys/conf/kern.pre.mk   Tue Jul  3 01:55:09 2018(r335879)
@@ -195,7 +195,7 @@ OFEDCFLAGS= ${CFLAGS:N-I*} -DCONFIG_INFINIBAND_USER_ME
 OFED_C_NOIMP=  ${CC} -c -o ${.TARGET} ${OFEDCFLAGS} ${WERROR} ${PROF}
 OFED_C=${OFED_C_NOIMP} ${.IMPSRC}
 
-GEN_CFILES= $S/$M/$M/genassym.c ${MFILES:T:S/.m$/.c/}
+GEN_CFILES= $S/$M/$M/genassym.c $S/kern/genoffset.c ${MFILES:T:S/.m$/.c/}
 SYSTEM_CFILES= config.c env.c hints.c vnode_if.c
 SYSTEM_DEP= Makefile ${SYSTEM_OBJS}
 SYSTEM_OBJS= locore.o ${MDOBJS} ${OBJS}

Added: head/sys/kern/genoffset.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/kern/genoffset.c   Tue Jul  3 01:55:09 2018(r335879)
@@ -0,0 +1,44 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (c) 2018, Matthew Macy 
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS