From owner-freebsd-bugs@FreeBSD.ORG Mon Jan 19 11:20:02 2009 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 20C1F1065834; Mon, 19 Jan 2009 11:20:01 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id ACCFC8FC12; Mon, 19 Jan 2009 11:20:01 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id n0JBK19w074553; Mon, 19 Jan 2009 11:20:01 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id n0JBK1jh074552; Mon, 19 Jan 2009 11:20:01 GMT (envelope-from gnats) Resent-Date: Mon, 19 Jan 2009 11:20:01 GMT Resent-Message-Id: <200901191120.n0JBK1jh074552@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@freebsd.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Cc: scottl@freebsd.org Resent-Reply-To: FreeBSD-gnats-submit@freebsd.org, Eygene Ryabinkin Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 55B801065CA5 for ; Mon, 19 Jan 2009 11:17:15 +0000 (UTC) (envelope-from rea-fbsd@codelabs.ru) Received: from 0.mx.codelabs.ru (0.mx.codelabs.ru [144.206.177.45]) by mx1.freebsd.org (Postfix) with ESMTP id 7B83B8FC43 for ; Mon, 19 Jan 2009 11:17:14 +0000 (UTC) (envelope-from rea-fbsd@codelabs.ru) Received: from void.codelabs.ru (void.codelabs.ru [144.206.177.25]) by 0.mx.codelabs.ru with esmtps (TLSv1:CAMELLIA256-SHA:256) id 1LOs81-0002HD-Kw for FreeBSD-gnats-submit@freebsd.org; Mon, 19 Jan 2009 14:17:13 +0300 Message-Id: <20090119111713.715D5DA81B@void.codelabs.ru> Date: Mon, 19 Jan 2009 14:17:13 +0300 (MSK) From: Eygene Ryabinkin To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.113 X-GNATS-Notify: scottl@freebsd.org Cc: Subject: kern/130735: [patch] pass M_NOWAIT to the malloc() call inside cdreaddvdstructure() X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Eygene Ryabinkin List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Jan 2009 11:20:30 -0000 >Number: 130735 >Category: kern >Synopsis: [patch] pass M_NOWAIT to the malloc() call inside cdreaddvdstructure() >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon Jan 19 11:20:01 UTC 2009 >Closed-Date: >Last-Modified: >Originator: Eygene Ryabinkin >Release: FreeBSD 7.1-STABLE amd64 >Organization: Code Labs >Environment: System: FreeBSD 7.1-STABLE amd64 >Description: cdreaddvdstructure() is called from cdioctl() with periph lock held (sys/dev/cam/scsi/scsi_cd.c): ----- cam_periph_lock(periph); error = cdreaddvdstructure(periph, dvdstruct); cam_periph_unlock(periph); ----- but malloc() inside cdreaddvdstructure() uses M_WAITOK. The following diagnostics is thrown with WITNESS enabled: ----- uma_zalloc_arg: zone "16" with the following non-sleepable locks held: exclusive sleep mutex ATAPICAM lock r = 0 (0xffffff000475a2a8) locked @ cam/cam_periph.h:182 KDB: stack backtrace: db_trace_self_wrapper() at db_trace_self_wrapper+0x2a witness_warn() at witness_warn+0x23a uma_zalloc_arg() at uma_zalloc_arg+0x338 malloc() at malloc+0x80 cdioctl() at cdioctl+0x13c3 g_disk_ioctl() at g_disk_ioctl+0x4c g_dev_ioctl() at g_dev_ioctl+0x83 devfs_ioctl_f() at devfs_ioctl_f+0x71 kern_ioctl() at kern_ioctl+0x91 ioctl() at ioctl+0xe8 syscall() at syscall+0x1ce Xfast_syscall() at Xfast_syscall+0xab --- syscall (54, FreeBSD ELF64, ioctl), rip = 0x801c2b27c, rsp = 0x7fffffffa268, rbp = 0x8072e7800 --- acd0: FAILURE - READ_BIG timed out ----- >How-To-Repeat: Try to play scratchy DVD/CD disk that will cause read timeouts. WITNESS will complain, if it is enabled. System could hang after some timeouts. Or may be it won't hang -- it depends on the actual thread layout. I am using atapicam emulation layer, but this should be also reproducible with native SCSI CD/DVD devices. >Fix: The following simple patch works for me. I am living with it for around a week and tried to play many scratchy disks -- no errors or hangups, just 'acd0: FAILURE - READ_BIG timed out' messages, but this is expected. --- scsi_cd-cdreaddvdstructure-use-M_NOWAIT.diff begins here --- >From 42386566b7816a95a7245df0163d8049d9d59376 Mon Sep 17 00:00:00 2001 From: Eygene Ryabinkin Date: Sat, 17 Jan 2009 07:31:41 +0300 Signed-off-by: Eygene Ryabinkin --- sys/cam/scsi/scsi_cd.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/sys/cam/scsi/scsi_cd.c b/sys/cam/scsi/scsi_cd.c index f97ed41..f084cae 100644 --- a/sys/cam/scsi/scsi_cd.c +++ b/sys/cam/scsi/scsi_cd.c @@ -4063,7 +4063,7 @@ cdreaddvdstructure(struct cam_periph *periph, struct dvd_struct *dvdstruct) } if (length != 0) { - databuf = malloc(length, M_DEVBUF, M_WAITOK | M_ZERO); + databuf = malloc(length, M_DEVBUF, M_NOWAIT | M_ZERO); } else databuf = NULL; -- 1.6.0.5 --- scsi_cd-cdreaddvdstructure-use-M_NOWAIT.diff ends here --- >Release-Note: >Audit-Trail: >Unformatted: