Two migrate disable related stubs for BPF to base the RT patches on
Unified · Split
| @@ -257,6 +257,13 @@ extern void __cant_sleep(const char *file, int line, int preempt_offset); · 256 unmodified lines | ||
| 257 | 257 | |
| 258 | 258 | #define might_sleep_if(cond) do { if (cond) might_sleep(); } while (0) |
| 259 | 259 | |
| 260 | +#ifndef CONFIG_PREEMPT_RT | |
| 261 | +# define cant_migrate() cant_sleep() | |
| 262 | +#else | |
| 263 | + /* Placeholder for now */ | |
| 264 | +# define cant_migrate() do { } while (0) | |
| 265 | +#endif | |
| 266 | + | |
| 260 | 267 | /** |
| 261 | 268 | * abs - return absolute value of an argument |
| 262 | 269 | * @x: the value. If it is unsigned type, it is converted to signed type first. |
| @@ -322,4 +322,34 @@ static inline void preempt_notifier_init(struct preempt_notifier *notifier, · 321 unmodified lines | ||
| 322 | 322 | |
| 323 | 323 | #endif |
| 324 | 324 | |
| 325 | +/** | |
| 326 | + * migrate_disable - Prevent migration of the current task | |
| 327 | + * | |
| 328 | + * Maps to preempt_disable() which also disables preemption. Use | |
| 329 | + * migrate_disable() to annotate that the intent is to prevent migration, | |
| 330 | + * but not necessarily preemption. | |
| 331 | + * | |
| 332 | + * Can be invoked nested like preempt_disable() and needs the corresponding | |
| 333 | + * number of migrate_enable() invocations. | |
| 334 | + */ | |
| 335 | +static __always_inline void migrate_disable(void) | |
| 336 | +{ | |
| 337 | + preempt_disable(); | |
| 338 | +} | |
| 339 | + | |
| 340 | +/** | |
| 341 | + * migrate_enable - Allow migration of the current task | |
| 342 | + * | |
| 343 | + * Counterpart to migrate_disable(). | |
| 344 | + * | |
| 345 | + * As migrate_disable() can be invoked nested, only the outermost invocation | |
| 346 | + * reenables migration. | |
| 347 | + * | |
| 348 | + * Currently mapped to preempt_enable(). | |
| 349 | + */ | |
| 350 | +static __always_inline void migrate_enable(void) | |
| 351 | +{ | |
| 352 | + preempt_enable(); | |
| 353 | +} | |
| 354 | + | |
| 325 | 355 | #endif /* __LINUX_PREEMPT_H */ |