Kexec Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Zhou Wenjian <zhouwj.fi@gmail.com>
To: kexec@lists.infradead.org
Cc: ats-kumagai@wm.jp.nec.com, Zhou Wenjian <zhouwj.fi@gmail.com>
Subject: [PATCH] makedumpfile: Fix a bug when multi-threads feature meets enospace
Date: Mon, 29 Jan 2018 20:54:39 +0800	[thread overview]
Message-ID: <1517230479-8440-1-git-send-email-zhouwj.fi@gmail.com> (raw)

Currently, when multi-threads feature meets enospace error,
the main thread will call pthread_join(). However, there is one
thread doing while{} and won't stop.

                pthread_mutex_lock(&info->page_data_mutex);
                while (page_data_buf[index].used != FALSE) {
                        index = (index + 1) % info->num_buffers;
                }
                page_data_buf[index].used = TRUE;
                pthread_mutex_unlock(&info->page_data_mutex);

Then makedumpfile hangs.

This patch add a cancel point in while{}.

Signed-off-by: Zhou Wenjian <zhouwj.fi@gmail.com>
---
 makedumpfile.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/makedumpfile.c b/makedumpfile.c
index ed138d3..f7ad50c 100644
--- a/makedumpfile.c
+++ b/makedumpfile.c
@@ -7731,11 +7731,13 @@ kdump_thread_function_cyclic(void *arg) {
 		buf_ready = FALSE;
 
 		pthread_mutex_lock(&info->page_data_mutex);
+		pthread_cleanup_push(pthread_mutex_unlock, &info->page_data_mutex);
 		while (page_data_buf[index].used != FALSE) {
+			pthread_testcancel();
 			index = (index + 1) % info->num_buffers;
 		}
 		page_data_buf[index].used = TRUE;
-		pthread_mutex_unlock(&info->page_data_mutex);
+		pthread_cleanup_pop(1); 
 
 		while (buf_ready == FALSE) {
 			pthread_testcancel();
-- 
1.8.3.1


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

             reply	other threads:[~2018-01-29 12:55 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-29 12:54 Zhou Wenjian [this message]
2018-02-08 11:53 ` [PATCH] makedumpfile: Fix a bug when multi-threads feature meets enospace Zhou Wenjian
     [not found]   ` <61D4E5D821F1674CB87C99F080A210BE0117AC32@BPXM01GP.gisp.nec.co.jp>
2018-02-09 11:23     ` FW: " Masahiko Hayashi
2018-02-09 11:31     ` Masahiko Hayashi
2018-02-16  2:45   ` Masaki Tachibana
2018-02-27 13:08     ` Zhou Wenjian

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=1517230479-8440-1-git-send-email-zhouwj.fi@gmail.com \
    --to=zhouwj.fi@gmail.com \
    --cc=ats-kumagai@wm.jp.nec.com \
    --cc=kexec@lists.infradead.org \
    /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