mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Shyam Saini <shyamsaini@linux.microsoft.com>
To: linux-kernel@vger.kernel.org
Cc: linux@rasmusvillemoes.dk, mcgrof@kernel.org, code@tyhicks.com,
	okaya@linux.microsoft.com, vijayb@linux.microsoft.com
Subject: [RFC] Revert "kernel/params.c: defer most of param_sysfs_init() to late_initcall time"
Date: Thu, 30 Jan 2025 14:58:03 -0800	[thread overview]
Message-ID: <20250130225803.321004-1-shyamsaini@linux.microsoft.com> (raw)

This reverts commit 96a1a2412acba8c057c041833641d9b7dbf52170,
as it breaks the creation of /sys/module/<built-in-module>/drivers.

The reverted commit changed the initcall order for
param_sysfs_builtin() from subsys_initcall() to late_initcall(),
which impacts the module_kset list and its population.

Drivers which are initialized from subsys_initcall() or any other
higher precedence initcall couldn't find the related kobject entry
in the module_kset list because module_kset is not fully populated
at this point due to the reverted change. As a consequence,
module_add_driver() returns early without calling make_driver_name().
Therefore, /sys/module/<built-in-module>/drivers is never created.

This breaks user-space applications for eg: DPDK, which expect
/sys/module/vfio_pci/drivers/pci:vfio-pci/new_id to be present.

This revert restores the initcall order for param_sysfs_builtin()
and fixes the above mentioned issue.

Fixes: 96a1a2412acb ("kernel/params.c: defer most of param_sysfs_init() to late_initcall time")
Signed-off-by: Shyam Saini <shyamsaini@linux.microsoft.com>
---
 kernel/params.c | 21 ++-------------------
 1 file changed, 2 insertions(+), 19 deletions(-)

diff --git a/kernel/params.c b/kernel/params.c
index 0074d29c9b80..890b44d36b1e 100644
--- a/kernel/params.c
+++ b/kernel/params.c
@@ -958,11 +958,7 @@ const struct kobj_type module_ktype = {
 };
 
 /*
- * param_sysfs_init - create "module" kset
- *
- * This must be done before the initramfs is unpacked and
- * request_module() thus becomes possible, because otherwise the
- * module load would fail in mod_sysfs_init.
+ * param_sysfs_init - wrapper for built-in params support
  */
 static int __init param_sysfs_init(void)
 {
@@ -973,24 +969,11 @@ static int __init param_sysfs_init(void)
 		return -ENOMEM;
 	}
 
-	return 0;
-}
-subsys_initcall(param_sysfs_init);
-
-/*
- * param_sysfs_builtin_init - add sysfs version and parameter
- * attributes for built-in modules
- */
-static int __init param_sysfs_builtin_init(void)
-{
-	if (!module_kset)
-		return -ENOMEM;
-
 	version_sysfs_builtin();
 	param_sysfs_builtin();
 
 	return 0;
 }
-late_initcall(param_sysfs_builtin_init);
+subsys_initcall(param_sysfs_init);
 
 #endif /* CONFIG_SYSFS */
-- 
2.34.1


             reply	other threads:[~2025-01-30 22:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-30 22:58 Shyam Saini [this message]
2025-02-03 13:15 ` Rasmus Villemoes
2025-02-04  5:12   ` Shyam Saini
2025-02-04  5:09 ` Shyam Saini

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=20250130225803.321004-1-shyamsaini@linux.microsoft.com \
    --to=shyamsaini@linux.microsoft.com \
    --cc=code@tyhicks.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=mcgrof@kernel.org \
    --cc=okaya@linux.microsoft.com \
    --cc=vijayb@linux.microsoft.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

all inboxes | Powered by JetHome®