All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vlastimil Babka <vbabka@suse.cz>
To: 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>
Cc: linux-mm@kvack.org, Andrew Morton <akpm@linux-foundation.org>,
	patches@lists.linux.dev, Vlastimil Babka <vbabka@suse.cz>
Subject: [PATCH v2 24/33] mm/slob: Convert SLOB to use struct slab
Date: Wed,  1 Dec 2021 19:15:01 +0100	[thread overview]
Message-ID: <20211201181510.18784-25-vbabka@suse.cz> (raw)
In-Reply-To: <20211201181510.18784-1-vbabka@suse.cz>

From: "Matthew Wilcox (Oracle)" <willy@infradead.org>

Use struct slab throughout the slob allocator.

[ vbabka@suse.cz: don't introduce wrappers for PageSlobFree in mm/slab.h just
  for the single callers being wrappers in mm/slob.c ]

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
---
 mm/slob.c | 34 +++++++++++++++++-----------------
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/mm/slob.c b/mm/slob.c
index d2d15e7f191c..d3512bcc3141 100644
--- a/mm/slob.c
+++ b/mm/slob.c
@@ -105,21 +105,21 @@ static LIST_HEAD(free_slob_large);
 /*
  * slob_page_free: true for pages on free_slob_pages list.
  */
-static inline int slob_page_free(struct page *sp)
+static inline int slob_page_free(struct slab *slab)
 {
-	return PageSlobFree(sp);
+	return PageSlobFree(slab_page(slab));
 }
 
-static void set_slob_page_free(struct page *sp, struct list_head *list)
+static void set_slob_page_free(struct slab *slab, struct list_head *list)
 {
-	list_add(&sp->slab_list, list);
-	__SetPageSlobFree(sp);
+	list_add(&slab->slab_list, list);
+	__SetPageSlobFree(slab_page(slab));
 }
 
-static inline void clear_slob_page_free(struct page *sp)
+static inline void clear_slob_page_free(struct slab *slab)
 {
-	list_del(&sp->slab_list);
-	__ClearPageSlobFree(sp);
+	list_del(&slab->slab_list);
+	__ClearPageSlobFree(slab_page(slab));
 }
 
 #define SLOB_UNIT sizeof(slob_t)
@@ -234,7 +234,7 @@ static void slob_free_pages(void *b, int order)
  *         freelist, in this case @page_removed_from_list will be set to
  *         true (set to false otherwise).
  */
