krishnanadh / rpms / rasdaemon

Forked from rpms/rasdaemon a year ago
Clone

Blame SOURCES/b22be68453b2497e86cbd273b9cd56fadc5859e3.patch

9748e8
commit b22be68453b2497e86cbd273b9cd56fadc5859e3
9748e8
Author: Ying Lv <lvying6@huawei.com>
9748e8
Date:   Wed May 15 11:15:42 2019 +0800
9748e8
9748e8
    fix rasdaemon high CPU usage when part of CPUs offline
9748e8
    
9748e8
    When we set part of CPU core offline, such as by setting the kernel cmdline
9748e8
    maxcpus = N(N is less than the total number of system CPU cores).
9748e8
    And then, we will observe that the CPU usage of some rasdaemon threads
9748e8
    is very close to 100.
9748e8
    
9748e8
    This is because when part of CPU offline, poll in read_ras_event_all_cpus func
9748e8
    will fallback to pthread way.
9748e8
    Offlined CPU thread will return negative value when read trace_pipe_raw,
9748e8
    negative return value will covert to positive value because of 'unsigned size'.
9748e8
    So code will always go into 'size > 0' branch, and the CPU usage is too high.
9748e8
    
9748e8
    Here, variable size uses int type will go to the right branch.
9748e8
    
9748e8
    Fiexs: eff7c9e0("ras-events: Only use pthreads for collect if poll() not available")
9748e8
    Reported-by: Zhipeng Xie <xiezhipeng1@huawei.com>
9748e8
    Signed-off-by: Ying Lv <lvying6@huawei.com>
9748e8
    Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
9748e8
9748e8
diff --git a/ras-events.c b/ras-events.c
9748e8
index 4e7b815..38ebe1e 100644
9748e8
--- a/ras-events.c
9748e8
+++ b/ras-events.c
9748e8
@@ -426,7 +426,7 @@ static int read_ras_event(int fd,
9748e8
 			  struct kbuffer *kbuf,
9748e8
 			  void *page)
9748e8
 {
9748e8
-	unsigned size;
9748e8
+	int size;
9748e8
 	unsigned long long time_stamp;
9748e8
 	void *data;
9748e8