linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Rob Herring <robherring2@gmail.com>
To: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
Cc: Frank Rowand <frowand.list@gmail.com>,
	Matt Porter <mporter@konsulko.com>,
	Grant Likely <grant.likely@secretlab.ca>,
	Koen Kooi <koen@dominion.thruhere.net>,
	Guenter Roeck <linux@roeck-us.net>, Marek Vasut <marex@denx.de>,
	Geert Uytterhoeven <geert@linux-m68k.org>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Pantelis Antoniou <panto@antoniou-consulting.com>
Subject: Re: [PATCH v2 3/5] of: unittest: hashed phandles unitest
Date: Mon, 16 May 2016 14:38:27 -0500	[thread overview]
Message-ID: <CAL_Jsq+=w1zo=QUWV3iMv=mpMTb+JtRFSPStrpd=3x67fte3rA@mail.gmail.com> (raw)
In-Reply-To: <1463417556-23087-4-git-send-email-pantelis.antoniou@konsulko.com>

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

  parent reply	other threads:[~2016-05-16 19:38 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-16 16:52 [PATCH v2 0/5] of: generic infrastructure fixes Pantelis Antoniou
2016-05-16 16:52 ` [PATCH v2 1/5] of: rename *_node_sysfs to _node_post Pantelis Antoniou
2016-05-16 16:52 ` [PATCH v2 2/5] of: Support hashtable lookups for phandles Pantelis Antoniou
2016-05-16 19:37   ` Rob Herring
2016-05-16 20:13     ` Pantelis Antoniou
2016-05-16 16:52 ` [PATCH v2 3/5] of: unittest: hashed phandles unitest Pantelis Antoniou
2016-05-16 19:04   ` Geert Uytterhoeven
2016-05-16 19:38   ` Rob Herring [this message]
2016-05-16 16:52 ` [PATCH v2 4/5] of: overlay: Pick up label symbols from overlays Pantelis Antoniou
2016-05-16 19:06   ` Geert Uytterhoeven
2016-05-16 19:27     ` Pantelis Antoniou
2016-05-16 19:40       ` Geert Uytterhoeven
2016-05-17  6:36         ` Geert Uytterhoeven
2016-05-16 16:52 ` [PATCH v2 5/5] of: overlay: Add pr_fmt for clarity Pantelis Antoniou

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='CAL_Jsq+=w1zo=QUWV3iMv=mpMTb+JtRFSPStrpd=3x67fte3rA@mail.gmail.com' \
    --to=robherring2@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=frowand.list@gmail.com \
    --cc=geert@linux-m68k.org \
    --cc=grant.likely@secretlab.ca \
    --cc=koen@dominion.thruhere.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=marex@denx.de \
    --cc=mporter@konsulko.com \
    --cc=pantelis.antoniou@konsulko.com \
    --cc=panto@antoniou-consulting.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: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).