Re: svn commit: r336047 - in head/sys: amd64/include i386/include sys

2018-08-07 Thread Gleb Smirnoff
On Sat, Aug 04, 2018 at 10:48:17AM +0300, Konstantin Belousov wrote:
K> On Fri, Aug 03, 2018 at 03:27:39PM -0700, Gleb Smirnoff wrote:
K> >   Hi Konstantin,
K> > 
K> > On Fri, Jul 06, 2018 at 07:50:44PM +, Konstantin Belousov wrote:
K> > K> Author: kib
K> > K> Date: Fri Jul  6 19:50:44 2018
K> > K> New Revision: 336047
K> > K> URL: https://svnweb.freebsd.org/changeset/base/336047
K> > K> 
K> > K> Log:
K> > K>   Expand x86 struct pcpus to UMA_PCPU_ALLOC_SIZE AKA PAGE_SIZE.
K> > K>   
K> > K>   This restores counters(9) operation.
K> > K>   Revert r336024. Improve assert of pcpu size on x86.
K> > K>   
K> > K>   Reviewed by:  mmacy
K> > K>   Sponsored by: The FreeBSD Foundation
K> > K>   Differential revision:https://reviews.freebsd.org/D16163
K> > 
K> > Since this has been broken already several times as people who edit
K> > surrounding code don't understand the magic, and since now we round
K> > the struct pcpu size to PAGE_SIZE anyways, what about stop carefully
K> > craft the padding and just change alignment of struct pcpu to PAGE_SIZE?
K> I do not see how it would avoided that breakage.  Also, I like the
K> explicitness in the padding, it is useful when new pcpu members are
K> added.  I have to do that more than once this year.

I was wrong. __aligned would do proper placement of items in an array,
but sizeof would return lesser value.

-- 
Gleb Smirnoff
___
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-unsubscr...@freebsd.org"


Re: svn commit: r336047 - in head/sys: amd64/include i386/include sys

2018-08-04 Thread Konstantin Belousov
On Fri, Aug 03, 2018 at 03:27:39PM -0700, Gleb Smirnoff wrote:
>   Hi Konstantin,
> 
> On Fri, Jul 06, 2018 at 07:50:44PM +, Konstantin Belousov wrote:
> K> Author: kib
> K> Date: Fri Jul  6 19:50:44 2018
> K> New Revision: 336047
> K> URL: https://svnweb.freebsd.org/changeset/base/336047
> K> 
> K> Log:
> K>   Expand x86 struct pcpus to UMA_PCPU_ALLOC_SIZE AKA PAGE_SIZE.
> K>   
> K>   This restores counters(9) operation.
> K>   Revert r336024. Improve assert of pcpu size on x86.
> K>   
> K>   Reviewed by: mmacy
> K>   Sponsored by:The FreeBSD Foundation
> K>   Differential revision:   https://reviews.freebsd.org/D16163
> 
> Since this has been broken already several times as people who edit
> surrounding code don't understand the magic, and since now we round
> the struct pcpu size to PAGE_SIZE anyways, what about stop carefully
> craft the padding and just change alignment of struct pcpu to PAGE_SIZE?
I do not see how it would avoided that breakage.  Also, I like the
explicitness in the padding, it is useful when new pcpu members are
added.  I have to do that more than once this year.
___
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-unsubscr...@freebsd.org"


Re: svn commit: r336047 - in head/sys: amd64/include i386/include sys

2018-08-03 Thread Gleb Smirnoff
  Hi Konstantin,

On Fri, Jul 06, 2018 at 07:50:44PM +, Konstantin Belousov wrote:
K> Author: kib
K> Date: Fri Jul  6 19:50:44 2018
K> New Revision: 336047
K> URL: https://svnweb.freebsd.org/changeset/base/336047
K> 
K> Log:
K>   Expand x86 struct pcpus to UMA_PCPU_ALLOC_SIZE AKA PAGE_SIZE.
K>   
K>   This restores counters(9) operation.
K>   Revert r336024. Improve assert of pcpu size on x86.
K>   
K>   Reviewed by:   mmacy
K>   Sponsored by:  The FreeBSD Foundation
K>   Differential revision: https://reviews.freebsd.org/D16163

Since this has been broken already several times as people who edit
surrounding code don't understand the magic, and since now we round
the struct pcpu size to PAGE_SIZE anyways, what about stop carefully
craft the padding and just change alignment of struct pcpu to PAGE_SIZE?

-- 
Gleb Smirnoff
___
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-unsubscr...@freebsd.org"


svn commit: r336047 - in head/sys: amd64/include i386/include sys

2018-07-06 Thread Konstantin Belousov
Author: kib
Date: Fri Jul  6 19:50:44 2018
New Revision: 336047
URL: https://svnweb.freebsd.org/changeset/base/336047

