Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 3 May 2002 08:12:31 -0700 (PDT)
From:      Julian Elischer <julian@elischer.org>
To:        Jonathan Mini <mini@FreeBSD.org>
Cc:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   Re: PERFORCE change 10740 for review
Message-ID:  <Pine.BSF.4.21.0205030807030.82741-100000@InterJet.elischer.org>
In-Reply-To: <200205031451.g43Epu600512@freefall.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help


On Fri, 3 May 2002, Jonathan Mini wrote:

> http://people.freebsd.org/~peter/p4db/chv.cgi?CH=10740
> 
> Change 10740 by mini@mini_stylus on 2002/05/03 07:51:09
> 
> 	- Change thread_get(void) -> thread_alloc(void) to keep from
> 	  conflicting with thread_get(struct proc *) in sys/kerne/kern_proc.c.

but, but but... the thread_get() in kern_proc.c is a standin for the 
one in kern_thread.c whe there is no kern_thread.c

they are supposed to be the same function.. teh one in kern_proc.c
is removed when kse is added.....

I called it thread_get rather than thread_alloc because
it caches them and doesn always need to allocate a new one....




> 	






> 	- uma_zalloc(,M_WAITOK) will never return NULL, so don't bother
> 	  testing for it.

You may be right, but I wasn't convinced that M_WAITOK was always
correct. I was trying to concieve af a case where you may not ba able to
wait when trying ot allocate a new thread..
for example if you are trying to allocate it when you are already in
 msleep().. it may be bad to sleep when in msleep already...
I think I may have other ways to stop this but think about it and
check the anti-recursion code in msleep(). 
It may be that M_NOWAIT is the right answer..





> 
> Affected files ...
> 
> ... //depot/projects/kse/sys/kern/kern_fork.c#62 edit
> ... //depot/projects/kse/sys/kern/kern_thread.c#43 edit
> ... //depot/projects/kse/sys/sys/proc.h#97 edit
> 
> Differences ...
> 
> ==== //depot/projects/kse/sys/kern/kern_fork.c#62 (text+ko) ====
> 
> @@ -346,7 +346,7 @@
>  			thread_single_end();
>  		return (EAGAIN);
>  	}
> -	td2 = thread_get();
> +	td2 = thread_alloc();
>  	if (td2 == NULL) {
>  		uma_zfree(proc_zone, p2);
>  		nprocs--;
> 
> ==== //depot/projects/kse/sys/kern/kern_thread.c#43 (text+ko) ====
> 
> @@ -142,7 +142,7 @@
>   * create one from the zone as per normal
>   */
>  struct thread *
> -thread_get(void)
> +thread_alloc(void)
>  {
>  	struct thread *td;
>  
> @@ -155,15 +155,10 @@
>  	} else {
>  		/* allocate the thread structure itself */
>  		td = uma_zalloc(thread_zone, M_WAITOK);
> -	
> -		/* assuming we got one, allocate pages for the stack it needs */
> -		if (td) {
> -			allocated_threads++;
> -			pmap_new_thread(td);
> -			cpu_thread_setup(td);
> -		} else {
> -			return (NULL);
> -		}
> +
> +		allocated_threads++;
> +		pmap_new_thread(td);
> +		cpu_thread_setup(td);
>  	}
>  	/* may need to set some stuff here.. re state? */
>  	/* Make sure the zero'd section is in fact zero'd */
> @@ -319,7 +314,7 @@
>  {
>  	struct thread *td2;
>  
> -	td2 = thread_get();
> +	td2 = thread_alloc();
>  	if (td2) {
>  		CTR3(KTR_PROC, "thread_schedule_upcall: thread %p (pid %d, %s)",
>  		     td, td->td_proc->p_pid, td->td_proc->p_comm);
> 
> ==== //depot/projects/kse/sys/sys/proc.h#97 (text+ko) ====
> 
> @@ -797,7 +797,7 @@
>  int	cpu_coredump(struct thread *, struct vnode *, struct ucred *);
>  
>  /* new in KSE */
> -struct thread *thread_get(void);
> +struct thread *thread_alloc(void);
>  void	thread_free(struct thread *td);  
>  int	cpu_export_context(struct thread *td);
>  void	cpu_free_kse_mdstorage(struct kse *kse);
> 


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe p4-projects" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0205030807030.82741-100000>