History log of /linux-master/drivers/base/test/test_async_driver_probe.c
Revision Date Author Comments
# 22d2381b 18-Jul-2023 Dan Carpenter <dan.carpenter@linaro.org>

driver core: test_async: fix an error code

The test_platform_device_register_node() function should return error
pointers instead of NULL. That is what the callers are expecting.

Fixes: 57ea974fb871 ("driver core: Rewrite test_async_driver_probe to cover serialization and NUMA affinity")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Link: https://lore.kernel.org/r/1e11ed19-e1f6-43d8-b352-474134b7c008@moroto.mountain
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 9be182da 24-Nov-2022 Chen Zhongjin <chenzhongjin@huawei.com>

driver core: Fix test_async_probe_init saves device in wrong array

In test_async_probe_init, second set of asynchronous devices are saved
in sync_dev[sync_id], which should be async_dev[async_id].
This makes these devices not unregistered when exit.

> modprobe test_async_driver_probe && \
> modprobe -r test_async_driver_probe && \
> modprobe test_async_driver_probe
...
> sysfs: cannot create duplicate filename '/devices/platform/test_async_driver.4'
> kobject_add_internal failed for test_async_driver.4 with -EEXIST,
don't try to register things with the same name in the same directory.

Fixes: 57ea974fb871 ("driver core: Rewrite test_async_driver_probe to cover serialization and NUMA affinity")
Signed-off-by: Chen Zhongjin <chenzhongjin@huawei.com>
Link: https://lore.kernel.org/r/20221125063541.241328-1-chenzhongjin@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 67aa58e8 28-Dec-2021 Mark-PK Tsai <mark-pk.tsai@mediatek.com>

driver core: Simplify async probe test code by using ktime_ms_delta()

Simplify async probe test code by using ktime_ms_delta().

Signed-off-by: Mark-PK Tsai <mark-pk.tsai@mediatek.com>
Link: https://lore.kernel.org/r/20211228092707.29987-1-mark-pk.tsai@mediatek.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 264d2527 27-Nov-2019 Guenter Roeck <linux@roeck-us.net>

driver core: Fix test_async_driver_probe if NUMA is disabled