Log:
  Expand x86 struct pcpus to UMA_PCPU_ALLOC_SIZE AKA PAGE_SIZE.
  
  This restores counters(9) operation.
  Revert r336024. Improve assert of pcpu size on x86.
  
  Reviewed by:  mmacy
  Sponsored by: The FreeBSD Foundation
  Differential revision:https://reviews.freebsd.org/D16163

Modified:
  head/sys/amd64/include/counter.h
  head/sys/amd64/include/pcpu.h
  head/sys/i386/include/pcpu.h
  head/sys/sys/pcpu.h

Modified: head/sys/amd64/include/counter.h
==
--- head/sys/amd64/include/counter.hFri Jul  6 19:50:25 2018
(r336046)
+++ head/sys/amd64/include/counter.hFri Jul  6 19:50:44 2018
(r336047)
@@ -83,18 +83,11 @@ counter_u64_zero_inline(counter_u64_t c)
 static inline void
 counter_u64_add(counter_u64_t c, int64_t inc)
 {
-   int64_t *p;
-#ifdef notyet
+
__asm __volatile("addq\t%1,%%gs:(%0)"
:
: "r" ((char *)c - (char *)&__pcpu[0]), "ri" (inc)
: "memory", "cc");
-#endif
-   /* temporary */
-   critical_enter();
-   p = zpcpu_get(c);
-   *p += inc;
-   critical_exit();
 }
 
 #endif /* ! __MACHINE_COUNTER_H__ */

Modified: head/sys/amd64/include/pcpu.h
==
--- head/sys/amd64/include/pcpu.h   Fri Jul  6 19:50:25 2018
(r336046)
+++ head/sys/amd64/include/pcpu.h   Fri Jul  6 19:50:44 2018
(r336047)
@@ -76,8 +76,7 @@
uint32_t pc_pcid_gen;   \
uint32_t pc_smp_tlb_done;   /* TLB op acknowledgement */\
uint32_t pc_ibpb_set;   \
-   char__pad[216]  /* be divisor of PAGE_SIZE  \
-  after cache alignment */
+   char__pad[3288] /* pad to UMA_PCPU_ALLOC_SIZE */
 
 #definePC_DBREG_CMD_NONE   0
 #definePC_DBREG_CMD_LOAD   1

Modified: head/sys/i386/include/pcpu.h
==
--- head/sys/i386/include/pcpu.hFri Jul  6 19:50:25 2018
(r336046)
+++ head/sys/i386/include/pcpu.hFri Jul  6 19:50:44 2018
(r336047)
@@ -80,7 +80,7 @@
caddr_t pc_pmap_eh_ptep;
\
uint32_t pc_smp_tlb_done;   /* TLB op acknowledgement */\
uint32_t pc_ibpb_set;   \
-   char__pad[538]
+   char__pad[3610]
 
 #ifdef _KERNEL
 

Modified: head/sys/sys/pcpu.h
==
--- head/sys/sys/pcpu.h Fri Jul  6 19:50:25 2018(r336046)
+++ head/sys/sys/pcpu.h Fri Jul  6 19:50:44 2018(r336047)
@@ -185,14 +185,6 @@ struct pcpu {
PCPU_MD_FIELDS;
 } __aligned(CACHE_LINE_SIZE);
 
-#ifdef CTASSERT
-/*
- * To minimize memory waste in per-cpu UMA zones, size of struct pcpu
- * should be denominator of PAGE_SIZE.
- */
-CTASSERT((PAGE_SIZE / sizeof(struct pcpu)) * sizeof(struct pcpu) == PAGE_SIZE);
-#endif
-
 #ifdef _KERNEL
 
 STAILQ_HEAD(cpuhead, pcpu);
@@ -208,6 +200,19 @@ extern struct pcpu *cpuid_to_pcpu[];
 #definecurvidata   PCPU_GET(vidata)
 
 #define UMA_PCPU_ALLOC_SIZEPAGE_SIZE
+
+#ifdef CTASSERT
+#if defined(__i386__) || defined(__amd64__)
+/* Required for counters(9) to work on x86. */
+CTASSERT(sizeof(struct pcpu) == UMA_PCPU_ALLOC_SIZE);
+#else
+/*
+ * To minimize memory waste in per-cpu UMA zones, size of struct pcpu
+ * should be denominator of PAGE_SIZE.
+ */
+CTASSERT((PAGE_SIZE / sizeof(struct pcpu)) * sizeof(struct pcpu) == PAGE_SIZE);
+#endif /* UMA_PCPU_ALLOC_SIZE && x86 */
+#endif /* CTASSERT */
 
 /* Accessor to elements allocated via UMA_ZONE_PCPU zone. */
 static inline void *
___
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-unsubscr...@freebsd.org"