linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Maxim Kochetkov <fido_max@inbox.ru>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: "open list:GPIO SUBSYSTEM" <linux-gpio@vger.kernel.org>,
	Bartosz Golaszewski <bgolaszewski@baylibre.com>
Subject: Re: gpiolib gpio_chrdev_release duration is about 30 ms
Date: Fri, 17 Jul 2020 16:44:26 +0300	[thread overview]
Message-ID: <9f141fd1-3c73-c839-b7ad-529a61645031@inbox.ru> (raw)
In-Reply-To: <CACRpkda-pXF71vr5v90yipKubc14tbZW5Ryw1o7rdn4FbWwsTw@mail.gmail.com>

------------------------------------------
#define GPIOS_NUM 8
static char* gpio_names[GPIOS_NUM] = {"IO0", "IO1", "IO2", "IO3", "WR", 
"CS", "OE", "ADD_EN"};
................
gpio_init() {

     int i;
     for (i = 0; i < GPIOS_NUM; ++i) {
         syslog(LOG_INFO,"%s %d",__FUNCTION__,__LINE__);
         gpio_lines[i] = gpiod_line_find(gpio_names[i]);
         syslog(LOG_INFO,"%s %d",__FUNCTION__,__LINE__);
     }
}
-------------------------------------------
I used syslog/printk to measure time.
syslog in example shows about 300ms on each gpiod_line_find call.
17.07.2020 16:37, Linus Walleij пишет:
> Hi Maxim,
> 
> On Fri, Jul 17, 2020 at 2:56 PM Maxim Kochetkov <fido_max@inbox.ru> wrote:
> 
>> I'm using libgpiod in userspace.
>> I have 6 gpiochip's on my board.
>> gpiod_line_find takes about 300ms to find GPIO line.
>>
>> gpiod_line_find calls gpiod_foreach_chip
>> then gpiod_chip_iter_next
>> then gpiod_chip_close then close(chip->fd)
>> then we are going to kernel gpiolib gpio_chrdev_release
>> then atomic_notifier_chain_unregister
>> then synchronize_rcu()
>>
>> synchronize_rcu takes about 30 ms (6*30ms=280ms)
>>
>> I tried to remove synchronize_rcu from atomic_notifier_chain_unregister
>> and gpiod_line_find takes about 2ms now.
> 
> Interesting! Can you provide some context? Are you just testing because
> curious or do you need to meet a design objective?
> 
> Did you use ftrace or similar instrumentation to drill down and find
> where time is spent?
> 
> Yours,
> Linus Walleij
> 

  reply	other threads:[~2020-07-17 13:44 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-17 12:56 gpiolib gpio_chrdev_release duration is about 30 ms Maxim Kochetkov
2020-07-17 13:37 ` Linus Walleij
2020-07-17 13:44   ` Maxim Kochetkov [this message]
2020-07-17 14:17   ` Maxim Kochetkov
2020-07-17 15:07     ` Andy Shevchenko
2020-07-18  4:25       ` Kent Gibson
2020-07-20  8:14         ` Maxim Kochetkov
2020-07-24 19:36           ` Bartosz Golaszewski
2020-07-25  3:52             ` Kent Gibson
2020-07-26 11:04               ` Bartosz Golaszewski
2020-07-26 22:32               ` Linus Walleij

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=9f141fd1-3c73-c839-b7ad-529a61645031@inbox.ru \
    --to=fido_max@inbox.ru \
    --cc=bgolaszewski@baylibre.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    /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).