Since commit 57ea974fb871 ("driver core: Rewrite test_async_driver_probe
to cover serialization and NUMA affinity"), running the test with NUMA
disabled results in warning messages similar to the following.

test_async_driver test_async_driver.12: NUMA node mismatch -1 != 0

If CONFIG_NUMA=n, dev_to_node(dev) returns -1, and numa_node_id()
returns 0. Both are widely used, so it appears risky to change return
values. Augment the check with IS_ENABLED(CONFIG_NUMA) instead
to fix the problem.

Cc: Alexander Duyck <alexander.h.duyck@linux.intel.com>
Fixes: 57ea974fb871 ("driver core: Rewrite test_async_driver_probe to cover serialization and NUMA affinity")
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Cc: stable <stable@vger.kernel.org>
Acked-by: Alexander Duyck <alexander.h.duyck@linux.intel.com>
Link: https://lore.kernel.org/r/20191127202453.28087-1-linux@roeck-us.net
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 57ea974f 22-Jan-2019 Alexander Duyck <alexander.h.duyck@linux.intel.com>

driver core: Rewrite test_async_driver_probe to cover serialization and NUMA affinity

The current async_probe test code is only testing one device allocated
prior to driver load and only loading one device afterwards. Instead of
doing things this way it makes much more sense to load one device per CPU
in order to actually stress the async infrastructure. By doing this we
should see delays significantly increase in the event of devices being
serialized.

In addition I have updated the test to verify that we are trying to place
the work on the correct NUMA node when we are running in async mode. By
doing this we can verify the best possible outcome for device and driver
load times.

I have added a timeout value that is used to disable the sleep and instead
cause the probe routine to report an error indicating it timed out. By
doing this we limit the maximum runtime for the test to 20 seconds or less.

The last major change in this set is that I have gone through and tuned it
for handling the massive number of possible events that will be scheduled.
Instead of reporting the sleep for each individual device it is moved to
only being displayed if we enable debugging.

With this patch applied below are what a failing test and a passing test
should look like. I elided a few hundred lines in the failing test that
were duplicated since the system I was testing on had a massive number of
CPU cores:

-- Failing --
[ 243.524697] test_async_driver_probe: registering first set of asynchronous devices...
[ 243.535625] test_async_driver_probe: registering asynchronous driver...
[ 243.543038] test_async_driver_probe: registration took 0 msecs
[ 243.549559] test_async_driver_probe: registering second set of asynchronous devices...
[ 243.568350] platform test_async_driver.447: registration took 9 msecs
[ 243.575544] test_async_driver_probe: registering first synchronous device...
[ 243.583454] test_async_driver_probe: registering synchronous driver...
[ 248.825920] test_async_driver_probe: registration took 5235 msecs
[ 248.825922] test_async_driver_probe: registering second synchronous device...
[ 248.825928] test_async_driver test_async_driver.443: NUMA node mismatch 3 != 1
[ 248.825932] test_async_driver test_async_driver.445: NUMA node mismatch 3 != 1
[ 248.825935] test_async_driver test_async_driver.446: NUMA node mismatch 3 != 1
[ 248.825939] test_async_driver test_async_driver.440: NUMA node mismatch 3 != 1
[ 248.825943] test_async_driver test_async_driver.441: NUMA node mismatch 3 != 1
...
[ 248.827150] test_async_driver test_async_driver.229: NUMA node mismatch 0 != 1
[ 248.827158] test_async_driver test_async_driver.228: NUMA node mismatch 0 != 1
[ 248.827220] test_async_driver test_async_driver.281: NUMA node mismatch 2 != 1
[ 248.827229] test_async_driver test_async_driver.282: NUMA node mismatch 2 != 1
[ 248.827240] test_async_driver test_async_driver.280: NUMA node mismatch 2 != 1
[ 253.945834] test_async_driver test_async_driver.1: NUMA node mismatch 0 != 1
[ 253.945878] test_sync_driver test_sync_driver.1: registration took 5119 msecs
[ 253.961693] test_async_driver_probe: async events still pending, forcing timeout and synchronize
[ 259.065839] test_async_driver test_async_driver.2: NUMA node mismatch 0 != 1
[ 259.073786] test_async_driver test_async_driver.3: async probe took too long
[ 259.081669] test_async_driver test_async_driver.3: NUMA node mismatch 0 != 1
[ 259.089569] test_async_driver test_async_driver.4: async probe took too long
[ 259.097451] test_async_driver test_async_driver.4: NUMA node mismatch 0 != 1
[ 259.105338] test_async_driver test_async_driver.5: async probe took too long
[ 259.113204] test_async_driver test_async_driver.5: NUMA node mismatch 0 != 1
[ 259.121089] test_async_driver test_async_driver.6: async probe took too long
[ 259.128961] test_async_driver test_async_driver.6: NUMA node mismatch 0 != 1
[ 259.136850] test_async_driver test_async_driver.7: async probe took too long
...
[ 262.124062] test_async_driver test_async_driver.221: async probe took too long
[ 262.132130] test_async_driver test_async_driver.221: NUMA node mismatch 3 != 1
[ 262.140206] test_async_driver test_async_driver.222: async probe took too long
[ 262.148277] test_async_driver test_async_driver.222: NUMA node mismatch 3 != 1
[ 262.156351] test_async_driver test_async_driver.223: async probe took too long
[ 262.164419] test_async_driver test_async_driver.223: NUMA node mismatch 3 != 1
[ 262.172630] test_async_driver_probe: Test failed with 222 errors and 336 warnings

-- Passing --
[ 105.419247] test_async_driver_probe: registering first set of asynchronous devices...
[ 105.432040] test_async_driver_probe: registering asynchronous driver...
[ 105.439718] test_async_driver_probe: registration took 0 msecs
[ 105.446239] test_async_driver_probe: registering second set of asynchronous devices...
[ 105.477986] platform test_async_driver.447: registration took 22 msecs
[ 105.485276] test_async_driver_probe: registering first synchronous device...
[ 105.493169] test_async_driver_probe: registering synchronous driver...
[ 110.597981] test_async_driver_probe: registration took 5097 msecs
[ 110.604806] test_async_driver_probe: registering second synchronous device...
[ 115.707490] test_sync_driver test_sync_driver.1: registration took 5094 msecs
[ 115.715478] test_async_driver_probe: completed successfully

Signed-off-by: Alexander Duyck <alexander.h.duyck@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 32825709 07-Nov-2017 Greg Kroah-Hartman <gregkh@linuxfoundation.org>

driver core: Remove redundant license text

Now that the SPDX tag is in all driver core files, that identifies the
license in a specific and legally-defined manner. So the extra GPL text
wording can be removed as it is no longer needed at all.

This is done on a quest to remove the 700+ different ways that files in
the kernel describe the GPL license text. And there's unneeded stuff
like the address (sometimes incorrect) for the FSF which is never
needed.

No copyright headers or other non-license-description text was removed.

Cc: Johannes Berg <johannes@sipsolutions.net>
Cc: "Luis R. Rodriguez" <mcgrof@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 989d42e8 07-Nov-2017 Greg Kroah-Hartman <gregkh@linuxfoundation.org>

driver core: add SPDX identifiers to all driver core files

It's good to have SPDX identifiers in all files to make it easier to
audit the kernel tree for correct licenses.

Update the driver core files files with the correct SPDX license
identifier based on the license text in the file itself. The SPDX
identifier is a legally binding shorthand, which can be used instead of
the full boiler plate text.

This work is based on a script and data from Thomas Gleixner, Philippe
Ombredanne, and Kate Stewart.

Cc: Johannes Berg <johannes@sipsolutions.net>
Cc: "Luis R. Rodriguez" <mcgrof@kernel.org>
Cc: William Breathitt Gray <vilhelm.gray@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Kate Stewart <kstewart@linuxfoundation.org>
Cc: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# f4f89f23 24-Sep-2017 Arvind Yadav <arvind.yadav.cs@gmail.com>

driver-core: pr_err() strings should end with newlines

pr_err() messages should terminated with a new-line to avoid
other messages being concatenated onto the end.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 0e0d3d2c 29-Nov-2016 Greg Kroah-Hartman <gregkh@linuxfoundation.org>

driver core: test_async: fix up typo found by 0-day

0-day pointed out a typo in the platform device registration logic, so
fix it.

Reported-by: kbuild test robot <fengguang.wu@intel.com>
Cc: Guenter Roeck <groeck@chromium.org>
Cc: Dmitry Torokhov <dtor@chromium.org>
Cc: Julia Lawall <julia.lawall@lip6.fr>
Cc: Thierry Escande <thierry.escande@collabora.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 2eed70de 10-Nov-2016 Julia Lawall <julia.lawall@lip6.fr>

driver-core: fix platform_no_drv_owner.cocci warnings

Remove .owner field initialization as the core will do it.

Generated by: scripts/coccinelle/api/platform_no_drv_owner.cocci

CC: Dmitry Torokhov <dtor@chromium.org>
Signed-off-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 79543cf2 29-Sep-2016 Dmitry Torokhov <dtor@chromium.org>

driver-core: add test module for asynchronous probing

This test module tries to test asynchronous driver probing by having a
driver that sleeps for an extended period of time (5 secs) in its
probe() method. It measures the time needed to register this driver
(with device already registered) and a new device (with driver already
registered). The module will fail to load if the time spent in register
call is more than half the probing sleep time.

As a sanity check the driver will then try to synchronously register
driver and device and fail if registration takes less than half of the
probing sleep time.

Signed-off-by: Dmitry Torokhov <dtor@chromium.org>
Reviewed-by: Olof Johansson <olofj@chromium.org>
Signed-off-by: Guenter Roeck <groeck@chromium.org>
Signed-off-by: Thierry Escande <thierry.escande@collabora.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>