summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libhurd-mm/ChangeLog9
-rw-r--r--libhurd-mm/storage.c43
-rw-r--r--libhurd-mm/storage.h5
-rw-r--r--viengoos/ChangeLog6
-rw-r--r--viengoos/as.c17
5 files changed, 65 insertions, 15 deletions
diff --git a/libhurd-mm/ChangeLog b/libhurd-mm/ChangeLog
index 4c86ccb..16e3be2 100644
--- a/libhurd-mm/ChangeLog
+++ b/libhurd-mm/ChangeLog
@@ -1,5 +1,14 @@
2008-05-31 Neal H. Walfield <neal@gnu.org>
+ * storage.h (storage_check_reserve): Take additional parameter
+ i_may_have_as_lock. Update users.
+ * storage.c (storage_check_reserve_internal): Add parameter
+ i_may_have_lock. If false, assume that we do not hold AS_LOCK.
+ (storage_check_reserve): Add parameter i_may_have_lock. Pass to
+ storage_check_reserve_internal.
+
+2008-05-31 Neal H. Walfield <neal@gnu.org>
+
* storage.c (storage_check_reserve_internal): If we don't get
AS_LOCK, don't jump to out_unlock, just return.
diff --git a/libhurd-mm/storage.c b/libhurd-mm/storage.c
index 20daf96..6ea8615 100644
--- a/libhurd-mm/storage.c
+++ b/libhurd-mm/storage.c
@@ -352,7 +352,8 @@ storage_low_mutex_init (void)
static void
storage_check_reserve_internal (bool force_allocate,
addr_t activity,
- enum storage_expectancy expectancy)
+ enum storage_expectancy expectancy,
+ bool i_may_have_lock)
{
top:
if (! force_allocate && likely (free_count > FREE_PAGES_LOW_WATER))
@@ -360,7 +361,7 @@ storage_check_reserve_internal (bool force_allocate,
/* Insufficient storage reserve. Allocate a new storage area. */
- if (free_count > 0)
+ if (i_may_have_lock && free_count > 0)
/* XXX: as_insert calls allocate_object, which calls us. When
we allocate a new folio, we need to insert it into the
address space. This requires calling as_insert, which
@@ -398,7 +399,33 @@ storage_check_reserve_internal (bool force_allocate,
have_lock = true;
}
- debug (3, "Allocating additional folio, " DEBUG_BOLD ("free count: %d"),
+ if (free_count == 0)
+ {
+ extern pthread_rwlock_t as_lock;
+
+ int tries;
+ for (tries = 0; ; tries ++)
+ if (pthread_rwlock_trywrlock (&as_lock) == EBUSY)
+ {
+ int i;
+ for (i = 0; i < 10000; i ++)
+ l4_yield ();
+
+ if (tries == 10)
+ {
+ debug (0, DEBUG_BOLD ("Free count is zero and it seems "
+ "that I have the as_lock!"));
+ break;
+ }
+ }
+ else
+ {
+ pthread_rwlock_unlock (&as_lock);
+ break;
+ }
+ }
+
+ debug (3, "Allocating additional folio, free count: %d",
free_count);
/* Although we have not yet allocated the objects, allocating
@@ -479,9 +506,10 @@ storage_check_reserve_internal (bool force_allocate,
}
void
-storage_check_reserve (void)
+storage_check_reserve (bool i_may_have_lock)
{
- storage_check_reserve_internal (false, meta_data_activity, STORAGE_UNKNOWN);
+ storage_check_reserve_internal (false, meta_data_activity, STORAGE_UNKNOWN,
+ i_may_have_lock);
}
#undef storage_alloc
@@ -497,7 +525,8 @@ storage_alloc (addr_t activity,
bool do_allocate = false;
do
{
- storage_check_reserve_internal (do_allocate, activity, expectancy);
+ storage_check_reserve_internal (do_allocate, activity, expectancy,
+ true);
/* Find an appropriate storage area. */
struct storage_desc *pluck (struct storage_desc *list)
@@ -606,7 +635,7 @@ storage_alloc (addr_t activity,
folio, idx, type,
policy, 0,
addr, ADDR_VOID);
- assert (! err);
+ assertx (! err, "Allocating object %d: %d!", idx, err);
/* We drop DESC->LOCK. */
ss_mutex_unlock (&desc->lock);
diff --git a/libhurd-mm/storage.h b/libhurd-mm/storage.h
index 939d830..f6ccceb 100644
--- a/libhurd-mm/storage.h
+++ b/libhurd-mm/storage.h
@@ -99,7 +99,8 @@ extern void storage_shadow_setup (struct cap *cap, addr_t folio);
/* Check the amount of available storage, allocating more if required.
This should be called by any function that takes the as_lock and
allocates storage (even indirectly) after it has dropped the
- as_lock. */
-extern void storage_check_reserve (void);
+ as_lock. Pass false if you know that you do not hold the as_lock.
+ True otherwise. */
+extern void storage_check_reserve (bool i_may_have_as_lock);
#endif /* _HURD_STORAGE_H */
diff --git a/viengoos/ChangeLog b/viengoos/ChangeLog
index 4bac1d3..6779dc2 100644
--- a/viengoos/ChangeLog
+++ b/viengoos/ChangeLog
@@ -1,3 +1,9 @@
+2008-05-31 Neal H. Walfield <neal@gnu.org>
+
+ * as.c (as_slot_ensure_full): Update use of storage_check_reserve
+ to be consistent with new API.
+ (as_insert): Likewise.
+
2008-05-30 Neal H. Walfield <neal@gnu.org>
* as.c [! RM_INTERN]: Include <hurd/storage.h>.
diff --git a/viengoos/as.c b/viengoos/as.c
index 9980644..c81ffd6 100644
--- a/viengoos/as.c
+++ b/viengoos/as.c
@@ -219,8 +219,10 @@ ID (as_build_internal) (activity_t activity,
{
debug (4, "Overwriting " ADDR_FMT " with " ADDR_FMT
" (at " ADDR_FMT ")",
- ADDR_PRINTF (addr_extend (addr_chop (addr, remaining),
- pte_guard, pte_gbits)),
+ ADDR_PRINTF (addr_extend (addr_chop (addr,
+ remaining),
+ pte_guard,
+ pte_gbits)),
ADDR_PRINTF (addr),
ADDR_PRINTF (addr_chop (addr, remaining)));
/* XXX: Free any data associated with the capability
@@ -495,9 +497,12 @@ ID (as_build_internal) (activity_t activity,
default:
AS_DUMP;
panic ("Can't insert object at " ADDR_FMT ": "
- "%s at " ADDR_FMT " does not translate address bits",
+ "%s at " ADDR_FMT " does not translate address bits "
+ "(remaining: %d, gbits: %d, pte guard: %d, my guard: %d)",
ADDR_PRINTF (addr), cap_type_string (pte->type),
- ADDR_PRINTF (addr_chop (addr, remaining)));
+ ADDR_PRINTF (addr_chop (addr, remaining)),
+ remaining, pte_gbits, pte_guard,
+ extract_bits64_inv (prefix, remaining - 1, pte_gbits));
}
/* That should not be more than we have left to translate. */
@@ -569,7 +574,7 @@ ID (as_slot_ensure_full) (activity_t activity,
AS_UNLOCK;
#ifndef RM_INTERN
- storage_check_reserve ();
+ storage_check_reserve (false);
#endif
return cap;
@@ -594,7 +599,7 @@ ID (as_insert) (activity_t activity,
AS_UNLOCK;
#ifndef RM_INTERN
- storage_check_reserve ();
+ storage_check_reserve (false);
#endif
return slot;