All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] nubus: Don't list card resources by default
@ 2023-03-23  6:03 Finn Thain
  2023-03-23  8:19 ` Geert Uytterhoeven
  2023-03-23  8:39 ` Andreas Schwab
  0 siblings, 2 replies; 14+ messages in thread
From: Finn Thain @ 2023-03-23  6:03 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: linux-m68k, linux-kernel

Some Nubus cards have many ROM resources. A single Radius video card
produced well over a thousand entries under /proc/bus/nubus/. Populating
/proc/bus/nubus on a slow machine with several such cards installed takes
long enough that the user may think that the system is wedged. All those
procfs entries also consume significant RAM though they are not normally
needed (except by developers). Omit these resources from /proc/bus/nubus/
by default and add a kernel parameter to enable them when needed.
On the test machine, this saved 300 kB and 10 seconds.

Tested-by: Stan Johnson <userm57@yahoo.com>
Signed-off-by: Finn Thain <fthain@linux-m68k.org>
---
Checkpatch says "externs should be avoided in .c files" and if this one
appeared twice I would agree. But as it only appears once, I can't see
any advantage to putting it in a new .h file instead of the .c file...
---
 drivers/nubus/nubus.c |  7 ++++++-
 drivers/nubus/proc.c  | 10 ++++++----
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/drivers/nubus/nubus.c b/drivers/nubus/nubus.c
index f70ba58dbc55..925aec257e1b 100644
--- a/drivers/nubus/nubus.c
+++ b/drivers/nubus/nubus.c
@@ -34,6 +34,9 @@
 
 LIST_HEAD(nubus_func_rsrcs);
 
+bool procfs_rsrcs;
+module_param(procfs_rsrcs, bool, 0444);
+
 /* Meaning of "bytelanes":
 
    The card ROM may appear on any or all bytes of each long word in
@@ -574,7 +577,9 @@ nubus_get_functional_resource(struct nubus_board *board, int slot,
 		default:
 			/* Local/Private resources have their own
 			   function */
-			nubus_get_private_resource(fres, dir.procdir, &ent);
+			if (procfs_rsrcs)
+				nubus_get_private_resource(fres, dir.procdir,
+							   &ent);
 		}
 	}
 
diff --git a/drivers/nubus/proc.c b/drivers/nubus/proc.c
index 2c320a84fd72..844e86636798 100644
--- a/drivers/nubus/proc.c
+++ b/drivers/nubus/proc.c
@@ -51,11 +51,13 @@ static struct proc_dir_entry *proc_bus_nubus_dir;
  * /proc/bus/nubus/x/ stuff
  */
 
+extern bool procfs_rsrcs;
+
 struct proc_dir_entry *nubus_proc_add_board(struct nubus_board *board)
 {
 	char name[2];
 
-	if (!proc_bus_nubus_dir)
+	if (!proc_bus_nubus_dir || !procfs_rsrcs)
 		return NULL;
 	snprintf(name, sizeof(name), "%x", board->slot);
 	return proc_mkdir(name, proc_bus_nubus_dir);
@@ -72,7 +74,7 @@ struct proc_dir_entry *nubus_proc_add_rsrc_dir(struct proc_dir_entry *procdir,
 	char name[9];
 	int lanes = board->lanes;
 
-	if (!procdir)
+	if (!procdir || !procfs_rsrcs)
 		return NULL;
 	snprintf(name, sizeof(name), "%x", ent->type);
 	remove_proc_subtree(name, procdir);
@@ -157,7 +159,7 @@ void nubus_proc_add_rsrc_mem(struct proc_dir_entry *procdir,
 	char name[9];
 	struct nubus_proc_pde_data *pded;
 
-	if (!procdir)
+	if (!procdir || !procfs_rsrcs)
 		return;
 
 	snprintf(name, sizeof(name), "%x", ent->type);
@@ -176,7 +178,7 @@ void nubus_proc_add_rsrc(struct proc_dir_entry *procdir,
 	char name[9];
 	unsigned char *data = (unsigned char *)ent->data;
 
-	if (!procdir)
+	if (!procdir || !procfs_rsrcs)
 		return;
 
 	snprintf(name, sizeof(name), "%x", ent->type);
-- 
2.37.5


^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2023-03-26  8:24 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-23  6:03 [PATCH v2] nubus: Don't list card resources by default Finn Thain
2023-03-23  8:19 ` Geert Uytterhoeven
2023-03-23 23:13   ` Finn Thain
2023-03-24  8:59     ` Brad Boyer
2023-03-24 23:35       ` Finn Thain
2023-03-25 12:44         ` Geert Uytterhoeven
2023-03-26  0:03           ` Brad Boyer
2023-03-26  8:23             ` Geert Uytterhoeven
2023-03-26  0:00         ` Brad Boyer
2023-03-26  3:22           ` Finn Thain
2023-03-23  8:39 ` Andreas Schwab
2023-03-23  8:41   ` Geert Uytterhoeven
2023-03-24  0:08     ` Finn Thain
2023-03-24  8:26       ` Geert Uytterhoeven

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.