-static void *slob_page_alloc(struct page *sp, size_t size, int align,
+static void *slob_page_alloc(struct slab *sp, size_t size, int align,
 			      int align_offset, bool *page_removed_from_list)
 {
 	slob_t *prev, *cur, *aligned = NULL;
@@ -301,7 +301,7 @@ static void *slob_page_alloc(struct page *sp, size_t size, int align,
 static void *slob_alloc(size_t size, gfp_t gfp, int align, int node,
 							int align_offset)
 {
-	struct page *sp;
+	struct slab *sp;
 	struct list_head *slob_list;
 	slob_t *b = NULL;
 	unsigned long flags;
@@ -323,7 +323,7 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node,
 		 * If there's a node specification, search for a partial
 		 * page with a matching node id in the freelist.
 		 */
-		if (node != NUMA_NO_NODE && page_to_nid(sp) != node)
+		if (node != NUMA_NO_NODE && slab_nid(sp) != node)
 			continue;
 #endif
 		/* Enough room on this page? */
@@ -358,8 +358,8 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node,
 		b = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
 		if (!b)
 			return NULL;
-		sp = virt_to_page(b);
-		__SetPageSlab(sp);
+		sp = virt_to_slab(b);
+		__SetPageSlab(slab_page(sp));
 
 		spin_lock_irqsave(&slob_lock, flags);
 		sp->units = SLOB_UNITS(PAGE_SIZE);
@@ -381,7 +381,7 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node,
  */
 static void slob_free(void *block, int size)
 {
-	struct page *sp;
+	struct slab *sp;
 	slob_t *prev, *next, *b = (slob_t *)block;
 	slobidx_t units;
 	unsigned long flags;
@@ -391,7 +391,7 @@ static void slob_free(void *block, int size)
 		return;
 	BUG_ON(!size);
 
-	sp = virt_to_page(block);
+	sp = virt_to_slab(block);
 	units = SLOB_UNITS(size);
 
 	spin_lock_irqsave(&slob_lock, flags);
@@ -401,8 +401,8 @@ static void slob_free(void *block, int size)
 		if (slob_page_free(sp))
 			clear_slob_page_free(sp);
 		spin_unlock_irqrestore(&slob_lock, flags);
-		__ClearPageSlab(sp);
-		page_mapcount_reset(sp);
+		__ClearPageSlab(slab_page(sp));
+		page_mapcount_reset(slab_page(sp));
 		slob_free_pages(b, 0);
 		return;
 	}
-- 
2.33.1


  parent reply	other threads:[~2021-12-01 18:15 UTC|newest]

Thread overview: 148+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-01 18:14 [PATCH v2 00/33] Separate struct slab from struct page Vlastimil Babka
2021-12-01 18:14 ` Vlastimil Babka
2021-12-01 18:14 ` Vlastimil Babka
2021-12-01 18:14 ` [PATCH v2 01/33] mm: add virt_to_folio() and folio_address() Vlastimil Babka
2021-12-14 14:20   ` Johannes Weiner
2021-12-14 14:27     ` Vlastimil Babka
2021-12-01 18:14 ` [PATCH v2 02/33] mm/slab: Dissolve slab_map_pages() in its caller Vlastimil Babka
2021-12-01 18:14 ` [PATCH v2 03/33] mm/slub: Make object_err() static Vlastimil Babka
2021-12-01 18:14 ` [PATCH v2 04/33] mm: Split slab into its own type Vlastimil Babka
2021-12-14 14:24   ` Johannes Weiner
2021-12-01 18:14 ` [PATCH v2 05/33] mm: Add account_slab() and unaccount_slab() Vlastimil Babka
2021-12-14 14:25   ` Johannes Weiner
2021-12-01 18:14 ` [PATCH v2 06/33] mm: Convert virt_to_cache() to use struct slab Vlastimil Babka
2021-12-14 14:26   ` Johannes Weiner
2021-12-01 18:14 ` [PATCH v2 07/33] mm: Convert __ksize() to " Vlastimil Babka
2021-12-14 14:28   ` Johannes Weiner
2021-12-01 18:14 ` [PATCH v2 08/33] mm: Use struct slab in kmem_obj_info() Vlastimil Babka
2021-12-01 18:14 ` [PATCH v2 09/33] mm: Convert check_heap_object() to use struct slab Vlastimil Babka
2021-12-01 18:14 ` [PATCH v2 10/33] mm/slub: Convert detached_freelist to use a " Vlastimil Babka
2021-12-01 18:14 ` [PATCH v2 11/33] mm/slub: Convert kfree() " Vlastimil Babka
2021-12-01 18:14 ` [PATCH v2 12/33] mm/slub: Convert __slab_lock() and __slab_unlock() to " Vlastimil Babka
2021-12-01 18:14 ` [PATCH v2 13/33] mm/slub: Convert print_page_info() to print_slab_info() Vlastimil Babka
2021-12-01 18:14 ` [PATCH v2 14/33] mm/slub: Convert alloc_slab_page() to return a struct slab Vlastimil Babka
2021-12-01 18:14 ` [PATCH v2 15/33] mm/slub: Convert __free_slab() to use " Vlastimil Babka
2021-12-01 18:14 ` [PATCH v2 16/33] mm/slub: Convert pfmemalloc_match() to take a " Vlastimil Babka
2021-12-01 18:14 ` [PATCH v2 17/33] mm/slub: Convert most struct page to struct slab by spatch Vlastimil Babka
2021-12-01 18:14 ` [PATCH v2 18/33] mm/slub: Finish struct page to struct slab conversion Vlastimil Babka
2021-12-01 18:14 ` [PATCH v2 19/33] mm/slab: Convert kmem_getpages() and kmem_freepages() to struct slab Vlastimil Babka
2021-12-01 18:14 ` [PATCH v2 20/33] mm/slab: Convert most struct page to struct slab by spatch Vlastimil Babka
2021-12-01 18:14 ` [PATCH v2 21/33] mm/slab: Finish struct page to struct slab conversion Vlastimil Babka
2021-12-01 18:14 ` [PATCH v2 22/33] mm: Convert struct page to struct slab in functions used by other subsystems Vlastimil Babka
2021-12-01 18:14   ` Vlastimil Babka
2021-12-02 17:16   ` Andrey Konovalov
2021-12-02 17:16     ` Andrey Konovalov
2021-12-14 14:31   ` Johannes Weiner
2021-12-14 14:31     ` Johannes Weiner
2021-12-01 18:15 ` [PATCH v2 23/33] mm/memcg: Convert slab objcgs from struct page to struct slab Vlastimil Babka
2021-12-01 18:15   ` Vlastimil Babka
2021-12-14 14:43   ` Johannes Weiner
2021-12-14 14:43     ` Johannes Weiner
2021-12-20 23:31     ` Vlastimil Babka
2021-12-20 23:31       ` Vlastimil Babka
2021-12-01 18:15 ` Vlastimil Babka [this message]
2021-12-10 10:44   ` [PATCH v2 24/33] mm/slob: Convert SLOB to use " Hyeonggon Yoo
2021-12-10 11:44     ` Vlastimil Babka
2021-12-10 15:29       ` Hyeonggon Yoo
2021-12-10 18:09         ` Vlastimil Babka
2021-12-11 10:54           ` Hyeonggon Yoo
2021-12-01 18:15 ` [PATCH v2 25/33] mm/kasan: Convert to struct folio and " Vlastimil Babka
2021-12-02 17:16   ` Andrey Konovalov
2021-12-01 18:15 ` [PATCH v2 26/33] mm/kfence: Convert kfence_guarded_alloc() to " Vlastimil Babka
2021-12-01 18:15 ` [PATCH v2 27/33] zsmalloc: Stop using slab fields in struct page Vlastimil Babka
2021-12-01 23:34   ` Minchan Kim
2021-12-14 14:58   ` Johannes Weiner
2021-12-01 18:15 ` [PATCH v2 28/33] bootmem: Use page->index instead of page->freelist Vlastimil Babka
2021-12-14 14:59   ` Johannes Weiner
2021-12-01 18:15 ` [PATCH v2 29/33] iommu: Use put_pages_list Vlastimil Babka
2021-12-01 18:15   ` Vlastimil Babka
2021-12-01 19:07   ` Matthew Wilcox
2021-12-01 19:07     ` Matthew Wilcox
2021-12-01 19:45     ` Robin Murphy
2021-12-01 19:45       ` Robin Murphy
2021-12-01 18:15 ` [PATCH v2 30/33] mm: Remove slab from struct page Vlastimil Babka
2021-12-14 14:46   ` Johannes Weiner
2021-12-01 18:15 ` [PATCH v2 31/33] mm/sl*b: Differentiate struct slab fields by sl*b implementations Vlastimil Babka
2021-12-10 16:37   ` Hyeonggon Yoo
2021-12-10 18:26     ` Vlastimil Babka
2021-12-11 11:55       ` Hyeonggon Yoo
2021-12-11 16:52         ` Matthew Wilcox
2021-12-12  5:54           ` Hyeonggon Yoo
2021-12-11 16:23       ` Matthew Wilcox
2021-12-12  6:00         ` Hyeonggon Yoo
2021-12-12  6:52   ` [PATCH] mm/slob: Remove unnecessary page_mapcount_reset() function call Hyeonggon Yoo
2021-12-14 11:51     ` Vlastimil Babka
2021-12-01 18:15 ` [PATCH v2 32/33] mm/slub: Simplify struct slab slabs field definition Vlastimil Babka
2021-12-14 15:06   ` Johannes Weiner
2021-12-01 18:15 ` [PATCH v2 33/33] mm/slub: Define struct slab fields for CONFIG_SLUB_CPU_PARTIAL only when enabled Vlastimil Babka
2021-12-01 18:39 ` slab tree for next Vlastimil Babka
2021-12-01 20:34   ` Vlastimil Babka
2021-12-02 16:36     ` Vlastimil Babka
2021-12-02 20:39       ` Stephen Rothwell
2022-01-04  0:21   ` Vlastimil Babka
2022-01-04  8:44     ` Stephen Rothwell
2023-08-29  9:55     ` Vlastimil Babka
2023-08-29 21:33       ` Stephen Rothwell
2021-12-02 12:25 ` [PATCH v2 00/33] Separate struct slab from struct page Vlastimil Babka
2021-12-02 12:25   ` Vlastimil Babka
2021-12-02 12:25   ` Vlastimil Babka
2021-12-14 12:57 ` Vlastimil Babka
2021-12-14 12:57   ` Vlastimil Babka
2021-12-14 12:57   ` Vlastimil Babka
2021-12-14 14:38   ` Hyeonggon Yoo
2021-12-14 14:38     ` Hyeonggon Yoo
2021-12-14 14:38     ` Hyeonggon Yoo
2021-12-14 14:43     ` Vlastimil Babka
2021-12-14 14:43       ` Vlastimil Babka
2021-12-14 14:43       ` Vlastimil Babka
2021-12-15  3:47       ` Hyeonggon Yoo
2021-12-15  3:47         ` Hyeonggon Yoo
2021-12-15  3:47         ` Hyeonggon Yoo
2021-12-15  1:03   ` Roman Gushchin
2021-12-15  1:03     ` Roman Gushchin via iommu
2021-12-15  1:03     ` Roman Gushchin via iommu
2021-12-15 23:38     ` Roman Gushchin
2021-12-15 23:38       ` Roman Gushchin
2021-12-15 23:38       ` Roman Gushchin via iommu
2021-12-16  9:19       ` Vlastimil Babka
2021-12-16  9:19         ` Vlastimil Babka
2021-12-16  9:19         ` Vlastimil Babka
2021-12-20  0:47       ` Vlastimil Babka
2021-12-20  0:47         ` Vlastimil Babka
2021-12-20  0:47         ` Vlastimil Babka
2021-12-20  1:42         ` Matthew Wilcox
2021-12-20  1:42           ` Matthew Wilcox
2021-12-20  1:42           ` Matthew Wilcox
2021-12-20  0:24     ` Vlastimil Babka
2021-12-20  0:24       ` Vlastimil Babka
2021-12-20  0:24       ` Vlastimil Babka
2021-12-16 15:00   ` Hyeonggon Yoo
2021-12-16 15:00     ` Hyeonggon Yoo
2021-12-16 15:00     ` Hyeonggon Yoo
2021-12-20 23:58     ` Vlastimil Babka
2021-12-20 23:58       ` Vlastimil Babka
2021-12-20 23:58       ` Vlastimil Babka
2021-12-21 17:25       ` Robin Murphy
2021-12-21 17:25         ` Robin Murphy
2021-12-21 17:25         ` Robin Murphy
2021-12-22  7:36       ` Hyeonggon Yoo
2021-12-22  7:36         ` Hyeonggon Yoo
2021-12-22  7:36         ` Hyeonggon Yoo
2021-12-22 16:56   ` Vlastimil Babka
2021-12-22 16:56     ` Vlastimil Babka
2021-12-22 16:56     ` Vlastimil Babka
2021-12-25  9:16     ` Hyeonggon Yoo
2021-12-25  9:16       ` Hyeonggon Yoo
2021-12-25  9:16       ` Hyeonggon Yoo
2021-12-25 17:53       ` Matthew Wilcox
2021-12-25 17:53         ` Matthew Wilcox
2021-12-25 17:53         ` Matthew Wilcox
2021-12-27  2:43         ` Hyeonggon Yoo
2021-12-27  2:43           ` Hyeonggon Yoo
2021-12-27  2:43           ` Hyeonggon Yoo
2021-12-29 11:22     ` Hyeonggon Yoo
2021-12-29 11:22       ` Hyeonggon Yoo
2021-12-29 11:22       ` Hyeonggon Yoo
2022-01-03 17:56       ` Vlastimil Babka
2022-01-03 17:56         ` Vlastimil Babka
2022-01-03 17:56         ` 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=20211201181510.18784-25-vbabka@suse.cz \
    --to=vbabka@suse.cz \
    --cc=akpm@linux-foundation.org \
    --cc=cl@linux.com \
    --cc=iamjoonsoo.kim@lge.com \
    --cc=linux-mm@kvack.org \
    --cc=patches@lists.linux.dev \
    --cc=penberg@kernel.org \
    --cc=rientjes@google.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.