]> www.infradead.org Git - users/mchehab/rasdaemon.git/commitdiff
fix rasdaemon high CPU usage when part of CPUs offline
authorYing Lv <lvying6@huawei.com>
Wed, 15 May 2019 03:15:42 +0000 (11:15 +0800)
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Tue, 11 Jun 2019 17:54:22 +0000 (14:54 -0300)
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>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
ras-events.c

index 4e7b81529d5d7a1702dc002042600a38a429c55e..38ebe1efe249f88ed01c6acca2686b87dde24267 100644 (file)
@@ -426,7 +426,7 @@ static int read_ras_event(int fd,
                          struct kbuffer *kbuf,
                          void *page)
 {
-       unsigned size;
+       int size;
        unsigned long long time_stamp;
        void *data;