Skip to content

Commit 72b44f6

Browse files
fthaingeertu
authored andcommitted
nubus: Don't list slot resources by default
Some Nubus card ROMs contain many slot 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. Cc: Brad Boyer <[email protected]> Reviewed-by: Brad Boyer <[email protected]> Tested-by: Stan Johnson <[email protected]> Signed-off-by: Finn Thain <[email protected]> Reviewed-by: Geert Uytterhoeven <[email protected]> Link: https://lore.kernel.org/r/71ed7fb234a5f7381a50253b0d841a656d53e64c.1684200125.git.fthain@linux-m68k.org Signed-off-by: Geert Uytterhoeven <[email protected]>
1 parent b7629ce commit 72b44f6

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

drivers/nubus/nubus.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@
3232

3333
/* Globals */
3434

35+
/* The "nubus.populate_procfs" parameter makes slot resources available in
36+
* procfs. It's deprecated and disabled by default because procfs is no longer
37+
* thought to be suitable for that and some board ROMs make it too expensive.
38+
*/
39+
bool nubus_populate_procfs;
40+
module_param_named(populate_procfs, nubus_populate_procfs, bool, 0);
41+
3542
LIST_HEAD(nubus_func_rsrcs);
3643

3744
/* Meaning of "bytelanes":
@@ -572,9 +579,9 @@ nubus_get_functional_resource(struct nubus_board *board, int slot,
572579
nubus_proc_add_rsrc(dir.procdir, &ent);
573580
break;
574581
default:
575-
/* Local/Private resources have their own
576-
function */
577-
nubus_get_private_resource(fres, dir.procdir, &ent);
582+
if (nubus_populate_procfs)
583+
nubus_get_private_resource(fres, dir.procdir,
584+
&ent);
578585
}
579586
}
580587

drivers/nubus/proc.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ struct proc_dir_entry *nubus_proc_add_board(struct nubus_board *board)
5555
{
5656
char name[2];
5757

58-
if (!proc_bus_nubus_dir)
58+
if (!proc_bus_nubus_dir || !nubus_populate_procfs)
5959
return NULL;
6060
snprintf(name, sizeof(name), "%x", board->slot);
6161
return proc_mkdir(name, proc_bus_nubus_dir);
@@ -72,7 +72,7 @@ struct proc_dir_entry *nubus_proc_add_rsrc_dir(struct proc_dir_entry *procdir,
7272
char name[9];
7373
int lanes = board->lanes;
7474

75-
if (!procdir)
75+
if (!procdir || !nubus_populate_procfs)
7676
return NULL;
7777
snprintf(name, sizeof(name), "%x", ent->type);
7878
remove_proc_subtree(name, procdir);
@@ -157,7 +157,7 @@ void nubus_proc_add_rsrc_mem(struct proc_dir_entry *procdir,
157157
char name[9];
158158
struct nubus_proc_pde_data *pded;
159159

160-
if (!procdir)
160+
if (!procdir || !nubus_populate_procfs)
161161
return;
162162

163163
snprintf(name, sizeof(name), "%x", ent->type);
@@ -176,7 +176,7 @@ void nubus_proc_add_rsrc(struct proc_dir_entry *procdir,
176176
char name[9];
177177
unsigned char *data = (unsigned char *)ent->data;
178178

179-
if (!procdir)
179+
if (!procdir || !nubus_populate_procfs)
180180
return;
181181

182182
snprintf(name, sizeof(name), "%x", ent->type);

include/linux/nubus.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ extern struct bus_type nubus_bus_type;
9393

9494
/* Generic NuBus interface functions, modelled after the PCI interface */
9595
#ifdef CONFIG_PROC_FS
96+
extern bool nubus_populate_procfs;
9697
void nubus_proc_init(void);
9798
struct proc_dir_entry *nubus_proc_add_board(struct nubus_board *board);
9899
struct proc_dir_entry *nubus_proc_add_rsrc_dir(struct proc_dir_entry *procdir,

0 commit comments

Comments
 (0)