From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B0A94C433DF for ; Fri, 17 Jul 2020 13:37:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8D39C2076A for ; Fri, 17 Jul 2020 13:37:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="AJt327Zm" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726512AbgGQNhZ (ORCPT ); Fri, 17 Jul 2020 09:37:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35968 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726079AbgGQNhZ (ORCPT ); Fri, 17 Jul 2020 09:37:25 -0400 Received: from mail-lj1-x243.google.com (mail-lj1-x243.google.com [IPv6:2a00:1450:4864:20::243]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE17DC061755 for ; Fri, 17 Jul 2020 06:37:24 -0700 (PDT) Received: by mail-lj1-x243.google.com with SMTP id z24so12653910ljn.8 for ; Fri, 17 Jul 2020 06:37:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=APP62M5KJnavAoumKi5PAm/yFARTAUHaqqfP4O6ogbw=; b=AJt327ZmU6sPumfnVeQR5qa8+PkRfY0SX4r8p0uWw5gmDDxHWs0wQL32a4krd/89np AP5UT8yP6pojwefApB9GkhD3VyOcAKZOqlUTnCXuQKaFNo318WfkgID8A6cLUu6PeYa7 73tbI8RIjDjJkk/dcutwvXi+/N05bcNLTwNgsi+G0pUMUTqr36vgpbEXeGJmo1UlhrNj olOeQadzKF3A+RP5fuCD1zr1uvUToxMfBbeobPlgnzGmC7GD0qlNeWSWhBk0y1t299Jx LFFpu+I02T9rq2F5Uf8d6QnYmmDS0bH95ErItdidLkcYmAFL9IIdn4Cfl4VA3CnX63Rc CyIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=APP62M5KJnavAoumKi5PAm/yFARTAUHaqqfP4O6ogbw=; b=jYvlCWpSF0eCVVWJa7nbW8FtOYZXk6TcOdI0C9xzgdiE3hsVSlT3Z20D4rsuMbZCtZ h2SRg9Qz9XP+iDSJZSlSoi3s3bN4No0oPsdLTFsBlU6+hGB39MntgCGcQkv0zt2tCNQY Jj9TN8iB1A0tlZH8q5HSy6gTYsOisxmu2jXxsSVNmd8iZDY45tdrC9IR/Xcu40OOILS9 PDrtxaTvZwCddikhSpiwWr+3IBpjcu1w/sNVU6XehO+y73+DezHGkOzNYK/IoSxGJFnx wD175XGAeiujG1zOGQwuNPQ2p0VD6MdeWt5oKO9M2erE3yab0nUPHxC1Z/qgaKvoIph/ 0wQA== X-Gm-Message-State: AOAM533RSvWmfWw9AAwj/K7iOjNBZzSQp7fWRWkEyvTcnoisOMlht/uY FsJv81o4n4s9mw56Q4rRj4To/DWEnJ2HiqF2KhQhQQ== X-Google-Smtp-Source: ABdhPJyDBwdNSvOponEGA/XoJ0GjdQLAWB568mug+gHjjG/nwgdM7/StDRcbqk31IOvJ/EGHfhT6dhrHW+0AbC6EDMs= X-Received: by 2002:a2e:7a1a:: with SMTP id v26mr4306904ljc.104.1594993043263; Fri, 17 Jul 2020 06:37:23 -0700 (PDT) MIME-Version: 1.0 References: <7eb11c0d-cd11-f873-c336-4ec955a7bdb3@inbox.ru> In-Reply-To: <7eb11c0d-cd11-f873-c336-4ec955a7bdb3@inbox.ru> From: Linus Walleij Date: Fri, 17 Jul 2020 15:37:12 +0200 Message-ID: Subject: Re: gpiolib gpio_chrdev_release duration is about 30 ms To: Maxim Kochetkov Cc: "open list:GPIO SUBSYSTEM" , Bartosz Golaszewski Content-Type: text/plain; charset="UTF-8" Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Hi Maxim, On Fri, Jul 17, 2020 at 2:56 PM Maxim Kochetkov 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