Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp67833rwl; Thu, 6 Apr 2023 13:18:41 -0700 (PDT) X-Google-Smtp-Source: AKy350YCAWodfVQxWm1NIR76cR4BFaPOKxpxRtNZZ3W6LIGLKiUo8OF2Eqgp/0uBsEUHPx4tfhvT X-Received: by 2002:a17:906:bcf2:b0:932:da0d:96ac with SMTP id op18-20020a170906bcf200b00932da0d96acmr186657ejb.10.1680812320992; Thu, 06 Apr 2023 13:18:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680812320; cv=none; d=google.com; s=arc-20160816; b=BnrsX1Tuv9nJtP7EXJSNyRpAt7CDeeR87FIWfR36yeNhUYMCxys3Jr8Ak7J5zunG4N Mp9TfYbdYk+br9d5Ao+CPIG/R8KHA05Lkn5xeXKHh1DtECxgJy7/vdYW701rT8GNA1Cv JMRJeijUWFg9CY3T/q3Brd2DUZW+yQl96eLsdHlU5geeUAdDwa9oHaCojzHs1zHX0Bmu GUr/d2YYAFt4iDVlez63oxHrS9dgZP8/xkLWmjMUBzZX6Gl7lf9a3abMEYMSiKRf41dY 0bDKHn9+SgC17EY5/mJz5ICYoFTNUv3LZ4IzKVN4ETpia5F0uY6kmUbx1VZzoS3gUL6G z2yw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=AgE9UJbm24hUUC4/QJHGtIh51uAO+JAZvd+7ye9ixEw=; b=HS1NXgBL53hNEtR9QNrACYQcluFj9uK5m9QQ3LbjYJcTHwBnBXi9DN0TXiSQhfsLI6 IQKChHQYFICDINOTBbg0jZHU3PwiuIdbUXwga7cvMS3kP76889xHRnu3XMCyswT8UOZ7 znpmULLasootXgePCm8J3ByI++3Ur3UiMgyQybC0UOShVTgf2OV0UpmMR+TW8mOUOIur EIQGFZIQCTjo1YCuk6Ir372rxqpElCSAuOzsBj6/u0hdkhZQFkZPDNCIK5vGmx4Cn6W9 /HiD7RkEou6dipkn6QmBSsXGBlkztsXDO2wQzKfKTlGV1f3KnyagCR4Nlrhn2SrAIWA6 WEFg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ib9-20020a1709072c6900b00930943f134esi1915636ejc.8.2023.04.06.13.18.15; Thu, 06 Apr 2023 13:18:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238761AbjDFUR1 (ORCPT + 99 others); Thu, 6 Apr 2023 16:17:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238444AbjDFUR0 (ORCPT ); Thu, 6 Apr 2023 16:17:26 -0400 Received: from cynthia.allandria.com (cynthia.allandria.com [50.242.82.17]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71FE04493; Thu, 6 Apr 2023 13:17:25 -0700 (PDT) Received: from flar by cynthia.allandria.com with local (Exim 4.84_2) (envelope-from ) id 1pkW2s-0007P4-RX; Thu, 06 Apr 2023 13:17:22 -0700 Date: Thu, 6 Apr 2023 13:17:22 -0700 From: Brad Boyer To: Finn Thain Cc: Geert Uytterhoeven , linux-m68k@lists.linux-m68k.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4] nubus: Don't list slot resources by default Message-ID: <20230406201722.GA28362@allandria.com> References: <1296c4d691bba057291246f067c191ef8a88531c.1680667933.git.fthain@linux-m68k.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1296c4d691bba057291246f067c191ef8a88531c.1680667933.git.fthain@linux-m68k.org> User-Agent: Mutt/1.5.23 (2014-03-12) X-Spam-Status: No, score=0.0 required=5.0 tests=SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Reviewed-by: Brad Boyer > Tested-by: Stan Johnson > Signed-off-by: Finn Thain > --- > 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 >