Skip to content

Commit

Permalink
Move all init into delay thread
Browse files Browse the repository at this point in the history
  • Loading branch information
lundman committed Oct 31, 2018
1 parent d23ab3c commit c3a671b
Showing 1 changed file with 23 additions and 19 deletions.
42 changes: 23 additions & 19 deletions module/spl/spl-osx.c
Expand Up @@ -412,17 +412,34 @@ static void spl_start_continue(void *ignored);

kern_return_t spl_start (kmod_info_t * ki, void * d)
{
//max_ncpus = processor_avail_count;
printf("SPL: loading\n");

(void)thread_create(NULL, 0, spl_start_continue, 0, 0, 0, 0, 92);

return KERN_SUCCESS;
}

static void spl_start_continue(void *ignored)
{
int ncpus;
size_t len = sizeof(ncpus);

printf("SPL: loading\n");
while(current_proc() == NULL) {
printf("SPL: waiting for kernel init...\n");
delay(hz>>1);
}

sysctlbyname("hw.logicalcpu_max", &max_ncpus, &len, NULL, 0);
if (!max_ncpus) max_ncpus = 1;
while (1) {
len = sizeof(total_memory);
sysctlbyname("hw.memsize", &total_memory, &len, NULL, 0);
if (total_memory != 0) break;

printf("SPL: waiting for sysctl...\n");
delay(hz>>1);
}

len = sizeof(total_memory);
sysctlbyname("hw.memsize", &total_memory, &len, NULL, 0);
sysctlbyname("hw.logicalcpu_max", &max_ncpus, &len, NULL, 0);
if (!max_ncpus) max_ncpus = 1;

/*
* Setting the total memory to physmem * 80% here, since kmem is
Expand Down Expand Up @@ -452,19 +469,6 @@ kern_return_t spl_start (kmod_info_t * ki, void * d)

strlcpy(utsname.nodename, hostname, sizeof(utsname.nodename));

(void)thread_create(NULL, 0, spl_start_continue, 0, 0, 0, 0, 92);

return KERN_SUCCESS;
}

static void spl_start_continue(void *ignored)
{

while(current_proc() == NULL) {
printf("SPL: waiting for kernel init...\n");
delay(hz>>1);
}

spl_mutex_subsystem_init();
spl_kmem_init(total_memory);
spl_vnode_init();
Expand Down

0 comments on commit c3a671b

Please sign in to comment.