Skip to contentSkip to conversation

parisc: led: Reduce CPU overhead for disk & lan LED computation

PATCH In review [email protected] 3 participants 7 messages Aug 25, 2023 – Aug 26, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/3 parisc: led: Reduce CPU overhead for disk & lan LED computation

From: Helge Deller <[email protected]>

Older PA-RISC machines have LEDs which show the disk- and LAN-activity. The computation is done in software and takes quite some time, e.g. on a J6500 this may take up to 60% time of one CPU if the machine is loaded via network traffic.

Since most people don't care about the LEDs, start with LEDs disabled and just show a CPU heartbeat LED. The disk and LAN LEDs can be turned on manually via /proc/pdc/led.

---
 drivers/parisc/led.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/parisc/led.c +5 -2
index 8bdc5e043831..765f19608f60 100644
@@ -56,8 +56,8 @@
 static int led_type __read_mostly = -1;
 static unsigned char lastleds;	/* LED state from most recent update */
 static unsigned int led_heartbeat __read_mostly = 1;
-static unsigned int led_diskio    __read_mostly = 1;
-static unsigned int led_lanrxtx   __read_mostly = 1;
+static unsigned int led_diskio    __read_mostly;
+static unsigned int led_lanrxtx   __read_mostly;
 static char lcd_text[32]          __read_mostly;
 static char lcd_text_default[32]  __read_mostly;
 static int  lcd_no_led_support    __read_mostly = 0; /* KittyHawk doesn't support LED on its LCD */
@@ -589,6 +589,9 @@ int __init register_led_driver(int model, unsigned long cmd_reg, unsigned long d
 		return 1;
 	}
 	
+	pr_info("LED: Enable disk and LAN activity LEDs "
+		"via /proc/pdc/led\n");
+
 	/* mark the LCD/LED driver now as initialized and 
 	 * register to the reboot notifier chain */
 	initialized++;
Signature · 1 line
2.41.0
#1 lore raw

PATCH 2/3 parisc: led: Switch LCD/LED driver to use a kthread

From: Helge Deller <[email protected]>

Rewrite and clean up the LCD/LED driver, mostly by switching to a kthread instead of using workqueues to update the LEDs. The benefit of the kthread is that it avoids creating new kworker nodes for updates, which is pretty slow on hppa.

Clean up the detection code too, use initcalls and fix kdoc issues.

---
 arch/parisc/include/asm/led.h |  11 +-
 arch/parisc/kernel/setup.c    |   5 -
 drivers/parisc/led.c          | 697 +++++++++++++++-------------------
 3 files changed, 304 insertions(+), 409 deletions(-)
arch/parisc/include/asm/led.h +4 -7
index 6de13d08a388..b99dffe02646 100644
@@ -25,19 +25,16 @@
 #define LED_CMD_REG_NONE 0		/* NULL == no addr for the cmd register */
 
 /* register_led_driver() */
-int __init register_led_driver(int model, unsigned long cmd_reg, unsigned long data_reg);
+int register_led_driver(int model, unsigned long cmd_reg, unsigned long data_reg);
 
 /* registers the LED regions for procfs */
-void __init register_led_regions(void);
+void register_led_regions(void);
 
 #ifdef CONFIG_CHASSIS_LCD_LED
 /* writes a string to the LCD display (if possible on this h/w) */
-int lcd_print(const char *str);
+void lcd_print(const char *str);
 #else
-#define lcd_print(str)
+#define lcd_print(str)	do { } while (0)
 #endif
 
-/* main LED initialization function (uses PDC) */ 
-int __init led_init(void);
-
 #endif /* LED_H */
arch/parisc/kernel/setup.c +0 -5
index 3e95b5417a50..7a2444c8b25b 100644
@@ -143,11 +143,6 @@ void __init setup_arch(char **cmdline_p)
 	parisc_cache_init();
 	paging_init();
 
-#ifdef CONFIG_CHASSIS_LCD_LED
-	/* initialize the LCD/LED after boot_cpu_data is available ! */
-	led_init();		/* LCD/LED initialization */
-#endif
-
 #ifdef CONFIG_PA11
 	dma_ops_init();
 #endif
drivers/parisc/led.c +300 -397

