linux-m68k.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4] nubus: Don't list slot resources by default
@ 2023-04-05  4:12 Finn Thain
  2023-04-06 20:17 ` Brad Boyer
  2023-05-15  9:44 ` Geert Uytterhoeven
  0 siblings, 2 replies; 4+ messages in thread
From: Finn Thain @ 2023-04-05  4:12 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: Brad Boyer, linux-m68k, linux-kernel

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>
Tested-by: Stan Johnson <userm57@yahoo.com>
Signed-off-by: Finn Thain <fthain@linux-m68k.org>
---
Changed since v3:
 - Better commentary.
Changed since v2:
 - Added commentary.
 - Moved declaration to nubus.h.
Changed since v1:
 - Expanded to cover all slot resources in procfs.
---
 drivers/nubus/nubus.c | 13 ++++++++++---
 drivers/nubus/proc.c  |  8 ++++----
 include/linux/nubus.h |  1 +
 3 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/drivers/nubus/nubus.c b/drivers/nubus/nubus.c
index f70ba58dbc55..f0c24d39f837 100644
--- a/drivers/nubus/nubus.c
+++ b/drivers/nubus/nubus.c
@@ -32,6 +32,13 @@
 
 /* Globals */
 
+/* The "nubus.populate_procfs" parameter makes slot resources available in
+ * procfs. It's deprecated and disabled by default because procfs is no longer
+ * thought to be suitable for that and some board ROMs make it too expensive.
+ */
+bool populate_procfs;
+module_param(populate_procfs, bool, 0);
+
 LIST_HEAD(nubus_func_rsrcs);
 
 /* Meaning of "bytelanes":
@@ -572,9 +579,9 @@ nubus_get_functional_resource(struct nubus_board *board, int slot,
 			nubus_proc_add_rsrc(dir.procdir, &ent);
 			break;
 		default:
-			/* Local/Private resources have their own
-			   function */
-			nubus_get_private_resource(fres, dir.procdir, &ent);
+			if (populate_procfs)
+				nubus_get_private_resource(fres, dir.procdir,
+							   &ent);
 		}
 	}
 
diff --git a/drivers/nubus/proc.c b/drivers/nubus/proc.c
index 2c320a84fd72..1808accb8214 100644
--- a/drivers/nubus/proc.c
+++ b/drivers/nubus/proc.c
@@ -55,7 +55,7 @@ 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 || !populate_procfs)
 		return NULL;
 	snprintf(name, sizeof(name), "%x", board->slot);
 	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,
 	char name[9];
 	int lanes = board->lanes;
 
-	if (!procdir)
+	if (!procdir || !populate_procfs)
 		return NULL;
 	snprintf(name, sizeof(name), "%x", ent->type);
 	remove_proc_subtree(name, procdir);
@@ -157,7 +157,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 || !populate_procfs)
 		return;
 
 	snprintf(name, sizeof(name), "%x", ent->type);
@@ -176,7 +176,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 || !populate_procfs)
 		return;
 
 	snprintf(name, sizeof(name), "%x", ent->type);
diff --git a/include/linux/nubus.h b/include/linux/nubus.h
index 392fc6c53e96..50c9145808d1 100644
--- a/include/linux/nubus.h
+++ b/include/linux/nubus.h
@@ -93,6 +93,7 @@ extern struct bus_type nubus_bus_type;
 
 /* Generic NuBus interface functions, modelled after the PCI interface */
 #ifdef CONFIG_PROC_FS
