From: Bob Liu <lliubbo@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: hughd@google.com, rientjes@google.com,
kamezawa.hiroyu@jp.fujitsu.com, minchan.kim@gmail.com,
linux-mm@kvack.org
Subject: Re: [PATCH 2/2] ksm: cleanup: introduce ksm_check_mm()
Date: Fri, 2 Mar 2012 10:30:07 +0800 [thread overview]
Message-ID: <CAA_GA1fU-Ah6VpnJFyFg0GzGTpj_+4YpEd-XHc5AGbcrJiaK_Q@mail.gmail.com> (raw)
In-Reply-To: <20120301125119.dee770f8.akpm@linux-foundation.org>
Hi Andrew,
On Fri, Mar 2, 2012 at 4:51 AM, Andrew Morton <akpm@linux-foundation.org> wrote:
> On Thu, 1 Mar 2012 17:32:54 +0800
> Bob Liu <lliubbo@gmail.com> wrote:
>
>> +static int ksm_check_mm(struct mm_struct *mm, struct vm_area_struct *vma,
>> + unsigned long addr)
>> +{
>> + if (ksm_test_exit(mm))
>> + return 0;
>> + vma = find_vma(mm, addr);
>> + if (!vma || vma->vm_start > addr)
>> + return 0;
>> + if (!(vma->vm_flags & VM_MERGEABLE) || !vma->anon_vma)
>> + return 0;
>> + return 1;
>> +}
>
> Can we please think of a suitable name for this check, other than
> "check"? IOW, give the function a meaningful name which describes what
> it is checking?
>
> And it's not checking the mm, is it? It is checking the address: to
> see whether it lies within a mergeable anon vma.
>
> So maybe
>
> --- a/mm/ksm.c~ksm-cleanup-introduce-ksm_check_mm-fix
> +++ a/mm/ksm.c
> @@ -375,17 +375,17 @@ static int break_ksm(struct vm_area_stru
> return (ret & VM_FAULT_OOM) ? -ENOMEM : 0;
> }
>
> -static int ksm_check_mm(struct mm_struct *mm, struct vm_area_struct *vma,
> - unsigned long addr)
> +static bool in_mergeable_anon_vma(struct mm_struct *mm,
> + struct vm_area_struct *vma, unsigned long addr)
> {
> if (ksm_test_exit(mm))
> - return 0;
> + return false;
> vma = find_vma(mm, addr);
> if (!vma || vma->vm_start > addr)
> - return 0;
> + return false;
> if (!(vma->vm_flags & VM_MERGEABLE) || !vma->anon_vma)
> - return 0;
> - return 1;
> + return false;
> + return true;
> }
>
> static void break_cow(struct rmap_item *rmap_item)
> @@ -401,7 +401,7 @@ static void break_cow(struct rmap_item *
> put_anon_vma(rmap_item->anon_vma);
>
> down_read(&mm->mmap_sem);
> - if (ksm_check_mm(mm, vma, addr))
> + if (in_mergeable_anon_vma(mm, vma, addr))
> break_ksm(vma, addr);
> up_read(&mm->mmap_sem);
> }
> @@ -428,7 +428,7 @@ static struct page *get_mergeable_page(s
> struct page *page;
>
> down_read(&mm->mmap_sem);
> - if (!ksm_check_mm(mm, vma, addr))
> + if (!in_mergeable_anon_vma(mm, vma, addr))
> goto out;
>
> page = follow_page(vma, addr, FOLL_GET);
> _
>
Yeah, It looks much better than mine, Thanks!
--
Regards,
--Bob
--
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:[~2012-03-02 2:30 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-01 9:32 [PATCH 1/2] ksm: clean up page_trans_compound_anon_split Bob Liu
2012-03-01 9:32 ` [PATCH 2/2] ksm: cleanup: introduce ksm_check_mm() Bob Liu
2012-03-01 20:51 ` Andrew Morton
2012-03-02 2:30 ` Bob Liu [this message]
2012-03-06 23:42 ` Hugh Dickins
2012-03-06 23:28 ` [PATCH 1/2] ksm: clean up page_trans_compound_anon_split Hugh Dickins
2012-03-07 0:11 ` Andrea Arcangeli
2012-03-07 0:26 ` Andrea Arcangeli
2012-03-07 10:39 ` Bob Liu
2012-03-07 15:47 ` Andrea Arcangeli
2012-03-07 1:21 ` Hugh Dickins
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=CAA_GA1fU-Ah6VpnJFyFg0GzGTpj_+4YpEd-XHc5AGbcrJiaK_Q@mail.gmail.com \
--to=lliubbo@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=hughd@google.com \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--cc=linux-mm@kvack.org \
--cc=minchan.kim@gmail.com \
--cc=rientjes@google.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