From: "Srivatsa S. Bhat" <srivatsa.bhat@linux.vnet.ibm.com>
To: Andrea Arcangeli <aarcange@redhat.com>
Cc: "Rafael J. Wysocki" <rjw@suse.com>,
linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
Jiri Slaby <jirislaby@gmail.com>,
linux-mm@kvack.org, Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] thp: reduce khugepaged freezing latency
Date: Wed, 09 Nov 2011 14:33:13 +0530 [thread overview]
Message-ID: <4EBA41D1.3020008@linux.vnet.ibm.com> (raw)
In-Reply-To: <20111109000146.GA5075@redhat.com>
On 11/09/2011 05:31 AM, Andrea Arcangeli wrote:
> On Wed, Nov 09, 2011 at 01:31:07AM +0530, Srivatsa S. Bhat wrote:
>> On 11/08/2011 08:59 PM, Andrea Arcangeli wrote:
>>> Lack of set_freezable_with_signal() prevented khugepaged to be waken
>>> up (and prevented to sleep again) across the
>>> schedule_timeout_interruptible() calls after freezing() becomes
>>> true. The tight loop in khugepaged_alloc_hugepage() also missed one
>>> try_to_freeze() call in case alloc_hugepage() would repeatedly fail in
>>> turn preventing the loop to break and to reach the try_to_freeze() in
>>> the khugepaged main loop.
>>>
>>> khugepaged would still freeze just fine by trying again the next
>>> minute but it's better if it freezes immediately.
>>>
>>> Reported-by: Jiri Slaby <jslaby@suse.cz>
>>> Signed-off-by: Andrea Arcangeli <aarcange@redhat.com>
>>> ---
>>> mm/huge_memory.c | 3 ++-
>>> 1 files changed, 2 insertions(+), 1 deletions(-)
>>>
>>> diff --git a/mm/huge_memory.c b/mm/huge_memory.c
>>> index 4298aba..67311d1 100644
>>> --- a/mm/huge_memory.c
>>> +++ b/mm/huge_memory.c
>>> @@ -2277,6 +2277,7 @@ static struct page *khugepaged_alloc_hugepage(void)
>>> if (!hpage) {
>>> count_vm_event(THP_COLLAPSE_ALLOC_FAILED);
>>> khugepaged_alloc_sleep();
>>> + try_to_freeze();
>>> } else
>>> count_vm_event(THP_COLLAPSE_ALLOC);
>>> } while (unlikely(!hpage) &&
>>> @@ -2331,7 +2332,7 @@ static int khugepaged(void *none)
>>> {
>>> struct mm_slot *mm_slot;
>>>
>>> - set_freezable();
>>> + set_freezable_with_signal();
>>> set_user_nice(current, 19);
>>>
>>> /* serialize with start_khugepaged() */
>>>
>>
>> Why do we need to use both set_freezable_with_signal() and an additional
>> try_to_freeze()? Won't just using either one of them be good enough?
>> Or am I missing something here?
>
> set_freezable_with_signal() makes khugepaged quit and not re-enter the
> sleep, try_to_freeze is needed to get the task from freezing to
> frozen, otherwise it'll loop without getting frozen.
>
Sorry, I still don't get it. Correct me if I am wrong, but my understanding
is this:
There are 2 ways to freeze a freezable kernel thread (one which has unset
the PF_NOFREEZE flag by calling set_freezable()):
set TIF_FREEZE flag and,
a) send a signal if PF_FREEZER_NOSIG is unset for that kernel thread (due
to the call to set_freezable_with_signal()). Then, try_to_freeze() will
get called in the signal handler.
b) otherwise, just wake up the kernel thread and hope that the kernel thread
itself will call try_to_freeze() sometime soon.
Now coming to your patch,
Case 1: You use set_freezable_with_signal() instead of set_freezable():
In this case, since the kernel thread doesn't block signals for
freezing, it will get a signal (with TIF_FREEZE set) and the signal
handler will call try_to_freeze(). So, no need for additional
try_to_freeze() here.
Case 2: You add the extra try_to_freeze():
In this case, the freezer will wake up the kernel thread, which in
turn will now execute the newly added try_to_freeze() and will get
frozen successfully. So, no need for set_freezable_with_signal() here.
Rafael, am I right?
Thanks,
Srivatsa S. Bhat
WARNING: multiple messages have this Message-ID (diff)
From: "Srivatsa S. Bhat" <srivatsa.bhat@linux.vnet.ibm.com>
To: Andrea Arcangeli <aarcange@redhat.com>
Cc: "Rafael J. Wysocki" <rjw@suse.com>,
linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
Jiri Slaby <jirislaby@gmail.com>,
linux-mm@kvack.org, Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] thp: reduce khugepaged freezing latency
Date: Wed, 09 Nov 2011 14:33:13 +0530 [thread overview]
Message-ID: <4EBA41D1.3020008@linux.vnet.ibm.com> (raw)
In-Reply-To: <20111109000146.GA5075@redhat.com>
On 11/09/2011 05:31 AM, Andrea Arcangeli wrote:
> On Wed, Nov 09, 2011 at 01:31:07AM +0530, Srivatsa S. Bhat wrote:
>> On 11/08/2011 08:59 PM, Andrea Arcangeli wrote:
>>> Lack of set_freezable_with_signal() prevented khugepaged to be waken
>>> up (and prevented to sleep again) across the
>>> schedule_timeout_interruptible() calls after freezing() becomes
>>> true. The tight loop in khugepaged_alloc_hugepage() also missed one
>>> try_to_freeze() call in case alloc_hugepage() would repeatedly fail in
>>> turn preventing the loop to break and to reach the try_to_freeze() in
>>> the khugepaged main loop.
>>>
>>> khugepaged would still freeze just fine by trying again the next
>>> minute but it's better if it freezes immediately.
>>>
>>> Reported-by: Jiri Slaby <jslaby@suse.cz>
>>> Signed-off-by: Andrea Arcangeli <aarcange@redhat.com>
>>> ---
>>> mm/huge_memory.c | 3 ++-
>>> 1 files changed, 2 insertions(+), 1 deletions(-)
>>>
>>> diff --git a/mm/huge_memory.c b/mm/huge_memory.c
>>> index 4298aba..67311d1 100644
>>> --- a/mm/huge_memory.c
>>> +++ b/mm/huge_memory.c
>>> @@ -2277,6 +2277,7 @@ static struct page *khugepaged_alloc_hugepage(void)
>>> if (!hpage) {
>>> count_vm_event(THP_COLLAPSE_ALLOC_FAILED);
>>> khugepaged_alloc_sleep();
>>> + try_to_freeze();
>>> } else
>>> count_vm_event(THP_COLLAPSE_ALLOC);
>>> } while (unlikely(!hpage) &&
>>> @@ -2331,7 +2332,7 @@ static int khugepaged(void *none)
>>> {
>>> struct mm_slot *mm_slot;
>>>
>>> - set_freezable();
>>> + set_freezable_with_signal();
>>> set_user_nice(current, 19);
>>>
>>> /* serialize with start_khugepaged() */
>>>
>>
>> Why do we need to use both set_freezable_with_signal() and an additional
>> try_to_freeze()? Won't just using either one of them be good enough?
>> Or am I missing something here?
>
> set_freezable_with_signal() makes khugepaged quit and not re-enter the
> sleep, try_to_freeze is needed to get the task from freezing to
> frozen, otherwise it'll loop without getting frozen.
>
Sorry, I still don't get it. Correct me if I am wrong, but my understanding
is this:
There are 2 ways to freeze a freezable kernel thread (one which has unset
the PF_NOFREEZE flag by calling set_freezable()):
set TIF_FREEZE flag and,
a) send a signal if PF_FREEZER_NOSIG is unset for that kernel thread (due
to the call to set_freezable_with_signal()). Then, try_to_freeze() will
get called in the signal handler.
b) otherwise, just wake up the kernel thread and hope that the kernel thread
itself will call try_to_freeze() sometime soon.
Now coming to your patch,
Case 1: You use set_freezable_with_signal() instead of set_freezable():
In this case, since the kernel thread doesn't block signals for
freezing, it will get a signal (with TIF_FREEZE set) and the signal
handler will call try_to_freeze(). So, no need for additional
try_to_freeze() here.
Case 2: You add the extra try_to_freeze():
In this case, the freezer will wake up the kernel thread, which in
turn will now execute the newly added try_to_freeze() and will get
frozen successfully. So, no need for set_freezable_with_signal() here.
Rafael, am I right?
Thanks,
Srivatsa S. Bhat
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2011-11-09 9:03 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-08 8:33 khugepaged doesn't want to freeze Jiri Slaby
2011-11-08 8:33 ` Jiri Slaby
2011-11-08 15:29 ` Andrea Arcangeli
2011-11-08 15:29 ` Andrea Arcangeli
2011-11-08 15:29 ` [PATCH] thp: reduce khugepaged freezing latency Andrea Arcangeli
2011-11-08 15:29 ` Andrea Arcangeli
2011-11-08 20:01 ` Srivatsa S. Bhat
2011-11-08 20:01 ` Srivatsa S. Bhat
2011-11-09 0:01 ` Andrea Arcangeli
2011-11-09 0:01 ` Andrea Arcangeli
2011-11-09 9:03 ` Srivatsa S. Bhat [this message]
2011-11-09 9:03 ` Srivatsa S. Bhat
2011-11-09 12:45 ` Srivatsa S. Bhat
2011-11-09 12:45 ` Srivatsa S. Bhat
2011-11-09 15:53 ` Tejun Heo
2011-11-09 15:53 ` Tejun Heo
2011-11-09 16:20 ` Srivatsa S. Bhat
2011-11-09 16:20 ` Srivatsa S. Bhat
2011-11-09 16:52 ` Andrea Arcangeli
2011-11-09 16:52 ` Andrea Arcangeli
2011-11-09 16:59 ` Tejun Heo
2011-11-09 16:59 ` Tejun Heo
2011-11-09 17:02 ` Tejun Heo
2011-11-09 17:02 ` Tejun Heo
2011-11-09 17:29 ` Andrea Arcangeli
2011-11-09 17:29 ` Andrea Arcangeli
2011-11-09 18:09 ` Tejun Heo
2011-11-09 18:09 ` Tejun Heo
2011-11-09 18:19 ` Andrea Arcangeli
2011-11-09 18:19 ` Andrea Arcangeli
2011-11-09 18:34 ` Tejun Heo
2011-11-09 18:34 ` Tejun Heo
2011-11-09 19:40 ` Andrea Arcangeli
2011-11-09 19:40 ` Andrea Arcangeli
2011-11-11 12:20 ` Jiri Slaby
2011-11-11 12:20 ` Jiri Slaby
2011-11-09 17:06 ` Tejun Heo
2011-11-09 17:06 ` Tejun Heo
2011-11-09 17:33 ` Andrea Arcangeli
2011-11-09 17:33 ` Andrea Arcangeli
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=4EBA41D1.3020008@linux.vnet.ibm.com \
--to=srivatsa.bhat@linux.vnet.ibm.com \
--cc=aarcange@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=jirislaby@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-pm@vger.kernel.org \
--cc=rjw@suse.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.