Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1240035

Re: [PATCH v6 21/22] driver core: Start processing deferred probes earlier

Path csiph.com!goblin3!goblin.stu.neva.ru!bolzen.all.de!fu-berlin.de!bofh.it!news.nic.it!robomod
From Frank Rowand <frowand.list@gmail.com>
Newsgroups linux.kernel
Subject Re: [PATCH v6 21/22] driver core: Start processing deferred probes earlier
Date Tue, 06 Oct 2015 02:00:02 +0200
Message-ID <qgnPI-5Rk-7@gated-at.bofh.it> (permalink)
References <qb9X3-rF-9@gated-at.bofh.it> <qb9X6-rF-71@gated-at.bofh.it>
X-Original-To Tomeu Vizoso <tomeu.vizoso@collabora.com>
Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:reply-to:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=aIY7Wgs/QwaL/WMR7p3+8ZX+KnDirW/QHJnWQceWxoU=; b=q4QvzdUwWn2YlGu51XM2utqyFLgRGgOeYZM+Dj1MoDPp68m4McKEMVc9covKKZPjGj yBlDnxOZSN9EhS9UPEWLWqcGDbLS8iW1X8TfPqn52Aa7p/LKYxDTmu5l9+rvcgCkvJp8 YGroMX/iGnMBqlpgckcf3oOvA+NI8rFjxcTVPmsK3ICn6ol8uUb2xu8AlUf7b1gdduDe pzL+cLcZC6PrjDU9rzk1UkdvcScGbEwTJZun73aTvVJvZg8jDLFDsVAwwf2Z0lrK568V ehzLAvZDmBs1OOsK1OnWqLgqEk9w+IWS6ZK/m+JqcLHB1QadAbJKJOqSK8fj7BuzoVLA hExA==
X-Received by 10.194.60.115 with SMTP id g19mr31898819wjr.29.1444089156909; Mon, 05 Oct 2015 16:52:36 -0700 (PDT)
Reply-To frowand.list@gmail.com
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130801 Thunderbird/17.0.8
MIME-Version 1.0
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding 7bit
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 83
Organization linux.* mail to news gateway
X-Original-Cc linux-kernel@vger.kernel.org, Rob Herring <robh+dt@kernel.org>, Stephen Warren <swarren@wwwdotorg.org>, Javier Martinez Canillas <javier@osg.samsung.com>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Mark Brown <broonie@kernel.org>, Thierry Reding <thierry.reding@gmail.com>, Alan Stern <stern@rowland.harvard.edu>, "Rafael J. Wysocki" <rjw@rjwysocki.net>, linux-arm-kernel@lists.infradead.org, Dmitry Torokhov <dmitry.torokhov@gmail.com>, devicetree@vger.kernel.org, Linus Walleij <linus.walleij@linaro.org>, linux-acpi@vger.kernel.org, Arnd Bergmann <arnd@arndb.de>
X-Original-Date Mon, 05 Oct 2015 16:52:35 -0700
X-Original-Message-ID <56130D43.10200@gmail.com>
X-Original-References <1442844182-27787-1-git-send-email-tomeu.vizoso@collabora.com> <1442844182-27787-22-git-send-email-tomeu.vizoso@collabora.com>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1240035

Show key headers only | View raw


On 9/21/2015 7:03 AM, Tomeu Vizoso wrote:
> Some initcalls in the late level assume that some devices will have
> already probed without explicitly checking for that.
> 
> After the recent move to defer most device probes when they are
> registered, pressure increased in the late initcall level.
> 
> By starting the processing of the deferred queue in device_initcall_sync
> we increase the chances that the initcalls mentioned before will find
> the devices they depend on to have already probed.
> 
> Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
> ---
> 
> Changes in v4:
> - Start processing deferred probes in device_initcall_sync
> 
>  drivers/base/dd.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/base/dd.c b/drivers/base/dd.c
> index 269ea76c1a4f..f0ef9233fcd6 100644
> --- a/drivers/base/dd.c
> +++ b/drivers/base/dd.c
> @@ -176,7 +176,7 @@ static void driver_deferred_probe_trigger(void)
>   *
>   * We don't want to get in the way when the bulk of drivers are getting probed.
>   * Instead, this initcall makes sure that deferred probing is delayed until
> - * late_initcall time.
> + * device_initcall_sync time.

This is a misuse of the *_sync initcall level.

If a deferred probe created a thread and expected a wait at the
following *_sync level then the wait would not occur because
there is no subsequent *_sync level.  This is not a problem today
because (as far as I know) there are no threads in the probe
functions.  But there has been interest in adding parallel
probing and that could expose this problem.

The purpose of the *_sync initcall levels is to allow the corresponding
initcall level to use multiple threads of execution instead of a single
thread.  The *_sync level provides a location for a wait for all of the
threads at the corresponding init level to complete.  This is better
explained in the git log:

commit 735a7ffb739b6efeaeb1e720306ba308eaaeb20e
Author: Andrew Morton <akpm@osdl.org>
Date:   Fri Oct 27 11:42:37 2006 -0700

    [PATCH] drivers: wait for threaded probes between initcall levels

    The multithreaded-probing code has a problem: after one initcall level (eg,
    core_initcall) has been processed, we will then start processing the next
    level (postcore_initcall) while the kernel threads which are handling
    core_initcall are still executing.  This breaks the guarantees which the
    layered initcalls previously gave us.

    IOW, we want to be multithreaded _within_ an initcall level, but not between
    different levels.

    Fix that up by causing the probing code to wait for all outstanding probes at
    one level to complete before we start processing the next level.

>   */
>  static int deferred_probe_initcall(void)
>  {
> @@ -190,7 +190,7 @@ static int deferred_probe_initcall(void)
>  	flush_workqueue(deferred_wq);
>  	return 0;
>  }
> -late_initcall(deferred_probe_initcall);
> +device_initcall_sync(deferred_probe_initcall);
>  
>  static void driver_bound(struct device *dev)
>  {
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Re: [PATCH v6 21/22] driver core: Start processing deferred probes  earlier Frank Rowand <frowand.list@gmail.com> - 2015-10-06 02:00 +0200
  Re: [PATCH v6 21/22] driver core: Start processing deferred probes earlier Rob Herring <robherring2@gmail.com> - 2015-10-06 05:00 +0200
    Re: [PATCH v6 21/22] driver core: Start processing deferred probes  earlier Mark Brown <broonie@kernel.org> - 2015-10-06 12:50 +0200

csiph-web