From owner-freebsd-current@FreeBSD.ORG Sun Jan 25 01:33:25 2009 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 335E610656CD; Sun, 25 Jan 2009 01:33:25 +0000 (UTC) (envelope-from maksim.yevmenkin@gmail.com) Received: from rv-out-0506.google.com (rv-out-0506.google.com [209.85.198.228]) by mx1.freebsd.org (Postfix) with ESMTP id E9FC18FC0A; Sun, 25 Jan 2009 01:33:24 +0000 (UTC) (envelope-from maksim.yevmenkin@gmail.com) Received: by rv-out-0506.google.com with SMTP id b25so5444307rvf.43 for ; Sat, 24 Jan 2009 17:33:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=nPVaSDwQEDHT9W7x4AZtuQwUvyEStfBPgrrEBE2M+JY=; b=R12KdgDffjoOSlbpRPHPX/zCyVHD6qidnKVvwxVCiyIZHXosJ4ACLrv9Niq7V0UHG2 0UOXas7497QiwZrDYMHnTMh42koVYxBPgdjlW+xXSSpf8D42/jPCtKy+I+ZehrOlpNFZ t8GRuSda8cJbLt9WDbjjFQP+A0Hymp4c1eO8s= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=VzTFJwTgPTa1OHSi4kTO8+e6jMUyOo1xhnpA0/CjZ62nWE8vtQ6xixK5G3auzQQRmM STj5l49zduXHD0qd/ZRilZgwpOvrWvrkctOgYu82VFoKh/yBPo7Az0QfPv6wrLWZymby 2C4fvMMhsc2EV3/pcDgeKTapQjyLmzZBpezig= MIME-Version: 1.0 Received: by 10.141.52.3 with SMTP id e3mr588911rvk.262.1232847204711; Sat, 24 Jan 2009 17:33:24 -0800 (PST) In-Reply-To: <20090125003010.GY87077@elvis.mu.org> References: <20090123154336.GJ60948@e.0x20.net> <200901232337.05627.hselasky@c2i.net> <200901240952.21670.hselasky@c2i.net> <20090125003010.GY87077@elvis.mu.org> Date: Sat, 24 Jan 2009 17:33:24 -0800 Message-ID: From: Maksim Yevmenkin To: Alfred Perlstein Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: freebsd-current@freebsd.org, current@freebsd.org, Hans Petter Selasky Subject: Re: panic: mutex Giant not owned at /usr/src/sys/kern/tty_ttydisc.c:1127 X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 25 Jan 2009 01:33:26 -0000 On Sat, Jan 24, 2009 at 4:30 PM, Alfred Perlstein wrote: > * Maksim Yevmenkin [090124 01:38] wrote: >> >> from what i can see you are _NOT_ using _SPIN_ mutexes (aka spin >> locks). you are using regular mutexes. let me quote locking(9) man >> page >> >> " >> Mutexes >> Basically (regular) mutexes will deschedule the thread if the mutex can >> not be acquired. A non-spin mutex can be considered to be equivalent to >> getting a write lock on an rw_lock (see below), >> " >> >> so, if thread can not get mutex it will be descheduled. this >> absolutely can not happen in netgraph! > > From a purely academic standpoint... why can't netgraph use > standard mutexes? > > Is there a pointer you can give me? well, its not that netgraph can not use mutexes at all. its just that there has to be an understanding between all subsystems that interact with netgraph. its just like Julian said, everybody has to play nice and ensure that control is given back to netgraph as soon as possible. netgraph thread can not be de-scheduled for too long because the same thread services other nodes. in fact, there are other netgraph nodes that use mutexes, there is no way around it. the only rule is that mutexes have to be used prudently. if there is a guarantee that every single code path that is called from netgraph context is "safe" (i.e. any mutexes that are touched in the code path are guaranteed to not cause de-scheduling of netgraph thread for any significant amount of time) then everything is fine. in any case, i really do hope that the patch that i send to Hans Petter today (you were cc'd) is something that we all can agree on. thanks, max