Date: Thu, 26 May 2016 14:25:41 -0700 From: Gleb Smirnoff <glebius@FreeBSD.org> To: Hans Petter Selasky <hselasky@FreeBSD.org> Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r300671 - in head/sys/compat/linuxkpi/common: include/linux src Message-ID: <20160526212541.GI58287@FreeBSD.org> In-Reply-To: <201605250904.u4P946CY055112@repo.freebsd.org> References: <201605250904.u4P946CY055112@repo.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
Hi! The SCHEDULER_STOPPED() already has __predict_false() in it, so unlikely() is superfluous. On Wed, May 25, 2016 at 09:04:06AM +0000, Hans Petter Selasky wrote: H> Author: hselasky H> Date: Wed May 25 09:04:06 2016 H> New Revision: 300671 H> URL: https://svnweb.freebsd.org/changeset/base/300671 H> H> Log: H> Add checks for SCHEDULER_STOPPED() so that code using the LinuxKPI can H> run after a panic(). This for example allows a LinuxKPI based graphics H> stack to receive prints during a panic. H> H> Obtained from: kmacy @ H> MFC after: 1 week H> Sponsored by: Mellanox Technologies H> H> Modified: H> head/sys/compat/linuxkpi/common/include/linux/sched.h H> head/sys/compat/linuxkpi/common/include/linux/wait.h H> head/sys/compat/linuxkpi/common/src/linux_compat.c H> H> Modified: head/sys/compat/linuxkpi/common/include/linux/sched.h H> ============================================================================== H> --- head/sys/compat/linuxkpi/common/include/linux/sched.h Wed May 25 09:00:05 2016 (r300670) H> +++ head/sys/compat/linuxkpi/common/include/linux/sched.h Wed May 25 09:04:06 2016 (r300671) H> @@ -91,7 +91,7 @@ CTASSERT(sizeof(((struct thread *)0)->td H> do { \ H> void *c; \ H> \ H> - if (cold) \ H> + if (cold || SCHEDULER_STOPPED()) \ H> break; \ H> c = curthread; \ H> sleepq_lock(c); \ H> H> Modified: head/sys/compat/linuxkpi/common/include/linux/wait.h H> ============================================================================== H> --- head/sys/compat/linuxkpi/common/include/linux/wait.h Wed May 25 09:00:05 2016 (r300670) H> +++ head/sys/compat/linuxkpi/common/include/linux/wait.h Wed May 25 09:04:06 2016 (r300671) H> @@ -31,6 +31,7 @@ H> #ifndef _LINUX_WAIT_H_ H> #define _LINUX_WAIT_H_ H> H> +#include <linux/compiler.h> H> #include <linux/spinlock.h> H> #include <linux/sched.h> H> #include <linux/list.h> H> @@ -81,6 +82,8 @@ do { \ H> void *c = &(q).wchan; \ H> if (!(cond)) { \ H> for (;;) { \ H> + if (unlikely(SCHEDULER_STOPPED())) \ H> + break; \ H> sleepq_lock(c); \ H> if (cond) { \ H> sleepq_release(c); \ H> @@ -100,6 +103,8 @@ do { \ H> _error = 0; \ H> if (!(cond)) { \ H> for (; _error == 0;) { \ H> + if (unlikely(SCHEDULER_STOPPED())) \ H> + break; \ H> sleepq_lock(c); \ H> if (cond) { \ H> sleepq_release(c); \ H> @@ -123,6 +128,8 @@ do { \ H> \ H> if (!(cond)) { \ H> for (; __rc == 0;) { \ H> + if (unlikely(SCHEDULER_STOPPED())) \ H> + break; \ H> sleepq_lock(c); \ H> if (cond) { \ H> sleepq_release(c); \ H> H> Modified: head/sys/compat/linuxkpi/common/src/linux_compat.c H> ============================================================================== H> --- head/sys/compat/linuxkpi/common/src/linux_compat.c Wed May 25 09:00:05 2016 (r300670) H> +++ head/sys/compat/linuxkpi/common/src/linux_compat.c Wed May 25 09:04:06 2016 (r300671) H> @@ -1093,6 +1093,8 @@ linux_complete_common(struct completion H> long H> linux_wait_for_common(struct completion *c, int flags) H> { H> + if (unlikely(SCHEDULER_STOPPED())) H> + return (0); H> H> if (flags != 0) H> flags = SLEEPQ_INTERRUPTIBLE | SLEEPQ_SLEEP; H> @@ -1123,6 +1125,9 @@ linux_wait_for_timeout_common(struct com H> { H> long end = jiffies + timeout; H> H> + if (unlikely(SCHEDULER_STOPPED())) H> + return (0); H> + H> if (flags != 0) H> flags = SLEEPQ_INTERRUPTIBLE | SLEEPQ_SLEEP; H> else H> _______________________________________________ H> svn-src-all@freebsd.org mailing list H> https://lists.freebsd.org/mailman/listinfo/svn-src-all H> To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org" -- Totus tuus, Glebius.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20160526212541.GI58287>