CDU: Support Dropping Clients when CDU DB is Full
This patch adds support for dropping the least recently seen clients in
the CDU DB. Prior to this patch, we would implicitly drop new clients when
the CDU DB was full (by refusing to add them to the CDU DB). With this
patch, we will instead drop the 10% least-recently seen clients.
To find the least-recently seen clients, we will sort O(nlog(n)) all the
clients and drop the last 10%. We do this as we're adding a new client
to the database, and so hopefully is safe enough.
PS2: Use CDU_INFO instead of pr_info_ratelimited. Also don't declare
variables for timing the sort unless we're in debug mode.
Change-Id: I99e339f089475a5945ebd8390b171bb563aa319c
diff --git a/client_data_usage/cdu_db.h b/client_data_usage/cdu_db.h
index c5a50b4..45d91cb 100644
--- a/client_data_usage/cdu_db.h
+++ b/client_data_usage/cdu_db.h
@@ -27,6 +27,7 @@
#define CDU_DB_CONNTR_NOCLEAR 0
extern struct hlist_head cdu_db_usage_hash[USAGE_HASH_BITS] __read_mostly;
+extern struct list_head cdu_db_usage_list;
extern spinlock_t cdu_db_hash_lock;
int cdu_db_init(void);