Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src Add MAX/MIN PAGE_SIZE and PAGE_SHIFT definitions of m68k for...



details:   https://anonhg.NetBSD.org/src/rev/ecf64c6f043c
branches:  trunk
changeset: 744450:ecf64c6f043c
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Sat Feb 01 19:41:48 2020 +0000

description:
Add MAX/MIN PAGE_SIZE and PAGE_SHIFT definitions of m68k for jemalloc(3).

Background:
- All m68k ports have fixed PAGE_SIZE value in their kernels,
  but each port uses different PAGE_SIZE value (4096 or 8192)
  due to historical reasons.
- Currently module(7) binaries are built per each port so
  all m68k kernel sources don't support run-time variable PAGE_SIZE.
- MI <uvm/uvm_param.h> assumes that the port supports a variable
  PAGE_SIZE on module(7) builds if both MAX_PAGE_SIZE and MIN_PAGE_SIZE
  are defined and they have different values.
- On the other hand, jemalloc(3) checks MAX_PAGE_SHIFT in
  src/external/bsd/jemalloc/include/jemalloc/internal/jemalloc_internal_defs.h
  for internal optimization.
- m68k ports share userland binaries (especially pkgsrc binaries)
  among all ports, so we need to define MAX_PAGE_SHIFT as 13 to
  support m68k ports where PAGE_SIZE==8192.
  (though this would affect only if static binaries built on
   4k page hosts are executed on 8k page hosts)

To solve these inconsistency on PAGE_SIZE definitions,
we should have an independent PAGE_SIZE related definitions
for userland, but it requires major reorganization.
For now (especially for netbsd-9) we define MAX/MIN PAGE_SIZE and
PAGE_SHIFT values in <m68k/vmparam.h> only in !defined(_KERNEL) case.

Discussed on source-changes-d@ and tech-kern@ with christos@ and thorpej@:
 https://mail-index.netbsd.org/source-changes-d/2020/01/thread1.html#012035
 https://mail-index.netbsd.org/tech-kern/2020/01/thread1.html#025954

Should be pulled up to netbsd-9.

diffstat:

 distrib/sets/lists/comp/ad.m68k    |   3 +-
 sys/arch/amiga/include/vmparam.h   |   9 +---
 sys/arch/atari/include/vmparam.h   |   9 +---
 sys/arch/cesfic/include/vmparam.h  |  10 +---
 sys/arch/hp300/include/vmparam.h   |  11 +----
 sys/arch/luna68k/include/vmparam.h |  10 +---
 sys/arch/m68k/include/Makefile     |   3 +-
 sys/arch/m68k/include/vmparam.h    |  74 ++++++++++++++++++++++++++++++++++++++
 sys/arch/mac68k/include/vmparam.h  |  10 +---
 sys/arch/mvme68k/include/vmparam.h |  10 +---
 sys/arch/news68k/include/vmparam.h |  10 +---
 sys/arch/next68k/include/vmparam.h |  10 +---
 sys/arch/sun3/include/vmparam.h    |   9 +---
 sys/arch/x68k/include/vmparam.h    |  10 +---
 14 files changed, 111 insertions(+), 77 deletions(-)

diffs (truncated from 385 to 300 lines):

diff -r 6fe6547f1ad6 -r ecf64c6f043c distrib/sets/lists/comp/ad.m68k
--- a/distrib/sets/lists/comp/ad.m68k   Sat Feb 01 19:29:27 2020 +0000
+++ b/distrib/sets/lists/comp/ad.m68k   Sat Feb 01 19:41:48 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: ad.m68k,v 1.62 2019/10/03 00:59:50 mrg Exp $
+# $NetBSD: ad.m68k,v 1.63 2020/02/01 19:41:48 tsutsui Exp $
 ./usr/bin/elf2aout                             comp-sysutil-bin
 ./usr/include/gcc-4.5/math-68881.h             comp-c-include          obsolete
 ./usr/include/gcc-4.5/tgmath.h                 comp-c-include          obsolete
@@ -70,6 +70,7 @@
 ./usr/include/m68k/trap.h                      comp-c-include
 ./usr/include/m68k/types.h                     comp-c-include
 ./usr/include/m68k/varargs.h                   comp-obsolete           obsolete
+./usr/include/m68k/vmparam.h                   comp-c-include
 ./usr/include/m68k/wchar_limits.h              comp-c-include
 ./usr/lib/libm68k.a                            comp-c-lib
 ./usr/lib/libm68k_p.a                          comp-c-lib              profile
diff -r 6fe6547f1ad6 -r ecf64c6f043c sys/arch/amiga/include/vmparam.h
--- a/sys/arch/amiga/include/vmparam.h  Sat Feb 01 19:29:27 2020 +0000
+++ b/sys/arch/amiga/include/vmparam.h  Sat Feb 01 19:41:48 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vmparam.h,v 1.47 2019/03/27 17:15:29 christos Exp $    */
+/*     $NetBSD: vmparam.h,v 1.48 2020/02/01 19:41:48 tsutsui Exp $     */
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -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.
  */
-#define        PAGE_SHIFT      PGSHIFT
-#define        PAGE_SIZE       (1 << PAGE_SHIFT)
-#define        PAGE_MASK       (PAGE_SIZE - 1)
+#include <m68k/vmparam.h>
 
 /*
  * USRSTACK is the top (end) of the user stack.
diff -r 6fe6547f1ad6 -r ecf64c6f043c sys/arch/atari/include/vmparam.h
--- a/sys/arch/atari/include/vmparam.h  Sat Feb 01 19:29:27 2020 +0000
+++ b/sys/arch/atari/include/vmparam.h  Sat Feb 01 19:41:48 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vmparam.h,v 1.33 2019/03/27 17:15:29 christos Exp $    */
+/*     $NetBSD: vmparam.h,v 1.34 2020/02/01 19:41:49 tsutsui Exp $     */
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -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.
  */
-#define        PAGE_SHIFT      PGSHIFT
-#define        PAGE_SIZE       (1 << PAGE_SHIFT)
-#define        PAGE_MASK       (PAGE_SIZE - 1)
+#include <m68k/vmparam.h>
 
 /*
  * USRSTACK is the top (end) of the user stack.
diff -r 6fe6547f1ad6 -r ecf64c6f043c sys/arch/cesfic/include/vmparam.h
--- a/sys/arch/cesfic/include/vmparam.h Sat Feb 01 19:29:27 2020 +0000
+++ b/sys/arch/cesfic/include/vmparam.h Sat Feb 01 19:41:48 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vmparam.h,v 1.18 2019/06/28 15:17:43 tsutsui Exp $     */
+/*     $NetBSD: vmparam.h,v 1.19 2020/02/01 19:41:49 tsutsui Exp $     */
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -46,13 +46,9 @@
  */
 
 /*
- * hp300 pmap derived m68k ports can use 4K or 8K pages.
- * The page size is specified by PGSHIFT in <machine/param.h>.
- * Override the PAGE_* definitions to be compile-time constants.
+ * Use common m68k definitions to define PAGE_SIZE and related constants.
  */
-#define        PAGE_SHIFT      PGSHIFT
-#define        PAGE_SIZE       (1 << PAGE_SHIFT)
-#define        PAGE_MASK       (PAGE_SIZE - 1)
+#include <m68k/vmparam.h>
 
 /*
  * USRSTACK is the top (end) of the user stack.
diff -r 6fe6547f1ad6 -r ecf64c6f043c sys/arch/hp300/include/vmparam.h
--- a/sys/arch/hp300/include/vmparam.h  Sat Feb 01 19:29:27 2020 +0000
+++ b/sys/arch/hp300/include/vmparam.h  Sat Feb 01 19:41:48 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vmparam.h,v 1.40 2019/06/28 15:17:43 tsutsui Exp $     */
+/*     $NetBSD: vmparam.h,v 1.41 2020/02/01 19:41:49 tsutsui Exp $     */
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -46,14 +46,9 @@
  */
 
 /*
- * hp300 pmap derived m68k ports can use 4K or 8K pages.
- * (except HPMMU machines)
- * The page size is specified by PGSHIFT in <machine/param.h>.
- * Override the PAGE_* definitions to be compile-time constants.
+ * Use common m68k definitions to define PAGE_SIZE and related constants.
  */
-#define        PAGE_SHIFT      PGSHIFT
-#define        PAGE_SIZE       (1 << PAGE_SHIFT)
-#define        PAGE_MASK       (PAGE_SIZE - 1)
+#include <m68k/vmparam.h>
 
 /*
  * USRSTACK is the top (end) of the user stack.
diff -r 6fe6547f1ad6 -r ecf64c6f043c sys/arch/luna68k/include/vmparam.h
--- a/sys/arch/luna68k/include/vmparam.h        Sat Feb 01 19:29:27 2020 +0000
+++ b/sys/arch/luna68k/include/vmparam.h        Sat Feb 01 19:41:48 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vmparam.h,v 1.22 2019/06/28 15:17:43 tsutsui Exp $     */
+/*     $NetBSD: vmparam.h,v 1.23 2020/02/01 19:41:49 tsutsui Exp $     */
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -42,13 +42,9 @@
 #define _MACHINE_VMPARAM_H_
 
 /*
- * hp300 pmap derived m68k ports can use 4K or 8K pages.
- * The page size is specified by PGSHIFT in <machine/param.h>.
- * Override the PAGE_* definitions to be compile-time constants.
+ * Use common m68k definitions to define PAGE_SIZE and related constants.
  */
-#define        PAGE_SHIFT      PGSHIFT
-#define        PAGE_SIZE       (1 << PAGE_SHIFT)
-#define        PAGE_MASK       (PAGE_SIZE - 1)
+#include <m68k/vmparam.h>
 
 /*
  * USRSTACK is the top (end) of the user stack.
diff -r 6fe6547f1ad6 -r ecf64c6f043c sys/arch/m68k/include/Makefile
--- a/sys/arch/m68k/include/Makefile    Sat Feb 01 19:29:27 2020 +0000
+++ b/sys/arch/m68k/include/Makefile    Sat Feb 01 19:41:48 2020 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.31 2018/08/22 01:05:22 msaitoh Exp $
+#      $NetBSD: Makefile,v 1.32 2020/02/01 19:41:48 tsutsui Exp $
 
 INCSDIR= /usr/include/m68k
 
@@ -17,6 +17,7 @@
        psl.h pte_motorola.h ptrace.h \
        reg.h rwlock.h setjmp.h signal.h sync_icache.h \
        trap.h types.h \
+       vmparam.h \
        wchar_limits.h
 
 .include <bsd.kinc.mk>
diff -r 6fe6547f1ad6 -r ecf64c6f043c sys/arch/m68k/include/vmparam.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/m68k/include/vmparam.h   Sat Feb 01 19:41:48 2020 +0000
@@ -0,0 +1,74 @@
+/*     $NetBSD: vmparam.h,v 1.1 2020/02/01 19:41:48 tsutsui Exp $      */
+
+/*
+ * 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, that support only 4K page)
+ * sun3 and sun3x use 8K pages.
+ * The page size is specified by PGSHIFT in <machine/param.h>.
+ * Override the PAGE_* definitions to be compile-time constants.
+ */
+#define        PAGE_SHIFT      PGSHIFT
+#define        PAGE_SIZE       (1 << PAGE_SHIFT)
+#define        PAGE_MASK       (PAGE_SIZE - 1)
+
+/* Some implemantations like jemalloc(3) require physical page size details. */
+/*
+ * XXX:
+ * <uvm/uvm_param.h> assumes PAGE_SIZE is not a constant macro
+ * but a variable (*uvmexp_pagesize) on MODULE builds in case of
+ * (MIN_PAGE_SIZE != MAX_PAGE_SIZE).  For now we define these macros
+ * for m68k ports only on !_KERNEL (currently just for jemalloc) builds.
+ */
+#if !defined(_KERNEL)
+#define        MIN_PAGE_SHIFT  12
+#define        MAX_PAGE_SHIFT  13
+#define        MIN_PAGE_SIZE   (1 << MIN_PAGE_SHIFT)
+#define        MAX_PAGE_SIZE   (1 << MAX_PAGE_SHIFT)
+#endif /* !_KERNEL */
+
+#endif /* _M68K_VMPARAM_H_ */
diff -r 6fe6547f1ad6 -r ecf64c6f043c sys/arch/mac68k/include/vmparam.h
--- a/sys/arch/mac68k/include/vmparam.h Sat Feb 01 19:29:27 2020 +0000
+++ b/sys/arch/mac68k/include/vmparam.h Sat Feb 01 19:41:48 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vmparam.h,v 1.45 2019/06/28 15:17:43 tsutsui Exp $     */
+/*     $NetBSD: vmparam.h,v 1.46 2020/02/01 19:41:49 tsutsui Exp $     */
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -81,13 +81,9 @@
  */
 
 /*
- * hp300 pmap derived m68k ports can use 4K or 8K pages.
- * The page size is specified by PGSHIFT in <machine/param.h>.
- * Override the PAGE_* definitions to be compile-time constants.
+ * Use common m68k definitions to define PAGE_SIZE and related constants.
  */
-#define        PAGE_SHIFT      PGSHIFT
-#define        PAGE_SIZE       (1 << PAGE_SHIFT)
-#define        PAGE_MASK       (PAGE_SIZE - 1)
+#include <m68k/vmparam.h>
 
 /*
  * USRSTACK is the top (end) of the user stack.
diff -r 6fe6547f1ad6 -r ecf64c6f043c sys/arch/mvme68k/include/vmparam.h
--- a/sys/arch/mvme68k/include/vmparam.h        Sat Feb 01 19:29:27 2020 +0000
+++ b/sys/arch/mvme68k/include/vmparam.h        Sat Feb 01 19:41:48 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vmparam.h,v 1.37 2019/06/28 15:17:44 tsutsui Exp $     */
+/*     $NetBSD: vmparam.h,v 1.38 2020/02/01 19:41:49 tsutsui Exp $     */
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -46,13 +46,9 @@
  */
 
 /*
- * hp300 pmap derived m68k ports can use 4K or 8K pages.
- * The page size is specified by PGSHIFT in <machine/param.h>.
- * Override the PAGE_* definitions to be compile-time constants.
+ * Use common m68k definitions to define PAGE_SIZE and related constants.
  */
-#define        PAGE_SHIFT      PGSHIFT
-#define        PAGE_SIZE       (1 << PAGE_SHIFT)
-#define        PAGE_MASK       (PAGE_SIZE - 1)
+#include <m68k/vmparam.h>
 
 /*
  * USRSTACK is the top (end) of the user stack.
diff -r 6fe6547f1ad6 -r ecf64c6f043c sys/arch/news68k/include/vmparam.h
--- a/sys/arch/news68k/include/vmparam.h        Sat Feb 01 19:29:27 2020 +0000
+++ b/sys/arch/news68k/include/vmparam.h        Sat Feb 01 19:41:48 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vmparam.h,v 1.22 2019/06/28 15:17:44 tsutsui Exp $     */
+/*     $NetBSD: vmparam.h,v 1.23 2020/02/01 19:41:49 tsutsui Exp $     */
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -46,13 +46,9 @@
  */
 
 /*
- * hp300 pmap derived m68k ports can use 4K or 8K pages.



Home | Main Index | Thread Index | Old Index