Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1401724
| From | Rob Herring <robherring2@gmail.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH v2 3/5] of: unittest: hashed phandles unitest |
| Date | 2016-05-16 21:40 +0200 |
| Message-ID | <rzwwV-2Lc-5@gated-at.bofh.it> (permalink) |
| References | <rzu25-13S-7@gated-at.bofh.it> <rzu26-13S-27@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Mon, May 16, 2016 at 11:52 AM, Pantelis Antoniou
<pantelis.antoniou@konsulko.com> wrote:
> Add a benchmarking hashed phandles unittest which report what kind
> of speed up we get switching to hashed phandle lookups.
>
> ### dt-test ### the hash method is 8.2 times faster than the original
>
> On the beaglebone we perform about 1877 phandle lookups until that
> point in the unittest. Each non-hashed lookup takes about 23us when
> the cash is hot, while the hash lookup takes about 3us.
>
> For those 1877 lookup we get a speedup in the boot sequence of
> 1877 * (23 - 3) = 37.5ms, which is not spectacular but there's no
> point in wasting cycles and energy.
>
> Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
> ---
> drivers/of/unittest.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 68 insertions(+)
>
> diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c
> index 7ea3689..59cad84 100644
> --- a/drivers/of/unittest.c
> +++ b/drivers/of/unittest.c
> @@ -25,6 +25,9 @@
>
> #include <linux/bitops.h>
>
> +#include <linux/timekeeping.h>
> +#include <linux/random.h>
> +
> #include "of_private.h"
>
> static struct unittest_results {
> @@ -2266,6 +2269,70 @@ out:
> static inline void __init of_unittest_overlay(void) { }
> #endif
>
> +#define PHANDLE_LOOKUPS 1000
> +
> +static void __init of_unittest_phandle_hash(void)
> +{
> + struct device_node *node;
> + phandle max_phandle;
> + u32 ph;
> + unsigned long flags;
> + int i, j, total;
> + ktime_t start, end;
> + s64 dur[2];
> + int dec, frac;
> +
> + /* test only available when hashing is available */
> + if (!of_phandle_ht_available()) {
> + pr_warn("phandle hash test requires hash to be initialized\n");
> + return;
As the point of the unittest is to test the core DT code, this should
be a test fail.
> + }
> +
> + /* find the maximum phandle of the tree */
> + raw_spin_lock_irqsave(&devtree_lock, flags);
> + max_phandle = 0;
> + total = 0;
> + for_each_of_allnodes(node) {
> + if (node->phandle != (phandle)-1U &&
> + node->phandle > max_phandle)
> + max_phandle = node->phandle;
> + total++;
> + }
> + raw_spin_unlock_irqrestore(&devtree_lock, flags);
> + max_phandle++;
> +
> + pr_debug("phandle: max-phandle #%u, #%d total nodes\n",
> + (u32)max_phandle, total);
> +
> + /* perform random lookups using the hash */
> + for (j = 0; j < 2; j++) {
> +
> + /* disabled for pass #0, enabled for pass #1 */
> + of_phandle_ht_is_disabled = j == 0;
I'm not wild about having this variable leaked from the core code just
for the unit test. Yet another step away from the unittest being a
module.
I think you should just measure current performance and users can
revert the hash table if they want to measure the slow path.
Rob
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v2 0/5] of: generic infrastructure fixes Pantelis Antoniou <pantelis.antoniou@konsulko.com> - 2016-05-16 19:00 +0200
[PATCH v2 3/5] of: unittest: hashed phandles unitest Pantelis Antoniou <pantelis.antoniou@konsulko.com> - 2016-05-16 19:00 +0200
Re: [PATCH v2 3/5] of: unittest: hashed phandles unitest Geert Uytterhoeven <geert@linux-m68k.org> - 2016-05-16 21:10 +0200
Re: [PATCH v2 3/5] of: unittest: hashed phandles unitest Rob Herring <robherring2@gmail.com> - 2016-05-16 21:40 +0200
[PATCH v2 4/5] of: overlay: Pick up label symbols from overlays. Pantelis Antoniou <pantelis.antoniou@konsulko.com> - 2016-05-16 19:00 +0200
Re: [PATCH v2 4/5] of: overlay: Pick up label symbols from overlays. Geert Uytterhoeven <geert@linux-m68k.org> - 2016-05-16 21:10 +0200
Re: [PATCH v2 4/5] of: overlay: Pick up label symbols from overlays. Pantelis Antoniou <pantelis.antoniou@konsulko.com> - 2016-05-16 21:30 +0200
Re: [PATCH v2 4/5] of: overlay: Pick up label symbols from overlays. Geert Uytterhoeven <geert@linux-m68k.org> - 2016-05-16 21:50 +0200
Re: [PATCH v2 4/5] of: overlay: Pick up label symbols from overlays. Geert Uytterhoeven <geert@linux-m68k.org> - 2016-05-17 08:40 +0200
csiph-web