Re: r315684 panic: sleepq_add: td 0xfffff80003c01a40 to sleep on wchan 0xfffff80006f0873c with sleeping prohibited

2017-04-04 Thread Gleb Smirnoff
On Mon, Apr 03, 2017 at 03:39:56PM +, Darren wrote:
D> I have not experienced the crash after updating with Glebs patch. Consider 
the issue solved. 

I really don't want to put ACCEPT_LOCK() on to the sendfile() path.

However, once I commit my listening sockets rewrite patch, there
will be no ACCEPT_LOCK(). I'll see how it goes. Will be fixed in
next month.

-- 
Totus tuus, Glebius.
___
freebsd-current@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"


Re: r315684 panic: sleepq_add: td 0xfffff80003c01a40 to sleep on wchan 0xfffff80006f0873c with sleeping prohibited

2017-04-03 Thread Darren
I have not experienced the crash after updating with Glebs patch. Consider the 
issue solved. 

Thanks, Darren.
___
freebsd-current@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"


Re: r315684 panic: sleepq_add: td 0xfffff80003c01a40 to sleep on wchan 0xfffff80006f0873c with sleeping prohibited

2017-03-26 Thread Gleb Smirnoff
On Sat, Mar 25, 2017 at 11:45:29AM +0200, Konstantin Belousov wrote:
K> On Fri, Mar 24, 2017 at 08:31:42PM -0700, Gleb Smirnoff wrote:
K> >   Darren,
K> > 
K> > On Sat, Mar 25, 2017 at 03:03:14AM +0200, Konstantin Belousov wrote:
K> > K> On Fri, Mar 24, 2017 at 05:40:15PM +, Darren wrote:
K> > K> > I am getting this panic every hour to every couple of hours.
K> > K> > 
K> > K> > FreeBSD asrock 12.0-CURRENT FreeBSD 12.0-CURRENT #0 r315684: Thu Mar 
23 14:56:45 EDT 2017 darren@asrock:/usr/obj/usr/src/sys/GENERIC  amd64
K> > K> > I manually typed out the following, apologize for any typos. 
K> > K> > 
K> > K> > 
K> > K> > panic: sleepq_add: td 0xf80003c01a40 to sleep on wchan 
0xf80006f0873c with sleeping prohibited
K> > K> > cpuid = 0
K> > K> > time = 1490372797
K> > K> > KDB: stack backtrace:
K> > K> > db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 
0xfe0072e33690
K> > K> > vpanic() at vpanic+0x19c/frame 0xfe0072e33710
K> > K> > kassert_panic() at kassert_panic+0x126/frame 0xfe0072e33780
K> > K> > sleepq_add() at sleepq_add+0x34f/frame 0xfe0072337d0
K> > K> > _sleep() at _sleep+0x28d/frame 0xfe0072e33870
K> > K> > soclose() at soclose+0xda/frame 0xfe0072e338b0
K> > K> > _fdrop() at _fdrop+0x1a/frame 0xfe0072e338d0
K> > K> > sendfile_iodone() at sendfile_iodone+0x19d/frame 0xfe0072e33910
K> > K> > vnode_pager_generic_getpages_done_async() at 
vnode_pager_generic_getpages_done_async+037/frame 0xfe0072e33930
K> > K> > bufdone() at bufdone+0x64/frame 0xfe0072e33960
K> > K> > g_io_deliver() at g_io_deliver+0x276/frame 0xfe0072e339b0
K> > K> > g_io_deliver() at g_io_deliver+0x276/frame 0xfe0072e33a00
K> > K> > g_disk_done() at g_disk_done+0x104/frame 0xfe0072e33a40
K> > K> > xpt_done_process() at xpt_done_process+0x35f/frame 0xfe0072e33a80
K> > K> > xpt_done_direct() at ahci_ch_intr_direct+0xd5/frame 0xfe0072e33af0
K> > K> > ahci_itr() at ahci_intr+0x102/frame 0xfe0072e33b20
K> > K> > intr_event_execute_handlers() at 
intr_event_execute_handlers+0x99/frame 0xfe0072e33b60
K> > K> > ithread_loop() at ithread_loop+0xb6/frame 0xfe0072e33bb0
K> > K> > fork_exit() at fork_exit+0x84/frame 0xfe0072e33bf0
K> > K> > fork_trampoline() at fork_trampoline+0xe/frame 0xfe0072e33bf0
K> > K> > --- trap 0, rip = 0, rsp = 0, rbp = 0 ---
K> > K> > KDB: enter: panic
K> > K> > [ thread pid 12 tid 100038 ]
K> > K> > Stopped at  kdb_enter+0x3b: movq    $0,kdb_why
K> > K> > db>
K> > K> 
K> > K> Indeed, the context where sendfile_iodone() is executed, cannot call 
fdrop().
K> > 
K> > Can you please test the attached patch?
K> > 
K> > -- 
K> > Totus tuus, Glebius.
K> 
K> > Index: sys/kern/kern_sendfile.c
K> > ===
K> > --- sys/kern/kern_sendfile.c   (revision 315926)
K> > +++ sys/kern/kern_sendfile.c   (working copy)
K> > @@ -296,8 +296,9 @@ sendfile_iodone(void *arg, vm_page_t *pg, int coun
K> >CURVNET_RESTORE();
K> >}
K> >  
K> > -  /* XXXGL: curthread */
K> > -  fdrop(sfio->sock_fp, curthread);
K> > +  ACCEPT_LOCK();
K> > +  SOCK_LOCK(so);
K> > +  sorele(so);
K> >free(sfio, M_TEMP);
K> >  }
K> >  
K> > @@ -860,7 +861,9 @@ prepend_header:
K> >} else {
K> >sfio->sock_fp = sock_fp;
K> >sfio->npages = npages;
K> > -  fhold(sock_fp);
K> > +  SOCK_LOCK(so);
K> > +  soref(so);
K> > +  SOCK_UNLOCK(so);
K> >error = (*so->so_proto->pr_usrreqs->pru_send)
K> >(so, PRUS_NOTREADY, m, NULL, NULL, td);
K> >sendfile_iodone(sfio, NULL, 0, 0);
K> 
K> With this patch, what prevents a close of the sfio->sock_fp file, which is
K> needed to get the pointer to socket ?

You are right, patch is unfinished. Here is better one.

-- 
Totus tuus, Glebius.
Index: sys/kern/kern_sendfile.c
===
--- sys/kern/kern_sendfile.c	(revision 315926)
+++ sys/kern/kern_sendfile.c	(working copy)
@@ -80,7 +80,7 @@ struct sf_io {
 	volatile u_int	nios;
 	u_int		error;
 	int		npages;
-	struct file	*sock_fp;
+	struct socket	*so;
 	struct mbuf	*m;
 	vm_page_t	pa[];
 };
@@ -255,7 +255,7 @@ static void
 sendfile_iodone(void *arg, vm_page_t *pg, int count, int error)
 {
 	struct sf_io *sfio = arg;
-	struct socket *so;
+	struct socket *so = sfio->so;
 
 	for (int i = 0; i < count; i++)
 		if (pg[i] != bogus_page)
@@ -267,8 +267,6 @@ sendfile_iodone(void *arg, vm_page_t *pg, int coun
 	if (!refcount_release(>nios))
 		return;
 
-	so = sfio->sock_fp->f_data;
-
 	if (sfio->error) {
 		struct mbuf *m;
 
@@ -296,8 +294,9 @@ sendfile_iodone(void *arg, vm_page_t *pg, int coun
 		CURVNET_RESTORE();
 	}
 
-	/* XXXGL: curthread */
-	fdrop(sfio->sock_fp, curthread);
+	ACCEPT_LOCK();
+	SOCK_LOCK(so);
+	sorele(so);
 	free(sfio, M_TEMP);
 }
 
@@ -858,9 +857,11 @@ 

Re: r315684 panic: sleepq_add: td 0xfffff80003c01a40 to sleep on wchan 0xfffff80006f0873c with sleeping prohibited

2017-03-25 Thread Darren
This is the new panic.  Just happened 6 times. Maybe as a result of fsck 
running.Again may not be exact due to me copying it by hand. 

Fatal trap 12: page fault while in kernel mode
cpuid = 0; apic id = 00
fault virtual address    = 0x20
fault code                    = supervisor read data, page not present
instruction pointer       = 0x20:0x80a4cfdb
stack pointer           = 0x28:0xfe007c6828e0
frame pointer              = 0x28:0xfe007c682910
code segment             = base 0x0, limit 0xf, type 0x1b
                                    = DPL 0, pres 1, long 1, def32 0, gran 1
processor eflags      = interrupt enabled, resume, IOPL = 0
current process            = 12 (irq256: ahci0
[ thread pid 12 tid 100038 ]
Stopped at         sendfile_iodone+0x9b:    movq    0x20(%rbx).%rax
db>


  From: Konstantin Belousov 
 To: Gleb Smirnoff  
Cc: Darren ; "freebsd-current@freebsd.org" 

 Sent: Saturday, March 25, 2017 5:45 AM
 Subject: Re: r315684 panic: sleepq_add: td 0xf80003c01a40 to sleep on 
wchan 0xf80006f0873c with sleeping prohibited
   
On Fri, Mar 24, 2017 at 08:31:42PM -0700, Gleb Smirnoff wrote:
>  Darren,
> 
> On Sat, Mar 25, 2017 at 03:03:14AM +0200, Konstantin Belousov wrote:
> K> On Fri, Mar 24, 2017 at 05:40:15PM +, Darren wrote:
> K> > I am getting this panic every hour to every couple of hours.
> K> > 
> K> > FreeBSD asrock 12.0-CURRENT FreeBSD 12.0-CURRENT #0 r315684: Thu Mar 23 
> 14:56:45 EDT 2017 darren@asrock:/usr/obj/usr/src/sys/GENERIC  amd64
> K> > I manually typed out the following, apologize for any typos. 
> K> > 
> K> > 
> K> > panic: sleepq_add: td 0xf80003c01a40 to sleep on wchan 
> 0xf80006f0873c with sleeping prohibited
> K> > cpuid = 0
> K> > time = 1490372797
> K> > KDB: stack backtrace:
> K> > db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 
> 0xfe0072e33690
> K> > vpanic() at vpanic+0x19c/frame 0xfe0072e33710
> K> > kassert_panic() at kassert_panic+0x126/frame 0xfe0072e33780
> K> > sleepq_add() at sleepq_add+0x34f/frame 0xfe0072337d0
> K> > _sleep() at _sleep+0x28d/frame 0xfe0072e33870
> K> > soclose() at soclose+0xda/frame 0xfe0072e338b0
> K> > _fdrop() at _fdrop+0x1a/frame 0xfe0072e338d0
> K> > sendfile_iodone() at sendfile_iodone+0x19d/frame 0xfe0072e33910
> K> > vnode_pager_generic_getpages_done_async() at 
> vnode_pager_generic_getpages_done_async+037/frame 0xfe0072e33930
> K> > bufdone() at bufdone+0x64/frame 0xfe0072e33960
> K> > g_io_deliver() at g_io_deliver+0x276/frame 0xfe0072e339b0
> K> > g_io_deliver() at g_io_deliver+0x276/frame 0xfe0072e33a00
> K> > g_disk_done() at g_disk_done+0x104/frame 0xfe0072e33a40
> K> > xpt_done_process() at xpt_done_process+0x35f/frame 0xfe0072e33a80
> K> > xpt_done_direct() at ahci_ch_intr_direct+0xd5/frame 0xfe0072e33af0
> K> > ahci_itr() at ahci_intr+0x102/frame 0xfe0072e33b20
> K> > intr_event_execute_handlers() at intr_event_execute_handlers+0x99/frame 
> 0xfe0072e33b60
> K> > ithread_loop() at ithread_loop+0xb6/frame 0xfe0072e33bb0
> K> > fork_exit() at fork_exit+0x84/frame 0xfe0072e33bf0
> K> > fork_trampoline() at fork_trampoline+0xe/frame 0xfe0072e33bf0
> K> > --- trap 0, rip = 0, rsp = 0, rbp = 0 ---
> K> > KDB: enter: panic
> K> > [ thread pid 12 tid 100038 ]
> K> > Stopped at  kdb_enter+0x3b: movq    $0,kdb_why
> K> > db>
> K> 
> K> Indeed, the context where sendfile_iodone() is executed, cannot call 
> fdrop().
> 
> Can you please test the attached patch?
> 
> -- 
> Totus tuus, Glebius.

> Index: sys/kern/kern_sendfile.c
> ===
> --- sys/kern/kern_sendfile.c    (revision 315926)
> +++ sys/kern/kern_sendfile.c    (working copy)
> @@ -296,8 +296,9 @@ sendfile_iodone(void *arg, vm_page_t *pg, int coun
>          CURVNET_RESTORE();
>      }
>  
> -    /* XXXGL: curthread */
> -    fdrop(sfio->sock_fp, curthread);
> +    ACCEPT_LOCK();
> +    SOCK_LOCK(so);
> +    sorele(so);
>      free(sfio, M_TEMP);
>  }
>  
> @@ -860,7 +861,9 @@ prepend_header:
>          } else {
>              sfio->sock_fp = sock_fp;
>              sfio->npages = npages;
> -            fhold(sock_fp);
> +            SOCK_LOCK(so);
> +            soref(so);
> +            SOCK_UNLOCK(so);
>              error = (*so->so_proto->pr_usrreqs->pru_send)
>                  (so, PRUS_NOTREADY, m, NULL, NULL, td);
>              sendfile_iodone(sfio, NULL, 0, 0);

With this patch, what prevents a close of the sfio->sock_fp file, which is
needed to get the pointer to socket ?


   
___
freebsd-current@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"

Re: r315684 panic: sleepq_add: td 0xfffff80003c01a40 to sleep on wchan 0xfffff80006f0873c with sleeping prohibited

2017-03-25 Thread Darren
So far I have not had a re-occurrence of the crash.  It has only been a couple 
hours so far, will update if it happens or not over the next couple days. 
Thanks!
-Darren

  
   
  Darren,

On Sat, Mar 25, 2017 at 03:03:14AM +0200, Konstantin Belousov wrote:
K> On Fri, Mar 24, 2017 at 05:40:15PM +, Darren wrote:
K> > I am getting this panic every hour to every couple of hours.
K> > 
K> > FreeBSD asrock 12.0-CURRENT FreeBSD 12.0-CURRENT #0 r315684: Thu Mar 23 
14:56:45 EDT 2017 darren@asrock:/usr/obj/usr/src/sys/GENERIC  amd64
K> > I manually typed out the following, apologize for any typos. 
K> > 
K> > 
K> > panic: sleepq_add: td 0xf80003c01a40 to sleep on wchan 
0xf80006f0873c with sleeping prohibited
K> > cpuid = 0
K> > time = 1490372797
K> > KDB: stack backtrace:
K> > db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 
0xfe0072e33690
K> > vpanic() at vpanic+0x19c/frame 0xfe0072e33710
K> > kassert_panic() at kassert_panic+0x126/frame 0xfe0072e33780
K> > sleepq_add() at sleepq_add+0x34f/frame 0xfe0072337d0
K> > _sleep() at _sleep+0x28d/frame 0xfe0072e33870
K> > soclose() at soclose+0xda/frame 0xfe0072e338b0
K> > _fdrop() at _fdrop+0x1a/frame 0xfe0072e338d0
K> > sendfile_iodone() at sendfile_iodone+0x19d/frame 0xfe0072e33910
K> > vnode_pager_generic_getpages_done_async() at 
vnode_pager_generic_getpages_done_async+037/frame 0xfe0072e33930
K> > bufdone() at bufdone+0x64/frame 0xfe0072e33960
K> > g_io_deliver() at g_io_deliver+0x276/frame 0xfe0072e339b0
K> > g_io_deliver() at g_io_deliver+0x276/frame 0xfe0072e33a00
K> > g_disk_done() at g_disk_done+0x104/frame 0xfe0072e33a40
K> > xpt_done_process() at xpt_done_process+0x35f/frame 0xfe0072e33a80
K> > xpt_done_direct() at ahci_ch_intr_direct+0xd5/frame 0xfe0072e33af0
K> > ahci_itr() at ahci_intr+0x102/frame 0xfe0072e33b20
K> > intr_event_execute_handlers() at intr_event_execute_handlers+0x99/frame 
0xfe0072e33b60
K> > ithread_loop() at ithread_loop+0xb6/frame 0xfe0072e33bb0
K> > fork_exit() at fork_exit+0x84/frame 0xfe0072e33bf0
K> > fork_trampoline() at fork_trampoline+0xe/frame 0xfe0072e33bf0
K> > --- trap 0, rip = 0, rsp = 0, rbp = 0 ---
K> > KDB: enter: panic
K> > [ thread pid 12 tid 100038 ]
K> > Stopped at  kdb_enter+0x3b: movq    $0,kdb_why
K> > db>
K> 
K> Indeed, the context where sendfile_iodone() is executed, cannot call fdrop().

Can you please test the attached patch?

-- 
Totus tuus, Glebius.


   
___
freebsd-current@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"

Re: r315684 panic: sleepq_add: td 0xfffff80003c01a40 to sleep on wchan 0xfffff80006f0873c with sleeping prohibited

2017-03-25 Thread Konstantin Belousov
On Fri, Mar 24, 2017 at 08:31:42PM -0700, Gleb Smirnoff wrote:
>   Darren,
> 
> On Sat, Mar 25, 2017 at 03:03:14AM +0200, Konstantin Belousov wrote:
> K> On Fri, Mar 24, 2017 at 05:40:15PM +, Darren wrote:
> K> > I am getting this panic every hour to every couple of hours.
> K> > 
> K> > FreeBSD asrock 12.0-CURRENT FreeBSD 12.0-CURRENT #0 r315684: Thu Mar 23 
> 14:56:45 EDT 2017 darren@asrock:/usr/obj/usr/src/sys/GENERIC  amd64
> K> > I manually typed out the following, apologize for any typos. 
> K> > 
> K> > 
> K> > panic: sleepq_add: td 0xf80003c01a40 to sleep on wchan 
> 0xf80006f0873c with sleeping prohibited
> K> > cpuid = 0
> K> > time = 1490372797
> K> > KDB: stack backtrace:
> K> > db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 
> 0xfe0072e33690
> K> > vpanic() at vpanic+0x19c/frame 0xfe0072e33710
> K> > kassert_panic() at kassert_panic+0x126/frame 0xfe0072e33780
> K> > sleepq_add() at sleepq_add+0x34f/frame 0xfe0072337d0
> K> > _sleep() at _sleep+0x28d/frame 0xfe0072e33870
> K> > soclose() at soclose+0xda/frame 0xfe0072e338b0
> K> > _fdrop() at _fdrop+0x1a/frame 0xfe0072e338d0
> K> > sendfile_iodone() at sendfile_iodone+0x19d/frame 0xfe0072e33910
> K> > vnode_pager_generic_getpages_done_async() at 
> vnode_pager_generic_getpages_done_async+037/frame 0xfe0072e33930
> K> > bufdone() at bufdone+0x64/frame 0xfe0072e33960
> K> > g_io_deliver() at g_io_deliver+0x276/frame 0xfe0072e339b0
> K> > g_io_deliver() at g_io_deliver+0x276/frame 0xfe0072e33a00
> K> > g_disk_done() at g_disk_done+0x104/frame 0xfe0072e33a40
> K> > xpt_done_process() at xpt_done_process+0x35f/frame 0xfe0072e33a80
> K> > xpt_done_direct() at ahci_ch_intr_direct+0xd5/frame 0xfe0072e33af0
> K> > ahci_itr() at ahci_intr+0x102/frame 0xfe0072e33b20
> K> > intr_event_execute_handlers() at intr_event_execute_handlers+0x99/frame 
> 0xfe0072e33b60
> K> > ithread_loop() at ithread_loop+0xb6/frame 0xfe0072e33bb0
> K> > fork_exit() at fork_exit+0x84/frame 0xfe0072e33bf0
> K> > fork_trampoline() at fork_trampoline+0xe/frame 0xfe0072e33bf0
> K> > --- trap 0, rip = 0, rsp = 0, rbp = 0 ---
> K> > KDB: enter: panic
> K> > [ thread pid 12 tid 100038 ]
> K> > Stopped at  kdb_enter+0x3b: movq    $0,kdb_why
> K> > db>
> K> 
> K> Indeed, the context where sendfile_iodone() is executed, cannot call 
> fdrop().
> 
> Can you please test the attached patch?
> 
> -- 
> Totus tuus, Glebius.

> Index: sys/kern/kern_sendfile.c
> ===
> --- sys/kern/kern_sendfile.c  (revision 315926)
> +++ sys/kern/kern_sendfile.c  (working copy)
> @@ -296,8 +296,9 @@ sendfile_iodone(void *arg, vm_page_t *pg, int coun
>   CURVNET_RESTORE();
>   }
>  
> - /* XXXGL: curthread */
> - fdrop(sfio->sock_fp, curthread);
> + ACCEPT_LOCK();
> + SOCK_LOCK(so);
> + sorele(so);
>   free(sfio, M_TEMP);
>  }
>  
> @@ -860,7 +861,9 @@ prepend_header:
>   } else {
>   sfio->sock_fp = sock_fp;
>   sfio->npages = npages;
> - fhold(sock_fp);
> + SOCK_LOCK(so);
> + soref(so);
> + SOCK_UNLOCK(so);
>   error = (*so->so_proto->pr_usrreqs->pru_send)
>   (so, PRUS_NOTREADY, m, NULL, NULL, td);
>   sendfile_iodone(sfio, NULL, 0, 0);

With this patch, what prevents a close of the sfio->sock_fp file, which is
needed to get the pointer to socket ?
___
freebsd-current@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"

Re: r315684 panic: sleepq_add: td 0xfffff80003c01a40 to sleep on wchan 0xfffff80006f0873c with sleeping prohibited

2017-03-24 Thread Gleb Smirnoff
  Darren,

On Sat, Mar 25, 2017 at 03:03:14AM +0200, Konstantin Belousov wrote:
K> On Fri, Mar 24, 2017 at 05:40:15PM +, Darren wrote:
K> > I am getting this panic every hour to every couple of hours.
K> > 
K> > FreeBSD asrock 12.0-CURRENT FreeBSD 12.0-CURRENT #0 r315684: Thu Mar 23 
14:56:45 EDT 2017 darren@asrock:/usr/obj/usr/src/sys/GENERIC  amd64
K> > I manually typed out the following, apologize for any typos. 
K> > 
K> > 
K> > panic: sleepq_add: td 0xf80003c01a40 to sleep on wchan 
0xf80006f0873c with sleeping prohibited
K> > cpuid = 0
K> > time = 1490372797
K> > KDB: stack backtrace:
K> > db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 
0xfe0072e33690
K> > vpanic() at vpanic+0x19c/frame 0xfe0072e33710
K> > kassert_panic() at kassert_panic+0x126/frame 0xfe0072e33780
K> > sleepq_add() at sleepq_add+0x34f/frame 0xfe0072337d0
K> > _sleep() at _sleep+0x28d/frame 0xfe0072e33870
K> > soclose() at soclose+0xda/frame 0xfe0072e338b0
K> > _fdrop() at _fdrop+0x1a/frame 0xfe0072e338d0
K> > sendfile_iodone() at sendfile_iodone+0x19d/frame 0xfe0072e33910
K> > vnode_pager_generic_getpages_done_async() at 
vnode_pager_generic_getpages_done_async+037/frame 0xfe0072e33930
K> > bufdone() at bufdone+0x64/frame 0xfe0072e33960
K> > g_io_deliver() at g_io_deliver+0x276/frame 0xfe0072e339b0
K> > g_io_deliver() at g_io_deliver+0x276/frame 0xfe0072e33a00
K> > g_disk_done() at g_disk_done+0x104/frame 0xfe0072e33a40
K> > xpt_done_process() at xpt_done_process+0x35f/frame 0xfe0072e33a80
K> > xpt_done_direct() at ahci_ch_intr_direct+0xd5/frame 0xfe0072e33af0
K> > ahci_itr() at ahci_intr+0x102/frame 0xfe0072e33b20
K> > intr_event_execute_handlers() at intr_event_execute_handlers+0x99/frame 
0xfe0072e33b60
K> > ithread_loop() at ithread_loop+0xb6/frame 0xfe0072e33bb0
K> > fork_exit() at fork_exit+0x84/frame 0xfe0072e33bf0
K> > fork_trampoline() at fork_trampoline+0xe/frame 0xfe0072e33bf0
K> > --- trap 0, rip = 0, rsp = 0, rbp = 0 ---
K> > KDB: enter: panic
K> > [ thread pid 12 tid 100038 ]
K> > Stopped at  kdb_enter+0x3b: movq    $0,kdb_why
K> > db>
K> 
K> Indeed, the context where sendfile_iodone() is executed, cannot call fdrop().

Can you please test the attached patch?

-- 
Totus tuus, Glebius.
Index: sys/kern/kern_sendfile.c
===
--- sys/kern/kern_sendfile.c	(revision 315926)
+++ sys/kern/kern_sendfile.c	(working copy)
@@ -296,8 +296,9 @@ sendfile_iodone(void *arg, vm_page_t *pg, int coun
 		CURVNET_RESTORE();
 	}
 
-	/* XXXGL: curthread */
-	fdrop(sfio->sock_fp, curthread);
+	ACCEPT_LOCK();
+	SOCK_LOCK(so);
+	sorele(so);
 	free(sfio, M_TEMP);
 }
 
@@ -860,7 +861,9 @@ prepend_header:
 		} else {
 			sfio->sock_fp = sock_fp;
 			sfio->npages = npages;
-			fhold(sock_fp);
+			SOCK_LOCK(so);
+			soref(so);
+			SOCK_UNLOCK(so);
 			error = (*so->so_proto->pr_usrreqs->pru_send)
 			(so, PRUS_NOTREADY, m, NULL, NULL, td);
 			sendfile_iodone(sfio, NULL, 0, 0);
___
freebsd-current@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"

Re: r315684 panic: sleepq_add: td 0xfffff80003c01a40 to sleep on wchan 0xfffff80006f0873c with sleeping prohibited

2017-03-24 Thread Konstantin Belousov
On Fri, Mar 24, 2017 at 05:40:15PM +, Darren wrote:
> I am getting this panic every hour to every couple of hours.
> 
> FreeBSD asrock 12.0-CURRENT FreeBSD 12.0-CURRENT #0 r315684: Thu Mar 23 
> 14:56:45 EDT 2017 darren@asrock:/usr/obj/usr/src/sys/GENERIC  amd64
> I manually typed out the following, apologize for any typos. 
> 
> 
> panic: sleepq_add: td 0xf80003c01a40 to sleep on wchan 0xf80006f0873c 
> with sleeping prohibited
> cpuid = 0
> time = 1490372797
> KDB: stack backtrace:
> db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xfe0072e33690
> vpanic() at vpanic+0x19c/frame 0xfe0072e33710
> kassert_panic() at kassert_panic+0x126/frame 0xfe0072e33780
> sleepq_add() at sleepq_add+0x34f/frame 0xfe0072337d0
> _sleep() at _sleep+0x28d/frame 0xfe0072e33870
> soclose() at soclose+0xda/frame 0xfe0072e338b0
> _fdrop() at _fdrop+0x1a/frame 0xfe0072e338d0
> sendfile_iodone() at sendfile_iodone+0x19d/frame 0xfe0072e33910
> vnode_pager_generic_getpages_done_async() at 
> vnode_pager_generic_getpages_done_async+037/frame 0xfe0072e33930
> bufdone() at bufdone+0x64/frame 0xfe0072e33960
> g_io_deliver() at g_io_deliver+0x276/frame 0xfe0072e339b0
> g_io_deliver() at g_io_deliver+0x276/frame 0xfe0072e33a00
> g_disk_done() at g_disk_done+0x104/frame 0xfe0072e33a40
> xpt_done_process() at xpt_done_process+0x35f/frame 0xfe0072e33a80
> xpt_done_direct() at ahci_ch_intr_direct+0xd5/frame 0xfe0072e33af0
> ahci_itr() at ahci_intr+0x102/frame 0xfe0072e33b20
> intr_event_execute_handlers() at intr_event_execute_handlers+0x99/frame 
> 0xfe0072e33b60
> ithread_loop() at ithread_loop+0xb6/frame 0xfe0072e33bb0
> fork_exit() at fork_exit+0x84/frame 0xfe0072e33bf0
> fork_trampoline() at fork_trampoline+0xe/frame 0xfe0072e33bf0
> --- trap 0, rip = 0, rsp = 0, rbp = 0 ---
> KDB: enter: panic
> [ thread pid 12 tid 100038 ]
> Stopped at  kdb_enter+0x3b: movq    $0,kdb_why
> db>

Indeed, the context where sendfile_iodone() is executed, cannot call fdrop().
___
freebsd-current@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"

Re: r315684 panic: sleepq_add: td 0xfffff80003c01a40 to sleep on wchan 0xfffff80006f0873c with sleeping prohibited

2017-03-24 Thread Jeffrey Bouquet


On Fri, 24 Mar 2017 17:40:15 + (UTC), Darren  wrote:

> I am getting this panic every hour to every couple of hours.
> 
> FreeBSD asrock 12.0-CURRENT FreeBSD 12.0-CURRENT #0 r315684: Thu Mar 23 
> 14:56:45 EDT 2017 darren@asrock:/usr/obj/usr/src/sys/GENERIC  amd64
> I manually typed out the following, apologize for any typos. 
> 
> 
> panic: sleepq_add: td 0xf80003c01a40 to sleep on wchan 0xf80006f0873c 
> with sleeping prohibited
> cpuid = 0
> time = 1490372797
> KDB: stack backtrace:
> db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xfe0072e33690
> vpanic() at vpanic+0x19c/frame 0xfe0072e33710
> kassert_panic() at kassert_panic+0x126/frame 0xfe0072e33780
> sleepq_add() at sleepq_add+0x34f/frame 0xfe0072337d0
> _sleep() at _sleep+0x28d/frame 0xfe0072e33870
> soclose() at soclose+0xda/frame 0xfe0072e338b0
> _fdrop() at _fdrop+0x1a/frame 0xfe0072e338d0
> sendfile_iodone() at sendfile_iodone+0x19d/frame 0xfe0072e33910
> vnode_pager_generic_getpages_done_async() at 
> vnode_pager_generic_getpages_done_async+037/frame 0xfe0072e33930
> bufdone() at bufdone+0x64/frame 0xfe0072e33960
> g_io_deliver() at g_io_deliver+0x276/frame 0xfe0072e339b0
> g_io_deliver() at g_io_deliver+0x276/frame 0xfe0072e33a00
> g_disk_done() at g_disk_done+0x104/frame 0xfe0072e33a40
> xpt_done_process() at xpt_done_process+0x35f/frame 0xfe0072e33a80
> xpt_done_direct() at ahci_ch_intr_direct+0xd5/frame 0xfe0072e33af0
> ahci_itr() at ahci_intr+0x102/frame 0xfe0072e33b20
> intr_event_execute_handlers() at intr_event_execute_handlers+0x99/frame 
> 0xfe0072e33b60
> ithread_loop() at ithread_loop+0xb6/frame 0xfe0072e33bb0
> fork_exit() at fork_exit+0x84/frame 0xfe0072e33bf0
> fork_trampoline() at fork_trampoline+0xe/frame 0xfe0072e33bf0
> --- trap 0, rip = 0, rsp = 0, rbp = 0 ---
> KDB: enter: panic
> [ thread pid 12 tid 100038 ]
> Stopped at  kdb_enter+0x3b: movq    $0,kdb_why
> db>
> 
> 
> 
> ___
> freebsd-current@freebsd.org mailing list
> https://lists.freebsd.org/mailman/listinfo/freebsd-current
> To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"


Will there ever be an auto-save to .txt upon break to debugger or lock
reversal or similar in code? or is beyond the capability of the OS once the
occurance has taken place, I wonder. 
___
freebsd-current@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"

r315684 panic: sleepq_add: td 0xfffff80003c01a40 to sleep on wchan 0xfffff80006f0873c with sleeping prohibited

2017-03-24 Thread Darren
I am getting this panic every hour to every couple of hours.

FreeBSD asrock 12.0-CURRENT FreeBSD 12.0-CURRENT #0 r315684: Thu Mar 23 
14:56:45 EDT 2017 darren@asrock:/usr/obj/usr/src/sys/GENERIC  amd64
I manually typed out the following, apologize for any typos. 


panic: sleepq_add: td 0xf80003c01a40 to sleep on wchan 0xf80006f0873c 
with sleeping prohibited
cpuid = 0
time = 1490372797
KDB: stack backtrace:
db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xfe0072e33690
vpanic() at vpanic+0x19c/frame 0xfe0072e33710
kassert_panic() at kassert_panic+0x126/frame 0xfe0072e33780
sleepq_add() at sleepq_add+0x34f/frame 0xfe0072337d0
_sleep() at _sleep+0x28d/frame 0xfe0072e33870
soclose() at soclose+0xda/frame 0xfe0072e338b0
_fdrop() at _fdrop+0x1a/frame 0xfe0072e338d0
sendfile_iodone() at sendfile_iodone+0x19d/frame 0xfe0072e33910
vnode_pager_generic_getpages_done_async() at 
vnode_pager_generic_getpages_done_async+037/frame 0xfe0072e33930
bufdone() at bufdone+0x64/frame 0xfe0072e33960
g_io_deliver() at g_io_deliver+0x276/frame 0xfe0072e339b0
g_io_deliver() at g_io_deliver+0x276/frame 0xfe0072e33a00
g_disk_done() at g_disk_done+0x104/frame 0xfe0072e33a40
xpt_done_process() at xpt_done_process+0x35f/frame 0xfe0072e33a80
xpt_done_direct() at ahci_ch_intr_direct+0xd5/frame 0xfe0072e33af0
ahci_itr() at ahci_intr+0x102/frame 0xfe0072e33b20
intr_event_execute_handlers() at intr_event_execute_handlers+0x99/frame 
0xfe0072e33b60
ithread_loop() at ithread_loop+0xb6/frame 0xfe0072e33bb0
fork_exit() at fork_exit+0x84/frame 0xfe0072e33bf0
fork_trampoline() at fork_trampoline+0xe/frame 0xfe0072e33bf0
--- trap 0, rip = 0, rsp = 0, rbp = 0 ---
KDB: enter: panic
[ thread pid 12 tid 100038 ]
Stopped at  kdb_enter+0x3b: movq    $0,kdb_why
db>



___
freebsd-current@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"