Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH v1] package/irqbalance: fix irqbalance/irqbalance-ui socket communication
@ 2021-02-20 23:12 Peter Seiderer
  2021-02-21  7:51 ` Yann E. MORIN
  2021-02-27 18:04 ` Peter Korsgaard
  0 siblings, 2 replies; 3+ messages in thread
From: Peter Seiderer @ 2021-02-20 23:12 UTC (permalink / raw)
  To: buildroot

Add patch to fix irqbalance/irqbalance-ui socket communication by
fixing uint64_t printf format usage.

Fixes:

  $ irqbalance-ui
  Invalid data sent.  Unexpected token: (null)TYPE

Signed-off-by: Peter Seiderer <ps.report@gmx.net>
---
 ...ix-uint64_t-printf-format-use-PRIu64.patch | 105 ++++++++++++++++++
 1 file changed, 105 insertions(+)
 create mode 100644 package/irqbalance/0001-fix-uint64_t-printf-format-use-PRIu64.patch

diff --git a/package/irqbalance/0001-fix-uint64_t-printf-format-use-PRIu64.patch b/package/irqbalance/0001-fix-uint64_t-printf-format-use-PRIu64.patch
new file mode 100644
index 0000000000..50524a6468
--- /dev/null
+++ b/package/irqbalance/0001-fix-uint64_t-printf-format-use-PRIu64.patch
@@ -0,0 +1,105 @@
+From 1897aceb1f2a81c0fa0e0c62c524787b2ccfb241 Mon Sep 17 00:00:00 2001
+From: Peter Seiderer <ps.report@gmx.net>
+Date: Sat, 20 Feb 2021 23:38:56 +0100
+Subject: [PATCH] fix uint64_t printf format (use PRIu64)
+
+Fixes (on arm 32-bit):
+
+  $ irqbalance-ui
+  Invalid data sent.  Unexpected token: (null)TYPE
+
+And strace showed the following:
+
+  237   sendmsg(3, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="stats", iov_len=5}], msg_iovlen=1, msg_control=[{cmsg_len=24, cmsg_level=SOL_SOCKET, cmsg_type=SCM_CREDENTIALS, cmsg_data={pid=237, uid=0, gid=0}}], msg_controllen=24, msg_flags=0}, 0) = 5
+  237   recv(3, "TYPE 3 NUMBER -1 LOAD 0 SAVE_MODE 0 (null)TYPE 2 NUMBER 0 LOAD 0 SAVE_MODE 0 (null)TYPE 1 NUMBER 0 LOAD 0 SAVE_MODE 0 (null)TYPE 0 NUMBER 3 LOAD 0 SAVE_MODE 0 (null)TYPE 1 NUMBER 1 LOAD 0 SAVE_MODE 0 (null)TYPE 0 NUMBER 1 LOAD 0 SAVE_MODE 0 (null)TYPE 1 NUMBER 2 LOAD 0 SAVE_MODE 0 (null)TYPE 0 NUMBER 2 LOAD 0 SAVE_MODE 0 (null)TYPE 1 NUMBER 3 LOAD 0 SAVE_MODE 0 (null)TYPE 0 NUMBER 0 LOAD 0 SAVE_MODE 0 (null)", 8192, 0) = 411
+
+[Upstream: https://github.com/Irqbalance/irqbalance/pull/173]
+Signed-off-by: Peter Seiderer <ps.report@gmx.net>
+---
+ cputree.c    | 3 ++-
+ irqbalance.c | 5 +++--
+ ui/ui.c      | 5 +++--
+ 3 files changed, 8 insertions(+), 5 deletions(-)
+
+diff --git a/cputree.c b/cputree.c
+index 5551784..dd99bf8 100644
+--- a/cputree.c
++++ b/cputree.c
+@@ -33,6 +33,7 @@
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #include <dirent.h>
++#include <inttypes.h>
+ 
+ #include <glib.h>
+ 
+@@ -431,7 +432,7 @@ static void dump_irq(struct irq_info *info, void *data)
+ 		indent[i] = log_indent[0];
+ 
+ 	indent[i] = '\0';
+-	log(TO_CONSOLE, LOG_INFO, "%sInterrupt %i node_num is %d (%s/%lu:%lu) \n", indent,
++	log(TO_CONSOLE, LOG_INFO, "%sInterrupt %i node_num is %d (%s/%" PRIu64 ":%" PRIu64 ") \n", indent,
+ 	    info->irq, irq_numa_node(info)->number, classes[info->class], info->load, (info->irq_count - info->last_irq_count));
+ 	free(indent);
+ }
+diff --git a/irqbalance.c b/irqbalance.c
+index c1a0e15..82435e5 100644
+--- a/irqbalance.c
++++ b/irqbalance.c
+@@ -34,6 +34,7 @@
+ #include <sys/socket.h>
+ #include <sys/un.h>
+ #include <fcntl.h>
++#include <inttypes.h>
+ #ifdef HAVE_GETOPT_LONG 
+ #include <getopt.h>
+ #endif
+@@ -312,7 +313,7 @@ void get_irq_data(struct irq_info *irq, void *data)
+ 		*irqdata = realloc(*irqdata, strlen(*irqdata) + 24 + 1 + 11 + 20 + 20 + 11);
+ 
+ 	sprintf(*irqdata + strlen(*irqdata),
+-			"IRQ %d LOAD %lu DIFF %lu CLASS %d ", irq->irq, irq->load,
++			"IRQ %d LOAD %" PRIu64 " DIFF %" PRIu64 " CLASS %d ", irq->irq, irq->load,
+ 			(irq->irq_count - irq->last_irq_count), irq->class);
+ }
+ 
+@@ -342,7 +343,7 @@ void get_object_stat(struct topo_obj *object, void *data)
+ 		*stats = realloc(*stats, strlen(*stats) + irqdlen + 31 + 11 + 20 + 11 + 1);
+ 	}
+ 
+-	sprintf(*stats + strlen(*stats), "TYPE %d NUMBER %d LOAD %lu SAVE_MODE %d %s",
++	sprintf(*stats + strlen(*stats), "TYPE %d NUMBER %d LOAD %" PRIu64 " SAVE_MODE %d %s",
+ 			object->obj_type, object->number, object->load,
+ 			object->powersave_mode, irq_data ? irq_data : "");
+ 	free(irq_data);
+diff --git a/ui/ui.c b/ui/ui.c
+index 06ec472..4cf68bf 100644
+--- a/ui/ui.c
++++ b/ui/ui.c
+@@ -1,4 +1,5 @@
+ 
++#include <inttypes.h>
+ #include <string.h>
+ #include "ui.h"
+ 
+@@ -563,7 +564,7 @@ void settings()
+ 
+ 	char info[128] = "Current sleep interval between rebalancing: \0";
+ 	uint8_t sleep_input_offset = strlen(info) + 3;
+-	snprintf(info + strlen(info), 128 - strlen(info), "%lu\n", setup.sleep);
++	snprintf(info + strlen(info), 128 - strlen(info), "%" PRIu64 "\n", setup.sleep);
+ 	attrset(COLOR_PAIR(1));
+ 	mvprintw(2, 3, info);
+ 	print_all_cpus();
+@@ -588,7 +589,7 @@ void settings()
+ 			if(new_sleep != setup.sleep) {
+ 				setup.sleep = new_sleep;
+ 				char settings_data[128];
+-				snprintf(settings_data, 128, "%s %lu", SET_SLEEP, new_sleep);
++				snprintf(settings_data, 128, "%s %" PRIu64, SET_SLEEP, new_sleep);
+ 				send_settings(settings_data);
+ 			}
+ 			break;
+-- 
+2.30.1
+
-- 
2.30.1

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

* [Buildroot] [PATCH v1] package/irqbalance: fix irqbalance/irqbalance-ui socket communication
  2021-02-20 23:12 [Buildroot] [PATCH v1] package/irqbalance: fix irqbalance/irqbalance-ui socket communication Peter Seiderer
@ 2021-02-21  7:51 ` Yann E. MORIN
  2021-02-27 18:04 ` Peter Korsgaard
  1 sibling, 0 replies; 3+ messages in thread
From: Yann E. MORIN @ 2021-02-21  7:51 UTC (permalink / raw)
  To: buildroot

Peter, All,

On 2021-02-21 00:12 +0100, Peter Seiderer spake thusly:
> Add patch to fix irqbalance/irqbalance-ui socket communication by
> fixing uint64_t printf format usage.
> 
> Fixes:
> 
>   $ irqbalance-ui
>   Invalid data sent.  Unexpected token: (null)TYPE
> 
> Signed-off-by: Peter Seiderer <ps.report@gmx.net>

Upstream has now applied your patch, so I tdid an actual backport.

Applied to master, thanks.

Regards,
Yann E. MORIN.

> ---
>  ...ix-uint64_t-printf-format-use-PRIu64.patch | 105 ++++++++++++++++++
>  1 file changed, 105 insertions(+)
>  create mode 100644 package/irqbalance/0001-fix-uint64_t-printf-format-use-PRIu64.patch
> 
> diff --git a/package/irqbalance/0001-fix-uint64_t-printf-format-use-PRIu64.patch b/package/irqbalance/0001-fix-uint64_t-printf-format-use-PRIu64.patch
> new file mode 100644
> index 0000000000..50524a6468
> --- /dev/null
> +++ b/package/irqbalance/0001-fix-uint64_t-printf-format-use-PRIu64.patch
> @@ -0,0 +1,105 @@
> +From 1897aceb1f2a81c0fa0e0c62c524787b2ccfb241 Mon Sep 17 00:00:00 2001
> +From: Peter Seiderer <ps.report@gmx.net>
> +Date: Sat, 20 Feb 2021 23:38:56 +0100
> +Subject: [PATCH] fix uint64_t printf format (use PRIu64)
> +
> +Fixes (on arm 32-bit):
> +
> +  $ irqbalance-ui
> +  Invalid data sent.  Unexpected token: (null)TYPE
> +
> +And strace showed the following:
> +
> +  237   sendmsg(3, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="stats", iov_len=5}], msg_iovlen=1, msg_control=[{cmsg_len=24, cmsg_level=SOL_SOCKET, cmsg_type=SCM_CREDENTIALS, cmsg_data={pid=237, uid=0, gid=0}}], msg_controllen=24, msg_flags=0}, 0) = 5
> +  237   recv(3, "TYPE 3 NUMBER -1 LOAD 0 SAVE_MODE 0 (null)TYPE 2 NUMBER 0 LOAD 0 SAVE_MODE 0 (null)TYPE 1 NUMBER 0 LOAD 0 SAVE_MODE 0 (null)TYPE 0 NUMBER 3 LOAD 0 SAVE_MODE 0 (null)TYPE 1 NUMBER 1 LOAD 0 SAVE_MODE 0 (null)TYPE 0 NUMBER 1 LOAD 0 SAVE_MODE 0 (null)TYPE 1 NUMBER 2 LOAD 0 SAVE_MODE 0 (null)TYPE 0 NUMBER 2 LOAD 0 SAVE_MODE 0 (null)TYPE 1 NUMBER 3 LOAD 0 SAVE_MODE 0 (null)TYPE 0 NUMBER 0 LOAD 0 SAVE_MODE 0 (null)", 8192, 0) = 411
> +
> +[Upstream: https://github.com/Irqbalance/irqbalance/pull/173]
> +Signed-off-by: Peter Seiderer <ps.report@gmx.net>
> +---
> + cputree.c    | 3 ++-
> + irqbalance.c | 5 +++--
> + ui/ui.c      | 5 +++--
> + 3 files changed, 8 insertions(+), 5 deletions(-)
> +
> +diff --git a/cputree.c b/cputree.c
> +index 5551784..dd99bf8 100644
> +--- a/cputree.c
> ++++ b/cputree.c
> +@@ -33,6 +33,7 @@
> + #include <sys/types.h>
> + #include <sys/stat.h>
> + #include <dirent.h>
> ++#include <inttypes.h>
> + 
> + #include <glib.h>
> + 
> +@@ -431,7 +432,7 @@ static void dump_irq(struct irq_info *info, void *data)
> + 		indent[i] = log_indent[0];
> + 
> + 	indent[i] = '\0';
> +-	log(TO_CONSOLE, LOG_INFO, "%sInterrupt %i node_num is %d (%s/%lu:%lu) \n", indent,
> ++	log(TO_CONSOLE, LOG_INFO, "%sInterrupt %i node_num is %d (%s/%" PRIu64 ":%" PRIu64 ") \n", indent,
> + 	    info->irq, irq_numa_node(info)->number, classes[info->class], info->load, (info->irq_count - info->last_irq_count));
> + 	free(indent);
> + }
> +diff --git a/irqbalance.c b/irqbalance.c
> +index c1a0e15..82435e5 100644
> +--- a/irqbalance.c
> ++++ b/irqbalance.c
> +@@ -34,6 +34,7 @@
> + #include <sys/socket.h>
> + #include <sys/un.h>
> + #include <fcntl.h>
> ++#include <inttypes.h>
> + #ifdef HAVE_GETOPT_LONG 
> + #include <getopt.h>
> + #endif
> +@@ -312,7 +313,7 @@ void get_irq_data(struct irq_info *irq, void *data)
> + 		*irqdata = realloc(*irqdata, strlen(*irqdata) + 24 + 1 + 11 + 20 + 20 + 11);
> + 
> + 	sprintf(*irqdata + strlen(*irqdata),
> +-			"IRQ %d LOAD %lu DIFF %lu CLASS %d ", irq->irq, irq->load,
> ++			"IRQ %d LOAD %" PRIu64 " DIFF %" PRIu64 " CLASS %d ", irq->irq, irq->load,
> + 			(irq->irq_count - irq->last_irq_count), irq->class);
> + }
> + 
> +@@ -342,7 +343,7 @@ void get_object_stat(struct topo_obj *object, void *data)
> + 		*stats = realloc(*stats, strlen(*stats) + irqdlen + 31 + 11 + 20 + 11 + 1);
> + 	}
> + 
> +-	sprintf(*stats + strlen(*stats), "TYPE %d NUMBER %d LOAD %lu SAVE_MODE %d %s",
> ++	sprintf(*stats + strlen(*stats), "TYPE %d NUMBER %d LOAD %" PRIu64 " SAVE_MODE %d %s",
> + 			object->obj_type, object->number, object->load,
> + 			object->powersave_mode, irq_data ? irq_data : "");
> + 	free(irq_data);
> +diff --git a/ui/ui.c b/ui/ui.c
> +index 06ec472..4cf68bf 100644
> +--- a/ui/ui.c
> ++++ b/ui/ui.c
> +@@ -1,4 +1,5 @@
> + 
> ++#include <inttypes.h>
> + #include <string.h>
> + #include "ui.h"
> + 
> +@@ -563,7 +564,7 @@ void settings()
> + 
> + 	char info[128] = "Current sleep interval between rebalancing: \0";
> + 	uint8_t sleep_input_offset = strlen(info) + 3;
> +-	snprintf(info + strlen(info), 128 - strlen(info), "%lu\n", setup.sleep);
> ++	snprintf(info + strlen(info), 128 - strlen(info), "%" PRIu64 "\n", setup.sleep);
> + 	attrset(COLOR_PAIR(1));
> + 	mvprintw(2, 3, info);
> + 	print_all_cpus();
> +@@ -588,7 +589,7 @@ void settings()
> + 			if(new_sleep != setup.sleep) {
> + 				setup.sleep = new_sleep;
> + 				char settings_data[128];
> +-				snprintf(settings_data, 128, "%s %lu", SET_SLEEP, new_sleep);
> ++				snprintf(settings_data, 128, "%s %" PRIu64, SET_SLEEP, new_sleep);
> + 				send_settings(settings_data);
> + 			}
> + 			break;
> +-- 
> +2.30.1
> +
> -- 
> 2.30.1
> 
> _______________________________________________
> buildroot mailing list
> buildroot at busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'

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

* [Buildroot] [PATCH v1] package/irqbalance: fix irqbalance/irqbalance-ui socket communication
  2021-02-20 23:12 [Buildroot] [PATCH v1] package/irqbalance: fix irqbalance/irqbalance-ui socket communication Peter Seiderer
  2021-02-21  7:51 ` Yann E. MORIN
@ 2021-02-27 18:04 ` Peter Korsgaard
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Korsgaard @ 2021-02-27 18:04 UTC (permalink / raw)
  To: buildroot

>>>>> "Peter" == Peter Seiderer <ps.report@gmx.net> writes:

 > Add patch to fix irqbalance/irqbalance-ui socket communication by
 > fixing uint64_t printf format usage.

 > Fixes:

 >   $ irqbalance-ui
 >   Invalid data sent.  Unexpected token: (null)TYPE

 > Signed-off-by: Peter Seiderer <ps.report@gmx.net>

Committed to 2020.02.x and 2020.11.x, thanks.

-- 
Bye, Peter Korsgaard

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

end of thread, other threads:[~2021-02-27 18:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-02-20 23:12 [Buildroot] [PATCH v1] package/irqbalance: fix irqbalance/irqbalance-ui socket communication Peter Seiderer
2021-02-21  7:51 ` Yann E. MORIN
2021-02-27 18:04 ` Peter Korsgaard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox