~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/sched_ext/include/scx/common.h

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0 */
  2 /*
  3  * Copyright (c) 2023 Meta Platforms, Inc. and affiliates.
  4  * Copyright (c) 2023 Tejun Heo <tj@kernel.org>
  5  * Copyright (c) 2023 David Vernet <dvernet@meta.com>
  6  */
  7 #ifndef __SCHED_EXT_COMMON_H
  8 #define __SCHED_EXT_COMMON_H
  9 
 10 #ifdef __KERNEL__
 11 #error "Should not be included by BPF programs"
 12 #endif
 13 
 14 #include <stdarg.h>
 15 #include <stdio.h>
 16 #include <stdlib.h>
 17 #include <stdint.h>
 18 #include <errno.h>
 19 
 20 typedef uint8_t u8;
 21 typedef uint16_t u16;
 22 typedef uint32_t u32;
 23 typedef uint64_t u64;
 24 typedef int8_t s8;
 25 typedef int16_t s16;
 26 typedef int32_t s32;
 27 typedef int64_t s64;
 28 
 29 #define SCX_BUG(__fmt, ...)                                                     \
 30         do {                                                                    \
 31                 fprintf(stderr, "[SCX_BUG] %s:%d", __FILE__, __LINE__);         \
 32                 if (errno)                                                      \
 33                         fprintf(stderr, " (%s)\n", strerror(errno));            \
 34                 else                                                            \
 35                         fprintf(stderr, "\n");                                  \
 36                 fprintf(stderr, __fmt __VA_OPT__(,) __VA_ARGS__);               \
 37                 fprintf(stderr, "\n");                                          \
 38                                                                                 \
 39                 exit(EXIT_FAILURE);                                             \
 40         } while (0)
 41 
 42 #define SCX_BUG_ON(__cond, __fmt, ...)                                  \
 43         do {                                                            \
 44                 if (__cond)                                             \
 45                         SCX_BUG((__fmt) __VA_OPT__(,) __VA_ARGS__);     \
 46         } while (0)
 47 
 48 /**
 49  * RESIZE_ARRAY - Convenience macro for resizing a BPF array
 50  * @__skel: the skeleton containing the array
 51  * @elfsec: the data section of the BPF program in which the array exists
 52  * @arr: the name of the array
 53  * @n: the desired array element count
 54  *
 55  * For BPF arrays declared with RESIZABLE_ARRAY(), this macro performs two
 56  * operations. It resizes the map which corresponds to the custom data
 57  * section that contains the target array. As a side effect, the BTF info for
 58  * the array is adjusted so that the array length is sized to cover the new
 59  * data section size. The second operation is reassigning the skeleton pointer
 60  * for that custom data section so that it points to the newly memory mapped
 61  * region.
 62  */
 63 #define RESIZE_ARRAY(__skel, elfsec, arr, n)                                            \
 64         do {                                                                            \
 65                 size_t __sz;                                                            \
 66                 bpf_map__set_value_size((__skel)->maps.elfsec##_##arr,                  \
 67                                 sizeof((__skel)->elfsec##_##arr->arr[0]) * (n));        \
 68                 (__skel)->elfsec##_##arr =                                              \
 69                         bpf_map__initial_value((__skel)->maps.elfsec##_##arr, &__sz);   \
 70         } while (0)
 71 
 72 #include "user_exit_info.h"
 73 #include "compat.h"
 74 
 75 #endif  /* __SCHED_EXT_COMMON_H */
 76 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php