xref: /foundation/resourceschedule/ffrt/src/eu/wgcm.h (revision 484543d1)
1/*
2 * Copyright (c) 2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16#ifndef _UAPI_LINUX_WGCM_H
17#define _UAPI_LINUX_WGCM_H
18
19#include <linux/types.h>
20
21constexpr int WGCM_TASK_ALIGN = 64;
22
23constexpr int WGCM_ACTIVELY_WAKE = 0x10;
24constexpr int PR_WGCM_CTL = 59;
25/*
26 * struct wgcm_workergrp_data: controls the state of WGCM tasks.
27 *
28 * The struct is aligned at 64 bytes to ensure that it fits into
29 * a single cache line.
30 */
31struct wgcm_workergrp_data {
32    /* wgcm workergroup's id */
33    __u32   gid;
34
35    /* server's thread id */
36    __u32   server_tid;
37
38    /*
39     * min_concur_workers & max_workers_sum:
40     * These two paras are used to detemine wether to wake up the server.
41     *
42     * When (workers_sum - blk_workers_sum < min_concur_workers) &&
43     * (workers_sum < max_workers_sum), wake up server.
44     */
45    __u32   min_concur_workers;
46    __u32   max_workers_sum;
47
48    /* count the number of workers which is bound with server */
49    __u32   workers_sum;
50
51    /* count the number of block workers */
52    __u32   blk_workers_sum;
53
54    /* indicates whether the server task is actively woken up */
55    __u32   woken_flag;
56
57    __u32   reserved;
58} __attribute__((packed, aligned(WGCM_TASK_ALIGN)));
59
60/**
61 * enum wgcm_ctl_flag - flags to pass to wgcm_ctl()
62 * @WGCM_CTL_SERVER_REG: register the current task as a WGCM server
63 * @WGCM_CTL_WORKER_REG: register the current task as a WGCM worker
64 * @WGCM_CTL_UNREGISTER: unregister the current task as a WGCM task
65 * @WGCM_CTL_GET: get infomation about workergroup
66 * @WGCM_CTL_SET_GRP: set min_concur_workers & max_workers_sum to workergroup
67 * @WGCM_CTL_WAIT: server thread enter the hibernation state
68 * @WGCM_CTL_WAKE: actively wakes up WGCM server
69 */
70enum wgcm_ctl_flag {
71    WGCM_CTL_SERVER_REG = 1,
72    WGCM_CTL_WORKER_REG,
73    WGCM_CTL_SET_GRP,
74    WGCM_CTL_UNREGISTER,
75    WGCM_CTL_GET = 5,
76    WGCM_CTL_WAIT,
77    WGCM_CTL_WAKE,
78    WGCM_CTL_MAX_NR,
79};
80
81#endif /* _UAPI_LINUX_WGCM_H */
82