* [PATCH] zsmalloc: remove obj_tagged()
@ 2023-07-09 2:56 Sergey Senozhatsky
2023-07-09 3:17 ` Nhat Pham
0 siblings, 1 reply; 2+ messages in thread
From: Sergey Senozhatsky @ 2023-07-09 2:56 UTC (permalink / raw)
To: Andrew Morton, Minchan Kim; +Cc: linux-mm, linux-kernel, Sergey Senozhatsky
obj_tagged() is not needed at this point, because objects can
only have one tag: OBJ_ALLOCATED_TAG. We needed obj_tagged()
for the zsmalloc LRU implementation, which has now been
removed. Simplify zsmalloc code and revert to the previous
implementation that was in place before the zsmalloc LRU series.
Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org>
---
mm/zsmalloc.c | 29 +++++++----------------------
1 file changed, 7 insertions(+), 22 deletions(-)
diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
index 84beadc088b8..32f5bc4074df 100644
--- a/mm/zsmalloc.c
+++ b/mm/zsmalloc.c
@@ -795,8 +795,8 @@ static unsigned long handle_to_obj(unsigned long handle)
return *(unsigned long *)handle;
}
-static bool obj_tagged(struct page *page, void *obj, unsigned long *phandle,
- int tag)
+static inline bool obj_allocated(struct page *page, void *obj,
+ unsigned long *phandle)
{
unsigned long handle;
struct zspage *zspage = get_zspage(page);
@@ -807,7 +807,7 @@ static bool obj_tagged(struct page *page, void *obj, unsigned long *phandle,
} else
handle = *(unsigned long *)obj;
- if (!(handle & tag))
+ if (!(handle & OBJ_ALLOCATED_TAG))
return false;
/* Clear all tags before returning the handle */
@@ -815,11 +815,6 @@ static bool obj_tagged(struct page *page, void *obj, unsigned long *phandle,
return true;
}
-static inline bool obj_allocated(struct page *page, void *obj, unsigned long *phandle)
-{
- return obj_tagged(page, obj, phandle, OBJ_ALLOCATED_TAG);
-}
-
static void reset_page(struct page *page)
{
__ClearPageMovable(page);
@@ -1551,11 +1546,11 @@ static void zs_object_copy(struct size_class *class, unsigned long dst,
}
/*
- * Find object with a certain tag in zspage from index object and
+ * Find alloced object in zspage from index object and
* return handle.
*/
-static unsigned long find_tagged_obj(struct size_class *class,
- struct page *page, int *obj_idx, int tag)
+static unsigned long find_alloced_obj(struct size_class *class,
+ struct page *page, int *obj_idx)
{
unsigned int offset;
int index = *obj_idx;
@@ -1566,7 +1561,7 @@ static unsigned long find_tagged_obj(struct size_class *class,
offset += class->size * index;
while (offset < PAGE_SIZE) {
- if (obj_tagged(page, addr + offset, &handle, tag))
+ if (obj_allocated(page, addr + offset, &handle))
break;
offset += class->size;
@@ -1580,16 +1575,6 @@ static unsigned long find_tagged_obj(struct size_class *class,
return handle;
}
-/*
- * Find alloced object in zspage from index object and
- * return handle.
- */
-static unsigned long find_alloced_obj(struct size_class *class,
- struct page *page, int *obj_idx)
-{
- return find_tagged_obj(class, page, obj_idx, OBJ_ALLOCATED_TAG);
-}
-
static void migrate_zspage(struct zs_pool *pool, struct zspage *src_zspage,
struct zspage *dst_zspage)
{
--
2.41.0.255.g8b1d071c50-goog
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] zsmalloc: remove obj_tagged()
2023-07-09 2:56 [PATCH] zsmalloc: remove obj_tagged() Sergey Senozhatsky
@ 2023-07-09 3:17 ` Nhat Pham
0 siblings, 0 replies; 2+ messages in thread
From: Nhat Pham @ 2023-07-09 3:17 UTC (permalink / raw)
To: Sergey Senozhatsky; +Cc: Andrew Morton, Minchan Kim, linux-mm, linux-kernel
On Sat, Jul 8, 2023 at 7:58 PM Sergey Senozhatsky
<senozhatsky@chromium.org> wrote:
>
> obj_tagged() is not needed at this point, because objects can
> only have one tag: OBJ_ALLOCATED_TAG. We needed obj_tagged()
> for the zsmalloc LRU implementation, which has now been
> removed. Simplify zsmalloc code and revert to the previous
> implementation that was in place before the zsmalloc LRU series.
>
> Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org>
> ---
> mm/zsmalloc.c | 29 +++++++----------------------
> 1 file changed, 7 insertions(+), 22 deletions(-)
>
> diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
> index 84beadc088b8..32f5bc4074df 100644
> --- a/mm/zsmalloc.c
> +++ b/mm/zsmalloc.c
> @@ -795,8 +795,8 @@ static unsigned long handle_to_obj(unsigned long handle)
> return *(unsigned long *)handle;
> }
>
> -static bool obj_tagged(struct page *page, void *obj, unsigned long *phandle,
> - int tag)
> +static inline bool obj_allocated(struct page *page, void *obj,
> + unsigned long *phandle)
> {
> unsigned long handle;
> struct zspage *zspage = get_zspage(page);
> @@ -807,7 +807,7 @@ static bool obj_tagged(struct page *page, void *obj, unsigned long *phandle,
> } else
> handle = *(unsigned long *)obj;
>
> - if (!(handle & tag))
> + if (!(handle & OBJ_ALLOCATED_TAG))
> return false;
>
> /* Clear all tags before returning the handle */
> @@ -815,11 +815,6 @@ static bool obj_tagged(struct page *page, void *obj, unsigned long *phandle,
> return true;
> }
>
> -static inline bool obj_allocated(struct page *page, void *obj, unsigned long *phandle)
> -{
> - return obj_tagged(page, obj, phandle, OBJ_ALLOCATED_TAG);
> -}
> -
> static void reset_page(struct page *page)
> {
> __ClearPageMovable(page);
> @@ -1551,11 +1546,11 @@ static void zs_object_copy(struct size_class *class, unsigned long dst,
> }
>
> /*
> - * Find object with a certain tag in zspage from index object and
> + * Find alloced object in zspage from index object and
> * return handle.
> */
> -static unsigned long find_tagged_obj(struct size_class *class,
> - struct page *page, int *obj_idx, int tag)
> +static unsigned long find_alloced_obj(struct size_class *class,
> + struct page *page, int *obj_idx)
> {
> unsigned int offset;
> int index = *obj_idx;
> @@ -1566,7 +1561,7 @@ static unsigned long find_tagged_obj(struct size_class *class,
> offset += class->size * index;
>
> while (offset < PAGE_SIZE) {
> - if (obj_tagged(page, addr + offset, &handle, tag))
> + if (obj_allocated(page, addr + offset, &handle))
> break;
>
> offset += class->size;
> @@ -1580,16 +1575,6 @@ static unsigned long find_tagged_obj(struct size_class *class,
> return handle;
> }
>
> -/*
> - * Find alloced object in zspage from index object and
> - * return handle.
> - */
> -static unsigned long find_alloced_obj(struct size_class *class,
> - struct page *page, int *obj_idx)
> -{
> - return find_tagged_obj(class, page, obj_idx, OBJ_ALLOCATED_TAG);
> -}
> -
> static void migrate_zspage(struct zs_pool *pool, struct zspage *src_zspage,
> struct zspage *dst_zspage)
> {
> --
> 2.41.0.255.g8b1d071c50-goog
>
>
LGTM! This was only introduced for the (temporary) deferred tag.
We've removed it so this should go away too.
Acked-by: Nhat Pham <nphamcs@gmail.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-07-09 3:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-09 2:56 [PATCH] zsmalloc: remove obj_tagged() Sergey Senozhatsky
2023-07-09 3:17 ` Nhat Pham
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox