[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20150824015945.58b25f3a@brouer.com>
Date: Mon, 24 Aug 2015 01:59:45 +0200
From: Jesper Dangaard Brouer <netdev@...uer.com>
To: "Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
Hugh Dickins <hughd@...gle.com>,
Andrea Arcangeli <aarcange@...hat.com>,
Dave Hansen <dave.hansen@...el.com>,
Vlastimil Babka <vbabka@...e.cz>,
Johannes Weiner <hannes@...xchg.org>,
Michal Hocko <mhocko@...e.cz>,
David Rientjes <rientjes@...gle.com>,
linux-kernel@...r.kernel.org, linux-mm@...ck.org,
Christoph Lameter <cl@...ux.com>
Subject: Re: [PATCHv3 4/5] mm: make compound_head() robust
On Wed, 19 Aug 2015 12:21:45 +0300
"Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com> wrote:
> Hugh has pointed that compound_head() call can be unsafe in some
> context. There's one example:
>
[...]
> diff --git a/include/linux/mm.h b/include/linux/mm.h
> index 0735bc0a351a..a4c4b7d07473 100644
> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
[...]
> -/*
> - * If we access compound page synchronously such as access to
> - * allocated page, there is no need to handle tail flag race, so we can
> - * check tail flag directly without any synchronization primitive.
> - */
> -static inline struct page *compound_head_fast(struct page *page)
> -{
> - if (unlikely(PageTail(page)))
> - return page->first_page;
> - return page;
> -}
> -
[...]
> @@ -548,13 +508,7 @@ static inline struct page *virt_to_head_page(const void *x)
> {
> struct page *page = virt_to_page(x);
>
> - /*
> - * We don't need to worry about synchronization of tail flag
> - * when we call virt_to_head_page() since it is only called for
> - * already allocated page and this page won't be freed until
> - * this virt_to_head_page() is finished. So use _fast variant.
> - */
> - return compound_head_fast(page);
> + return compound_head(page);
> }
I hope this does not slow down the SLAB/slub allocator?
(which calls virt_to_head_page() frequently)
--
Best regards,
Jesper Dangaard Brouer
MSc.CS, Sr. Network Kernel Developer at Red Hat
Author of http://www.iptv-analyzer.org
LinkedIn: http://www.linkedin.com/in/brouer
--
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