linux-edac.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ying Lv <lvying6@huawei.com>
To: <mchehab@kernel.org>, <linux-edac@vger.kernel.org>
Cc: <shanshishi@huawei.com>, <hehuazhen@huawei.com>,
	<chenjialong@huawei.com>, <xiezhipeng1@huawei.com>,
	<xuchunmei@huawei.com>
Subject: [PATCH] fix rasdaemon high CPU usage when part of CPUs offline
Date: Wed, 15 May 2019 11:15:42 +0800	[thread overview]
Message-ID: <20190515031542.13739-1-lvying6@huawei.com> (raw)

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


             reply	other threads:[~2019-05-15  7:05 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-15  3:15 Ying Lv [this message]
  -- strict thread matches above, loose matches on Subject: below --
2019-05-13 22:16 [PATCH] fix rasdaemon high CPU usage when part of CPUs offline Ying Lv

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190515031542.13739-1-lvying6@huawei.com \
    --to=lvying6@huawei.com \
    --cc=chenjialong@huawei.com \
    --cc=hehuazhen@huawei.com \
    --cc=linux-edac@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=shanshishi@huawei.com \
    --cc=xiezhipeng1@huawei.com \
    --cc=xuchunmei@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).