Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1211699 > unrolled thread
| Started by | Jesper Dangaard Brouer <netdev@brouer.com> |
|---|---|
| First post | 2015-08-24 02:20 +0200 |
| Last post | 2015-08-24 11:40 +0200 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: [PATCHv3 4/5] mm: make compound_head() robust Jesper Dangaard Brouer <netdev@brouer.com> - 2015-08-24 02:20 +0200
Re: [PATCHv3 4/5] mm: make compound_head() robust "Kirill A. Shutemov" <kirill@shutemov.name> - 2015-08-24 11:40 +0200
| From | Jesper Dangaard Brouer <netdev@brouer.com> |
|---|---|
| Date | 2015-08-24 02:20 +0200 |
| Subject | Re: [PATCHv3 4/5] mm: make compound_head() robust |
| Message-ID | <q0NEu-8ab-7@gated-at.bofh.it> |
On Wed, 19 Aug 2015 12:21:45 +0300
"Kirill A. Shutemov" <kirill.shutemov@linux.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@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | "Kirill A. Shutemov" <kirill@shutemov.name> |
|---|---|
| Date | 2015-08-24 11:40 +0200 |
| Message-ID | <q0Wos-3Lk-21@gated-at.bofh.it> |
| In reply to | #1211699 |
On Mon, Aug 24, 2015 at 01:59:45AM +0200, Jesper Dangaard Brouer wrote:
> On Wed, 19 Aug 2015 12:21:45 +0300
> "Kirill A. Shutemov" <kirill.shutemov@linux.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)
It should be slightly faster.
Before:
00002e90 <test_virt_to_head_page>:
2e90: 8b 15 00 00 00 00 mov 0x0,%edx
2e96: 05 00 00 00 40 add $0x40000000,%eax
2e9b: c1 e8 0c shr $0xc,%eax
2e9e: c1 e0 05 shl $0x5,%eax
2ea1: 01 d0 add %edx,%eax
2ea3: 8b 10 mov (%eax),%edx
2ea5: f6 c6 80 test $0x80,%dh
2ea8: 75 06 jne 2eb0 <test_virt_to_head_page+0x20>
2eaa: c3 ret
2eab: 90 nop
2eac: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
2eb0: 8b 40 1c mov 0x1c(%eax),%eax
2eb3: c3 ret
After:
00003070 <test_virt_to_head_page>:
3070: 8b 15 00 00 00 00 mov 0x0,%edx
3076: 05 00 00 00 40 add $0x40000000,%eax
307b: c1 e8 0c shr $0xc,%eax
307e: c1 e0 05 shl $0x5,%eax
3081: 01 d0 add %edx,%eax
3083: 8b 50 14 mov 0x14(%eax),%edx
3086: 8d 4a ff lea -0x1(%edx),%ecx
3089: f6 c2 01 test $0x1,%dl
308c: 0f 45 c1 cmovne %ecx,%eax
308f: c3 ret
--
Kirill A. Shutemov
--
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/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web