mm/zsmalloc: use ARRAY_SIZE in isolate_zspage()
Subsystems (2)
PATCH 1/2 mm/zsmalloc: use ARRAY_SIZE in isolate_zspage()
Better not to use hardcoded constants.
--- mm/zsmalloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/zsmalloc.c +1 -1
@@ -1888,7 +1888,7 @@ static struct zspage *isolate_zspage(struct size_class *class, bool source) fg[1 ] =ZS_ALMOST_EMPTY ; } -for (i =0 ; i <2 ; i++) { +for (i =0 ; i <ARRAY_SIZE (fg); i++) { zspage =list_first_entry_or_null (&class->fullness_list[fg[i]], struct zspage, list);if (zspage) {
Signature · 1 line
2.38.1
PATCH 2/2 mm/zsmalloc: get rid of PAGE_MASK
Use offset_in_page() macro instead of 'val & ~PAGE_MASK'
--- mm/zsmalloc.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
mm/zsmalloc.c +6 -6
@@ -1425,7 +1425,7 @@ void *zs_map_object(struct zs_pool *pool, unsigned long handle,spin_unlock (&pool->lock); class =zspage_class (pool, zspage); - off = (class->size * obj_idx) & ~PAGE_MASK ; + off =offset_in_page (class->size * obj_idx);local_lock (&zs_map_area.lock); area =this_cpu_ptr (&zs_map_area);
@@ -1465,7 +1465,7 @@ void zs_unmap_object(struct zs_pool *pool, unsigned long handle)obj_to_location (obj, &page, &obj_idx); zspage =get_zspage (page); class =zspage_class (pool, zspage); - off = (class->size * obj_idx) & ~PAGE_MASK ; + off =offset_in_page (class->size * obj_idx); area =this_cpu_ptr (&zs_map_area);if (off + class->size <=PAGE_SIZE )
@@ -1522,7 +1522,7 @@ static unsigned long obj_malloc(struct zs_pool *pool, offset = obj * class->size; nr_page = offset >>PAGE_SHIFT ; - m_offset = offset & ~PAGE_MASK ; + m_offset =offset_in_page (offset); m_page =get_first_page (zspage);for (i =0 ; i < nr_page; i++)
@@ -1626,7 +1626,7 @@ static void obj_free(int class_size, unsigned long obj, unsigned long *handle)void *vaddr;obj_to_location (obj, &f_page, &f_objidx); - f_offset = (class_size * f_objidx) & ~PAGE_MASK ; + f_offset =offset_in_page (class_size * f_objidx); zspage =get_zspage (f_page); vaddr =kmap_atomic (f_page);
@@ -1718,8 +1718,8 @@ static void zs_object_copy(struct size_class *class, unsigned long dst,obj_to_location (src, &s_page, &s_objidx);obj_to_location (dst, &d_page, &d_objidx); - s_off = (class->size * s_objidx) & ~PAGE_MASK ; - d_off = (class->size * d_objidx) & ~PAGE_MASK ; + s_off =offset_in_page (class->size * s_objidx); + d_off =offset_in_page (class->size * d_objidx);if (s_off + class->size >PAGE_SIZE ) s_size =PAGE_SIZE - s_off;
Signature · 1 line
2.38.1
Re: [PATCH v1 2/2] mm/zsmalloc: get rid of PAGE_MASK
Quoted 4 lines · Alexey Romanov
Use
offset_in_page()macro instead of 'val & ~PAGE_MASK'Signed-off-by Alexey Romanov <[email protected]>
Sergey Senozhatsky
maintainerQuoted 8 lines · Alexey Romanov
mm/zsmalloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)mm/zsmalloc.c +0
-0
mm/zsmalloc.c static struct zspage *isolate_zspage(struct size_class *class, bool source) · line 1894
Quoted 8 lines
mm/zsmalloc.c +1
-1@@ -1888,7 +1888,7 @@ static struct zspage *isolate_zspage(struct size_class *class, bool source) fg[1 ] =ZS_ALMOST_EMPTY ; } -for (i =0 ; i <2 ; i++) { +for (i =0 ; i <ARRAY_SIZE (fg); i++) { zspage =list_first_entry_or_null (&class->fullness_list[fg[i]], struct zspage, list);if (zspage) {
This patch needs to be dropped. We don't have that function anymore.
Hello!
Quoted 12 lines · Sergey Senozhatsky
Quoted 11 lines · Alexey Romanov
mm/zsmalloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)mm/zsmalloc.c +0
-0@@ -1888,7 +1888,7 @@ static struct zspage *isolate_zspage(struct size_class *class, bool source) fg[1 ] =ZS_ALMOST_EMPTY ; }
Quoted 7 lines
mm/zsmalloc.c static struct zspage *isolate_zspage(struct size_class *class, bool source) · line 1894
Quoted 5 lines
mm/zsmalloc.c +1
-1-for (i =0 ; i <2 ; i++) { +for (i =0 ; i <ARRAY_SIZE (fg); i++) { zspage =list_first_entry_or_null (&class->fullness_list[fg[i]], struct zspage, list);if (zspage) {This patch needs to be dropped. We don't have that function anymore.
Do I need to sumbit v2 without this patch, or will Andrew just take only the 2/2 patch into the branch?
Signature · 2 lines
Thank you, Alexey
Sergey Senozhatsky
maintainerQuoted 16 lines · Alexey Romanov
Quoted 8 lines
Quoted 8 lines
mm/zsmalloc.c +0
-0@@ -1888,7 +1888,7 @@ static struct zspage *isolate_zspage(struct size_class *class, bool source) fg[1 ] =ZS_ALMOST_EMPTY ; }Quoted 7 lines
mm/zsmalloc.c static struct zspage *isolate_zspage(struct size_class *class, bool source) · line 1894
Quoted 5 lines
mm/zsmalloc.c +1
-1-for (i =0 ; i <2 ; i++) { +for (i =0 ; i <ARRAY_SIZE (fg); i++) { zspage =list_first_entry_or_null (&class->fullness_list[fg[i]], struct zspage, list);if (zspage) {This patch needs to be dropped. We don't have that function anymore.
Quoted 2 lines
Do I need to sumbit v2 without this patch, or will Andrew just take only the 2/2 patch into the branch?
Let's hear from Andrew, but I think v2 won't be necessary.