From: Alexander Holler <holler@ahsoftware.de> To: linux-kernel@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, Greg KH <gregkh@linuxfoundation.org>, Russel King <linux@arm.linux.org.uk>, Andrew Morton <akpm@linux-foundation.org>, Grant Likely <grant.likely@linaro.org>, Tomeu Vizoso <tomeu.vizoso@collabora.com>, Alexander Holler <holler@ahsoftware.de> Subject: [PATCH 2/2] deps: avoid multiple calls to memmove by just setting duplicates to 0 Date: Wed, 9 Sep 2015 20:35:25 +0200 [thread overview] Message-ID: <1441823725-8869-3-git-send-email-holler@ahsoftware.de> (raw) In-Reply-To: <1441823725-8869-1-git-send-email-holler@ahsoftware.de> Besides make the code (almost unmeasurable) faster, this makes the ugly looking loop I've used to remove duplicates cleaner. Disadvantage is that the ordered array now contains 'holes' and the number of elements in the array doesn't really match the number of ordered elements. But this only makes a difference for debugging. This patch also adds an of_node_put() for duplicate dt nodes, something I previously had forgotten. Signed-off-by: Alexander Holler <holler@ahsoftware.de> --- drivers/of/of_dependencies.c | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/drivers/of/of_dependencies.c b/drivers/of/of_dependencies.c index 85cef84..ac0c0f5 100644 --- a/drivers/of/of_dependencies.c +++ b/drivers/of/of_dependencies.c @@ -323,21 +323,20 @@ static bool __init all_compatibles_same(struct device_node *node1, /* * The order is based on devices but we are calling drivers. * Therefor the order contains some drivers more than once. - * Remove the duplicates. + * Disable the duplicates by setting them to 0. */ -static void __init of_init_remove_duplicates(void) +static void __init of_init_disable_duplicates(void) { unsigned i, j; for (i = 1; i < order.count; ++i) for (j = 0; j < i; ++j) { + if (!order.order[j]) + continue; if (all_compatibles_same(order.order[j], order.order[i])) { - --order.count; - memmove(&order.order[i], &order.order[i+1], - (order.count - i) * - sizeof(order.order[0])); - --i; + of_node_put(order.order[i]); + order.order[i] = 0; break; } } @@ -416,7 +415,8 @@ static void __init build_tgroups(void) unsigned dist = 0; for (i = 0; i < order.count; ++i) { - if (distance[order.order[i]->phandle] != dist) { + if (order.order[i] && + distance[order.order[i]->phandle] != dist) { dist = distance[order.order[i]->phandle]; count_groups++; tgroup[count_groups].start = i; @@ -436,6 +436,8 @@ static void __init of_init_print_order(void) pr_info("Initialization order:\n"); for (i = 0; i < order.count; ++i) { + if (!order.order[i]) + continue; #ifdef CONFIG_OF_DEPENDENCIES_PARALLEL pr_info("init %u 0x%x (group %u)", i, order.order[i]->phandle, @@ -496,10 +498,10 @@ static int __init of_init_build_order(void) #ifdef CONFIG_OF_DEPENDENCIES_PARALLEL build_order_by_distance(); - of_init_remove_duplicates(); + of_init_disable_duplicates(); build_tgroups(); #else - of_init_remove_duplicates(); + of_init_disable_duplicates(); #endif #ifdef CONFIG_OF_DEPENDENCIES_PRINT_INIT_ORDER @@ -516,7 +518,8 @@ static void __init of_init_free_order(void) unsigned i; for (i = 0; i < order.count; ++i) - of_node_put(order.order[i]); + if (order.order[i]) + of_node_put(order.order[i]); order.count = 0; /* remove_new_phandles(); */ } @@ -593,8 +596,10 @@ static int __init initcall_thread(void *thread_nr) start = atomic_read(&ostart); count = atomic_read(&ocount); while ((i = atomic_dec_return(&shared_counter)) >= 0) - init_if_matched(order.order[start + count - 1 - i], - (unsigned)thread_nr); + if (order.order[start + count - 1 - i]) + init_if_matched( + order.order[start + count - 1 - i], + (unsigned)thread_nr); prepare_to_wait(&group_waitqueue, &wait, TASK_UNINTERRUPTIBLE); if (!atomic_dec_and_test(&count_initcall_threads)) { schedule(); @@ -629,7 +634,8 @@ static void __init of_init_drivers_non_threaded(void) if (!of_init_build_order()) { for (i = 0; i < order.count; ++i) - init_if_matched(order.order[i], 0); + if (order.order[i]) + init_if_matched(order.order[i], 0); of_init_free_order(); } ac = __annotated_initcall_start; -- 2.1.0
WARNING: multiple messages have this Message-ID (diff)
From: holler@ahsoftware.de (Alexander Holler) To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 2/2] deps: avoid multiple calls to memmove by just setting duplicates to 0 Date: Wed, 9 Sep 2015 20:35:25 +0200 [thread overview] Message-ID: <1441823725-8869-3-git-send-email-holler@ahsoftware.de> (raw) In-Reply-To: <1441823725-8869-1-git-send-email-holler@ahsoftware.de> Besides make the code (almost unmeasurable) faster, this makes the ugly looking loop I've used to remove duplicates cleaner. Disadvantage is that the ordered array now contains 'holes' and the number of elements in the array doesn't really match the number of ordered elements. But this only makes a difference for debugging. This patch also adds an of_node_put() for duplicate dt nodes, something I previously had forgotten. Signed-off-by: Alexander Holler <holler@ahsoftware.de> --- drivers/of/of_dependencies.c | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/drivers/of/of_dependencies.c b/drivers/of/of_dependencies.c index 85cef84..ac0c0f5 100644 --- a/drivers/of/of_dependencies.c +++ b/drivers/of/of_dependencies.c @@ -323,21 +323,20 @@ static bool __init all_compatibles_same(struct device_node *node1, /* * The order is based on devices but we are calling drivers. * Therefor the order contains some drivers more than once. - * Remove the duplicates. + * Disable the duplicates by setting them to 0. */ -static void __init of_init_remove_duplicates(void) +static void __init of_init_disable_duplicates(void) { unsigned i, j; for (i = 1; i < order.count; ++i) for (j = 0; j < i; ++j) { + if (!order.order[j]) + continue; if (all_compatibles_same(order.order[j], order.order[i])) { - --order.count; - memmove(&order.order[i], &order.order[i+1], - (order.count - i) * - sizeof(order.order[0])); - --i; + of_node_put(order.order[i]); + order.order[i] = 0; break; } } @@ -416,7 +415,8 @@ static void __init build_tgroups(void) unsigned dist = 0; for (i = 0; i < order.count; ++i) { - if (distance[order.order[i]->phandle] != dist) { + if (order.order[i] && + distance[order.order[i]->phandle] != dist) { dist = distance[order.order[i]->phandle]; count_groups++; tgroup[count_groups].start = i; @@ -436,6 +436,8 @@ static void __init of_init_print_order(void) pr_info("Initialization order:\n"); for (i = 0; i < order.count; ++i) { + if (!order.order[i]) + continue; #ifdef CONFIG_OF_DEPENDENCIES_PARALLEL pr_info("init %u 0x%x (group %u)", i, order.order[i]->phandle, @@ -496,10 +498,10 @@ static int __init of_init_build_order(void) #ifdef CONFIG_OF_DEPENDENCIES_PARALLEL build_order_by_distance(); - of_init_remove_duplicates(); + of_init_disable_duplicates(); build_tgroups(); #else - of_init_remove_duplicates(); + of_init_disable_duplicates(); #endif #ifdef CONFIG_OF_DEPENDENCIES_PRINT_INIT_ORDER @@ -516,7 +518,8 @@ static void __init of_init_free_order(void) unsigned i; for (i = 0; i < order.count; ++i) - of_node_put(order.order[i]); + if (order.order[i]) + of_node_put(order.order[i]); order.count = 0; /* remove_new_phandles(); */ } @@ -593,8 +596,10 @@ static int __init initcall_thread(void *thread_nr) start = atomic_read(&ostart); count = atomic_read(&ocount); while ((i = atomic_dec_return(&shared_counter)) >= 0) - init_if_matched(order.order[start + count - 1 - i], - (unsigned)thread_nr); + if (order.order[start + count - 1 - i]) + init_if_matched( + order.order[start + count - 1 - i], + (unsigned)thread_nr); prepare_to_wait(&group_waitqueue, &wait, TASK_UNINTERRUPTIBLE); if (!atomic_dec_and_test(&count_initcall_threads)) { schedule(); @@ -629,7 +634,8 @@ static void __init of_init_drivers_non_threaded(void) if (!of_init_build_order()) { for (i = 0; i < order.count; ++i) - init_if_matched(order.order[i], 0); + if (order.order[i]) + init_if_matched(order.order[i], 0); of_init_free_order(); } ac = __annotated_initcall_start; -- 2.1.0
next prev parent reply other threads:[~2015-09-09 18:36 UTC|newest] Thread overview: 70+ messages / expand[flat|nested] mbox.gz Atom feed top 2015-08-26 12:28 [PATCH 00/16] deps: deterministic driver initialization order Alexander Holler 2015-08-26 12:28 ` Alexander Holler 2015-08-26 12:28 ` Alexander Holler 2015-08-26 12:28 ` [PATCH 01/16] deps: dtc: Automatically add new property 'dependencies' which contains a list of referenced phandles Alexander Holler 2015-08-26 12:28 ` Alexander Holler 2015-08-26 12:28 ` [PATCH 02/16] deps: dtc: Add option to print initialization order Alexander Holler 2015-08-26 12:28 ` Alexander Holler 2015-08-26 12:28 ` Alexander Holler 2015-08-26 12:28 ` [PATCH 03/16] deps: dtc: Add option to print dependency graph as dot (Graphviz) Alexander Holler 2015-08-26 12:28 ` Alexander Holler 2015-08-26 12:28 ` [PATCH 04/16] deps: dtc: introduce new (virtual) property no-dependencies Alexander Holler 2015-08-26 12:28 ` Alexander Holler 2015-08-26 12:28 ` [PATCH 05/16] deps: introduce initcalls annotated with a struct device_driver Alexander Holler 2015-08-26 12:28 ` Alexander Holler 2015-08-26 12:28 ` [PATCH 06/16] deps: deterministic driver initialization sequence based on dependencies from the DT Alexander Holler 2015-08-26 12:28 ` Alexander Holler 2015-08-26 12:28 ` [PATCH 07/16] deps: add debug configuration options Alexander Holler 2015-08-26 12:28 ` Alexander Holler 2015-08-26 12:28 ` [PATCH 08/16] deps: dts: kirkwood: dockstar: add dependency ehci -> usb power regulator Alexander Holler 2015-08-26 12:28 ` Alexander Holler 2015-08-26 12:28 ` [PATCH 09/16] deps: dts: imx6q: make some remote-endpoints non-dependencies Alexander Holler 2015-08-26 12:28 ` Alexander Holler 2015-08-26 12:28 ` [PATCH 10/16] deps: dts: omap: beagle: " Alexander Holler 2015-08-26 12:28 ` Alexander Holler 2015-08-26 12:28 ` Alexander Holler 2015-08-26 12:28 ` [PATCH 11/16] deps: WIP: generic: annotate some initcalls Alexander Holler 2015-08-26 12:28 ` Alexander Holler 2015-08-26 12:28 ` [PATCH 12/16] deps: WIP: imx: " Alexander Holler 2015-08-26 12:28 ` Alexander Holler 2015-08-26 12:28 ` [PATCH 13/16] deps: WIP: omap: " Alexander Holler 2015-08-26 12:28 ` Alexander Holler 2015-08-26 12:28 ` [PATCH 14/16] deps: WIP: kirkwood: " Alexander Holler 2015-08-26 12:28 ` Alexander Holler 2015-08-26 12:28 ` [PATCH 15/16] mtd: mtdcore: fix initcall level Alexander Holler 2015-08-26 12:28 ` Alexander Holler 2015-09-01 21:19 ` Brian Norris 2015-09-01 21:19 ` Brian Norris 2015-09-01 21:19 ` Brian Norris 2015-09-02 5:34 ` Alexander Holler 2015-09-02 5:34 ` Alexander Holler 2015-09-04 4:00 ` Alexander Holler 2015-09-04 4:00 ` Alexander Holler 2015-09-04 4:00 ` Alexander Holler 2015-09-08 19:36 ` Alexander Holler 2015-09-08 19:36 ` Alexander Holler 2015-09-08 19:36 ` Alexander Holler 2015-08-26 12:28 ` [PATCH 16/16] phy: phy-core: " Alexander Holler 2015-08-26 12:28 ` Alexander Holler 2015-09-18 6:16 ` Kishon Vijay Abraham I 2015-09-18 6:16 ` Kishon Vijay Abraham I 2015-09-18 6:16 ` Kishon Vijay Abraham I 2015-09-18 6:59 ` Alexander Holler 2015-09-18 6:59 ` Alexander Holler 2015-09-18 6:59 ` Alexander Holler 2015-08-27 19:01 ` [PATCH 00/16] deps: deterministic driver initialization order Alexander Holler 2015-08-27 19:01 ` Alexander Holler 2015-08-27 19:15 ` Alexander Holler 2015-08-27 19:15 ` Alexander Holler 2015-08-27 19:15 ` Alexander Holler 2015-09-04 9:18 ` deps: update in regard to parallel initialization of static linked drivers Alexander Holler 2015-09-04 9:18 ` Alexander Holler 2015-09-09 18:35 ` [PATCH 0/2] deps: parallel initialization of (device-)drivers Alexander Holler 2015-09-09 18:35 ` Alexander Holler 2015-09-09 18:35 ` [PATCH 1/2] " Alexander Holler 2015-09-09 18:35 ` Alexander Holler 2015-09-09 18:35 ` Alexander Holler [this message] 2015-09-09 18:35 ` [PATCH 2/2] deps: avoid multiple calls to memmove by just setting duplicates to 0 Alexander Holler 2015-09-14 19:53 ` [PATCH 0/2] deps: parallel initialization of (device-)drivers Alexander Holler 2015-09-14 19:53 ` Alexander Holler 2015-09-14 19:53 ` Alexander Holler
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=1441823725-8869-3-git-send-email-holler@ahsoftware.de \ --to=holler@ahsoftware.de \ --cc=akpm@linux-foundation.org \ --cc=devicetree@vger.kernel.org \ --cc=grant.likely@linaro.org \ --cc=gregkh@linuxfoundation.org \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux@arm.linux.org.uk \ --cc=tomeu.vizoso@collabora.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.