928 lines not on this page · raw message

Signature · 1 line
2.41.0
#2 lore raw

PATCH 3/3 parisc: chassis: Do not overwrite LCD display

In reply to [email protected]

From: Helge Deller <[email protected]>

If we have the LCD/LED driver and tell PDC about a status change of the system, PDC will usually overwrite the contents on the LCD.

To avoid that, just write the LCD string again via the LCD driver.

---
 arch/parisc/kernel/pdc_chassis.c | 6 ++++++
 1 file changed, 6 insertions(+)
arch/parisc/kernel/pdc_chassis.c +6 -0
index 0a9d7008ef2a..d477d0177c2f 100644
@@ -31,6 +31,7 @@
 #include <asm/processor.h>
 #include <asm/pdc.h>
 #include <asm/pdcpat.h>
+#include <asm/led.h>
 
 #define PDC_CHASSIS_VER	"0.05"
 
@@ -234,6 +235,11 @@ int pdc_chassis_send_status(int message)
 		} else retval = -1;
 #endif /* CONFIG_64BIT */
 	}	/* if (pdc_chassis_enabled) */
+
+	/* if system has LCD display, update current string */
+	if (retval != -1 && IS_ENABLED(CONFIG_CHASSIS_LCD_LED))
+		lcd_print(NULL);
+
 #endif /* CONFIG_PDC_CHASSIS */
 	return retval;
 }
Signature · 1 line
2.41.0
maintainer
#3 lore raw
In reply to [email protected]
Quoted 33 lines · On Fri, Aug 25, 2023 at 08:09:26PM +0200, [email protected] wrote:

From: Helge Deller <[email protected]>

Older PA-RISC machines have LEDs which show the disk- and LAN-activity. The computation is done in software and takes quite some time, e.g. on a J6500 this may take up to 60% time of one CPU if the machine is loaded via network traffic.

Since most people don't care about the LEDs, start with LEDs disabled and just show a CPU heartbeat LED. The disk and LAN LEDs can be turned on manually via /proc/pdc/led.

---
 drivers/parisc/led.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/parisc/led.c +2 -2
index 8bdc5e043831..765f19608f60 100644
@@ -56,8 +56,8 @@
 static int led_type __read_mostly = -1;
 static unsigned char lastleds;	/* LED state from most recent update */
 static unsigned int led_heartbeat __read_mostly = 1;
-static unsigned int led_diskio    __read_mostly = 1;
-static unsigned int led_lanrxtx   __read_mostly = 1;
+static unsigned int led_diskio    __read_mostly;
+static unsigned int led_lanrxtx   __read_mostly;
 static char lcd_text[32]          __read_mostly;
 static char lcd_text_default[32]  __read_mostly;
 static int  lcd_no_led_support    __read_mostly = 0; /* KittyHawk doesn't support LED on its LCD */

drivers/parisc/led.c int __init register_led_driver(int model, unsigned long cmd_reg, unsigned long d · line 593

Quoted 5 lines
drivers/parisc/led.c +2 -0
@@ -589,6 +589,9 @@ int __init register_led_driver(int model, unsigned long cmd_reg, unsigned long d
 		return 1;
 	}
 
+	pr_info("LED: Enable disk and LAN activity LEDs "
+		"via /proc/pdc/led\n");

When drivers are working properly, they should be quiet. Who is going to see this message?

I don't even understand it, are you saying that you now need to go enable the led through proc? And why are leds in proc, I thought they had a real class for them? Why not use that instead?

And finally, you shouldn't split strings across lines :)

thanks,

greg k-h

maintainer
#4 lore raw
Quoted 37 lines · Greg KH
Quoted 36 lines · On Fri, Aug 25, 2023 at 08:09:26PM +0200, [email protected] wrote:

From: Helge Deller <[email protected]>

Older PA-RISC machines have LEDs which show the disk- and LAN-activity. The computation is done in software and takes quite some time, e.g. on a J6500 this may take up to 60% time of one CPU if the machine is loaded via network traffic.

Since most people don't care about the LEDs, start with LEDs disabled and just show a CPU heartbeat LED. The disk and LAN LEDs can be turned on manually via /proc/pdc/led.

---
  drivers/parisc/led.c | 7 +++++--
  1 file changed, 5 insertions(+), 2 deletions(-)
drivers/parisc/led.c +2 -2
index 8bdc5e043831..765f19608f60 100644
@@ -56,8 +56,8 @@
  static int led_type __read_mostly = -1;
  static unsigned char lastleds;	/* LED state from most recent update */
  static unsigned int led_heartbeat __read_mostly = 1;
-static unsigned int led_diskio    __read_mostly = 1;
-static unsigned int led_lanrxtx   __read_mostly = 1;
+static unsigned int led_diskio    __read_mostly;
+static unsigned int led_lanrxtx   __read_mostly;
  static char lcd_text[32]          __read_mostly;
  static char lcd_text_default[32]  __read_mostly;
  static int  lcd_no_led_support    __read_mostly = 0; /* KittyHawk doesn't support LED on its LCD */
@@ -589,6 +589,9 @@ int __init register_led_driver(int model, unsigned long cmd_reg, unsigned long d
  		return 1;
  	}
 
Quoted 5 lines

drivers/parisc/led.c int __init register_led_driver(int model, unsigned long cmd_reg, unsigned long d · line 593

Quoted 2 lines
drivers/parisc/led.c +2 -0
+	pr_info("LED: Enable disk and LAN activity LEDs "
+		"via /proc/pdc/led\n");

When drivers are working properly, they should be quiet. Who is going to see this message?

That patch shouldn't have gone to stable@ yet... git-send-patch just pulled the CC in and I didn't noticed.
So, please don't apply it yet.

Anyway, yes, I can drop this info.

Quoted 3 lines

I don't even understand it, are you saying that you now need to go enable the led through proc? And why are leds in proc, I thought they had a real class for them? Why not use that instead?

This is an old driver from the very beginning, and I don't want to change much in it for old kernels other than to reduce the CPU overhead it generates.

Additionally I've started a rewrite of the driver (in my for-next tree), and I did look at the led class and led trigger classes. If it fits, I'll convert to those, but at least for hdd activity it seems only IDE/ATA activity is monitored and SCSI activity is missing. Anyway, this is still work-in-progress...

Quoted 1 line

And finally, you shouldn't split strings across lines :)

Ok.

Thanks!
Helge

maintainer
#5 lore raw
Quoted 44 lines · Helge Deller
Quoted 37 lines · Greg KH
Quoted 36 lines · On Fri, Aug 25, 2023 at 08:09:26PM +0200, [email protected] wrote:

From: Helge Deller <[email protected]>

Older PA-RISC machines have LEDs which show the disk- and LAN-activity. The computation is done in software and takes quite some time, e.g. on a J6500 this may take up to 60% time of one CPU if the machine is loaded via network traffic.

Since most people don't care about the LEDs, start with LEDs disabled and just show a CPU heartbeat LED. The disk and LAN LEDs can be turned on manually via /proc/pdc/led.

---
  drivers/parisc/led.c | 7 +++++--
  1 file changed, 5 insertions(+), 2 deletions(-)
drivers/parisc/led.c +2 -2
index 8bdc5e043831..765f19608f60 100644
@@ -56,8 +56,8 @@
  static int led_type __read_mostly = -1;
  static unsigned char lastleds;	/* LED state from most recent update */
  static unsigned int led_heartbeat __read_mostly = 1;
-static unsigned int led_diskio    __read_mostly = 1;
-static unsigned int led_lanrxtx   __read_mostly = 1;
+static unsigned int led_diskio    __read_mostly;
+static unsigned int led_lanrxtx   __read_mostly;
  static char lcd_text[32]          __read_mostly;
  static char lcd_text_default[32]  __read_mostly;
  static int  lcd_no_led_support    __read_mostly = 0; /* KittyHawk doesn't support LED on its LCD */
@@ -589,6 +589,9 @@ int __init register_led_driver(int model, unsigned long cmd_reg, unsigned long d
  		return 1;
  	}
 
Quoted 5 lines

drivers/parisc/led.c int __init register_led_driver(int model, unsigned long cmd_reg, unsigned long d · line 593

Quoted 2 lines
drivers/parisc/led.c +2 -0
+	pr_info("LED: Enable disk and LAN activity LEDs "
+		"via /proc/pdc/led\n");

When drivers are working properly, they should be quiet. Who is going to see this message?

Quoted 3 lines

That patch shouldn't have gone to stable@ yet... git-send-patch just pulled the CC in and I didn't noticed.
So, please don't apply it yet.

I will not, and it's fine to cc: stable@ on stuff that is still making it's way into the kernel tree. It gives us a heads-up on stuff, AND sometimes it gives you an additional free review :)

Quoted 6 lines
Quoted 3 lines

I don't even understand it, are you saying that you now need to go enable the led through proc? And why are leds in proc, I thought they had a real class for them? Why not use that instead?

This is an old driver from the very beginning, and I don't want to change much in it for old kernels other than to reduce the CPU overhead it generates.

Ah, makes sense, that is a crazy amount of cpu time for a blinking led.

How about just default to it off (like the first chunk you have here), which will go to stable trees, and then a rewrite to use the proper LED api? Or not, your call, I doubt many people actually have this hardware to care about it...

thanks,

greg k-h

maintainer
#6 lore raw
Quoted 45 lines · Greg KH
Quoted 44 lines · Helge Deller
Quoted 42 lines · Greg KH
Quoted 33 lines · On Fri, Aug 25, 2023 at 08:09:26PM +0200, [email protected] wrote:

From: Helge Deller <[email protected]>

Older PA-RISC machines have LEDs which show the disk- and LAN-activity. The computation is done in software and takes quite some time, e.g. on a J6500 this may take up to 60% time of one CPU if the machine is loaded via network traffic.

Since most people don't care about the LEDs, start with LEDs disabled and just show a CPU heartbeat LED. The disk and LAN LEDs can be turned on manually via /proc/pdc/led.

---
   drivers/parisc/led.c | 7 +++++--
   1 file changed, 5 insertions(+), 2 deletions(-)
drivers/parisc/led.c +2 -2
index 8bdc5e043831..765f19608f60 100644
@@ -56,8 +56,8 @@
   static int led_type __read_mostly = -1;
   static unsigned char lastleds;	/* LED state from most recent update */
   static unsigned int led_heartbeat __read_mostly = 1;
-static unsigned int led_diskio    __read_mostly = 1;
-static unsigned int led_lanrxtx   __read_mostly = 1;
+static unsigned int led_diskio    __read_mostly;
+static unsigned int led_lanrxtx   __read_mostly;
   static char lcd_text[32]          __read_mostly;
   static char lcd_text_default[32]  __read_mostly;
   static int  lcd_no_led_support    __read_mostly = 0; /* KittyHawk doesn't support LED on its LCD */

drivers/parisc/led.c int __init register_led_driver(int model, unsigned long cmd_reg, unsigned long d · line 593

Quoted 5 lines
drivers/parisc/led.c +2 -0
@@ -589,6 +589,9 @@ int __init register_led_driver(int model, unsigned long cmd_reg, unsigned long d
   		return 1;
   	}
 
+	pr_info("LED: Enable disk and LAN activity LEDs "
+		"via /proc/pdc/led\n");

When drivers are working properly, they should be quiet. Who is going to see this message?

Quoted 7 lines
Quoted 3 lines

That patch shouldn't have gone to stable@ yet... git-send-patch just pulled the CC in and I didn't noticed.
So, please don't apply it yet.

I will not, and it's fine to cc: stable@ on stuff that is still making it's way into the kernel tree. It gives us a heads-up on stuff, AND sometimes it gives you an additional free review :)

Yes, thanks! :-)

Quoted 11 lines
Quoted 6 lines
Quoted 3 lines

I don't even understand it, are you saying that you now need to go enable the led through proc? And why are leds in proc, I thought they had a real class for them? Why not use that instead?

This is an old driver from the very beginning, and I don't want to change much in it for old kernels other than to reduce the CPU overhead it generates.

Ah, makes sense, that is a crazy amount of cpu time for a blinking led.

How about just default to it off (like the first chunk you have here), which will go to stable trees,

Yes, that was the idea of this patch. I'll drop the pr_info() next time.

Quoted 1 line

and then a rewrite to use the proper LED api?

Yes.

Helge