linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: 郭雪楠 <guoxuenan@huawei.com>
To: Michal Hocko <mhocko@kernel.org>
Cc: <akpm@linux-foundation.org>, <minchan@kernel.org>,
	<linux-mm@kvack.org>, <linux-kernel@vger.kernel.org>,
	<rppt@linux.vnet.ibm.com>, <yi.zhang@huawei.com>,
	<miaoxie@huawei.com>, <aarcange@redhat.com>,
	<mgorman@techsingularity.net>, <kirill.shutemov@linux.intel.com>,
	<rientjes@google.com>, <khandual@linux.vnet.ibm.com>,
	<riel@redhat.com>, <hillf.zj@alibaba-inc.com>, <shli@fb.com>
Subject: Re: [PATCH] mm,madvise: bugfix of madvise systemcall infinite loop under special circumstances.
Date: Mon, 27 Nov 2017 10:54:39 +0800	[thread overview]
Message-ID: <cef000ae-c74d-f460-64d8-0be23350005b@huawei.com> (raw)
In-Reply-To: <52b8bab4-6656-fe76-ed21-ee3c4682a5e3@huawei.com>

Hi,Michal, Whether  need me to modify according your modification and 
resubmit a new patch?

在 2017/11/25 9:52, 郭雪楠 写道:
> Yes , your modification is much better! thanks.
> 
> 在 2017/11/24 21:08, Michal Hocko 写道:
>> On Fri 24-11-17 20:51:29, 郭雪楠 wrote:
>>> Sorry,I explained  wrong before. But,I've tested using trinity in DAX
>>> mode,and I'am sure it has possibility of triggering an soft lockup. I 
>>> have
>>> encountered the problem of endless loop here .
>>>
>>> I had a little problem here,I correct it .
>>> under Initial state :
>>> [ start = vam->vm_start < vam->vm_end < end ]
>>>
>>> When [start = vam->vm_start] the program enters  for{;;} loop
>>> ,find_vma_prev() will set the pointer vma and the pointer prev (prev =
>>> vam->vm_prev ). Normally ,madvise_vma() will always move the pointer 
>>> prev
>>> ,but when use DAX mode , it will never update .
>> [...]
>>> if (prev) // here prev not NULL,it will always enter this branch ..
>>>     vma = prev->vm_next;
>>> else    /* madvise_remove dropped mmap_sem */
>>>     vma = find_vma(current->mm, start);
>>
>> You are right! My fault, I managed to confuse myself in the code flow.
>> It really looks like this has been broken for more than 10 years since
>> fe77ba6f4f97 ("[PATCH] xip: madvice/fadvice: execute in place").
>>
>> Maybe the following would be more readable and less error prone?
>> ---
>> diff --git a/mm/madvise.c b/mm/madvise.c
>> index 375cf32087e4..a631c414f915 100644
>> --- a/mm/madvise.c
>> +++ b/mm/madvise.c
>> @@ -276,30 +276,26 @@ static long madvise_willneed(struct 
>> vm_area_struct *vma,
>>   {
>>       struct file *file = vma->vm_file;
>> +    *prev = vma;
>>   #ifdef CONFIG_SWAP
>>       if (!file) {
>> -        *prev = vma;
>>           force_swapin_readahead(vma, start, end);
>>           return 0;
>>       }
>> -    if (shmem_mapping(file->f_mapping)) {
>> -        *prev = vma;
>> +    if (shmem_mapping(file->f_mapping))
>>           force_shm_swapin_readahead(vma, start, end,
>>                       file->f_mapping);
>>           return 0;
>> -    }
>>   #else
>>       if (!file)
>>           return -EBADF;
>>   #endif
>> -    if (IS_DAX(file_inode(file))) {
>> +    if (IS_DAX(file_inode(file)))
>>           /* no bad return value, but ignore advice */
>>           return 0;
>> -    }
>> -    *prev = vma;
>>       start = ((start - vma->vm_start) >> PAGE_SHIFT) + vma->vm_pgoff;
>>       if (end > vma->vm_end)
>>           end = vma->vm_end;
>>

  reply	other threads:[~2017-11-27  3:16 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-24  2:27 [PATCH] mm,madvise: bugfix of madvise systemcall infinite loop under special circumstances guoxuenan
2017-11-24  8:05 ` Michal Hocko
     [not found]   ` <829af987-4d65-382c-dbd4-0c81222ebb51@huawei.com>
     [not found]     ` <20171124130803.hafb3zbhy7gdqkvi@dhcp22.suse.cz>
2017-11-25  1:52       ` 郭雪楠
2017-11-27  2:54         ` 郭雪楠 [this message]
2017-11-27  7:59           ` Michal Hocko
2017-11-27 11:53 guoxuenan
2017-11-27 11:58 ` Michal Hocko
2017-11-27 12:28   ` guoxuenan
2017-11-27 12:42   ` Mike Rapoport

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=cef000ae-c74d-f460-64d8-0be23350005b@huawei.com \
    --to=guoxuenan@huawei.com \
    --cc=aarcange@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=hillf.zj@alibaba-inc.com \
    --cc=khandual@linux.vnet.ibm.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mgorman@techsingularity.net \
    --cc=mhocko@kernel.org \
    --cc=miaoxie@huawei.com \
    --cc=minchan@kernel.org \
    --cc=riel@redhat.com \
    --cc=rientjes@google.com \
    --cc=rppt@linux.vnet.ibm.com \
    --cc=shli@fb.com \
    --cc=yi.zhang@huawei.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;
as well as URLs for NNTP newsgroup(s).