Message ID | 20220104001046.12263-8-vbabka@suse.cz (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | Separate struct slab from struct page | expand |
On Tue, Jan 04, 2022 at 01:10:21AM +0100, Vlastimil Babka wrote: > From: "Matthew Wilcox (Oracle)" <willy@infradead.org> > > In SLUB, use folios, and struct slab to access slab_cache field. > In SLOB, use folios to properly resolve pointers beyond > PAGE_SIZE offset of the object. > > [ vbabka@suse.cz: use folios, and only convert folio_test_slab() == true > folios to struct slab ] > > Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> > Signed-off-by: Vlastimil Babka <vbabka@suse.cz> > Acked-by: Johannes Weiner <hannes@cmpxchg.org> > Reviewed-by: Roman Gushchin <guro@fb.com> > --- > mm/slob.c | 8 ++++---- > mm/slub.c | 12 +++++------- > 2 files changed, 9 insertions(+), 11 deletions(-) > > diff --git a/mm/slob.c b/mm/slob.c > index 03deee1e6a94..c8a4290012a6 100644 > --- a/mm/slob.c > +++ b/mm/slob.c > @@ -570,7 +570,7 @@ EXPORT_SYMBOL(kfree); > /* can't use ksize for kmem_cache_alloc memory, only kmalloc */ > size_t __ksize(const void *block) > { > - struct page *sp; > + struct folio *folio; > int align; > unsigned int *m; > > @@ -578,9 +578,9 @@ size_t __ksize(const void *block) > if (unlikely(block == ZERO_SIZE_PTR)) > return 0; > > - sp = virt_to_page(block); > - if (unlikely(!PageSlab(sp))) > - return page_size(sp); > + folio = virt_to_folio(block); > + if (unlikely(!folio_test_slab(folio))) > + return folio_size(folio); > > align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN); > m = (unsigned int *)(block - align); > diff --git a/mm/slub.c b/mm/slub.c > index c94fb4b4d655..269e10d341a8 100644 > --- a/mm/slub.c > +++ b/mm/slub.c > @@ -4527,19 +4527,17 @@ void __check_heap_object(const void *ptr, unsigned long n, struct page *page, > > size_t __ksize(const void *object) > { > - struct page *page; > + struct folio *folio; > > if (unlikely(object == ZERO_SIZE_PTR)) > return 0; > > - page = virt_to_head_page(object); > + folio = virt_to_folio(object); > > - if (unlikely(!PageSlab(page))) { > - WARN_ON(!PageCompound(page)); > - return page_size(page); > - } > + if (unlikely(!folio_test_slab(folio))) > + return folio_size(folio); > > - return slab_ksize(page->slab_cache); > + return slab_ksize(folio_slab(folio)->slab_cache); > } > EXPORT_SYMBOL(__ksize); > This patch Looks good. Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> BTW, I see no reason to implement SLAB version of __ksize separately. And there are no modules that use __ksize. EXPORT_SYMBOL is unnecessary. BTW, Until when can I review your patches? until next week before starting window? Thanks! > -- > 2.34.1 >
On 1/6/22 14:42, Hyeonggon Yoo wrote: > On Tue, Jan 04, 2022 at 01:10:21AM +0100, Vlastimil Babka wrote: > > This patch Looks good. > Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Thanks! > BTW, I see no reason to implement SLAB version of __ksize separately. > And there are no modules that use __ksize. EXPORT_SYMBOL is unnecessary. OK, I'll look at a cleanup later. Or you can try? > BTW, Until when can I review your patches? until next week before starting > window? I will send it tomorrow already, so records of any further review will be archived in the mailing list only, but not git. Thanks again! > Thanks! > >> -- >> 2.34.1 >>
On Thu, Jan 06, 2022 at 06:26:06PM +0100, Vlastimil Babka wrote: > On 1/6/22 14:42, Hyeonggon Yoo wrote: > > On Tue, Jan 04, 2022 at 01:10:21AM +0100, Vlastimil Babka wrote: > > > > This patch Looks good. > > Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> > > Thanks! > :> > > BTW, I see no reason to implement SLAB version of __ksize separately. > > And there are no modules that use __ksize. EXPORT_SYMBOL is unnecessary. > > OK, I'll look at a cleanup later. Or you can try? I want to try it. > > > BTW, Until when can I review your patches? until next week before starting > > window? > > I will send it tomorrow already, so records of any further review will be > archived in the mailing list only, but not git. Thanks again! > Got it. Thanks! > > Thanks! > > > >> -- > >> 2.34.1 > >> >
diff --git a/mm/slob.c b/mm/slob.c index 03deee1e6a94..c8a4290012a6 100644 --- a/mm/slob.c +++ b/mm/slob.c @@ -570,7 +570,7 @@ EXPORT_SYMBOL(kfree); /* can't use ksize for kmem_cache_alloc memory, only kmalloc */ size_t __ksize(const void *block) { - struct page *sp; + struct folio *folio; int align; unsigned int *m; @@ -578,9 +578,9 @@ size_t __ksize(const void *block) if (unlikely(block == ZERO_SIZE_PTR)) return 0; - sp = virt_to_page(block); - if (unlikely(!PageSlab(sp))) - return page_size(sp); + folio = virt_to_folio(block); + if (unlikely(!folio_test_slab(folio))) + return folio_size(folio); align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN); m = (unsigned int *)(block - align); diff --git a/mm/slub.c b/mm/slub.c index c94fb4b4d655..269e10d341a8 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -4527,19 +4527,17 @@ void __check_heap_object(const void *ptr, unsigned long n, struct page *page, size_t __ksize(const void *object) { - struct page *page; + struct folio *folio; if (unlikely(object == ZERO_SIZE_PTR)) return 0; - page = virt_to_head_page(object); + folio = virt_to_folio(object); - if (unlikely(!PageSlab(page))) { - WARN_ON(!PageCompound(page)); - return page_size(page); - } + if (unlikely(!folio_test_slab(folio))) + return folio_size(folio); - return slab_ksize(page->slab_cache); + return slab_ksize(folio_slab(folio)->slab_cache); } EXPORT_SYMBOL(__ksize);