Skip to content

SCX eBPF macro SCX_OPS_DEFINE

v6.12

The SCX_OPS_DEFINE macro is used to define a full sched_ext_ops implementation.

Definition

#define SCX_OPS_DEFINE(__name, ...)     \
    SEC(".struct_ops.link")             \
    struct sched_ext_ops __name = {     \
        __VA_ARGS__,                    \
    };

Usage

This macro can be used to define a full sched_ext_ops implementation, associating the separate BPF programs with the corresponding sched_ext_ops functions.

Example

/* SPDX-License-Identifier: GPL-2.0 */
/* Copyright (c) 2022 Meta Platforms, Inc. and affiliates.
 * Copyright (c) 2022 Tejun Heo <tj@kernel.org>
 * Copyright (c) 2022 David Vernet <dvernet@meta.com>
 */

SCX_OPS_DEFINE(simple_ops,
           .select_cpu      = (void *)simple_select_cpu,
           .enqueue         = (void *)simple_enqueue,
           .dispatch        = (void *)simple_dispatch,
           .running         = (void *)simple_running,
           .stopping        = (void *)simple_stopping,
           .enable          = (void *)simple_enable,
           .init            = (void *)simple_init,
           .exit            = (void *)simple_exit,
           .name            = "simple");