+extern bool populate_procfs;
 void nubus_proc_init(void);
 struct proc_dir_entry *nubus_proc_add_board(struct nubus_board *board);
 struct proc_dir_entry *nubus_proc_add_rsrc_dir(struct proc_dir_entry *procdir,
-- 
2.37.5


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

* Re: [PATCH v4] nubus: Don't list slot resources by default
  2023-04-05  4:12 [PATCH v4] nubus: Don't list slot resources by default Finn Thain
@ 2023-04-06 20:17 ` Brad Boyer
  2023-05-15  9:44 ` Geert Uytterhoeven
  1 sibling, 0 replies; 4+ messages in thread
From: Brad Boyer @ 2023-04-06 20:17 UTC (permalink / raw)
  To: Finn Thain; +Cc: Geert Uytterhoeven, linux-m68k, linux-kernel

On Wed, Apr 05, 2023 at 02:12:13PM +1000, Finn Thain wrote:
> 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>
> ---
> Changed since v3:
>  - Better commentary.
> Changed since v2:
>  - Added commentary.
>  - Moved declaration to nubus.h.
> Changed since v1:
>  - Expanded to cover all slot resources in procfs.
> ---
>  drivers/nubus/nubus.c | 13 ++++++++++---
>  drivers/nubus/proc.c  |  8 ++++----
>  include/linux/nubus.h |  1 +
>  3 files changed, 15 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/nubus/nubus.c b/drivers/nubus/nubus.c
> index f70ba58dbc55..f0c24d39f837 100644
> --- a/drivers/nubus/nubus.c
> +++ b/drivers/nubus/nubus.c
> @@ -32,6 +32,13 @@
>  
>  /* Globals */
>  
> +/* The "nubus.populate_procfs" parameter makes slot resources available in
> + * procfs. It's deprecated and disabled by default because procfs is no longer
> + * thought to be suitable for that and some board ROMs make it too expensive.
> + */
> +bool populate_procfs;
> +module_param(populate_procfs, bool, 0);
> +
>  LIST_HEAD(nubus_func_rsrcs);
>  
>  /* Meaning of "bytelanes":
> @@ -572,9 +579,9 @@ nubus_get_functional_resource(struct nubus_board *board, int slot,
>  			nubus_proc_add_rsrc(dir.procdir, &ent);
>  			break;
>  		default:
> -			/* Local/Private resources have their own
> -			   function */
> -			nubus_get_private_resource(fres, dir.procdir, &ent);
> +			if (populate_procfs)
> +				nubus_get_private_resource(fres, dir.procdir,
> +							   &ent);
>  		}
>  	}
>  
> diff --git a/drivers/nubus/proc.c b/drivers/nubus/proc.c
> index 2c320a84fd72..1808accb8214 100644
> --- a/drivers/nubus/proc.c
> +++ b/drivers/nubus/proc.c
> @@ -55,7 +55,7 @@ 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 || !populate_procfs)
>  		return NULL;
>  	snprintf(name, sizeof(name), "%x", board->slot);
>  	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,
>  	char name[9];
>  	int lanes = board->lanes;
>  
> -	if (!procdir)
> +	if (!procdir || !populate_procfs)
>  		return NULL;
>  	snprintf(name, sizeof(name), "%x", ent->type);
>  	remove_proc_subtree(name, procdir);
> @@ -157,7 +157,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 || !populate_procfs)
>  		return;
>  
>  	snprintf(name, sizeof(name), "%x", ent->type);
> @@ -176,7 +176,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 || !populate_procfs)
>  		return;
>  
>  	snprintf(name, sizeof(name), "%x", ent->type);
> diff --git a/include/linux/nubus.h b/include/linux/nubus.h
> index 392fc6c53e96..50c9145808d1 100644
> --- a/include/linux/nubus.h
> +++ b/include/linux/nubus.h
> @@ -93,6 +93,7 @@ extern struct bus_type nubus_bus_type;
>  
>  /* Generic NuBus interface functions, modelled after the PCI interface */
>  #ifdef CONFIG_PROC_FS
> +extern bool populate_procfs;
>  void nubus_proc_init(void);
>  struct proc_dir_entry *nubus_proc_add_board(struct nubus_board *board);
>  struct proc_dir_entry *nubus_proc_add_rsrc_dir(struct proc_dir_entry *procdir,
> -- 
> 2.37.5
> 

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

* Re: [PATCH v4] nubus: Don't list slot resources by default
  2023-04-05  4:12 [PATCH v4] nubus: Don't list slot resources by default Finn Thain
  2023-04-06 20:17 ` Brad Boyer
@ 2023-05-15  9:44 ` Geert Uytterhoeven
  2023-05-15 10:11   ` Geert Uytterhoeven
  1 sibling, 1 reply; 4+ messages in thread
From: Geert Uytterhoeven @ 2023-05-15  9:44 UTC (permalink / raw)
  To: Finn Thain; +Cc: Brad Boyer, linux-m68k, linux-kernel

On Wed, Apr 5, 2023 at 6:19 AM Finn Thain <fthain@linux-m68k.org> wrote:
> 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>
> Tested-by: Stan Johnson <userm57@yahoo.com>
> Signed-off-by: Finn Thain <fthain@linux-m68k.org>
> ---
> Changed since v3:
>  - Better commentary.
> Changed since v2:
>  - Added commentary.
>  - Moved declaration to nubus.h.
> Changed since v1:
>  - Expanded to cover all slot resources in procfs.

Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
i.e. will queue in the m68k for-v6.5 branch.

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH v4] nubus: Don't list slot resources by default
  2023-05-15  9:44 ` Geert Uytterhoeven
@ 2023-05-15 10:11   ` Geert Uytterhoeven
  0 siblings, 0 replies; 4+ messages in thread
From: Geert Uytterhoeven @ 2023-05-15 10:11 UTC (permalink / raw)
  To: Finn Thain; +Cc: Brad Boyer, linux-m68k, linux-kernel

Hi Finn,

On Mon, May 15, 2023 at 11:44 AM Geert Uytterhoeven
<geert@linux-m68k.org> wrote:
> On Wed, Apr 5, 2023 at 6:19 AM Finn Thain <fthain@linux-m68k.org> wrote:
> > 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>
> > Tested-by: Stan Johnson <userm57@yahoo.com>
> > Signed-off-by: Finn Thain <fthain@linux-m68k.org>
> > ---
> > Changed since v3:
> >  - Better commentary.
> > Changed since v2:
> >  - Added commentary.
> >  - Moved declaration to nubus.h.
> > Changed since v1:
> >  - Expanded to cover all slot resources in procfs.
>
> Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
> i.e. will queue in the m68k for-v6.5 branch.

Upon second look, "populate_procfs" is too generic for a global
variable.  Please add a "nubus_"-prefix, and use module_param_named()
instead.

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

end of thread, other threads:[~2023-05-15 10:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-05  4:12 [PATCH v4] nubus: Don't list slot resources by default Finn Thain
2023-04-06 20:17 ` Brad Boyer
2023-05-15  9:44 ` Geert Uytterhoeven
2023-05-15 10:11   ` Geert Uytterhoeven

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).