Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 25 May 2016 09:04:06 +0000 (UTC)
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r300671 - in head/sys/compat/linuxkpi/common: include/linux src
Message-ID:  <201605250904.u4P946CY055112@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: hselasky
Date: Wed May 25 09:04:06 2016
New Revision: 300671
URL: https://svnweb.freebsd.org/changeset/base/300671

Log:
  Add checks for SCHEDULER_STOPPED() so that code using the LinuxKPI can
  run after a panic(). This for example allows a LinuxKPI based graphics
  stack to receive prints during a panic.
  
  Obtained from:	kmacy @
  MFC after:	1 week
  Sponsored by:	Mellanox Technologies

Modified:
  head/sys/compat/linuxkpi/common/include/linux/sched.h
  head/sys/compat/linuxkpi/common/include/linux/wait.h
  head/sys/compat/linuxkpi/common/src/linux_compat.c

Modified: head/sys/compat/linuxkpi/common/include/linux/sched.h
==============================================================================
--- head/sys/compat/linuxkpi/common/include/linux/sched.h	Wed May 25 09:00:05 2016	(r300670)
+++ head/sys/compat/linuxkpi/common/include/linux/sched.h	Wed May 25 09:04:06 2016	(r300671)
@@ -91,7 +91,7 @@ CTASSERT(sizeof(((struct thread *)0)->td
 do {									\
 	void *c;							\
 									\
-	if (cold)							\
+	if (cold || SCHEDULER_STOPPED())				\
 		break;							\
 	c = curthread;							\
 	sleepq_lock(c);							\

Modified: head/sys/compat/linuxkpi/common/include/linux/wait.h
==============================================================================
--- head/sys/compat/linuxkpi/common/include/linux/wait.h	Wed May 25 09:00:05 2016	(r300670)
+++ head/sys/compat/linuxkpi/common/include/linux/wait.h	Wed May 25 09:04:06 2016	(r300671)
@@ -31,6 +31,7 @@
 #ifndef	_LINUX_WAIT_H_
 #define	_LINUX_WAIT_H_
 
+#include <linux/compiler.h>
 #include <linux/spinlock.h>
 #include <linux/sched.h>
 #include <linux/list.h>
@@ -81,6 +82,8 @@ do {									\
 	void *c = &(q).wchan;						\
 	if (!(cond)) {							\
 		for (;;) {						\
+			if (unlikely(SCHEDULER_STOPPED()))		\
+				break;					\
 			sleepq_lock(c);					\
 			if (cond) {					\
 				sleepq_release(c);			\
@@ -100,6 +103,8 @@ do {									\
 	_error = 0;							\
 	if (!(cond)) {							\
 		for (; _error == 0;) {					\
+			if (unlikely(SCHEDULER_STOPPED()))		\
+				break;					\
 			sleepq_lock(c);					\
 			if (cond) {					\
 				sleepq_release(c);			\
@@ -123,6 +128,8 @@ do {									\
 									\
 	if (!(cond)) {							\
 		for (; __rc == 0;) {					\
+			if (unlikely(SCHEDULER_STOPPED()))		\
+				break;					\
 			sleepq_lock(c);					\
 			if (cond) {					\
 				sleepq_release(c);			\

Modified: head/sys/compat/linuxkpi/common/src/linux_compat.c
==============================================================================
--- head/sys/compat/linuxkpi/common/src/linux_compat.c	Wed May 25 09:00:05 2016	(r300670)
+++ head/sys/compat/linuxkpi/common/src/linux_compat.c	Wed May 25 09:04:06 2016	(r300671)
@@ -1093,6 +1093,8 @@ linux_complete_common(struct completion 
 long
 linux_wait_for_common(struct completion *c, int flags)
 {
+	if (unlikely(SCHEDULER_STOPPED()))
+		return (0);
 
 	if (flags != 0)
 		flags = SLEEPQ_INTERRUPTIBLE | SLEEPQ_SLEEP;
@@ -1123,6 +1125,9 @@ linux_wait_for_timeout_common(struct com
 {
 	long end = jiffies + timeout;
 
+	if (unlikely(SCHEDULER_STOPPED()))
+		return (0);
+
 	if (flags != 0)
 		flags = SLEEPQ_INTERRUPTIBLE | SLEEPQ_SLEEP;
 	else



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201605250904.u4P946CY055112>