u3: makes loom length configurable

This commit is contained in:
Joe Bryan 2022-08-10 10:34:06 -04:00
parent eec9354849
commit c9a80338ee
11 changed files with 46 additions and 30 deletions

View File

@ -7,7 +7,7 @@
static void
_setup(void)
{
u3m_init();
u3m_init(1 << 23);
u3m_pave(c3y);
}

View File

@ -37,7 +37,7 @@
/* u3m_init(): start the environment.
*/
void
u3m_init();
u3m_init(size_t len_i);
/* u3m_pave(): instantiate or activate image.
*/

View File

@ -1042,6 +1042,11 @@ u3e_live(c3_o nuu_o, c3_c* dir_c)
_ce_patch_delete();
}
if ( u3P.nor_u.pgs_w + u3P.sou_u.pgs_w >= u3P.pag_w ) {
fprintf(stderr, "boot: snapshot too big for loom\r\n");
exit(1);
}
// mark all pages dirty (pages in the snapshot will be marked clean)
//
u3e_foul();

View File

@ -1791,41 +1791,49 @@ _cm_free2(void* tox_v, size_t siz_i)
/* u3m_init(): start the environment.
*/
void
u3m_init(void)
u3m_init(size_t len_i)
{
_cm_limits();
_cm_signals();
_cm_crypto();
/* Make sure GMP uses our malloc.
*/
// make sure GMP uses our malloc.
//
mp_set_memory_functions(u3a_malloc, _cm_realloc2, _cm_free2);
/* Map at fixed address.
*/
// make sure that [len_i] is a fully-addressible non-zero power of two.
//
if ( !len_i
|| (len_i & (len_i - 1))
|| (len_i < (1 << (u3a_page + 2)))
|| (len_i > u3a_bytes) )
{
size_t len_i = u3a_bytes;
void* map_v;
u3l_log("loom: bad size: %zu\r\n", len_i);
exit(1);
}
map_v = mmap((void *)u3_Loom,
// map at fixed address.
//
{
void* map_v = mmap((void *)u3_Loom,
len_i,
(PROT_READ | PROT_WRITE),
(MAP_ANON | MAP_FIXED | MAP_PRIVATE),
-1, 0);
if ( -1 == (c3_ps)map_v ) {
void* dyn_v = mmap((void *)0,
map_v = mmap((void *)0,
len_i,
PROT_READ,
MAP_ANON | MAP_PRIVATE,
(PROT_READ | PROT_WRITE),
(MAP_ANON | MAP_PRIVATE),
-1, 0);
u3l_log("boot: mapping %zuMB failed\r\n", len_i >> 20);
u3l_log("see urbit.org/using/install/#about-swap-space"
" for adding swap space\r\n");
if ( -1 != (c3_ps)dyn_v ) {
if ( -1 != (c3_ps)map_v ) {
u3l_log("if porting to a new platform, try U3_OS_LoomBase %p\r\n",
dyn_v);
map_v);
}
exit(1);
}
@ -1855,7 +1863,7 @@ u3m_boot(c3_c* dir_c)
/* Activate the loom.
*/
u3m_init();
u3m_init(u3a_bytes);
/* Activate the storage system.
*/
@ -1906,7 +1914,7 @@ u3m_boot_lite(void)
{
/* Activate the loom.
*/
u3m_init();
u3m_init(u3a_bytes);
/* Activate tracing.
*/

View File

@ -6,7 +6,7 @@
static void
_setup(void)
{
u3m_init();
u3m_init(1 << 22);
u3m_pave(c3y);
}

View File

@ -9,7 +9,7 @@ c3_w _ch_skip_slot(c3_w mug_w, c3_w lef_w);
static void
_setup(void)
{
u3m_init();
u3m_init(1 << 26);
u3m_pave(c3y);
}

View File

@ -6,7 +6,7 @@
static void
_setup(void)
{
u3m_init();
u3m_init(1 << 23);
u3m_pave(c3y);
}

View File

@ -5,7 +5,7 @@
static void
_setup(void)
{
u3m_init();
u3m_init(1 << 20);
u3m_pave(c3y);
}

View File

@ -5,7 +5,7 @@
static void
_setup(void)
{
u3m_init();
u3m_init(1 << 20);
u3m_pave(c3y);
}

View File

@ -6,7 +6,7 @@
static void
_setup(void)
{
u3m_init();
u3m_init(1 << 20);
u3m_pave(c3y);
}

View File

@ -5,7 +5,10 @@
static void
_setup(void)
{
u3m_init();
// XX at 1<<24, this succeeds on mac, but bail:exit's on linux.
// investigate possible u3n_prog corruption
//
u3m_init(1 << 25);
u3m_pave(c3y);
u3e_init();
}