[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <523C0FAF.10401@suse.cz>
Date: Fri, 20 Sep 2013 11:04:47 +0200
From: Vlastimil Babka <vbabka@...e.cz>
To: Bob Liu <bob.liu@...cle.com>
Cc: Fengguang Wu <fengguang.wu@...el.com>, linux-mm@...ck.org,
linux-kernel@...r.kernel.org,
Jörn Engel <joern@...fs.org>,
Mel Gorman <mgorman@...e.de>,
Michel Lespinasse <walken@...gle.com>,
Hugh Dickins <hughd@...gle.com>,
Rik van Riel <riel@...hat.com>,
Johannes Weiner <hannes@...xchg.org>,
Michal Hocko <mhocko@...e.cz>
Subject: Re: [RFC PATCH RESEND] mm: munlock: Prevent walking off the end of
a pagetable in no-pmd configuration
On 09/18/2013 03:17 AM, Bob Liu wrote:
> On 09/17/2013 10:22 PM, Vlastimil Babka wrote:
>> --- a/mm/mlock.c
>> +++ b/mm/mlock.c
>> @@ -379,10 +379,14 @@ static unsigned long __munlock_pagevec_fill(struct pagevec *pvec,
>>
>> /*
>> * Initialize pte walk starting at the already pinned page where we
>> - * are sure that there is a pte.
>> + * are sure that there is a pte, as it was pinned under the same
>> + * mmap_sem write op.
>> */
>> pte = get_locked_pte(vma->vm_mm, start, &ptl);
>> - end = min(end, pmd_addr_end(start, end));
>> + /* Make sure we do not cross the page table boundary */
>> + end = pgd_addr_end(start, end);
>> + end = pud_addr_end(start, end);
>> + end = pmd_addr_end(start, end);
>>
>
> Nitpick, how about unfolding pmd_addr_end(start, end) directly? Like:
>
> --- a/mm/mlock.c
> +++ b/mm/mlock.c
> @@ -376,13 +376,14 @@ static unsigned long __munlock_pagevec_fill(struct
> pagevec *pvec,
> {
> pte_t *pte;
> spinlock_t *ptl;
> + unsigned long pmd_end = (start + PMD_SIZE) & PMD_MASK;
> + end = (pmd_end - 1 < end - 1) ? pmd_end : end;
>
> /*
> * Initialize pte walk starting at the already pinned page where we
> * are sure that there is a pte.
> */
> pte = get_locked_pte(vma->vm_mm, start, &ptl);
> - end = min(end, pmd_addr_end(start, end));
>
> /* The page next to the pinned page is the first we will try to
> get */
> start += PAGE_SIZE;
>
That should also work but for maintainability reasons I wouldn't like to
special case it like this, instead of using standard functions as they
would be used in a full pagewalk.
> Anyway,
> Reviewed-by: Bob Liu <bob.liu@...cle.com>
Thanks.
Vlastimil
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists