Kexec Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "\"Zhou, Wenjian/周文?\"" <zhouwj-fnst@cn.fujitsu.com>
To: Minoru Usui <min-usui@ti.jp.nec.com>,
	"kexec@lists.infradead.org" <kexec@lists.infradead.org>
Subject: Re: [PATCH v2] Improve the performance of --num-threads -d 31
Date: Wed, 2 Mar 2016 11:59:25 +0800	[thread overview]
Message-ID: <56D6651D.2050705@cn.fujitsu.com> (raw)
In-Reply-To: <BE691E4CBA06214BB0FA8EEFC7C61A4D0181914F@BPXM02GP.gisp.nec.co.jp>

Hi,

On 03/02/2016 11:05 AM, Minoru Usui wrote:
> Hi, Zhou
> 
>>>>>>> ===
>>>>>>>       producer                   Consumer
>>>>>>> ---------------------------------------------------------
>>>>>>>       pthread_mutex_lock()
>>>>>>>       pfn = info->current_pfn
>>>>>>>                                  info->current_pfn = end_pfn
>>>>>>>       info->current_pfn++
>>>>>>>         -> end_pfn + 1
>>>>>>>       pthread_mutex_unlock()
>>>>>>> ===
>>
>> How about just changing "info->current_pfn = end_pfn" to "info->current_pfn--" ?
>> Just like the first version of the patch.
> 
> If you don't get mutex lock in consumer side, this change is meaningless.
> Of course, info->current_pfn may equal to end_pfn at the end of the cycle,
> but there is a timing that info->current_pfn is bigger than end_pfn in processing producer thread.
> 
> The root cause is producer increments info->current_pfn everytime, even if info->current_pfn == end_pfn
> in following code.
> 

Actually, I didn't get what you mean exactly until this letter...

I think there is no problem if the info->current_pfn is larger than the end_pfn
in the function write_kdump_pages_parallel_cyclic(), for no other one will use
current_pfn here.
Since we can't and needn't prevent using info->current_pfn outside the function,
we should keep info->current_pfn correct before returning from the function.

> ===
>>>>> +			/* get next pfn */
>>>>> +			pthread_mutex_lock(&info->current_pfn_mutex);
>>>>> +			pfn = info->current_pfn;
>>>>> +			info->current_pfn++;                        # increment everytime
>>>>> +			page_flag_buf->ready = FLAG_FILLING;
>>>>> +			pthread_mutex_unlock(&info->current_pfn_mutex);
>>>>>
>>>>> -			buf_ready = TRUE;
>>>>> +			page_flag_buf->pfn = pfn;
>>>>>
>>>>> -			page_data_buf[index].pfn = pfn;
>>>>> -			page_data_buf[index].ready = 1;
>>>>> +			if (pfn >= kdump_thread_args->end_pfn) {
>>>>> +				page_data_buf[index].used = FALSE;
>>>>> +				page_flag_buf->ready = FLAG_READY;
>>>>> +				break;                             # not decrement
>>>>> +			}
> ===
> 
> If you don't allow info->current_pfn is bigger than end_pfn,
> you don't need to increment info->current_pfn when pfn >= kdump_thread_args->end_pfn like following.
> 
> ===
>                          /* get next pfn */
>                          pthread_mutex_lock(&info->current_pfn_mutex);
>                          pfn = info->current_pfn;
>                          page_flag_buf->pfn = pfn;
>                          if (pfn >= kdump_thread_args->end_pfn) {
>                                  page_data_buf[index].used = FALSE;
>                                  page_flag_buf->ready = FLAG_READY;
>                                  pthread_mutex_unlock(&info->current_pfn_mutex);
>                                  break;
>                          }
>                          page_flag_buf->ready = FLAG_FILLING;
>                          info->current_pfn++;
>                          pthread_mutex_unlock(&info->current_pfn_mutex);
> ===
> 
> If you allow info->current_pfn is bigger than end_pfn, producer doesn't need to change info->current_pfn.
> 

I also have thought about it.
It can keep current_pfn never larger than the end.
But it also makes the code a bit more complex.
If there aren't any special reason, I don't think it's worth to do it.

-- 
Thanks
Zhou



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

  parent reply	other threads:[~2016-03-02  4:01 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-17  7:05 [PATCH v2] Improve the performance of --num-threads -d 31 Zhou Wenjian
2016-02-22 16:58 ` Minfei Huang
2016-02-23  5:26   ` Minfei Huang
2016-02-23  5:47     ` "Zhou, Wenjian/周文剑"
2016-02-24  1:43       ` Minfei Huang
2016-02-24  2:20         ` "Zhou, Wenjian/周文剑"
2016-02-24  2:24           ` Minfei Huang
2016-03-01  6:59             ` "Zhou, Wenjian/周文剑"
2016-03-01  8:16               ` Minfei Huang
2016-03-02 10:25                 ` Minfei Huang
2016-03-04  0:59                   ` Minoru Usui
2016-03-04  4:17                     ` Minfei Huang
2016-03-01  7:20             ` "Zhou, Wenjian/周文剑"
2016-03-01  8:17               ` Minfei Huang
2016-02-23  1:32 ` Minoru Usui
2016-02-23  3:45   ` "Zhou, Wenjian/周文?"
2016-02-23  8:00     ` Minoru Usui
2016-02-23  8:29       ` "Zhou, Wenjian/周文?"
2016-02-24  0:45         ` Minoru Usui
2016-03-01  7:49           ` "Zhou, Wenjian/周文?"
2016-03-02  3:05             ` Minoru Usui
2016-03-02  3:16               ` Minoru Usui
2016-03-02  3:59               ` "Zhou, Wenjian/周文?" [this message]
2016-03-02  6:23                 ` Minoru Usui
2016-02-24  8:13 ` Minoru Usui
2016-03-01  7:34   ` "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=56D6651D.2050705@cn.fujitsu.com \
    --to=zhouwj-fnst@cn.fujitsu.com \
    --cc=kexec@lists.infradead.org \
    --cc=min-usui@ti.jp.nec.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