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: Tue, 1 Mar 2016 15:49:50 +0800 [thread overview]
Message-ID: <56D5499E.10809@cn.fujitsu.com> (raw)
In-Reply-To: <BE691E4CBA06214BB0FA8EEFC7C61A4D0180E77E@BPXM02GP.gisp.nec.co.jp>
Hi,
On 02/24/2016 08:45 AM, Minoru Usui wrote:
>>>>>>
>>>>>> - /*
>>>>>> - * check pfn first without mutex locked to reduce the time
>>>>>> - * trying to lock the mutex
>>>>>> - */
>>>>>> - if (page_data_buf[index].pfn != consuming_pfn)
>>>>>> - continue;
>>>>>> + info->page_flag_buf[i]->ready = FLAG_UNUSED;
>>>>>>
>>>>>> - if (pthread_mutex_trylock(&page_data_buf[index].mutex) != 0)
>>>>>> - continue;
>>>>>> + info->current_pfn = end_pfn;
>>>>>
>>>>> This part doesn't get info->current_pfn_mutex.
>>>>> It becomes bigger than end_pfn at the end of producer thread in following case.
>>>>>
>>>>> ===
>>>>> producer Consumer
>>>>> ---------------------------------------------------------
>>>>> pthread_mutex_lock()
>>>>> pfn = info->current_pfn
>>>>> info->current_pfn = end_pfn
>>>>> info->current_pfn++
>>>>> -> end_pfn + 1
>>>>> pthread_mutex_unlock()
>>>>> ===
>>>>>
>>>>> But I know, if this race is happened, processing other producer thread and consumer thread works well
>>>>> in current cycle.
>>>>> Because each thread checks whether info->current_pfn >= end_pfn.
>>>>>
>>>>> On the other hand, info->current_pfn is initialized to cycle->start_pfn before pthread_create()
>>>>> in write_kdump_pages_parallel_cyclic().
>>>>> This means it does not cause a problem in next cycle, too.
>>>>>
>>>>> In other words, my point is following.
>>>>>
>>>>> a) When info->current_pfn changes, you have to get info->current_pfn_mutex.
>>>>> b) If you allow info->current_pfn is bigger than end_pfn at the end of each cycle,
>>>>> "info->current_pfn = end_pfn;" is unnecessary.
>>>>>
>>>>> Honestly, I don't like approach b).
>>>>
>>>> You're right. Some thing I thought is wrong.
>>>> But I don't like lock if I have other choice.
>>>> I will set info->current_pfn before returning.
>>>> How about it?
>>>
>>> If you mean you set info->current_pfn by producer side,
>>> this race will occur between producer A and producer B.
>>>
>>> I think you can't avoid getting mutex lock, if you will change info->current_pfn.
>>>
>>
>> I mean setting it by consumer.
>
> I'm sorry, I can't imagine your proposal.
> What do you change?
>
> Please show me the code.
>
At that time, I meant setting the current_pfn at the end of the function
write_kdump_pages_parallel_cyclic().
But I don't think it is good choice now.
>>>>> ===
>>>>> 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.
--
Thanks
Zhou
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
next prev parent reply other threads:[~2016-03-01 7:51 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/周文?" [this message]
2016-03-02 3:05 ` Minoru Usui
2016-03-02 3:16 ` Minoru Usui
2016-03-02 3:59 ` "Zhou, Wenjian/周文?"
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=56D5499E.10809@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.