[rh7,v3,1/4] linux/preempt_mask.h: Add in_task() macro.

Submitted by Andrey Ryabinin on Aug. 23, 2018, 4:12 p.m.

Details

Message ID 20180823161248.18657-1-aryabinin@virtuozzo.com
State New
Series "Series without cover letter"
Headers show

Commit Message

Andrey Ryabinin Aug. 23, 2018, 4:12 p.m.
in_task() returns true if we are executing in the task context.
Implementation has been stolen from upstream.

https://jira.sw.ru/browse/PSBM-87797
Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
---
 include/linux/preempt_mask.h | 2 ++
 1 file changed, 2 insertions(+)

Patch hide | download patch | download mbox

diff --git a/include/linux/preempt_mask.h b/include/linux/preempt_mask.h
index a492ae8e6f10..5eb3970311dc 100644
--- a/include/linux/preempt_mask.h
+++ b/include/linux/preempt_mask.h
@@ -88,6 +88,8 @@ 
 #define in_softirq()		(softirq_count())
 #define in_interrupt()		(irq_count())
 #define in_serving_softirq()	(softirq_count() & SOFTIRQ_OFFSET)
+#define in_task()		(!(preempt_count() & \
+				   (NMI_MASK | HARDIRQ_MASK | SOFTIRQ_OFFSET)))
 
 /*
  * Are we in NMI context?

Comments

Denis V. Lunev Aug. 30, 2018, 11:06 a.m.
On 08/23/2018 07:12 PM, Andrey Ryabinin wrote:
> in_task() returns true if we are executing in the task context.
> Implementation has been stolen from upstream.
>
> https://jira.sw.ru/browse/PSBM-87797
> Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
> ---
>  include/linux/preempt_mask.h | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/include/linux/preempt_mask.h b/include/linux/preempt_mask.h
> index a492ae8e6f10..5eb3970311dc 100644
> --- a/include/linux/preempt_mask.h
> +++ b/include/linux/preempt_mask.h
> @@ -88,6 +88,8 @@
>  #define in_softirq()		(softirq_count())
>  #define in_interrupt()		(irq_count())
>  #define in_serving_softirq()	(softirq_count() & SOFTIRQ_OFFSET)
> +#define in_task()		(!(preempt_count() & \
> +				   (NMI_MASK | HARDIRQ_MASK | SOFTIRQ_OFFSET)))
>  
>  /*
>   * Are we in NMI context?
Reviewed-by: Denis V. Lunev <den@openvz.org>