Skip to contentSkip to conversation

makedumpfile: Fix a bug when multi-threads feature meets enospace

PATCH In review Zhou Wenjian 3 participants 6 messages Jan 29, 2018 – Feb 27, 2018 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 makedumpfile: Fix a bug when multi-threads feature meets enospace

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{}.

---
 makedumpfile.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
makedumpfile.c +3 -1
index ed138d3..f7ad50c 100644
@@ -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();
Signature · 7 lines
1.8.3.1


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#1 lore raw

ping...

Quoted 39 lines · Zhou Wenjian

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{}.

---
  makedumpfile.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
makedumpfile.c +3 -1
index ed138d3..f7ad50c 100644
@@ -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();
Signature · 8 lines
Thanks
Zhou


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

A message that is not in the archive (sent off-list or not yet received): [email protected]

#3 lore raw

PATCH 1/1 makedumpfile: Fix a bug when multi-threads feature meets enospace

Quoted 7 lines

-----Original Message-----
From: Tachibana Masaki(橘 正樹)
Sent: Friday, February 09, 2018 8:05 PM
To: Zhou Wenjian <[email protected]>
Cc: [email protected]; Hayashi Masahiko(林 正彦) <[email protected]>
Subject: RE: [PATCH] makedumpfile: Fix a bug when multi-threads feature meets enospace

Quoted 69 lines

Hi Zhou,

Sorry for the late reply.
Makedumpfile team are busy now for another development. I'll reply in about a week.

Thanks
tachibana

Quoted 60 lines

-----Original Message-----
From: kexec [mailto:[email protected]] On Behalf Of Zhou Wenjian
Sent: Thursday, February 08, 2018 8:53 PM
To: [email protected]
Cc: Kumagai Atsushi <[email protected]>; Suzuki Keiichirou <[email protected]>
Subject: Re: [PATCH] makedumpfile: Fix a bug when multi-threads feature meets enospace

ping...

Quoted 29 lines · Zhou Wenjian

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{}.

---
  makedumpfile.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
makedumpfile.c +1 -0
index ed138d3..f7ad50c 100644
@@ -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);

makedumpfile.c kdump_thread_function_cyclic(void *arg) { · line 7743

Quoted 10 lines
makedumpfile.c +2 -1
  		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();

--
Thanks
Zhou

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#4 lore raw
In reply to a message not in the archive

Hi Zhou-san

I will forward Tachibana's mail.

Thank you

Quoted 83 lines

-----Original Message-----
From: Hayashi Masahiko(林 正彦)
Sent: Friday, February 09, 2018 8:24 PM
To: Zhou Wenjian <[email protected]>
Cc: [email protected]
Subject: FW: [PATCH] makedumpfile: Fix a bug when multi-threads feature meets enospace

Quoted 76 lines

-----Original Message-----
From: Tachibana Masaki(橘 正樹)
Sent: Friday, February 09, 2018 8:05 PM
To: Zhou Wenjian <[email protected]>
Cc: [email protected]; Hayashi Masahiko(林 正彦) <[email protected]>
Subject: RE: [PATCH] makedumpfile: Fix a bug when multi-threads feature meets enospace

Hi Zhou,

Sorry for the late reply.
Makedumpfile team are busy now for another development. I'll reply in about a week.

Thanks
tachibana

Quoted 60 lines

-----Original Message-----
From: kexec [mailto:[email protected]] On Behalf Of Zhou Wenjian
Sent: Thursday, February 08, 2018 8:53 PM
To: [email protected]
Cc: Kumagai Atsushi <[email protected]>; Suzuki Keiichirou <[email protected]>
Subject: Re: [PATCH] makedumpfile: Fix a bug when multi-threads feature meets enospace

ping...

Quoted 29 lines · Zhou Wenjian

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{}.

---
  makedumpfile.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
makedumpfile.c +1 -0
index ed138d3..f7ad50c 100644
@@ -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);

makedumpfile.c kdump_thread_function_cyclic(void *arg) { · line 7743

Quoted 10 lines
makedumpfile.c +2 -1
  		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();

--
Thanks
Zhou

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#5 lore raw
In reply to Zhou Wenjian

Hi,

Atsushi Kumagai has retired, so other members will maintain makedumpfile.

Wenjian

Sorry for the late reply.
Your patch looks good to me.
I'll merge it into V1.6.4.

Thanks
tachibana

Quoted 56 lines

-----Original Message-----
From: kexec [mailto:[email protected]] On Behalf Of Zhou Wenjian
Sent: Thursday, February 08, 2018 8:53 PM
To: [email protected]
Cc: Kumagai Atsushi() <[email protected]>; Suzuki Keiichirou() <[email protected]>
Subject: Re: [PATCH] makedumpfile: Fix a bug when multi-threads feature meets enospace

ping...

Quoted 29 lines · Zhou Wenjian

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{}.

---
  makedumpfile.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
makedumpfile.c +1 -0
index ed138d3..f7ad50c 100644
@@ -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);

makedumpfile.c kdump_thread_function_cyclic(void *arg) { · line 7743

Quoted 10 lines
makedumpfile.c +2 -1
  		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();

--
Thanks
Zhou

Quoted 4 lines

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#6 lore raw

Hi Tachibana,

Thanks for your reply.

And I do appreciate Kumagai-san's help these years.

Quoted 81 lines · Masaki Tachibana

Hi,

Atsushi Kumagai has retired, so other members will maintain makedumpfile.

Wenjian

Sorry for the late reply.
Your patch looks good to me.
I'll merge it into V1.6.4.

Thanks
tachibana

Quoted 55 lines

-----Original Message-----
From: kexec [mailto:[email protected]] On Behalf Of Zhou Wenjian
Sent: Thursday, February 08, 2018 8:53 PM
To: [email protected]
Cc: Kumagai Atsushi() <[email protected]>; Suzuki Keiichirou() <[email protected]>
Subject: Re: [PATCH] makedumpfile: Fix a bug when multi-threads feature meets enospace

ping...

Quoted 29 lines · Zhou Wenjian

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{}.

---
   makedumpfile.c | 4 +++-
   1 file changed, 3 insertions(+), 1 deletion(-)
makedumpfile.c +1 -0
index ed138d3..f7ad50c 100644
@@ -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);

makedumpfile.c kdump_thread_function_cyclic(void *arg) { · line 7743

Quoted 10 lines
makedumpfile.c +2 -1
   		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();

--
Thanks
Zhou

Quoted 4 lines

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

Signature · 8 lines
Thanks
Zhou


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec