dlog_logger: refactor QoS distributions
[platform/core/system/dlog.git] / src / logger / qos.h
1 #pragma once
2
3 /* Copyright (c) 2020, Samsung Electronics Co., Ltd. All rights reserved.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License. */
16
17 // C
18 #include <time.h>
19
20 // DLog
21 #include <metrics.h>
22
23 struct metrics_pid_aggr_info {
24         pid_t pid;
25         int count;
26 };
27
28 struct qos_module;
29
30 typedef void (*qos_distribution_func)(struct qos_module *qos, struct metrics_pid_aggr_info *infos, int count);
31
32 struct qos_module {
33         qos_distribution_func distribution_func;
34         struct metrics *log_metrics;
35         char *file_path;
36         int max_throughput;
37         int threshold;
38         int threshold_reapply;
39         int limit_duration;
40         struct timespec cancel_limits_at;
41         bool currently_limiting;
42 };
43
44 qos_distribution_func qos_get_distribution_func_by_name(const char *name);
45
46 bool qos_is_enabled(const struct qos_module *qos);
47 void qos_create_limits_file(struct qos_module *qos, bool is_limiting);
48 void qos_set_next_update_time(struct qos_module *qos, struct timespec now);
49 void qos_apply_limits(struct qos_module *qos);
50 void qos_relax_limits(struct qos_module *qos);
51 void qos_add_log(struct qos_module *qos, const struct dlogutil_entry *due);
52 void qos_free(struct qos_module *qos);