From owner-freebsd-hackers@FreeBSD.ORG Sun Dec 21 02:49:44 2008 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8FA1A1065673 for ; Sun, 21 Dec 2008 02:49:44 +0000 (UTC) (envelope-from fernercc@gmail.com) Received: from yx-out-2324.google.com (yx-out-2324.google.com [74.125.44.28]) by mx1.freebsd.org (Postfix) with ESMTP id 433CA8FC1B for ; Sun, 21 Dec 2008 02:49:43 +0000 (UTC) (envelope-from fernercc@gmail.com) Received: by yx-out-2324.google.com with SMTP id 8so1273272yxb.13 for ; Sat, 20 Dec 2008 18:49:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:subject:from:to:cc :in-reply-to:references:content-type:date:message-id:mime-version :x-mailer:content-transfer-encoding; bh=CKeGXQVhokel5zX4AhwZZ7jKq6uOYg/oIJAbAdq9PRA=; b=AVo5/t8cN4vYl0IrDSB1iPwewT1Nj0w81EbaD54T+azDIhmSjRqwLuwiHpgHF04cHc YWMsHY6bEtPySs4YB4UWvSpN/DiuBO+H3OAfyc7aOI5eIXvv7+9lJe89IgqdBzdGI84o ZDgN4yJoY0iGTnON/9k4/sUzsC/zFGSUibF4s= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=subject:from:to:cc:in-reply-to:references:content-type:date :message-id:mime-version:x-mailer:content-transfer-encoding; b=QoBhK7APYWweSIhu1YLjWmaxqa+MqxaK0RvKAUsXLUPeAllxLQxLAPliZe44LIJa7z 9OKB8rbtPQY6z4YDIj49SIqZNiv+K1yickBr7tB7LR/ex+nAjjFC9io+Zz/ghtBNQ+lF 15/LP+yEEgLcoQa03B4VXyygIfc6qMVNws6yU= Received: by 10.100.128.2 with SMTP id a2mr3138620and.93.1229827783323; Sat, 20 Dec 2008 18:49:43 -0800 (PST) Received: from ?192.168.2.2? (cpe-70-112-179-136.austin.res.rr.com [70.112.179.136]) by mx.google.com with ESMTPS id c1sm6561577ana.36.2008.12.20.18.49.41 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 20 Dec 2008 18:49:42 -0800 (PST) From: Ferner Cilloniz To: Michelle Li In-Reply-To: <823694.23548.qm@web65403.mail.ac4.yahoo.com> References: <823694.23548.qm@web65403.mail.ac4.yahoo.com> Content-Type: text/plain Date: Sat, 20 Dec 2008 20:49:39 +0000 Message-Id: <1229806179.4952.3.camel@mobiliare.Belkin> Mime-Version: 1.0 X-Mailer: Evolution 2.24.2 Content-Transfer-Encoding: 7bit Cc: freebsd-hackers@freebsd.org Subject: Re: reg: adding proc to allproc X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 21 Dec 2008 02:49:44 -0000 for the sake of this discussion its suffice to consider new_entry->p as read-only pointer because i never modify it. I am just storing its address. It easily just be considered an unsigned long value. However, would really calling LIST_INSERT_HEAD(&allproc, entry->p, p_list) result in a hang of the system? I'm flipping through pages in FreeBSD design and implementation right now. On Sat, 2008-12-20 at 18:05 -0800, Michelle Li wrote: > reg: adding proc to allproc (Ferner Cilloniz) > > new_entry->p ..... > is accessing the "read/write" pointer declared in the proc_ll struct > > new_entry->p = p; > is attempting an assignment of a "read ONLY" const pointer that > has been passed into add_proc_entry() to a "read/write" pointer > > new_entry->"read/write pointer" = "read ONLY pointer"; > is invalid > > "new_entry->p = p; // maybe doing this assignment isnt correct?" > with this assertion I agree > > > freebsd-hackers-request@freebsd.org wrote: Send freebsd-hackers mailing list submissions to > freebsd-hackers@freebsd.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://lists.freebsd.org/mailman/listinfo/freebsd-hackers > or, via email, send a message with subject or body 'help' to > freebsd-hackers-request@freebsd.org > > You can reach the person managing the list at > freebsd-hackers-owner@freebsd.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of freebsd-hackers digest..." > > > Today's Topics: > > 1. adding proc to allproc (Ferner Cilloniz) > 2. Re: adding proc to allproc (Julian Elischer) > 3. Re: adding proc to allproc (Ferner Cilloniz) > 4. Re: adding proc to allproc (Julian Elischer) > 5. Re: adding proc to allproc (Ferner Cilloniz) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Fri, 19 Dec 2008 22:39:20 +0000 > From: Ferner Cilloniz > Subject: adding proc to allproc > To: freebsd-hackers@freebsd.org > Message-ID: <1229726360.5614.15.camel@mobiliare.Belkin> > Content-Type: text/plain > > Hello everyone. > > I am playing with freebsd and just learning some things about the > FreeBSD kernel. > > So for my first quest i am placing random processes from the allproc > list into a list of my own and trying to add them back into allproc > > I have pasted the code below. > > ----------------------------------------------------------------------- > struct proc *p = a process from my own list; > if( p != NULL && (p->p_state == PRS_NEW || p->p_state == PRS_NORMAL) ){ > LIST_INSERT_HEAD(&allproc, p, p_list); > } > ----------------------------------------------------------------------- > > Thanks. > > > > ------------------------------ > > Message: 2 > Date: Fri, 19 Dec 2008 21:27:34 -0800 > From: Julian Elischer > Subject: Re: adding proc to allproc > To: Ferner Cilloniz > Cc: freebsd-hackers@freebsd.org > Message-ID: <494C8246.3020703@elischer.org> > Content-Type: text/plain; charset=ISO-8859-1; format=flowed > > Ferner Cilloniz wrote: > > Hello everyone. > > > > I am playing with freebsd and just learning some things about the > > FreeBSD kernel. > > > > So for my first quest i am placing random processes from the allproc > > list into a list of my own and trying to add them back into allproc > > > > I have pasted the code below. > > > > ----------------------------------------------------------------------- > > struct proc *p = a process from my own list; > > if( p != NULL && (p->p_state == PRS_NEW || p->p_state == PRS_NORMAL) ){ > > LIST_INSERT_HEAD(&allproc, p, p_list); > > } > > ----------------------------------------------------------------------- > > > > Thanks. > > and your question is? > > > > > > _______________________________________________ > > freebsd-hackers@freebsd.org mailing list > > http://lists.freebsd.org/mailman/listinfo/freebsd-hackers > > To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org" > > > > ------------------------------ > > Message: 3 > Date: Fri, 19 Dec 2008 23:28:46 +0000 > From: Ferner Cilloniz > Subject: Re: adding proc to allproc > To: Julian Elischer > Cc: freebsd-hackers@freebsd.org > Message-ID: <1229729326.5614.16.camel@mobiliare.Belkin> > Content-Type: text/plain > > When i run the code from a KLD it hangs the system. No reboot occurs > however, it just hangs there. > > > On Fri, 2008-12-19 at 21:27 -0800, Julian Elischer wrote: > > Ferner Cilloniz wrote: > > > Hello everyone. > > > > > > I am playing with freebsd and just learning some things about the > > > FreeBSD kernel. > > > > > > So for my first quest i am placing random processes from the allproc > > > list into a list of my own and trying to add them back into allproc > > > > > > I have pasted the code below. > > > > > > ----------------------------------------------------------------------- > > > struct proc *p = a process from my own list; > > > if( p != NULL && (p->p_state == PRS_NEW || p->p_state == PRS_NORMAL) ){ > > > LIST_INSERT_HEAD(&allproc, p, p_list); > > > } > > > ----------------------------------------------------------------------- > > > > > > Thanks. > > > > and your question is? > > > > > > > > > > _______________________________________________ > > > freebsd-hackers@freebsd.org mailing list > > > http://lists.freebsd.org/mailman/listinfo/freebsd-hackers > > > To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org" > > > -- > Cilloniz Bicchi, Ferner > > Research Assistant > Dept. of Computer Sciences > The University of Texas at Austin > http://www.cs.utexas.edu/~fernercc > fernercc@cs.utexas.edu > > > > ------------------------------ > > Message: 4 > Date: Fri, 19 Dec 2008 21:39:20 -0800 > From: Julian Elischer > Subject: Re: adding proc to allproc > To: Ferner Cilloniz > Cc: freebsd-hackers@freebsd.org > Message-ID: <494C8508.2020000@elischer.org> > Content-Type: text/plain; charset=ISO-8859-1; format=flowed > > Ferner Cilloniz wrote: > > When i run the code from a KLD it hangs the system. No reboot occurs > > however, it just hangs there. > > well, firstly you have no locking though that would probably let you > get away with it most times. > > Where does the process come from in the first place? > > It sounds like you are making a circular list somewhere or somehow... > > have you tried going into ddb? > > > > > > > > > > On Fri, 2008-12-19 at 21:27 -0800, Julian Elischer wrote: > >> Ferner Cilloniz wrote: > >>> Hello everyone. > >>> > >>> I am playing with freebsd and just learning some things about the > >>> FreeBSD kernel. > >>> > >>> So for my first quest i am placing random processes from the allproc > >>> list into a list of my own and trying to add them back into allproc > >>> > >>> I have pasted the code below. > >>> > >>> ----------------------------------------------------------------------- > >>> struct proc *p = a process from my own list; > >>> if( p != NULL && (p->p_state == PRS_NEW || p->p_state == PRS_NORMAL) ){ > >>> LIST_INSERT_HEAD(&allproc, p, p_list); > >>> } > >>> ----------------------------------------------------------------------- > > >> > >>> _______________________________________________ > >>> freebsd-hackers@freebsd.org mailing list > >>> http://lists.freebsd.org/mailman/listinfo/freebsd-hackers > >>> To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org" > > > > ------------------------------ > > Message: 5 > Date: Sat, 20 Dec 2008 02:23:20 +0000 > From: Ferner Cilloniz > Subject: Re: adding proc to allproc > To: Julian Elischer > Cc: freebsd-hackers@freebsd.org > Message-ID: <1229739800.5614.24.camel@mobiliare.Belkin> > Content-Type: text/plain > > The process comes from the allproc list. > I am simply iterating through this list and removing the first 1/2 of > allproc list and adding the removed process to my own singly linked > list. > > LIST_REMOVE(current_proc, p_list); // remove from the allproc > add_proc_entry(current_proc); > > Later, i am iterating through my singly linked list and doing the below: > > struct proc *p = current->p; > f( p != NULL && (p->p_state == PRS_NEW || p->p_state == PRS_NORMAL) ){ > LIST_INSERT_HEAD(&allproc, p, p_list); > } > > Could this be causing a circular list? > > I am adding the proc entries to my singly linked list as follows: > > static void add_proc_entry(const struct proc *p) > { > struct proc_ll *new_entry = (struct proc_ll*)malloc(sizeof(struct > proc_ll), M_TEMP, M_ZERO | M_NOWAIT); > int done = 0; > > new_entry->p = p; // maybe doing this assignment isnt correct? > > if(proc_entries == NULL) { > proc_entries = new_entry; > return; > } > > struct proc_ll *current = proc_entries; > > while(current != NULL) { > if(current->next == NULL) { > current->next = new_entry; > break; > } > current = current->next; > } > } > > > struct proc_ll { > struct proc *p; > struct proc_ll *next; > }; > > > A circular list does sound like it could cause hanging to occur but the > above code, atleast from my eyes, doesn't seem to cause it. > > On Fri, 2008-12-19 at 21:39 -0800, Julian Elischer wrote: > > Ferner Cilloniz wrote: > > > When i run the code from a KLD it hangs the system. No reboot occurs > > > however, it just hangs there. > > > > well, firstly you have no locking though that would probably let you > > get away with it most times. > > > > Where does the process come from in the first place? > > > > It sounds like you are making a circular list somewhere or somehow... > > > > have you tried going into ddb? > > > > > > > > > > > > > > > > > On Fri, 2008-12-19 at 21:27 -0800, Julian Elischer wrote: > > >> Ferner Cilloniz wrote: > > >>> Hello everyone. > > >>> > > >>> I am playing with freebsd and just learning some things about the > > >>> FreeBSD kernel. > > >>> > > >>> So for my first quest i am placing random processes from the allproc > > >>> list into a list of my own and trying to add them back into allproc > > >>> > > >>> I have pasted the code below. > > >>> > > >>> ----------------------------------------------------------------------- > > >>> struct proc *p = a process from my own list; > > >>> if( p != NULL && (p->p_state == PRS_NEW || p->p_state == PRS_NORMAL) ){ > > >>> LIST_INSERT_HEAD(&allproc, p, p_list); > > >>> } > > >>> ----------------------------------------------------------------------- > > > > >> > > >>> _______________________________________________ > > >>> freebsd-hackers@freebsd.org mailing list > > >>> http://lists.freebsd.org/mailman/listinfo/freebsd-hackers > > >>> To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org" > > > > > > > ------------------------------ > > _______________________________________________ > freebsd-hackers@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-hackers > To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org" > > End of freebsd-hackers Digest, Vol 299, Issue 5 > *********************************************** > > > > _______________________________________________ > freebsd-hackers@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-hackers > To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org" -- Cilloniz Bicchi, Ferner Research Assistant Dept. of Computer Sciences The University of Texas at Austin http://www.cs.utexas.edu/~fernercc fernercc@cs.utexas.edu