From: Hyeonggon Yoo <42.hyeyoo@gmail.com>
To: Vlastimil Babka <vbabka@suse.cz>
Cc: Matthew Wilcox <willy@infradead.org>,
Christoph Lameter <cl@linux.com>,
David Rientjes <rientjes@google.com>,
Joonsoo Kim <iamjoonsoo.kim@lge.com>,
Pekka Enberg <penberg@kernel.org>,
linux-mm@kvack.org, Andrew Morton <akpm@linux-foundation.org>,
Johannes Weiner <hannes@cmpxchg.org>,
Roman Gushchin <guro@fb.com>,
patches@lists.linux.dev
Subject: Re: [PATCH v4 07/32] mm: Convert __ksize() to struct slab
Date: Thu, 6 Jan 2022 13:42:16 +0000 [thread overview]
Message-ID: <YdbxuCMUz9l1TW8e@ip-172-31-30-232.ap-northeast-1.compute.internal> (raw)
In-Reply-To: <20220104001046.12263-8-vbabka@suse.cz>
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
>
next prev parent reply other threads:[~2022-01-06 13:42 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-04 0:10 [PATCH v4 00/32] Separate struct slab from struct page Vlastimil Babka
2022-01-04 0:10 ` [PATCH v4 01/32] mm: add virt_to_folio() and folio_address() Vlastimil Babka
2022-01-04 0:10 ` [PATCH v4 02/32] mm/slab: Dissolve slab_map_pages() in its caller Vlastimil Babka
2022-01-06 6:40 ` Hyeonggon Yoo
2022-01-04 0:10 ` [PATCH v4 03/32] mm/slub: Make object_err() static Vlastimil Babka
2022-01-04 0:10 ` [PATCH v4 04/32] mm: Split slab into its own type Vlastimil Babka
2022-01-06 11:54 ` Hyeonggon Yoo
2022-01-04 0:10 ` [PATCH v4 05/32] mm: Convert [un]account_slab_page() to struct slab Vlastimil Babka
2022-01-06 13:04 ` Hyeonggon Yoo
2022-01-04 0:10 ` [PATCH v4 06/32] mm: Convert virt_to_cache() to use " Vlastimil Babka
2022-01-06 6:44 ` Hyeonggon Yoo
2022-01-04 0:10 ` [PATCH v4 07/32] mm: Convert __ksize() to " Vlastimil Babka
2022-01-06 13:42 ` Hyeonggon Yoo [this message]
2022-01-06 17:26 ` Vlastimil Babka
2022-01-08 6:21 ` Hyeonggon Yoo
2022-01-04 0:10 ` [PATCH v4 08/32] mm: Use struct slab in kmem_obj_info() Vlastimil Babka
2022-01-04 0:10 ` [PATCH v4 09/32] mm: Convert check_heap_object() to use struct slab Vlastimil Babka
2022-01-06 13:56 ` Hyeonggon Yoo
2022-01-04 0:10 ` [PATCH v4 10/32] mm/slub: Convert detached_freelist to use a " Vlastimil Babka
2022-01-05 0:58 ` Roman Gushchin
2022-01-04 0:10 ` [PATCH v4 11/32] mm/slub: Convert kfree() " Vlastimil Babka
2022-01-05 1:00 ` Roman Gushchin
2022-01-04 0:10 ` [PATCH v4 12/32] mm/slub: Convert __slab_lock() and __slab_unlock() to " Vlastimil Babka
2022-01-04 0:10 ` [PATCH v4 13/32] mm/slub: Convert print_page_info() to print_slab_info() Vlastimil Babka
2022-01-04 0:10 ` [PATCH v4 14/32] mm/slub: Convert alloc_slab_page() to return a struct slab Vlastimil Babka
2022-01-04 0:10 ` [PATCH v4 15/32] mm/slub: Convert __free_slab() to use " Vlastimil Babka
2022-01-04 0:10 ` [PATCH v4 16/32] mm/slub: Convert pfmemalloc_match() to take a " Vlastimil Babka
2022-01-04 0:10 ` [PATCH v4 17/32] mm/slub: Convert most struct page to struct slab by spatch Vlastimil Babka
2022-01-04 0:10 ` [PATCH v4 18/32] mm/slub: Finish struct page to struct slab conversion Vlastimil Babka
2022-01-04 0:10 ` [PATCH v4 19/32] mm/slab: Convert kmem_getpages() and kmem_freepages() to struct slab Vlastimil Babka
2022-01-04 0:10 ` [PATCH v4 20/32] mm/slab: Convert most struct page to struct slab by spatch Vlastimil Babka
2022-01-05 1:52 ` Roman Gushchin
2022-01-04 0:10 ` [PATCH v4 21/32] mm/slab: Finish struct page to struct slab conversion Vlastimil Babka
2022-01-05 2:05 ` Roman Gushchin
2022-01-04 0:10 ` [PATCH v4 22/32] mm: Convert struct page to struct slab in functions used by other subsystems Vlastimil Babka
2022-01-05 2:12 ` Roman Gushchin
2022-01-05 16:39 ` Vlastimil Babka
2022-01-04 0:10 ` [PATCH v4 23/32] mm/memcg: Convert slab objcgs from struct page to struct slab Vlastimil Babka
2022-01-05 2:41 ` Roman Gushchin
2022-01-05 17:08 ` Vlastimil Babka
2022-01-06 3:36 ` Roman Gushchin
2022-01-05 2:55 ` Roman Gushchin
2022-01-04 0:10 ` [PATCH v4 24/32] mm/slob: Convert SLOB to use struct slab and struct folio Vlastimil Babka
2022-01-04 0:10 ` [PATCH v4 25/32] mm/kasan: Convert to struct folio and struct slab Vlastimil Babka
2022-01-06 4:06 ` Roman Gushchin
2022-01-04 0:10 ` [PATCH v4 26/32] mm/kfence: Convert kfence_guarded_alloc() to " Vlastimil Babka
2022-01-04 0:10 ` [PATCH v4 27/32] mm/sl*b: Differentiate struct slab fields by sl*b implementations Vlastimil Babka
2022-01-06 4:12 ` Roman Gushchin
2022-01-04 0:10 ` [PATCH v4 28/32] mm/slub: Simplify struct slab slabs field definition Vlastimil Babka
2022-01-06 4:13 ` Roman Gushchin
2022-01-04 0:10 ` [PATCH v4 29/32] mm/slub: Define struct slab fields for CONFIG_SLUB_CPU_PARTIAL only when enabled Vlastimil Babka
2022-01-06 4:16 ` Roman Gushchin
2022-01-04 0:10 ` [PATCH v4 30/32] zsmalloc: Stop using slab fields in struct page Vlastimil Babka
2022-01-04 0:10 ` [PATCH v4 31/32] bootmem: Use page->index instead of page->freelist Vlastimil Babka
2022-01-04 0:10 ` [PATCH v4 32/32] mm/slob: Remove unnecessary page_mapcount_reset() function call Vlastimil Babka
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YdbxuCMUz9l1TW8e@ip-172-31-30-232.ap-northeast-1.compute.internal \
--to=42.hyeyoo@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=cl@linux.com \
--cc=guro@fb.com \
--cc=hannes@cmpxchg.org \
--cc=iamjoonsoo.kim@lge.com \
--cc=linux-mm@kvack.org \
--cc=patches@lists.linux.dev \
--cc=penberg@kernel.org \
--cc=rientjes@google.com \
--cc=vbabka@suse.cz \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox