[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnumach] 01/03: Imported Upstream version 1.5+git20150827
From: |
Samuel Thibault |
Subject: |
[gnumach] 01/03: Imported Upstream version 1.5+git20150827 |
Date: |
Fri, 28 Aug 2015 12:52:20 +0000 |
This is an automated email from the git hooks/post-receive script.
sthibault pushed a commit to branch master
in repository gnumach.
commit de567f32576d125ab64aa29a4191d8e629dec8d0
Author: Samuel Thibault <address@hidden>
Date: Thu Aug 27 23:55:49 2015 +0000
Imported Upstream version 1.5+git20150827
---
ChangeLog | 109 +++++++++++++++++++++++++++++++++
configfrag.ac | 2 +-
configure | 22 +++----
ddb/db_trap.c | 4 ++
doc/mach.info | 2 +-
doc/mach.info-1 | 4 +-
doc/mach.info-2 | 2 +-
doc/stamp-vti | 4 +-
doc/version.texi | 4 +-
i386/intel/pmap.c | 14 ++---
kern/ast.c | 2 +-
kern/bootstrap.c | 2 +-
kern/exception.c | 32 ++++++++--
kern/lock.c | 74 +++++++++++++++++-----
kern/lock.h | 35 ++++++++++-
kern/machine.c | 8 +--
kern/macros.h | 8 +++
kern/profile.c | 4 +-
kern/sched_prim.c | 8 +--
kern/sched_prim.h | 2 +
kern/task.c | 4 +-
kern/thread.c | 6 +-
kern/thread.h | 4 +-
linux/src/include/linux/compiler-gcc.h | 2 +
linux/src/include/linux/compiler.h | 8 ++-
version.m4 | 2 +-
vm/vm_fault.c | 2 -
vm/vm_object.c | 31 +---------
vm/vm_user.c | 3 -
29 files changed, 297 insertions(+), 107 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 0b4d770..b0e910c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,112 @@
+2015-08-28 Flávio Cruz <address@hidden>
+
+ Make sure the reply port's reference is released when the thread needs
to be halted.
+ * kern/thread.h (thread_halt_self): Add continuation_t parameter.
+ * kern/thread.c (thread_halt_self): Pass continuation_t parameter to
+ thread_block instead of thread_exception_return.
+ * kern/ast.c (ast_taken): Pass thread_exception_return to
thread_halt_self.
+ * kern/profile.c (profile_thread): Likewise.
+ * kern/exception.c (exception_no_server): Likewise.
+ (thread_release_and_exception_return): New function.
+ (exception_raise_continue_slow): Pass
thread_release_and_exception_return to
+ thread_halt_self.
+
+2015-08-28 Flávio Cruz <address@hidden>
+
+ Add a thread_no_continuation definition
+ to replace the use of the NULL pointer.
+
+ * kern/sched_prim.h (thread_no_continuation): New macro.
+ * kern/machine.c (processor_assign, processor_doaction): Use
+ thread_no_continuation instead of 0.
+ * kern/profile.c (send_last_sample_buf): Likewise
+ * kern/sched_prim.c (thread_sleep, thread_invoke, thread_dispatch):
+ Likewise.
+ * kern/task.c (task_terminate, task_assign): Likewise.
+ * kern/thread.c (thread_suspend): Likewise.
+ * kern/thread.h (struct thread): Change type of swap_func field to
+ continuation_t.
+
+2015-08-20 Justus Winter <address@hidden>
+
+ kern/bootstrap: tune locking
+ * kern/bootstrap.c (boot_script_exec_cmd): Avoid holding the lock
+ across the call to `thread_create'.
+
+ i386: enable assertions
+ * i386/intel/pmap.c (pmap_page_protect): Enable assertions.
+ (phys_attribute_clear, phys_attribute_test): Likewise.
+
+ kern: really zero-out unused simple lock info entries
+ * kern/lock.c (simple_unlock): Really zero-out unused simple lock info
+ entries.
+
+2015-08-18 Justus Winter <address@hidden>
+
+ i386: fix panic message
+ * i386/intel/pmap.c (pmap_page_protect): Fix function name in panic
+ message.
+
+ vm: collapse unreachable branch into assertion
+ * vm/vm_object.c (vm_object_collapse): Collapse unreachable branch
+ into assertion.
+
+2015-08-17 Justus Winter <address@hidden>
+
+ kern: keep track of the writer when debugging locks
+ * configfrag.ac (MACH_LDEBUG): Adjust comment, we use it to sanity
+ check all locks now.
+ * kern/lock.c (lock_write): Keep track of the writer thread.
+ (lock_done): Clear writer.
+ (lock_read_to_write): Keep track of the writer thread.
+ (lock_write_to_read): Assert that the current thread holds the lock.
+ Clear writer.
+ (lock_try_write): Keep track of the writer thread.
+ (lock_try_read_to_write): Likewise.
+ (lock_set_recursive): Assert that the current thread holds the lock.
+ * kern/lock.h (struct lock): New field `writer'.
+ (have_read_lock, have_write_lock, have_lock): New macros that can be
+ used to assert that the current thread holds the given lock. If
+ MACH_LDEBUG is not set, they evaluate to true.
+
+2015-08-17 Justus Winter <address@hidden>
+
+ kern: improve simple lock debugging
+ Do not bother saving the return address when acquire a simple lock.
+ Save the location as provided by the compiler as string instead. Also
+ save the lock parameter.
+
+ * kern/lock.c (struct simple_locks_info): Drop `ra', add `expr', `loc'.
+ (simple_lock): Rename to `_simple_lock', add expression and location
+ parameters and save them.
+ (simple_lock_try): Likewise.
+ (simple_unlock): Zero-out the now unused slot in the list of taken
locks.
+ (db_show_all_slocks): Use the new information.
+ * kern/lock.h (simple_lock, simple_lock_try): Provide macro versions
+ passing the location and expression as string.
+
+2015-08-17 Justus Winter <address@hidden>
+
+ kern: disable the simple lock checks while debugging
+ * kern/lock.c (do_check_simple_locks): New variable.
+ (check_simple_locks): Make check conditional.
+ (check_simple_locks_{en,dis}able): New functions.
+ * kern/lock.h (check_simple_locks_{en,dis}able): New declarations.
+ * ddb/db_trap.c (db_task_trap): Disable simple lock checks.
+
+2015-08-15 Justus Winter <address@hidden>
+
+ vm: fix compiler warning
+ * vm/vm_user.c (vm_wire): Drop unused but set variable `host'.
+
+ vm: enable extra assertions
+ * vm/vm_fault.c (vm_fault_page): Enable extra assertions.
+
+ Avoid re-defining macros
+ * kern/macros.h: Avoid re-defining macros.
+ * linux/src/include/linux/compiler-gcc.h: Likewise.
+ * linux/src/include/linux/compiler.h: Likewise.
+
2015-07-25 Justus Winter <address@hidden>
kern: add boot-time clock, use it for time stamps
diff --git a/configfrag.ac b/configfrag.ac
index e41a3a1..c0e04b3 100644
--- a/configfrag.ac
+++ b/configfrag.ac
@@ -63,7 +63,7 @@ AC_DEFINE([MACH_IPC_DEBUG], [1], [MACH_IPC_DEBUG])
# Testing code/printfs.
AC_DEFINE([MACH_IPC_TEST], [0], [MACH_IPC_TEST])
-# Sanity-check simple locking.
+# Sanity-check locking.
AC_DEFINE([MACH_LDEBUG], [0], [MACH_LDEBUG])
# MP lock monitoring. Registers use of locks, contention. Depending on
diff --git a/configure b/configure
index 8da0203..efd8295 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for GNU Mach 1.5+git20150728.
+# Generated by GNU Autoconf 2.69 for GNU Mach 1.5+git20150827.
#
# Report bugs to <address@hidden>.
#
@@ -579,8 +579,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='GNU Mach'
PACKAGE_TARNAME='gnumach'
-PACKAGE_VERSION='1.5+git20150728'
-PACKAGE_STRING='GNU Mach 1.5+git20150728'
+PACKAGE_VERSION='1.5+git20150827'
+PACKAGE_STRING='GNU Mach 1.5+git20150827'
PACKAGE_BUGREPORT='address@hidden'
PACKAGE_URL=''
@@ -1584,7 +1584,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures GNU Mach 1.5+git20150728 to adapt to many kinds of
systems.
+\`configure' configures GNU Mach 1.5+git20150827 to adapt to many kinds of
systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1654,7 +1654,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of GNU Mach 1.5+git20150728:";;
+ short | recursive ) echo "Configuration of GNU Mach 1.5+git20150827:";;
esac
cat <<\_ACEOF
@@ -2002,7 +2002,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-GNU Mach configure 1.5+git20150728
+GNU Mach configure 1.5+git20150827
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
@@ -2094,7 +2094,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by GNU Mach $as_me 1.5+git20150728, which was
+It was created by GNU Mach $as_me 1.5+git20150827, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
@@ -2960,7 +2960,7 @@ fi
# Define the identity of the package.
PACKAGE='gnumach'
- VERSION='1.5+git20150728'
+ VERSION='1.5+git20150827'
# Some tools Automake needs.
@@ -6414,7 +6414,7 @@ $as_echo "#define MACH_IPC_DEBUG 1" >>confdefs.h
$as_echo "#define MACH_IPC_TEST 0" >>confdefs.h
-# Sanity-check simple locking.
+# Sanity-check locking.
$as_echo "#define MACH_LDEBUG 0" >>confdefs.h
@@ -12116,7 +12116,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by GNU Mach $as_me 1.5+git20150728, which was
+This file was extended by GNU Mach $as_me 1.5+git20150827, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -12187,7 +12187,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //;
s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
-GNU Mach config.status 1.5+git20150728
+GNU Mach config.status 1.5+git20150827
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
diff --git a/ddb/db_trap.c b/ddb/db_trap.c
index 7e10731..cbb6bde 100644
--- a/ddb/db_trap.c
+++ b/ddb/db_trap.c
@@ -45,6 +45,7 @@
#include <ddb/db_trap.h>
#include <ddb/db_run.h>
#include <machine/db_interface.h>
+#include <kern/lock.h>
extern jmp_buf_t *db_recover;
@@ -65,6 +66,8 @@ db_task_trap(
boolean_t watchpt;
task_t task_space;
+ check_simple_locks_disable();
+
task_space = db_target_space(current_thread(), user_space);
bkpt = IS_BREAKPOINT_TRAP(type, code);
watchpt = IS_WATCHPOINT_TRAP(type, code);
@@ -97,6 +100,7 @@ db_task_trap(
db_command_loop();
}
+ check_simple_locks_enable();
db_restart_at_pc(watchpt, task_space);
}
diff --git a/doc/mach.info b/doc/mach.info
index c50a3ba..aa283a7 100644
--- a/doc/mach.info
+++ b/doc/mach.info
@@ -3,7 +3,7 @@ This is mach.info, produced by makeinfo version 6.0 from
mach.texi.
This file documents the GNU Mach microkernel.
This is edition 0.4, last updated on 9 July 2015, of 'The GNU Mach
-Reference Manual', for version 1.5+git20150728.
+Reference Manual', for version 1.5+git20150827.
Copyright (C) 2001, 2002, 2006, 2007, 2008 Free Software Foundation,
Inc.
diff --git a/doc/mach.info-1 b/doc/mach.info-1
index 1e77c43..69cdb55 100644
--- a/doc/mach.info-1
+++ b/doc/mach.info-1
@@ -3,7 +3,7 @@ This is mach.info, produced by makeinfo version 6.0 from
mach.texi.
This file documents the GNU Mach microkernel.
This is edition 0.4, last updated on 9 July 2015, of 'The GNU Mach
-Reference Manual', for version 1.5+git20150728.
+Reference Manual', for version 1.5+git20150827.
Copyright (C) 2001, 2002, 2006, 2007, 2008 Free Software Foundation,
Inc.
@@ -46,7 +46,7 @@ Main Menu
This file documents the GNU Mach microkernel.
This is edition 0.4, last updated on 9 July 2015, of 'The GNU Mach
-Reference Manual', for version 1.5+git20150728.
+Reference Manual', for version 1.5+git20150827.
Copyright (C) 2001, 2002, 2006, 2007, 2008 Free Software Foundation,
Inc.
diff --git a/doc/mach.info-2 b/doc/mach.info-2
index d602f4c..ec764d6 100644
--- a/doc/mach.info-2
+++ b/doc/mach.info-2
@@ -3,7 +3,7 @@ This is mach.info, produced by makeinfo version 6.0 from
mach.texi.
This file documents the GNU Mach microkernel.
This is edition 0.4, last updated on 9 July 2015, of 'The GNU Mach
-Reference Manual', for version 1.5+git20150728.
+Reference Manual', for version 1.5+git20150827.
Copyright (C) 2001, 2002, 2006, 2007, 2008 Free Software Foundation,
Inc.
diff --git a/doc/stamp-vti b/doc/stamp-vti
index 6aaef12..3b4e6b4 100644
--- a/doc/stamp-vti
+++ b/doc/stamp-vti
@@ -1,4 +1,4 @@
@set UPDATED 9 July 2015
@set UPDATED-MONTH July 2015
address@hidden EDITION 1.5+git20150728
address@hidden VERSION 1.5+git20150728
address@hidden EDITION 1.5+git20150827
address@hidden VERSION 1.5+git20150827
diff --git a/doc/version.texi b/doc/version.texi
index 6aaef12..3b4e6b4 100644
--- a/doc/version.texi
+++ b/doc/version.texi
@@ -1,4 +1,4 @@
@set UPDATED 9 July 2015
@set UPDATED-MONTH July 2015
address@hidden EDITION 1.5+git20150728
address@hidden VERSION 1.5+git20150728
address@hidden EDITION 1.5+git20150827
address@hidden VERSION 1.5+git20150827
diff --git a/i386/intel/pmap.c b/i386/intel/pmap.c
index dc9f360..cf7a736 100644
--- a/i386/intel/pmap.c
+++ b/i386/intel/pmap.c
@@ -1585,8 +1585,8 @@ void pmap_page_protect(
/*
* Consistency checks.
*/
- /* assert(*pte & INTEL_PTE_VALID); XXX */
- /* assert(pte_to_phys(*pte) == phys); */
+ assert(*pte & INTEL_PTE_VALID);
+ assert(pte_to_pa(*pte) == phys);
/*
* Remove the mapping if new protection is NONE
@@ -1597,7 +1597,7 @@ void pmap_page_protect(
* Remove the mapping, collecting any modify bits.
*/
if (*pte & INTEL_PTE_WIRED)
- panic("pmap_remove_all removing a wired page");
+ panic("pmap_page_protect removing a wired page");
{
int i = ptes_per_vm_page;
@@ -2463,13 +2463,11 @@ phys_attribute_clear(
va = pv_e->va;
pte = pmap_pte(pmap, va);
-#if 0
/*
* Consistency checks.
*/
assert(*pte & INTEL_PTE_VALID);
- /* assert(pte_to_phys(*pte) == phys); */
-#endif
+ assert(pte_to_pa(*pte) == phys);
/*
* Clear modify or reference bits.
@@ -2556,13 +2554,11 @@ phys_attribute_test(
va = pv_e->va;
pte = pmap_pte(pmap, va);
-#if 0
/*
* Consistency checks.
*/
assert(*pte & INTEL_PTE_VALID);
- /* assert(pte_to_phys(*pte) == phys); */
-#endif
+ assert(pte_to_pa(*pte) == phys);
}
/*
diff --git a/kern/ast.c b/kern/ast.c
index 4b9d63d..2772ed3 100644
--- a/kern/ast.c
+++ b/kern/ast.c
@@ -96,7 +96,7 @@ ast_taken(void)
if (self != current_processor()->idle_thread) {
#ifndef MIGRATING_THREADS
while (thread_should_halt(self))
- thread_halt_self();
+ thread_halt_self(thread_exception_return);
#endif
/*
diff --git a/kern/bootstrap.c b/kern/bootstrap.c
index cb0f976..aad0fb1 100644
--- a/kern/bootstrap.c
+++ b/kern/bootstrap.c
@@ -719,10 +719,10 @@ boot_script_exec_cmd (void *hook, task_t task, char
*path, int argc,
thread_t thread;
struct user_bootstrap_info info = { mod, argv, 0, };
simple_lock_init (&info.lock);
- simple_lock (&info.lock);
err = thread_create ((task_t)task, &thread);
assert(err == 0);
+ simple_lock (&info.lock);
thread->saved.other = &info;
thread_start (thread, user_bootstrap);
err = thread_resume (thread);
diff --git a/kern/exception.c b/kern/exception.c
index 6cb3bfb..63a63d6 100644
--- a/kern/exception.c
+++ b/kern/exception.c
@@ -231,7 +231,7 @@ exception_no_server(void)
*/
while (thread_should_halt(self))
- thread_halt_self();
+ thread_halt_self(thread_exception_return);
#if 0
@@ -257,7 +257,7 @@ exception_no_server(void)
*/
(void) task_terminate(self->task);
- thread_halt_self();
+ thread_halt_self(thread_exception_return);
panic("terminating the task didn't kill us");
/*NOTREACHED*/
}
@@ -848,6 +848,26 @@ exception_raise_continue(void)
}
/*
+ * Routine: thread_release_and_exception_return
+ * Purpose:
+ * Continue after thread was halted.
+ * Conditions:
+ * Nothing locked. We are running on a new kernel stack and
+ * control goes back to thread_exception_return.
+ * Returns:
+ * Doesn't return.
+ */
+static void
+thread_release_and_exception_return(void)
+{
+ ipc_thread_t self = current_thread();
+ /* reply port must be released */
+ ipc_port_release(self->ith_port);
+ thread_exception_return();
+ /*NOTREACHED*/
+}
+
+/*
* Routine: exception_raise_continue_slow
* Purpose:
* Continue after finishing an ipc_mqueue_receive
@@ -876,10 +896,14 @@ exception_raise_continue_slow(
*/
while (thread_should_halt(self)) {
- /* don't terminate while holding a reference */
+ /* if thread is about to terminate, release the port */
if (self->ast & AST_TERMINATE)
ipc_port_release(reply_port);
- thread_halt_self();
+ /*
+ * Use the continuation to release the port in
+ * case the thread is about to halt.
+ */
+ thread_halt_self(thread_release_and_exception_return);
}
ip_lock(reply_port);
diff --git a/kern/lock.c b/kern/lock.c
index 3c74fec..1daf1b4 100644
--- a/kern/lock.c
+++ b/kern/lock.c
@@ -133,12 +133,25 @@ unsigned int simple_locks_taken = 0;
struct simple_locks_info {
simple_lock_t l;
- void *ra;
+ const char *expr;
+ const char *loc;
} simple_locks_info[NSLINFO];
+int do_check_simple_locks = 1;
+
void check_simple_locks(void)
{
- assert(simple_locks_taken == 0);
+ assert(! do_check_simple_locks || simple_locks_taken == 0);
+}
+
+void check_simple_locks_enable(void)
+{
+ do_check_simple_locks = 1;
+}
+
+void check_simple_locks_disable(void)
+{
+ do_check_simple_locks = 0;
}
/* Need simple lock sanity checking code if simple locks are being
@@ -150,8 +163,10 @@ void simple_lock_init(
l->lock_data = 0;
}
-void simple_lock(
- simple_lock_t l)
+void _simple_lock(
+ simple_lock_t l,
+ const char *expression,
+ const char *location)
{
struct simple_locks_info *info;
@@ -161,12 +176,14 @@ void simple_lock(
info = &simple_locks_info[simple_locks_taken++];
info->l = l;
- info->ra =
- __builtin_extract_return_addr (__builtin_return_address (0));
+ info->expr = expression;
+ info->loc = location;
}
-boolean_t simple_lock_try(
- simple_lock_t l)
+boolean_t _simple_lock_try(
+ simple_lock_t l,
+ const char *expression,
+ const char *location)
{
struct simple_locks_info *info;
@@ -177,8 +194,8 @@ boolean_t simple_lock_try(
info = &simple_locks_info[simple_locks_taken++];
info->l = l;
- info->ra =
- __builtin_extract_return_addr (__builtin_return_address (0));
+ info->expr = expression;
+ info->loc = location;
return TRUE;
}
@@ -203,6 +220,7 @@ void simple_unlock(
simple_locks_info[i] = simple_locks_info[simple_locks_taken-1];
}
simple_locks_taken--;
+ simple_locks_info[simple_locks_taken] = (struct simple_locks_info) {0};
}
#endif /* MACH_SLOCKS && NCPUS == 1 */
@@ -300,6 +318,9 @@ void lock_write(
simple_lock(&l->interlock);
}
}
+#if MACH_LDEBUG
+ l->writer = current_thread();
+#endif /* MACH_LDEBUG */
simple_unlock(&l->interlock);
}
@@ -316,8 +337,12 @@ void lock_done(
else
if (l->want_upgrade)
l->want_upgrade = FALSE;
- else
+ else {
l->want_write = FALSE;
+#if MACH_LDEBUG
+ l->writer = THREAD_NULL;
+#endif /* MACH_LDEBUG */
+ }
/*
* There is no reason to wakeup a waiting thread
@@ -434,6 +459,9 @@ boolean_t lock_read_to_write(
}
}
+#if MACH_LDEBUG
+ l->writer = current_thread();
+#endif /* MACH_LDEBUG */
simple_unlock(&l->interlock);
return FALSE;
}
@@ -442,6 +470,9 @@ void lock_write_to_read(
lock_t l)
{
simple_lock(&l->interlock);
+#if MACH_LDEBUG
+ assert(l->writer == current_thread());
+#endif /* MACH_LDEBUG */
l->read_count++;
if (l->recursion_depth != 0)
@@ -457,6 +488,9 @@ void lock_write_to_read(
thread_wakeup(l);
}
+#if MACH_LDEBUG
+ l->writer = THREAD_NULL;
+#endif /* MACH_LDEBUG */
simple_unlock(&l->interlock);
}
@@ -496,6 +530,9 @@ boolean_t lock_try_write(
*/
l->want_write = TRUE;
+#if MACH_LDEBUG
+ l->writer = current_thread();
+#endif /* MACH_LDEBUG */
simple_unlock(&l->interlock);
return TRUE;
}
@@ -572,6 +609,9 @@ boolean_t lock_try_read_to_write(
simple_lock(&l->interlock);
}
+#if MACH_LDEBUG
+ l->writer = current_thread();
+#endif /* MACH_LDEBUG */
simple_unlock(&l->interlock);
return TRUE;
}
@@ -584,6 +624,10 @@ void lock_set_recursive(
lock_t l)
{
simple_lock(&l->interlock);
+#if MACH_LDEBUG
+ assert(l->writer == current_thread());
+#endif /* MACH_LDEBUG */
+
if (!l->want_write) {
panic("lock_set_recursive: don't have write lock");
}
@@ -616,13 +660,9 @@ void db_show_all_slocks(void)
for (i = 0; i < simple_locks_taken; i++) {
info = &simple_locks_info[i];
- db_printf("%d: ", i);
+ db_printf("%d: %s (", i, info->expr);
db_printsym(info->l, DB_STGY_ANY);
-#if defined(__i386__)
- db_printf(" locked by ");
- db_printsym(info->ra, DB_STGY_PROC);
-#endif
- db_printf("\n");
+ db_printf(") locked by %s\n", info->loc);
}
}
#else /* MACH_SLOCKS && NCPUS == 1 */
diff --git a/kern/lock.h b/kern/lock.h
index 435ee1d..2781a48 100644
--- a/kern/lock.h
+++ b/kern/lock.h
@@ -81,6 +81,8 @@ class simple_lock_data_t name;
#define simple_lock_taken(lock) (simple_lock_assert(lock),
\
1) /* always succeeds */
#define check_simple_locks()
+#define check_simple_locks_enable()
+#define check_simple_locks_disable()
#else /* NCPUS > 1 */
/*
@@ -88,15 +90,28 @@ class simple_lock_data_t name;
*/
extern void simple_lock_init(simple_lock_t);
-extern void simple_lock(simple_lock_t);
+extern void _simple_lock(simple_lock_t,
+ const char *, const char *);
extern void simple_unlock(simple_lock_t);
-extern boolean_t simple_lock_try(simple_lock_t);
+extern boolean_t _simple_lock_try(simple_lock_t,
+ const char *, const char *);
+
+/* We provide simple_lock and simple_lock_try so that we can save the
+ location. */
+#define XSTR(x) #x
+#define STR(x) XSTR(x)
+#define LOCATION __FILE__ ":" STR(__LINE__)
+
+#define simple_lock(lock) _simple_lock((lock), #lock, LOCATION)
+#define simple_lock_try(lock) _simple_lock_try((lock), #lock, LOCATION)
#define simple_lock_pause()
#define simple_lock_taken(lock) (simple_lock_assert(lock),
\
(lock)->lock_data)
extern void check_simple_locks(void);
+extern void check_simple_locks_enable(void);
+extern void check_simple_locks_disable(void);
#endif /* NCPUS > 1 */
@@ -121,6 +136,8 @@ class struct simple_lock_data_empty name;
#define simple_lock_taken(l) (simple_lock_assert(l), \
1) /* always succeeds */
#define check_simple_locks()
+#define check_simple_locks_enable()
+#define check_simple_locks_disable()
#define simple_lock_pause()
#endif /* MACH_SLOCKS */
@@ -157,6 +174,9 @@ struct lock {
/* boolean_t */ can_sleep:1, /* Can attempts to lock go to sleep? */
recursion_depth:12, /* Depth of recursion */
:0;
+#if MACH_LDEBUG
+ struct thread *writer;
+#endif /* MACH_LDEBUG */
decl_simple_lock_data(,interlock)
/* Hardware interlock field.
Last in the structure so that
@@ -186,6 +206,17 @@ extern boolean_t lock_try_read_to_write(lock_t);
extern void lock_set_recursive(lock_t);
extern void lock_clear_recursive(lock_t);
+/* Lock debugging support. */
+#if ! MACH_LDEBUG
+#define have_read_lock(l) 1
+#define have_write_lock(l) 1
+#else /* MACH_LDEBUG */
+/* XXX: We don't keep track of readers, so this is an approximation. */
+#define have_read_lock(l) ((l)->read_count > 0)
+#define have_write_lock(l) ((l)->writer == current_thread())
+#endif /* MACH_LDEBUG */
+#define have_lock(l) (have_read_lock(l) || have_write_lock(l))
+
void db_show_all_slocks(void);
#endif /* _KERN_LOCK_H_ */
diff --git a/kern/machine.c b/kern/machine.c
index eced768..3f7a7f7 100644
--- a/kern/machine.c
+++ b/kern/machine.c
@@ -270,7 +270,7 @@ Retry:
assert_wait((event_t) processor, TRUE);
processor_unlock(processor);
splx(s);
- thread_block((void(*)()) 0);
+ thread_block(thread_no_continuation);
goto Retry;
}
@@ -299,7 +299,7 @@ Retry:
assert_wait((event_t)processor, TRUE);
processor_unlock(processor);
splx(s);
- thread_block((void (*)()) 0);
+ thread_block(thread_no_continuation);
s = splsched();
processor_lock(processor);
}
@@ -415,7 +415,7 @@ void processor_doaction(processor_t processor)
*/
this_thread = current_thread();
thread_bind(this_thread, processor);
- thread_block((void (*)()) 0);
+ thread_block(thread_no_continuation);
pset = processor->processor_set;
#if MACH_HOST
@@ -572,7 +572,7 @@ Restart_pset:
thread_deallocate(prev_thread);
thread_bind(this_thread, PROCESSOR_NULL);
- thread_block((void (*)()) 0);
+ thread_block(thread_no_continuation);
return;
}
diff --git a/kern/macros.h b/kern/macros.h
index fb8dc5e..7cc579d 100644
--- a/kern/macros.h
+++ b/kern/macros.h
@@ -54,15 +54,23 @@
#define alignof(x) __alignof__(x)
+#ifndef likely
#define likely(expr) __builtin_expect(!!(expr), 1)
+#endif /* likely */
+#ifndef unlikely
#define unlikely(expr) __builtin_expect(!!(expr), 0)
+#endif /* unlikely */
+#ifndef barrier
#define barrier() asm volatile("" : : : "memory")
+#endif /* barrier */
#define __noreturn __attribute__((noreturn))
#define __aligned(x) __attribute__((aligned(x)))
#define __always_inline inline __attribute__((always_inline))
+#ifndef __section
#define __section(x) __attribute__((section(x)))
+#endif /* __section */
#define __packed __attribute__((packed))
#define __alias(x) __attribute__((alias(x)))
diff --git a/kern/profile.c b/kern/profile.c
index 5510721..1381b1a 100644
--- a/kern/profile.c
+++ b/kern/profile.c
@@ -172,7 +172,7 @@ printf("profile_thread: mach_msg failed returned
%x\n",(int)mr);
sizeof(struct buf_to_send));
}
- thread_halt_self();
+ thread_halt_self(thread_exception_return);
}
@@ -213,7 +213,7 @@ thread_t th;
thread_wakeup((event_t) profile_thread);
assert_wait((event_t) &buf_entry->wakeme, TRUE);
splx(s);
- thread_block((void (*)()) 0);
+ thread_block(thread_no_continuation);
} else {
splx(s);
kmem_free(kernel_map, vm_buf_entry, sizeof(struct buf_to_send));
diff --git a/kern/sched_prim.c b/kern/sched_prim.c
index e8f260e..580ca43 100644
--- a/kern/sched_prim.c
+++ b/kern/sched_prim.c
@@ -454,7 +454,7 @@ void thread_sleep(
{
assert_wait(event, interruptible); /* assert event */
simple_unlock(lock); /* release the lock */
- thread_block((void (*)()) 0); /* block ourselves */
+ thread_block(thread_no_continuation); /* block ourselves */
}
/*
@@ -617,7 +617,7 @@ boolean_t thread_invoke(
thread_unlock(new_thread);
thread_wakeup(TH_EV_STATE(new_thread));
- if (continuation != (void (*)()) 0) {
+ if (continuation != thread_no_continuation) {
(void) spl0();
call_continuation(continuation);
/*NOTREACHED*/
@@ -630,7 +630,7 @@ boolean_t thread_invoke(
*/
thread_lock(new_thread);
if ((old_thread->stack_privilege != current_stack()) &&
- (continuation != (void (*)()) 0))
+ (continuation != thread_no_continuation))
{
switch (new_thread->state & TH_SWAP_STATE) {
case TH_SWAPPED:
@@ -915,7 +915,7 @@ void thread_dispatch(
thread_lock(thread);
- if (thread->swap_func != (void (*)()) 0) {
+ if (thread->swap_func != thread_no_continuation) {
assert((thread->state & TH_SWAP_STATE) == 0);
thread->state |= TH_SWAPPED;
stack_free(thread);
diff --git a/kern/sched_prim.h b/kern/sched_prim.h
index 62698dc..bb1865c 100644
--- a/kern/sched_prim.h
+++ b/kern/sched_prim.h
@@ -52,6 +52,8 @@ typedef void *event_t; /* wait
event */
typedef void (*continuation_t)(void); /* continuation */
+#define thread_no_continuation ((continuation_t) 0) /* no continuation */
+
/*
* Exported interface to sched_prim.c.
*/
diff --git a/kern/task.c b/kern/task.c
index 9a3d848..e9e6ba2 100644
--- a/kern/task.c
+++ b/kern/task.c
@@ -377,7 +377,7 @@ kern_return_t task_terminate(
task_unlock(task);
thread_force_terminate(thread);
thread_deallocate(thread);
- thread_block((void (*)()) 0);
+ thread_block(thread_no_continuation);
task_lock(task);
}
task_unlock(task);
@@ -893,7 +893,7 @@ task_assign(
task->assign_active = TRUE;
assert_wait((event_t)&task->assign_active, TRUE);
task_unlock(task);
- thread_block((void (*)()) 0);
+ thread_block(thread_no_continuation);
task_lock(task);
}
diff --git a/kern/thread.c b/kern/thread.c
index 865a1cc..3e90079 100644
--- a/kern/thread.c
+++ b/kern/thread.c
@@ -1132,7 +1132,7 @@ void __attribute__((noreturn)) walking_zombie(void)
* Thread calls this routine on exit from the kernel when it
* notices a halt request.
*/
-void thread_halt_self(void)
+void thread_halt_self(continuation_t continuation)
{
thread_t thread = current_thread();
spl_t s;
@@ -1173,7 +1173,7 @@ void thread_halt_self(void)
thread_unlock(thread);
splx(s);
counter(c_thread_halt_self_block++);
- thread_block(thread_exception_return);
+ thread_block(continuation);
/*
* thread_release resets TH_HALTED.
*/
@@ -1348,7 +1348,7 @@ kern_return_t thread_suspend(
while (thread->state & TH_UNINT) {
assert_wait(TH_EV_STATE(thread), TRUE);
thread_unlock(thread);
- thread_block(NULL);
+ thread_block(thread_no_continuation);
thread_lock(thread);
}
if (thread->user_stop_count++ == 0) {
diff --git a/kern/thread.h b/kern/thread.h
index 0e85d8c..7106fd2 100644
--- a/kern/thread.h
+++ b/kern/thread.h
@@ -100,7 +100,7 @@ struct thread {
vm_offset_t stack_privilege;/* reserved kernel stack */
/* Swapping information */
- void (*swap_func)(); /* start here after swapin */
+ continuation_t swap_func; /* start here after swapin */
/* Blocking information */
event_t wait_event; /* event we are waiting on */
@@ -362,7 +362,7 @@ extern void thread_release(thread_t);
extern kern_return_t thread_halt(
thread_t thread,
boolean_t must_halt);
-extern void thread_halt_self(void);
+extern void thread_halt_self(continuation_t);
extern void thread_force_terminate(thread_t);
extern thread_t kernel_thread(
task_t task,
diff --git a/linux/src/include/linux/compiler-gcc.h
b/linux/src/include/linux/compiler-gcc.h
index 59e4028..b1a0be0 100644
--- a/linux/src/include/linux/compiler-gcc.h
+++ b/linux/src/include/linux/compiler-gcc.h
@@ -9,7 +9,9 @@
/* Optimization barrier */
/* The "volatile" is due to gcc bugs */
+#ifndef barrier
#define barrier() __asm__ __volatile__("": : :"memory")
+#endif /* barrier */
/*
* This macro obfuscates arithmetic on a variable address so that gcc
diff --git a/linux/src/include/linux/compiler.h
b/linux/src/include/linux/compiler.h
index 320d6c9..eb3dd94 100644
--- a/linux/src/include/linux/compiler.h
+++ b/linux/src/include/linux/compiler.h
@@ -143,8 +143,12 @@ void ftrace_likely_update(struct ftrace_branch_data *f,
int val, int expect);
#endif /* CONFIG_PROFILE_ALL_BRANCHES */
#else
-# define likely(x) __builtin_expect(!!(x), 1)
-# define unlikely(x) __builtin_expect(!!(x), 0)
+# ifndef likely
+# define likely(x) __builtin_expect(!!(x), 1)
+# endif /* likely */
+# ifndef unlikely
+# define unlikely(x) __builtin_expect(!!(x), 0)
+# endif /* unlikely */
#endif
/* Optimization barrier */
diff --git a/version.m4 b/version.m4
index 7727c51..1d5b41f 100644
--- a/version.m4
+++ b/version.m4
@@ -1,4 +1,4 @@
m4_define([AC_PACKAGE_NAME],[GNU Mach])
-m4_define([AC_PACKAGE_VERSION],[1.5+git20150728])
+m4_define([AC_PACKAGE_VERSION],[1.5+git20150827])
m4_define([AC_PACKAGE_BUGREPORT],address@hidden)
m4_define([AC_PACKAGE_TARNAME],[gnumach])
diff --git a/vm/vm_fault.c b/vm/vm_fault.c
index 0fa4d6a..46779f6 100644
--- a/vm/vm_fault.c
+++ b/vm/vm_fault.c
@@ -768,12 +768,10 @@ vm_fault_return_t vm_fault_page(
* objects.
*/
-#if EXTRA_ASSERTIONS
assert(m->busy && !m->absent);
assert((first_m == VM_PAGE_NULL) ||
(first_m->busy && !first_m->absent &&
!first_m->active && !first_m->inactive));
-#endif /* EXTRA_ASSERTIONS */
/*
* If the page is being written, but isn't
diff --git a/vm/vm_object.c b/vm/vm_object.c
index deac0c2..133181f 100644
--- a/vm/vm_object.c
+++ b/vm/vm_object.c
@@ -2465,34 +2465,9 @@ void vm_object_collapse(
VM_PAGE_FREE(p);
}
else {
- if (pp != VM_PAGE_NULL) {
- /*
- * Parent has an absent page...
- * it's not being paged in, so
- * it must really be missing from
- * the parent.
- *
- * Throw out the absent page...
- * any faults looking for that
- * page will restart with the new
- * one.
- */
-
- /*
- * This should never happen -- the
- * parent cannot have ever had an
- * external memory object, and thus
- * cannot have absent pages.
- */
- panic("vm_object_collapse: bad
case");
-
- VM_PAGE_FREE(pp);
-
- /*
- * Fall through to move the backing
- * object's page up.
- */
- }
+ assert(pp == VM_PAGE_NULL || !
+ "vm_object_collapse: bad case");
+
/*
* Parent now has no page.
* Move the backing object's page
up.
diff --git a/vm/vm_user.c b/vm/vm_user.c
index 8c7a5d8..c71e9f5 100644
--- a/vm/vm_user.c
+++ b/vm/vm_user.c
@@ -412,7 +412,6 @@ kern_return_t vm_wire(port, map, start, size, access)
vm_size_t size;
vm_prot_t access;
{
- host_t host;
boolean_t priv;
if (!IP_VALID(port))
@@ -430,8 +429,6 @@ kern_return_t vm_wire(port, map, start, size, access)
priv = ip_kotype(port) == IKOT_HOST_PRIV;
ip_unlock(port);
- host = (host_t) port->ip_kobject;
-
if (map == VM_MAP_NULL)
return KERN_INVALID_TASK;
--
Alioth's /usr/local/bin/git-commit-notice on
/srv/git.debian.org/git/pkg-hurd/gnumach.git