Re: CVS commit: src/sys/arch/arm/include/arm32

2020-01-11 Thread Izumi Tsutsui
thorpej@ wrote:

> > PGSHIFT is defined in  and
> > PAGE_SHIFT and PAGE_SIZE is in ,
> > but there is no common .
> 
> Make a common  that all of the platforms can #include, and 
> just put these common definitions in it (for now)?

How about the attached diff? (untested, just for review)

- Only sun3 use immediate "13" (not PGSHIFT) for PG_SHIFT,
  but sun3/include/param.h also has "#define PGSHIFT 13".
- For now I'll leave evbcf as is. (I doubt its MACHINE_ARCH is m68k)

--- /dev/null   2020-01-12 15:11:38.258153018 +0900
+++ m68k/include/vmparam.h  2020-01-12 15:29:21.866107854 +0900
@@ -0,0 +1,65 @@
+/* $NetBSD$*/
+
+/*
+ * Copyright (c) 1988 University of Utah.
+ * Copyright (c) 1982, 1986, 1990, 1993
+ * The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * 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.
+ * 3. Neither the name of the University nor the names of its contributors
+ *may be used to endorse or promote products derived from this software
+ *without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * from: Utah $Hdr: vmparam.h 1.16 91/01/18$
+ *
+ * @(#)vmparam.h   8.2 (Berkeley) 4/19/94
+ */
+
+#ifndef _M68K_VMPARAM_H_
+#define_M68K_VMPARAM_H_
+
+/*
+ * Common constants for m68k ports
+ */
+
+/*
+ * hp300 pmap derived m68k ports can use 4K or 8K pages.
+ * (except HPMMU machines)
+ * sun3 and sun3x use 8K pages.
+ * The page size is specified by PGSHIFT in .
+ * Override the PAGE_* definitions to be compile-time constants.
+ */
+#definePAGE_SHIFT  PGSHIFT
+#definePAGE_SIZE   (1 << PAGE_SHIFT)
+#definePAGE_MASK   (PAGE_SIZE - 1)
+
+/* Some implemantations like jemalloc(3) require physical page size details. */
+#defineMIN_PAGE_SHIFT  12
+#defineMAX_PAGE_SHIFT  13
+#defineMIN_PAGE_SIZE   (1 << MIN_PAGE_SHIFT)
+#defineMAX_PAGE_SIZE   (1 << MAX_PAGE_SHIFT)
+
+#endif /* _M68K_VMPARAM_H_ */

Index: amiga/include/vmparam.h
===
RCS file: /cvsroot/src/sys/arch/amiga/include/vmparam.h,v
retrieving revision 1.47
diff -u -p -d -r1.47 vmparam.h
--- amiga/include/vmparam.h 27 Mar 2019 17:15:29 -  1.47
+++ amiga/include/vmparam.h 12 Jan 2020 06:29:56 -
@@ -46,12 +46,9 @@
  */
 
 /*
- * We use 8K pages on the Amiga.  Override the PAGE_* definitions
- * to be compie-time constants.
+ * Use common m68k definitions to define PAGE_SIZE and related constants.
  */
-#definePAGE_SHIFT  PGSHIFT
-#definePAGE_SIZE   (1 << PAGE_SHIFT)
-#definePAGE_MASK   (PAGE_SIZE - 1)
+#include 
 
 /*
  * USRSTACK is the top (end) of the user stack.
Index: atari/include/vmparam.h
===
RCS file: /cvsroot/src/sys/arch/atari/include/vmparam.h,v
retrieving revision 1.33
diff -u -p -d -r1.33 vmparam.h
--- atari/include/vmparam.h 27 Mar 2019 17:15:29 -  1.33
+++ atari/include/vmparam.h 12 Jan 2020 06:29:56 -
@@ -46,12 +46,9 @@
  */
 
 /*
- * We use 8K pages on the Atari.  Override the PAGE_* definitions
- * to be compile-time constants.
+ * Use common m68k definitions to define PAGE_SIZE and related constants.
  */
-#definePAGE_SHIFT  PGSHIFT
-#definePAGE_SIZE   (1 << PAGE_SHIFT)
-#definePAGE_MASK   (PAGE_SIZE - 1)
+#include 
 
 /*
  * USRSTACK is the top (end) of the user stack.
Index: cesfic/include/vmparam.h
===
RCS file: 

Re: CVS commit: src/sys/arch/arm/include/arm32

2020-01-11 Thread Jason Thorpe



> On Jan 11, 2020, at 8:32 PM, Izumi Tsutsui  wrote:
> 
> PGSHIFT is defined in  and
> PAGE_SHIFT and PAGE_SIZE is in ,
> but there is no common .

Make a common  that all of the platforms can #include, and just 
put these common definitions in it (for now)?

-- thorpej



Re: CVS commit: src/sys/arch/arm/include/arm32

2020-01-11 Thread Izumi Tsutsui
> >m68k also needs this? (currently no common  though)
> 
> Good catch. Yup, looks like it:
 :
> 
> #define   MIN_PAGE_SHIFT  11  /* sun2 */
> #define   MAX_PAGE_SHIFT  13  /* amiga,atari,sun3 */
> #define   MIN_PAGE_SIZE   (1 << MIN_PAGE_SHIFT)
> #define   MAX_PAGE_SIZE   (1 << MAX_PAGE_SHIFT)

sun2 is different MACHINE_ARCH (m68000) from other m68k ports,
so MIN_PAGE_SHIFT should be 12.

> Should I take care of it or can you?

I just wonder which header file these definitions should be in.
Is  ok?

PGSHIFT is defined in  and
PAGE_SHIFT and PAGE_SIZE is in ,
but there is no common .

---
Izumi Tsutsui


Re: CVS commit: src/sys/arch/arm/include/arm32

2020-01-11 Thread Christos Zoulas
In article <200112121414.m0101...@mirage.ceres.dti.ne.jp>,
Izumi Tsutsui   wrote:
>> Module Name: src
>> Committed By:christos
>> Date:Sat Jan 11 19:06:35 UTC 2020
>> 
>> Modified Files:
>>  src/sys/arch/arm/include/arm32: vmparam.h
>> 
>> Log Message:
>> Define the min and max page size supported for the benefit of jemalloc
>> 
>> 
>> To generate a diff of this commit:
>> cvs rdiff -u -r1.45 -r1.46 src/sys/arch/arm/include/arm32/vmparam.h
>
>--- src/sys/arch/arm/include/arm32/vmparam.h:1.45  Wed Jun 19 09:54:42 2019
>+++ src/sys/arch/arm/include/arm32/vmparam.h   Sat Jan 11 19:06:34 2020
>@@ -84,6 +84,11 @@
> #define   PAGE_SIZE   (1 << PAGE_SHIFT)
> #define   PAGE_MASK   (PAGE_SIZE - 1)
> 
>+#define   MIN_PAGE_SHIFT  12  /* normal */
>+#define   MAX_PAGE_SHIFT  13  /* _ARM_ARCH_6 */
>+#define   MIN_PAGE_SIZE   (1 << MIN_PAGE_SHIFT)
>+#define   MAX_PAGE_SIZE   (1 << MAX_PAGE_SHIFT)
>+
> /*
>  * Mach derived constants
>  */
>
>---
>
>m68k also needs this? (currently no common  though)

Good catch. Yup, looks like it:

$ fgrep PGSHIFT 
{amiga,atari,hp300,luna68k,mac68k,mvme68k,next68k,sun2,sun3,x68k}/
param.h
amiga/include/param.h:#define   PGSHIFT 13  /* LOG2(NBPG) */
atari/include/param.h:#define   PGSHIFT 13  /* LOG2(NBPG) */
hp300/include/param.h:#define   PGSHIFT 12  /* LOG2(NBPG) */
luna68k/include/param.h:#define PGSHIFT 12  /* LOG2(NBPG) */
mac68k/include/param.h:#define  PGSHIFT 12  /* LOG2(NBPG) */
mvme68k/include/param.h:#define PGSHIFT 12  /* LOG2(NBPG) */
next68k/include/param.h:#define PGSHIFT 12  /* LOG2(NBPG) */
sun2/include/param.h:#define PGSHIFT11  /* LOG2(NBPG) */
sun3/include/param.h:#definePGSHIFT 13  /* LOG2(NBPG) */
x68k/include/param.h:#definePGSHIFT 12  /* LOG2(NBPG) */

...

#define   MIN_PAGE_SHIFT  11  /* sun2 */
#define   MAX_PAGE_SHIFT  13  /* amiga,atari,sun3 */
#define   MIN_PAGE_SIZE   (1 << MIN_PAGE_SHIFT)
#define   MAX_PAGE_SIZE   (1 << MAX_PAGE_SHIFT)

Should I take care of it or can you?

christos



Re: CVS commit: src/sys/arch/arm/include/arm32

