From: Marek Szyprowski Date: Wed, 17 Aug 2022 14:47:08 +0000 (+0200) Subject: Assorted fixes from product division X-Git-Tag: submit/tizen/20220906.135332~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=59184136dcf288abd39b30dfc7f8a82f260ecb80;p=platform%2Fkernel%2Flinux-tizen-modules-source.git Assorted fixes from product division This commit brings following changes from product divisions aligning codebases together: - introduce dbus match cache (performance optimization), - raise max number of possible matches, - minor fixes. Change-Id: I6a58e52d48b9ac8a2eb8cb333e7d20b4e821c08c Signed-off-by: Karol Lewandowski [ Describe in more detail what this change brings ] Signed-off-by: Marek Szyprowski --- diff --git a/kernel/kdbus/connection.c b/kernel/kdbus/connection.c index 4677c5d..4d4c754 100644 --- a/kernel/kdbus/connection.c +++ b/kernel/kdbus/connection.c @@ -905,8 +905,10 @@ int kdbus_conn_entry_insert(struct kdbus_conn *conn_src, if (reply) { kdbus_reply_link(reply); - if (!reply->sync) + if (!reply->sync) { + cancel_delayed_work(&conn_src->work); schedule_delayed_work(&conn_src->work, 0); + } } /* diff --git a/kernel/kdbus/limits.h b/kernel/kdbus/limits.h index 59e3608..bbc973c 100644 --- a/kernel/kdbus/limits.h +++ b/kernel/kdbus/limits.h @@ -41,7 +41,7 @@ #define KDBUS_SYSNAME_MAX_LEN 63 /* maximum number of matches per connection */ -#define KDBUS_MATCH_MAX 256 +#define KDBUS_MATCH_MAX 1024 /* maximum number of queued messages from the same individual user */ #define KDBUS_CONN_MAX_MSGS 256 diff --git a/kernel/kdbus/main.c b/kernel/kdbus/main.c index 1ad4dc8..54c7f58 100644 --- a/kernel/kdbus/main.c +++ b/kernel/kdbus/main.c @@ -19,6 +19,7 @@ #include "util.h" #include "fs.h" #include "handle.h" +#include "match.h" #include "metadata.h" #include "node.h" @@ -86,15 +87,21 @@ static int __init kdbus_init(void) if (!kdbus_dir) return -ENOMEM; + ret = kdbus_init_cache_create(); + if (ret < 0) + goto exit_dir; + ret = kdbus_fs_init(); if (ret < 0) { pr_err("cannot register filesystem: %d\n", ret); - goto exit_dir; + goto exit_cache; } pr_info("initialized\n"); return 0; +exit_cache: + kdbus_init_cache_destroy(); exit_dir: kobject_put(kdbus_dir); return ret; @@ -103,6 +110,7 @@ exit_dir: static void __exit kdbus_exit(void) { kdbus_fs_exit(); + kdbus_init_cache_destroy(); kobject_put(kdbus_dir); ida_destroy(&kdbus_node_ida); } diff --git a/kernel/kdbus/match.c b/kernel/kdbus/match.c index 4ee6a1f..1c1ef9b 100644 --- a/kernel/kdbus/match.c +++ b/kernel/kdbus/match.c @@ -96,6 +96,35 @@ struct kdbus_match_rule { struct list_head rules_entry; }; +struct kmem_cache *kdbus_match_entry_cachep, *kdbus_match_rule_cachep; + +int kdbus_init_cache_create(void) +{ + kdbus_match_entry_cachep = kmem_cache_create("kdbus_match_entry_cache", + sizeof(struct kdbus_match_entry), 0, 0, NULL); + if (!kdbus_match_entry_cachep) + return -ENOMEM; + kdbus_match_rule_cachep = kmem_cache_create("kdbus_match_rule_cache", + sizeof(struct kdbus_match_rule), 0, 0, NULL); + if (!kdbus_match_rule_cachep) { + kmem_cache_destroy(kdbus_match_entry_cachep); + return -ENOMEM; + } + return 0; +} + +void kdbus_init_cache_destroy(void) +{ + if (kdbus_match_entry_cachep) { + kmem_cache_destroy(kdbus_match_entry_cachep); + kdbus_match_entry_cachep = NULL; + } + if (kdbus_match_rule_cachep) { + kmem_cache_destroy(kdbus_match_rule_cachep); + kdbus_match_rule_cachep = NULL; + } +} + static void kdbus_match_rule_free(struct kdbus_match_rule *rule) { if (!rule) @@ -124,7 +153,7 @@ static void kdbus_match_rule_free(struct kdbus_match_rule *rule) } list_del(&rule->rules_entry); - kfree(rule); + kmem_cache_free(kdbus_match_rule_cachep, rule); } static void kdbus_match_entry_free(struct kdbus_match_entry *entry) @@ -138,7 +167,7 @@ static void kdbus_match_entry_free(struct kdbus_match_entry *entry) kdbus_match_rule_free(r); list_del(&entry->list_entry); - kfree(entry); + kmem_cache_free(kdbus_match_entry_cachep, entry); } /** @@ -386,7 +415,7 @@ int kdbus_cmd_match_add(struct kdbus_conn *conn, void __user *argp) if (ret != 0) return ret; - entry = kzalloc(sizeof(*entry), GFP_KERNEL); + entry = kmem_cache_zalloc(kdbus_match_entry_cachep, GFP_KERNEL); if (!entry) { ret = -ENOMEM; goto exit; @@ -400,7 +429,7 @@ int kdbus_cmd_match_add(struct kdbus_conn *conn, void __user *argp) struct kdbus_match_rule *rule; size_t size = item->size - offsetof(struct kdbus_item, data); - rule = kzalloc(sizeof(*rule), GFP_KERNEL); + rule = kmem_cache_zalloc(kdbus_match_rule_cachep, GFP_KERNEL); if (!rule) { ret = -ENOMEM; goto exit; diff --git a/kernel/kdbus/match.h b/kernel/kdbus/match.h index ceb492f..486010d 100644 --- a/kernel/kdbus/match.h +++ b/kernel/kdbus/match.h @@ -20,6 +20,8 @@ struct kdbus_match_db; struct kdbus_staging; struct kdbus_match_db *kdbus_match_db_new(void); +int kdbus_init_cache_create(void); +void kdbus_init_cache_destroy(void); void kdbus_match_db_free(struct kdbus_match_db *db); int kdbus_match_db_add(struct kdbus_conn *conn, struct kdbus_cmd_match *cmd); diff --git a/kernel/kdbus/reply.c b/kernel/kdbus/reply.c index 07cb133..e6791d8 100644 --- a/kernel/kdbus/reply.c +++ b/kernel/kdbus/reply.c @@ -117,7 +117,7 @@ void kdbus_reply_link(struct kdbus_reply *r) if (WARN_ON(!list_empty(&r->entry))) return; - list_add_tail(&r->entry, &r->reply_dst->reply_list); + list_add(&r->entry, &r->reply_dst->reply_list); kdbus_reply_ref(r); }