From owner-freebsd-geom@freebsd.org Wed Apr 20 18:38:28 2016 Return-Path: Delivered-To: freebsd-geom@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4DE2AB16185; Wed, 20 Apr 2016 18:38:28 +0000 (UTC) (envelope-from rpokala@mac.com) Received: from mr11p00im-asmtp002.me.com (mr11p00im-asmtp002.me.com [17.110.69.253]) (using TLSv1.2 with cipher DHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3D2531EA3; Wed, 20 Apr 2016 18:38:28 +0000 (UTC) (envelope-from rpokala@mac.com) Received: from [172.17.133.77] (dip-cali.panasas.com [64.80.217.3]) by mr11p00im-asmtp002.me.com (Oracle Communications Messaging Server 7.0.5.36.0 64bit (built Sep 8 2015)) with ESMTPSA id <0O5Y003Z63RXHW10@mr11p00im-asmtp002.me.com>; Wed, 20 Apr 2016 18:38:22 +0000 (GMT) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-04-20_12:,, signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 clxscore=1011 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1510270003 definitions=main-1604200295 User-Agent: Microsoft-MacOutlook/f.15.1.160411 Date: Wed, 20 Apr 2016 11:38:20 -0700 Subject: g_event and sysctllock From: Ravi Pokala To: "freebsd-hackers@freebsd.org" , "freebsd-geom@freebsd.org" , "Rai, Sushanth" Message-id: <1E22BEFB-5C0E-4DE2-91E1-FD5F8AEFD04A@mac.com> Thread-topic: g_event and sysctllock MIME-version: 1.0 Content-type: text/plain; charset=UTF-8 Content-transfer-encoding: 7bit X-BeenThere: freebsd-geom@freebsd.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: GEOM-specific discussions and implementations List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Apr 2016 18:38:28 -0000 Hi folks, My colleague Sushanth (CCed) tried to send this to hackers@ yesterday, but it didn't go through for some reason. Resending on his behalf, adding geom@, and noting that while we saw this on 7-STABLE, it looks like it could still be an issue in -HEAD. -------------------------------- Hello, We have a home-grown geom driver that creates sysctl in the device creation path. Device creation is handled by the geom event thread. The call to SYSCTL_ADD_NODE() takes the sysctllock in exclusive mode. If the event thread is racing with another thread that calls sysctl_disks(), then you end up with a deadlock since sysctl_disks() tickles the event thread and goes to sleep while holding the sysctllock. It is expected to woken up by the event thread when the event of listing all the disks is processed. But the geom event is blocked waiting for the sysctllock. I did see g_disk_create() adds a sysctl variable in a similar fashion, hence the email. I'm thinking of fixing the sysctl_disks() to drop the sysctllock before going to sleep and reacquiring it after being woken up. Let me know your thoughts. Thanks, Sushanth -------------------------------- -Ravi (rpokala@)