2020-01-11 Thread Izumi Tsutsui
> Module Name:  src
> Committed By: christos
> Date: Sat Jan 11 19:06:35 UTC 2020
> 
> Modified Files:
>   src/sys/arch/arm/include/arm32: vmparam.h
> 
> Log Message:
> Define the min and max page size supported for the benefit of jemalloc
> 
> 
> To generate a diff of this commit:
> cvs rdiff -u -r1.45 -r1.46 src/sys/arch/arm/include/arm32/vmparam.h

--- src/sys/arch/arm/include/arm32/vmparam.h:1.45   Wed Jun 19 09:54:42 2019
+++ src/sys/arch/arm/include/arm32/vmparam.hSat Jan 11 19:06:34 2020
@@ -84,6 +84,11 @@
 #definePAGE_SIZE   (1 << PAGE_SHIFT)
 #definePAGE_MASK   (PAGE_SIZE - 1)
 
+#defineMIN_PAGE_SHIFT  12  /* normal */
+#defineMAX_PAGE_SHIFT  13  /* _ARM_ARCH_6 */
+#defineMIN_PAGE_SIZE   (1 << MIN_PAGE_SHIFT)
+#defineMAX_PAGE_SIZE   (1 << MAX_PAGE_SHIFT)
+
 /*
  * Mach derived constants
  */

---

m68k also needs this? (currently no common  though)

---
Izumi Tsutsui


Re: [x86 pmap changes] CVS commit: src/sys/arch

2020-01-11 Thread Chavdar Ivanov
BTW, on a just-built 9.99.36, qemu-nvmm now works. However, it seems
at least three times slower than before.

Chavdar

On Sat, 11 Jan 2020 at 20:59, Andrew Doran  wrote:
>
> On Fri, Jan 10, 2020 at 06:56:29PM +, Andrew Doran wrote:
>
> > On Thu, Jan 09, 2020 at 05:46:13PM +0100, Maxime Villard wrote:
> >
> > > This FPU issue should be fixed in the latest nvmm_x86_vmx.c, we still have
> > > STTS/CLTS (not needed but for debugging) as part of context switches, and
> > > when overhauling the FPU code I overlooked that VMX needs special CR0_TS
> > > care that SVM doesn't need.
> > >
> > > Note that dropping STTS/CLTS would probably increase cswitch performance,
> > > because updating cr0 is costly.
> > >
> > > Having said that, I am still hitting a KASSERT related to pmap:
> > >
> > > kernel diagnostic assertion "ptp->wire_count == 1" failed file
> > > ".../x86/x86/pmap.c", line 1969
> > > pmap_freepages
> > > pmap_ept_free_ptp
> > > pmap_ept_remove
> > > pmap_remove
> > > uvm_unmap_remove
> > > uvmspace_free
> > > nvmm_ioctl
> > > sys_ioctl
> >
> > Taking a look.  I think it's probably related to the changes I made to
> > further defer freeing PTPs (ugly but necessary for yamt-pagecache).  I think
> > I see a more elegant way to handle that.
>
> Yes that's the problem. I have a fix and will commit soon.
>
> Andrew



-- 



Re: [x86 pmap changes] CVS commit: src/sys/arch

2020-01-11 Thread Andrew Doran
On Fri, Jan 10, 2020 at 06:56:29PM +, Andrew Doran wrote:

> On Thu, Jan 09, 2020 at 05:46:13PM +0100, Maxime Villard wrote:
> 
> > This FPU issue should be fixed in the latest nvmm_x86_vmx.c, we still have
> > STTS/CLTS (not needed but for debugging) as part of context switches, and
> > when overhauling the FPU code I overlooked that VMX needs special CR0_TS
> > care that SVM doesn't need.
> > 
> > Note that dropping STTS/CLTS would probably increase cswitch performance,
> > because updating cr0 is costly.
> > 
> > Having said that, I am still hitting a KASSERT related to pmap:
> > 
> > kernel diagnostic assertion "ptp->wire_count == 1" failed file
> > ".../x86/x86/pmap.c", line 1969
> > pmap_freepages
> > pmap_ept_free_ptp
> > pmap_ept_remove
> > pmap_remove
> > uvm_unmap_remove
> > uvmspace_free
> > nvmm_ioctl
> > sys_ioctl
> 
> Taking a look.  I think it's probably related to the changes I made to
> further defer freeing PTPs (ugly but necessary for yamt-pagecache).  I think
> I see a more elegant way to handle that.

Yes that's the problem. I have a fix and will commit soon.

Andrew