Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <flar@allandria.com>
Reviewed-by: Brad Boyer <flar@allandria.com>
Tested-by: Stan Johnson <userm57@yahoo.com>
Signed-off-by: Finn Thain <fthain@linux-m68k.org>
Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
Link: https://lore.kernel.org/r/71ed7fb234a5f7381a50253b0d841a656d53e64c.1684200125.git.fthain@linux-m68k.org
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>

authored by

Finn Thain and committed by
Geert Uytterhoeven
72b44f65 b7629ce6

+15 -7
+10 -3
drivers/nubus/nubus.c
··· 32 32 33 33 /* Globals */ 34 34 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 + 35 42 LIST_HEAD(nubus_func_rsrcs); 36 43 37 44 /* Meaning of "bytelanes": ··· 579 572 nubus_proc_add_rsrc(dir.procdir, &ent); 580 573 break; 581 574 default: 582 - /* Local/Private resources have their own 583 - function */ 584 - nubus_get_private_resource(fres, dir.procdir, &ent); 575 + if (nubus_populate_procfs) 576 + nubus_get_private_resource(fres, dir.procdir, 577 + &ent); 585 578 } 586 579 } 587 580
+4 -4
drivers/nubus/proc.c
··· 55 55 { 56 56 char name[2]; 57 57 58 - if (!proc_bus_nubus_dir) 58 + if (!proc_bus_nubus_dir || !nubus_populate_procfs) 59 59 return NULL; 60 60 snprintf(name, sizeof(name), "%x", board->slot); 61 61 return proc_mkdir(name, proc_bus_nubus_dir); ··· 72 72 char name[9]; 73 73 int lanes = board->lanes; 74 74 75 - if (!procdir) 75 + if (!procdir || !nubus_populate_procfs) 76 76 return NULL; 77 77 snprintf(name, sizeof(name), "%x", ent->type); 78 78 remove_proc_subtree(name, procdir); ··· 157 157 char name[9]; 158 158 struct nubus_proc_pde_data *pded; 159 159 160 - if (!procdir) 160 + if (!procdir || !nubus_populate_procfs) 161 161 return; 162 162 163 163 snprintf(name, sizeof(name), "%x", ent->type); ··· 176 176 char name[9]; 177 177 unsigned char *data = (unsigned char *)ent->data; 178 178 179 - if (!procdir) 179 + if (!procdir || !nubus_populate_procfs) 180 180 return; 181 181 182 182 snprintf(name, sizeof(name), "%x", ent->type);
+1
include/linux/nubus.h
··· 93 93 94 94 /* Generic NuBus interface functions, modelled after the PCI interface */ 95 95 #ifdef CONFIG_PROC_FS 96 + extern bool nubus_populate_procfs; 96 97 void nubus_proc_init(void); 97 98 struct proc_dir_entry *nubus_proc_add_board(struct nubus_board *board); 98 99 struct proc_dir_entry *nubus_proc_add_rsrc_dir(struct proc_dir_entry *procdir,