Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1244440
| From | Vlastimil Babka <vbabka@suse.cz> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [RFC] mm: fix a BUG, the page is allocated 2 times |
| Date | 2015-10-12 09:40 +0200 |
| Message-ID | <qiFS9-Bb-3@gated-at.bofh.it> (permalink) |
| References | <qiBlw-2to-13@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On 10/12/2015 04:40 AM, yalin wang wrote:
> Remove unlikely(order), because we are sure order is not zero if
> code reach here, also add if (page == NULL), only allocate page again if
> __rmqueue_smallest() failed or alloc_flags & ALLOC_HARDER == 0
The second mentioned change is actually more important as it removes a
memory leak! Thanks for catching this. The problem is in patch
mm-page_alloc-reserve-pageblocks-for-high-order-atomic-allocations-on-demand.patch
and seems to have been due to a change in the last submitted version to
make sure the tracepoint is called.
> Signed-off-by: yalin wang <yalin.wang2010@gmail.com>
> ---
> mm/page_alloc.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index 0d6f540..de82e2c 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -2241,13 +2241,13 @@ struct page *buffered_rmqueue(struct zone *preferred_zone,
> spin_lock_irqsave(&zone->lock, flags);
>
> page = NULL;
> - if (unlikely(order) && (alloc_flags & ALLOC_HARDER)) {
> + if (alloc_flags & ALLOC_HARDER) {
> page = __rmqueue_smallest(zone, order, MIGRATE_HIGHATOMIC);
> if (page)
> trace_mm_page_alloc_zone_locked(page, order, migratetype);
> }
> -
> - page = __rmqueue(zone, order, migratetype, gfp_flags);
> + if (page == NULL)
"if (!page)" is more common and already used below.
We could skip the check for !page in case we don't go through the
ALLOC_HARDER branch, but I guess it's not worth the goto, and hopefully
the compiler is smart enough anyway...
> + page = __rmqueue(zone, order, migratetype, gfp_flags);
> spin_unlock(&zone->lock);
> if (!page)
> goto failed;
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[RFC] mm: fix a BUG, the page is allocated 2 times yalin wang <yalin.wang2010@gmail.com> - 2015-10-12 04:50 +0200
Re: [RFC] mm: fix a BUG, the page is allocated 2 times Vlastimil Babka <vbabka@suse.cz> - 2015-10-12 09:40 +0200
Re: [RFC] mm: fix a BUG, the page is allocated 2 times yalin wang <yalin.wang2010@gmail.com> - 2015-10-12 10:00 +0200
Re: [RFC] mm: fix a BUG, the page is allocated 2 times "Kirill A. Shutemov" <kirill@shutemov.name> - 2015-10-12 12:10 +0200
Re: [RFC] mm: fix a BUG, the page is allocated 2 times Vlastimil Babka <vbabka@suse.cz> - 2015-10-12 13:30 +0200
Re: [RFC] mm: fix a BUG, the page is allocated 2 times Mel Gorman <mgorman@techsingularity.net> - 2015-10-12 16:00 +0200
Re: [RFC] mm: fix a BUG, the page is allocated 2 times yalin wang <yalin.wang2010@gmail.com> - 2015-10-13 03:50 +0200
csiph-web