Re: svn commit: r364310 - in head/sys: kern vm

2020-08-18 Thread Mark Johnston
On Tue, Aug 18, 2020 at 01:03:25AM +0300, Andriy Gapon wrote:
> On 17/08/2020 18:37, Gleb Smirnoff wrote:
> > Author: glebius
> > Date: Mon Aug 17 15:37:08 2020
> > New Revision: 364310
> > URL: https://svnweb.freebsd.org/changeset/base/364310
> > 
> > Log:
> >   With INVARIANTS panic immediately if M_WAITOK is requested in a
> >   non-sleepable context.  Previously only _sleep() would panic.
> >   This will catch misuse of M_WAITOK at development stage rather
> >   than at stress load stage.
> >   
> >   Reviewed by:  markj
> >   Differential Revision:https://reviews.freebsd.org/D26027
> 
> I think that there is going to be a lot of fallout from this.
> Will you handle it?
> A warning from WITNESS is one thing, a panic is another.

Indeed, based on a few reports from freebsd-current I reverted the
commit.  It seems there are a number of places in CAM that will require
modification, particularly in async event handling.  Note that CAM doneq
threads execute handlers with TD_NO_SLEEPING.
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r364310 - in head/sys: kern vm

2020-08-17 Thread Shawn Webb
On Tue, Aug 18, 2020 at 01:03:25AM +0300, Andriy Gapon wrote:
> On 17/08/2020 18:37, Gleb Smirnoff wrote:
> > Author: glebius
> > Date: Mon Aug 17 15:37:08 2020
> > New Revision: 364310
> > URL: https://svnweb.freebsd.org/changeset/base/364310
> > 
> > Log:
> >   With INVARIANTS panic immediately if M_WAITOK is requested in a
> >   non-sleepable context.  Previously only _sleep() would panic.
> >   This will catch misuse of M_WAITOK at development stage rather
> >   than at stress load stage.
> >   
> >   Reviewed by:  markj
> >   Differential Revision:https://reviews.freebsd.org/D26027
> 
> I think that there is going to be a lot of fallout from this.
> Will you handle it?
> A warning from WITNESS is one thing, a panic is another.

Hint: There may also be fallout downstream. ;P

Thanks,

-- 
Shawn Webb
Cofounder / Security Engineer
HardenedBSD

GPG Key ID:  0xFF2E67A277F8E1FA
GPG Key Fingerprint: D206 BB45 15E0 9C49 0CF9  3633 C85B 0AF8 AB23 0FB2
https://git-01.md.hardenedbsd.org/HardenedBSD/pubkeys/src/branch/master/Shawn_Webb/03A4CBEBB82EA5A67D9F3853FF2E67A277F8E1FA.pub.asc


signature.asc
Description: PGP signature


Re: svn commit: r364310 - in head/sys: kern vm

2020-08-17 Thread Andriy Gapon
On 17/08/2020 18:37, Gleb Smirnoff wrote:
> Author: glebius
> Date: Mon Aug 17 15:37:08 2020
> New Revision: 364310
> URL: https://svnweb.freebsd.org/changeset/base/364310
> 
> Log:
>   With INVARIANTS panic immediately if M_WAITOK is requested in a
>   non-sleepable context.  Previously only _sleep() would panic.
>   This will catch misuse of M_WAITOK at development stage rather
>   than at stress load stage.
>   
>   Reviewed by:markj
>   Differential Revision:  https://reviews.freebsd.org/D26027

I think that there is going to be a lot of fallout from this.
Will you handle it?
A warning from WITNESS is one thing, a panic is another.


-- 
Andriy Gapon
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r364310 - in head/sys: kern vm

2020-08-17 Thread Gleb Smirnoff
Author: glebius
Date: Mon Aug 17 15:37:08 2020
New Revision: 364310
URL: https://svnweb.freebsd.org/changeset/base/364310

Log:
  With INVARIANTS panic immediately if M_WAITOK is requested in a
  non-sleepable context.  Previously only _sleep() would panic.
  This will catch misuse of M_WAITOK at development stage rather
  than at stress load stage.
  
  Reviewed by:  markj
  Differential Revision:https://reviews.freebsd.org/D26027

Modified:
  head/sys/kern/kern_malloc.c
  head/sys/vm/uma_core.c

Modified: head/sys/kern/kern_malloc.c
==
--- head/sys/kern/kern_malloc.c Mon Aug 17 15:11:46 2020(r364309)
+++ head/sys/kern/kern_malloc.c Mon Aug 17 15:37:08 2020(r364310)
@@ -618,6 +618,9 @@ void *
unsigned long osize = size;
 #endif
 
+   KASSERT((flags & M_WAITOK) == 0 || THREAD_CAN_SLEEP(),
+   ("malloc(M_WAITOK) in non-sleepable context"));
+
 #ifdef MALLOC_DEBUG
va = NULL;
if (malloc_dbg(&va, &size, mtp, flags) != 0)

Modified: head/sys/vm/uma_core.c
==
--- head/sys/vm/uma_core.c  Mon Aug 17 15:11:46 2020(r364309)
+++ head/sys/vm/uma_core.c  Mon Aug 17 15:37:08 2020(r364310)
@@ -3328,6 +3328,9 @@ uma_zalloc_smr(uma_zone_t zone, int flags)
uma_cache_bucket_t bucket;
uma_cache_t cache;
 
+   KASSERT((flags & M_WAITOK) == 0 || THREAD_CAN_SLEEP(),
+   ("uma_zalloc_smr(M_WAITOK) in non-sleepable context"));
+
 #ifdef UMA_ZALLOC_DEBUG
void *item;
 
@@ -3351,6 +3354,9 @@ uma_zalloc_arg(uma_zone_t zone, void *udata, int flags
 {
uma_cache_bucket_t bucket;
uma_cache_t cache;
+
+   KASSERT((flags & M_WAITOK) == 0 || THREAD_CAN_SLEEP(),
+   ("uma_zalloc(M_WAITOK) in non-sleepable context"));
 
/* Enable entropy collection for RANDOM_ENABLE_UMA kernel option */
random_harvest_fast_uma(&zone, sizeof(zone), RANDOM_UMA);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"