linux-edac.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fix rasdaemon high CPU usage when part of CPUs offline
@ 2019-05-13 22:16 Ying Lv
  0 siblings, 0 replies; 2+ messages in thread
From: Ying Lv @ 2019-05-13 22:16 UTC (permalink / raw)
  To: mchehab, linux-edac
  Cc: shanshishi, hehuazhen, chenjialong, xiezhipeng1, xuchunmei

When we set part of CPU core offline, such as by setting the kernel cmdline
maxcpus = N(N is less than the total number of system CPU cores).
And then, we will observe that the CPU usage of some rasdaemon threads
is very close to 100.

This is because when part of CPU offline, poll in read_ras_event_all_cpus func
will fallback to pthread way.
Offlined CPU thread will return negative value when read trace_pipe_raw,
negative return value will covert to positive value because of 'unsigned size'.
So code will always go into 'size > 0' branch, and the CPU usage is too high.

Here, variable size uses int type will go to the right branch.

Fiexs: eff7c9e0("ras-events: Only use pthreads for collect if poll() not available")
Reported-by: Zhipeng Xie <xiezhipeng1@huawei.com>
Signed-off-by: Ying Lv <lvying6@huawei.com>
---
 ras-events.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ras-events.c b/ras-events.c
index 9395f6f..1094df0 100644
--- a/ras-events.c
+++ b/ras-events.c
@@ -421,7 +421,7 @@ static int read_ras_event(int fd,
 			  struct kbuffer *kbuf,
 			  void *page)
 {
-	unsigned size;
+	int size;
 	unsigned long long time_stamp;
 	void *data;
 
-- 
2.21.0


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

* [PATCH] fix rasdaemon high CPU usage when part of CPUs offline
@ 2019-05-15  3:15 Ying Lv
  0 siblings, 0 replies; 2+ messages in thread
From: Ying Lv @ 2019-05-15  3:15 UTC (permalink / raw)
  To: mchehab, linux-edac
  Cc: shanshishi, hehuazhen, chenjialong, xiezhipeng1, xuchunmei

When we set part of CPU core offline, such as by setting the kernel cmdline
maxcpus = N(N is less than the total number of system CPU cores).
And then, we will observe that the CPU usage of some rasdaemon threads
is very close to 100.

This is because when part of CPU offline, poll in read_ras_event_all_cpus func
will fallback to pthread way.
Offlined CPU thread will return negative value when read trace_pipe_raw,
negative return value will covert to positive value because of 'unsigned size'.
So code will always go into 'size > 0' branch, and the CPU usage is too high.

Here, variable size uses int type will go to the right branch.

Fiexs: eff7c9e0("ras-events: Only use pthreads for collect if poll() not available")
Reported-by: Zhipeng Xie <xiezhipeng1@huawei.com>
Signed-off-by: Ying Lv <lvying6@huawei.com>
---
 ras-events.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ras-events.c b/ras-events.c
index 9395f6f..1094df0 100644
--- a/ras-events.c
+++ b/ras-events.c
@@ -421,7 +421,7 @@ static int read_ras_event(int fd,
 			  struct kbuffer *kbuf,
 			  void *page)
 {
-	unsigned size;
+	int size;
 	unsigned long long time_stamp;
 	void *data;
 
-- 
2.21.0


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

end of thread, other threads:[~2019-05-15  7:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-13 22:16 [PATCH] fix rasdaemon high CPU usage when part of CPUs offline Ying Lv
2019-05-15  3:15 Ying Lv

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).