From owner-p4-projects Fri May 3 8:20:36 2002 Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 5BC3937B400; Fri, 3 May 2002 08:20:15 -0700 (PDT) Delivered-To: perforce@freebsd.org Received: from rwcrmhc51.attbi.com (rwcrmhc51.attbi.com [204.127.198.38]) by hub.freebsd.org (Postfix) with ESMTP id D917837B416; Fri, 3 May 2002 08:20:08 -0700 (PDT) Received: from InterJet.elischer.org ([12.232.206.8]) by rwcrmhc51.attbi.com (InterMail vM.4.01.03.27 201-229-121-127-20010626) with ESMTP id <20020503152008.ZQZD9799.rwcrmhc51.attbi.com@InterJet.elischer.org>; Fri, 3 May 2002 15:20:08 +0000 Received: from localhost (localhost.elischer.org [127.0.0.1]) by InterJet.elischer.org (8.9.1a/8.9.1) with ESMTP id IAA82850; Fri, 3 May 2002 08:12:33 -0700 (PDT) Date: Fri, 3 May 2002 08:12:31 -0700 (PDT) From: Julian Elischer To: Jonathan Mini Cc: Perforce Change Reviews Subject: Re: PERFORCE change 10740 for review In-Reply-To: <200205031451.g43Epu600512@freefall.freebsd.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-p4-projects@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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