external/sd-daemon/sd-daemon.c \
src/logger/logger.c \
src/logger/log_storage.c \
+ src/logger/qos.c \
src/shared/backend_androidlogger.c \
src/shared/ptrs_list.c \
src/shared/logcommon.c \
return qos->threshold > 0 && qos->max_throughput > 0 && qos->file_path && strlen(qos->file_path) > 0;
}
-struct metrics_pid_aggr_info {
- pid_t pid;
- int count;
-};
-
-void (*qos_distribution_func)(struct qos_module *qos, struct metrics_pid_aggr_info *infos, int count);
-
-void qos_distribution_proportional(struct qos_module *qos, struct metrics_pid_aggr_info *infos, int count)
-{
- const double proportion = (double) qos->max_throughput / (metrics_get_total(qos->log_metrics) ?: 1);
-
- for (int i = 0; i < count; ++i)
- infos[i].count = (int) (infos[i].count * proportion + 0.5);
-}
-
-void qos_distribution_equal(struct qos_module *qos, struct metrics_pid_aggr_info *infos, int count)
-{
- /* round upwards so that it's never 0, to give all clients a chance
- * to log at least something (so a developer can tell it's alive) */
- const int equal_limit_for_everybody = (qos->max_throughput + (count - 1)) / count;
-
- for (int i = 0; i < count; ++i)
- infos[i].count = equal_limit_for_everybody;
-}
-
void qos_create_limits_file(struct qos_module *qos, bool is_limiting)
{
__attribute__((cleanup(close_fd))) int fd = creat(qos->file_path, 0644);
#include <backend_androidlogger.h>
#include <queued_entry_timestamp.h>
#include <dlogutil-internal.h>
+#include "qos.h"
#ifdef __cplusplus
extern "C" {
int fd;
};
-struct qos_module {
- struct metrics *log_metrics;
- char *file_path;
- int max_throughput;
- int threshold;
- int threshold_reapply;
- int limit_duration;
- struct timespec cancel_limits_at;
- bool currently_limiting;
-};
-
/**
* @brief Service a writer
* @details Specific handler that event is delegated to, according to writers type
--- /dev/null
+/* Copyright (c) 2020, Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. */
+
+#include "qos.h"
+
+void (*qos_distribution_func)(struct qos_module *qos, struct metrics_pid_aggr_info *infos, int count);
+
+void qos_distribution_proportional(struct qos_module *qos, struct metrics_pid_aggr_info *infos, int count)
+{
+ const double proportion = (double) qos->max_throughput / (metrics_get_total(qos->log_metrics) ?: 1);
+
+ for (int i = 0; i < count; ++i)
+ infos[i].count = (int) (infos[i].count * proportion + 0.5);
+}
+
+void qos_distribution_equal(struct qos_module *qos, struct metrics_pid_aggr_info *infos, int count)
+{
+ /* round upwards so that it's never 0, to give all clients a chance
+ * to log at least something (so a developer can tell it's alive) */
+ const int equal_limit_for_everybody = (qos->max_throughput + (count - 1)) / count;
+
+ for (int i = 0; i < count; ++i)
+ infos[i].count = equal_limit_for_everybody;
+}
+
--- /dev/null
+#pragma once
+
+/* Copyright (c) 2020, Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. */
+
+// C
+#include <time.h>
+
+// DLog
+#include <metrics.h>
+
+struct metrics_pid_aggr_info {
+ pid_t pid;
+ int count;
+};
+
+struct qos_module {
+ struct metrics *log_metrics;
+ char *file_path;
+ int max_throughput;
+ int threshold;
+ int threshold_reapply;
+ int limit_duration;
+ struct timespec cancel_limits_at;
+ bool currently_limiting;
+};
+
+extern void (*qos_distribution_func)(struct qos_module *qos, struct metrics_pid_aggr_info *infos, int count);
+
+void qos_distribution_equal(struct qos_module *qos, struct metrics_pid_aggr_info *infos, int count);
+void qos_distribution_proportional(struct qos_module *qos, struct metrics_pid_aggr_info *infos, int count);
+