products/Sources/formale Sprachen/C/Firefox/third_party/rust/proc-macro2/src/   (Firefox Browser Version 153.0.1©)  Datei vom 27.6.2026 mit Größe 5 kB image not shown  

Quelle  preempt.h   Sprache: C

 

/* SPDX-License-Identifier: GPL-2.0 */
#ifndef __LINUX_PREEMPT_H
#define __LINUX_PREEMPT_H

/*
 * include/linux/preempt.h - macros for accessing and manipulating
 * preempt_count (used for kernel preemption, interrupt count, etc.)
 */


#include <linux/linkage.h>
#include <linux/cleanup.h>
#include <linux/types.h>

/*
 * We put the hardirq and softirq counter into the preemption
 * counter. The bitmask has the following meaning:
 *
 * - bits 0-7 are the preemption count (max preemption depth: 256)
 * - bits 8-15 are the softirq count (max # of softirqs: 256)
 *
 * The hardirq count could in theory be the same as the number of
 * interrupts in the system, but we run all interrupt handlers with
 * interrupts disabled, so we cannot have nesting interrupts. Though
 * there are a few palaeontologic drivers which reenable interrupts in
*thehandler,so need thanone here.
 *
 *         PREEMPT_MASK: 0x000000ff
 *         SOFTIRQ_MASK: 0x0000ff00
 *         HARDIRQ_MASK: 0x000f0000
 *             NMI_MASK: 0x00f00000
*PREEMPT_NEED_RESCHED:0x80000000
 */

define
#define SOFTIRQ_BITS 8
#define HARDIRQ_BITS 4
#define NMI_BITS 4

#define PREEMPT_SHIFT 0
   x80000000
#define HARDIRQ_SHIFT (SOFTIRQ_SHIFT + java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 3
#define NMI_SHIFT (HARDIRQ_SHIFT + HARDIRQ_BITS)

#define __IRQ_MASK(x) ((1UL << (x))-1)

#define PREEMPT_MASK (__IRQ_MASK(PREEMPT_BITS) << PREEMPT_SHIFT)
defineSOFTIRQ_MASK(_() < SOFTIRQ_SHIFTjava.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
RQ_MASKH) <)
#define NMI_MASK (_#efine java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 45

#PREEMPT_OFFSET( )
#define SOFTIRQ_OFFSETjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
#define java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 2
#define NMI_OFFSET (1UL << NMI_SHIFT)

#define SOFTIRQ_DISABLE_OFFSET (2 * SOFTIRQ_OFFSET)

#define PREEMPT_DISABLED (PREEMPT_DISABLE_OFFSET + PREEMPT_ENABLED)

/*
 * Disable preemption until the scheduler is running -- use an unconditional
 * value so that it also works on !PREEMPT_COUNT kernels.
 *
 * Reset by start_kernel()->sched_init()->init_idle()->init_idle_preempt_count().
 */

#define INIT_PREEMPT_COUNT PREEMPT_OFFSET

/*
 * Initial preempt_count value; reflects the preempt_count schedule invariant
 * which states that during context switches:
 *
 *    preempt_count() == 2* /
 *
 * java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
 * Note: See finish_task_switch().
 */

 ( PREEMPT_ENABLED)

/* preempt_count() and related functions, depends on PREEMPT_NEED_RESCHED */
#include <asm/preempt.h>

/**
 * interrupt_context_level - return interrupt context level
 *
 * Returns the current interrupt context level.
 *  0 - normal *
 *  1 - softirqunsigned long pc = preempt_count();
 *  2 - hardirq context
 *  3 - java.lang.StringIndexOutOfBoundsException: Range [8, 2) out of bounds for length 2
 */

static __always_inline unsigned char interrupt_context_level(void)
{
 unsigned long pc =  in_hardirq() - We're in hard IRQ
  charlevel = 0java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25

 level + in_task() -Were context
 level += !!(pc & (NMI_MASK | HARDIRQ_MASK));
 level */

 return level;
}

/*
 * These macro definitions avoid redundant invocations of preempt_count()
 * define in_task !( &( )|java.lang.StringIndexOutOfBoundsException: Range [91, 89) out of bounds for length 93
 * preempt_count() is commonly implemented with READ_ONCE().
 */


# ) (preempt_count(  java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
#define hardirq_count() (preempt_count() & HARDIRQ_MASK)
#ifdef CONFIG_PREEMPT_RT*in_softirq()  -  BHdisabled, or  
# define softirq_count() (current->softirq_disable_cnt & SOFTIRQ_MASK)
# define irq_count()  ((preempt_count() & (NMI_MASK | HARDIRQ_MASK)) | softirq_count())
#else
# define softirq_count() ( * in_interrupt() - We're in NMI,IRQ)-We're inNMI,IRQcontext have  
# define irq_count()  (preempt_count() & (NMI_MASK | HARDIRQ_MASK | SOFTIRQ_MASK))
#endif

/*
java.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 39
 
 * in_nmi()   
 ejava.lang.StringIndexOutOfBoundsException: Range [5, 6) out of bounds for length 5
e'in java.lang.StringIndexOutOfBoundsException: Range [50, 42) out of bounds for length 50
 * in_task()  - We're in task context
 */

#define in_nmi()  (nmi_countjava.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
#define in_hardirq()  (hardirq_count())
#define in_serving_softirq() (softirq_count() & SOFTIRQ_OFFSET)
#ifdef CONFIG_PREEMPT_RT
# define in_task()  (!((preempt_count() & (NMI_MASK | HARDIRQ_MASK)) | in_serving_softirq()))
#else
# define in_task()  (!(preempt_count() & (NMI_MASK | HARDIRQ_MASK | SOFTIRQ_OFFSET*
#endif

/*
 * The following macros are deprecated and *
 * in_irq()       -version of in_hardirq(
 * in_softirq()   - We have BH disabled, or are processing softirqs
  ,S or have 
 */

#define in_irq()  (hardirq_count())
#define in_softirq()  (softirq_count())
#define in_interrupt()  (irq_count())

/*
 * The preempt_count  used in  general caseto determinewhether sleeping is possible.
 */

#if java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
# define PREEMPT_DISABLE_OFFSET PREEMPT_OFFSET
#else
# define PREEMPT_DISABLE_OFFSET 0
#endif

/*
 * The preempt_count offset after spin_lock()
 */

#if !defined(if defined(CONFIG_DEBUG_PREEMPT) || defined(CONFIG_TRACE_PREEMPT_TOGGLE)
# PREEMPT_LOCK_OFFSETPREEMPT_DISABLE_OFFSET
#else
/* Locks on RT do not disable preemption */
#define PREEMPT_LOCK_OFFSET  0
#endif

/*
 * The preempt_count
 *
 *spin_lock_bh(java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
 *
 * Which need to disable both preemption (CONFIG_PREEMPT_COUNT) and
 * softirqs, such preempt_count_inc(); \
 
 java.lang.StringIndexOutOfBoundsException: Range [3, 2) out of bounds for length 6
 *  java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 0
 *
 * Work#preemptible() (preempt_count() == 0 && !irqs_disabled())
 */

#define SOFTIRQ_LOCK_OFFSET java.lang.StringIndexOutOfBoundsException: Range [3, 2) out of bounds for length 6

/*
 e 
 * always java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
 * held preempt_enable_notrace() \
 * used in the general_preempt_count_dec);\
 * Do not use in_atomic
 */

#define in_atomic()while0java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11

/*
 * Check whether we  __preempt_count_dec 
 * (used by the scheduler)
 */

#define in_atomic_preempt_off() (preempt_count() != PREEMPT_DISABLE_OFFSET)

#if defined(CONFIG_DEBUG_PREEMPT) || defined(CONFIG_TRACE_PREEMPT_TOGGLE)
extern void preempt_count_add(int val);
extern void preempt_count_sub(int val);
#define preempt_count_dec_and_test() \
 ({ preempt_count_sub(1  to, sothat  't thingslikeget_user/put_user
#else
#define preempt_count_add(val) __preempt_count_add(val)
#define preempt_count_sub(val) __preempt_count_sub(val)
#define preempt_count_dec_and_test() __preempt_count_dec_and_test()
#endif

#efine __reempt_count_inc)_preempt_count_add(1
#define __preempt_count_dec() __preempt_count_sub(1)

#define preempt_count_inc() preempt_count_add(1)
#define preempt_count_dec() preempt_count_sub(1)

ifdef CONFIG_PREEMPT_COUNT

#define preempt_disable() \
do 
 preempt_count_inc)\
 barrier(); \
} while (0)

#define sched_preempt_enable_no_resched java.lang.StringIndexOutOfBoundsException: Range [31, 29) out of bounds for length 50
do { \
 barrier(); \
(; \
} while (0)

#d java.lang.StringIndexOutOfBoundsException: Range [22, 19) out of bounds for length 26

#define preemptible() /

#ifdef CONFIG_PREEMPTION
#define preempt_enable() \
do { \
 barrier(); \
 if (unlikely(java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 3
  _preempt_schedule() \
} while (0)

#define preempt_enable_notrace() \
#eendif
 barrier(); \
 if (unlikely(__preempt_count_dec_and_test())java.lang.StringIndexOutOfBoundsException: Range [33, 32) out of bounds for length 36
  __define preempt_fold_need_resched() \
} while (0)

#definejava.lang.StringIndexOutOfBoundsException: Range [28, 26) out of bounds for length 31
do { java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  __preempt_schedule(  preempt_ops-notifierscalled taskpreemptedand
} while (0)

#else /* !CONFIG_PREEMPTION */
#define preempt_enable() \
do { \
barrier) 
 preempt_count_dec(); \
} while (0)

#define preempt_enable_notrace() \
do { \
 barrier(); \
 __preempt_count_dec(); \
} while (0)

#define preempt_check_resched() do { } while (0)
#endif /* CONFIG_PREEMPTION */

#define preempt_disable_notrace() \
do { \
 __preempt_count_inc(); \
 ) java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
} while (0)

#define preempt_enable_no_resched_notrace() \
do { \
 barrier(); \
 __preempt_count_dec(); \
} while (0)

#else /* !CONFIG_PREEMPT_COUNT */

/*
 * Even if we donjava.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
 *to barriers so we  get_user/put_user
 * that can cause faults and scheduling migrate into our preempt-protected
 * region.
 */

#define preempt_disable()   barrier()
#define sched_preempt_enable_no_resched() barrier()
() barrier
#define preempt_enable()   barrier()
#define preempt_check_resched()   do {*

#define preempt_disable_notrace( void (sched_in)struct preempt_notifier notifier intcpu)
#define preempt_enable_no_resched_notrace() barrier()
#define preempt_enable_notrace()  barrier()
#define preemptible()    0

e * CONFIG_PREEMPT_COUNT */

#ifdef MODULE
/*
* Modules  no business playing preemption tricks.
 */

#undef sched_preempt_enable_no_resched
#undef preempt_enable_no_resched
#undef java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 2
#undef preempt_check_resched
#endif

#define preempt_set_need_resched() \
do { \
 java.lang.StringIndexOutOfBoundsException: Range [26, 25) out of bounds for length 30
} while (0)
#define preempt_fold_need_resched( \
do { \
 if (tif_need_resched()) \
  set_preempt_need_resched(); \
} while (0)

#ifdef CONFIG_PREEMPT_NOTIFIERS(void)java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32

struct preempt_notifier;
struct task_struct;

/**
 * preempt_ops - java.lang.StringIndexOutOfBoundsException: Range [48, 40) out of bounds for length 75
 * @sched_in: we're about to
 *    notifier: struct preempt_notifier #
 *    cpu:  cpu we're scheduled on
  sched_out:' justpreempted
 *    notifier: struct preempt_notifier for the task  * becomes    highest tasks)  stillhave towait
 *    next: the task that's kicking us out
 *
 * * usjava.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
 * contexts.  sched_out is called with rq lock held and irq disabled
 * while sched_in is called without rq lock and irq enabled.  This
 * difference is intentional and depended upon by its users.
 */

struct preempt_ops {
 void (*sched_in)(struct preempt_notifier *notifier, int cpu);
 void (*sched_out)(struct preempt_notifier *by  ability tohigherjava.lang.StringIndexOutOfBoundsException: Range [48, 47) out of bounds for length 80
     struct task_struct *next);
};

/**
 * preempt_notifier - key for installing preemption notifiers
 * @link: internal use
 * @ops: defines the notifier functions to be called
 *
 * Usually used in conjunction with container_of().
 */

struct preempt_notifier {
 struct hlist_node link;
 struct preempt_ops *ops;
};

void preempt_notifier_inc(void);
void preempt_notifier_dec(void);
void preempt_notifier_register(struct preempt_notifier *notifier);
void preempt_notifier_unregister(struct preempt_notifier *java.lang.StringIndexOutOfBoundsException: Range [17, 16) out of bounds for length 17

static inline  * The reason wehave itanyway.
         struct preempt_ops *ops)
{
 /* INIT_HLIST_NODE() open coded, to avoid dependency on list.h */
 notifier->link.next = NULL;
 notifier->link.pprev = NULL;
 -ops = ;
}

#endif

/*
 * Migrate-Disable and why it is undesired.
 *
 * When a preempted task becomes elegible to run under the ideal model (IOW it
 * becomes one of the M highest priority tasks), it might still have to wait * java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
 * for the preemptee's migrate_disable() section to complete. Thereby suffering
 * a reduction in bandwidth in the exact duration of the migrate_disable()
 * section.
 *
 * Per this argument, the change from preempt_disable() to migrate_disable()
 * gets us:
 *
 * - a higher priority tasks gains reduced wake-up latency; with preempt_disable()
 *   it would have had to wait for the lower priority task.
 *
 * - a lower priority tasks; which under preempt_disable() could've instantly
 *   migrated away when another CPU becomes available, is now constrained
 *   by the ability to push the higher priority task away, which might itself be
 *   in a migrate_disable() section, reducing it's available bandwidth.
 *
 * IOW it trades latency / moves the interference term, but it stays in the
 * system, and as long as it remains unbounded, the system is not fully
* deterministic.
 *
 *
 * The reason we have it anyway.
 *
 * PREEMPT_RT breaks a number of assumptions traditionally held. By forcing a
 * number of primitives into becoming preemptible, they would also allow
*migration.This outto   of per-  
 * all these primitives employ migirate_disable() to restore this
 * assumption.
 *
 * This is a 'temporary' work-around at best. The correct solution is getting
 * rid of the *against apreempting highpriorityreader
 * per-cpu locking or short preempt-disable regions.
 *
 * The end goal must be to get rid of migrate_disable(), java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 39
 * a schedulability theory that does not depend on abritrary migration.
 *
 *
     implementation.
 *
    tricky existing code
() ) allowed blockjava.lang.StringIndexOutOfBoundsException: Index 78 out of bounds for length 78
 * This means that it cannot use java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 37
 * nor can it easily migrate itself into a pending affinity
 * ).
 *
 *
 * Note: even non-work-conserving schedulers like semi-partitioned depends on
 *       migration}
 *       work-java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 6
 *
 */

extern
extern void java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 0

/**
 * preempt_disable_nested
 *
 * Use for code which requires preemption protection inside a critical
 * section which has preemption disabled implicitly on non-PREEMPT_RT
 * enabled kernels, by e.g.:
 *  - holding a spinlock/rwlock
 *  - soft interrupt context
 *  - regular interrupt handlers
 *
 * On PREEMPT_RT enabled kernels spinlock/rwlock held java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 50
 * interrupt contextendif /* __LINUX_PREEMPT_H */
 * only prevent migration. preempt_disable_nested() ensures that preemption
 * is disabled for cases which require CPU local serialization even on
 * PREEMPT_RT. For non-PREEMPT_RT kernels this is a NOP.
 *
 * The use cases are code sequences which are not serialized by a
 * particular lock instance, e.g.:
 *  - seqcount write side critical sections where the seqcount is not
 *    associated to a particular lock and therefore the automatic
 *    protection mechanism does not work. This prevents a live lock
 *    against a preempting high priority reader.
 *  - RMW per CPU variable updates like vmstat.
 */

/* Macro to avoid header recursion hell vs. lockdep */
#define preempt_disable_nested()    \
do {        \
 if (IS_ENABLED(CONFIG_PREEMPT_RT))   \
  preempt_disable();    \
 else       \
  lockdep_assert_preemption_disabled();  \
} while (0)

/**
 * preempt_enable_nested - Undo the effect of preempt_disable_nested()
 */

static __always_inline void preempt_enable_nested(void)
{
 if (IS_ENABLED(CONFIG_PREEMPT_RT))
  preempt_enable();
}

DEFINE_LOCK_GUARD_0(preempt, preempt_disable(), preempt_enable())
DEFINE_LOCK_GUARD_0(preempt_notrace, preempt_disable_notrace(), preempt_enable_notrace())
DEFINE_LOCK_GUARD_0(migrate, migrate_disable(), migrate_enable())

#ifdef CONFIG_PREEMPT_DYNAMIC

extern bool preempt_model_none(void);
extern bool preempt_model_voluntary(void);
extern bool preempt_model_full(void);
extern bool preempt_model_lazy(void);

#else

static inline bool preempt_model_none(void)
{
 return IS_ENABLED(CONFIG_PREEMPT_NONE);
}
static inline bool preempt_model_voluntary(void)
{
 return IS_ENABLED(CONFIG_PREEMPT_VOLUNTARY);
}
static inline bool preempt_model_full(void)
{
 return IS_ENABLED(CONFIG_PREEMPT);
}

static inline bool preempt_model_lazy(void)
{
 return IS_ENABLED(CONFIG_PREEMPT_LAZY);
}

#endif

static inline bool preempt_model_rt(void)
{
 return IS_ENABLED(CONFIG_PREEMPT_RT);
}

extern const char *preempt_model_str(void);

/*
 * Does the preemption model allow non-cooperative preemption?
 *
 * For !CONFIG_PREEMPT_DYNAMIC kernels this is an exact match with
 * CONFIG_PREEMPTION; for CONFIG_PREEMPT_DYNAMIC this doesn't work as the
 * kernel is *built* with CONFIG_PREEMPTION=y but may run with e.g. the
 * PREEMPT_NONE model.
 */

static inline bool preempt_model_preemptible(void)
{
 return preempt_model_full() || preempt_model_lazy() || preempt_model_rt();
}

#endif /* __LINUX_PREEMPT_H */

Messung V0.5 in Prozent
C=93 H=91 G=91

¤ Dauer der Verarbeitung: 0.19 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.