drm/buddy: fix issue that force_merge cannot free all roots
Subsystems (3)
Arunpravin Paneer Selvam
maintainerPATCH v2 1/2 drm/buddy: fix issue that force_merge cannot free all roots
From: Lin.Cao <[email protected]>
If buddy manager have more than one roots and each root have sub-block need to be free. When drm_buddy_fini called, the first loop of force_merge will merge and free all of the sub block of first root, which offset is 0x0 and size is biggest(more than have of the mm size). In subsequent force_merge rounds, if we use 0 as start and use remaining mm size as end, the block of other roots will be skipped in __force_merge function. It will cause the other roots can not be freed.
Solution: use roots' offset as the start could fix this issue.
--- drivers/gpu/drm/drm_buddy.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_buddy.c +3 -2
@@ -324,7 +324,7 @@ EXPORT_SYMBOL(drm_buddy_init);*/ void drm_buddy_fini (struct drm_buddy *mm) { -u64 root_size, size; +u64 root_size, size, start;unsigned int order;int i;
@@ -332,7 +332,8 @@ void drm_buddy_fini(struct drm_buddy *mm)for (i =0 ; i < mm->n_roots; ++i) { order =ilog2 (size) -ilog2 (mm->chunk_size); -__force_merge (mm,0 , size, order); + start =drm_buddy_block_offset (mm->roots[i]); +__force_merge (mm, start, start + size, order);WARN_ON (!drm_buddy_block_is_free (mm->roots[i]));drm_block_free (mm, mm->roots[i]);
Signature · 1 line
2.25.1
Arunpravin Paneer Selvam
maintainerPATCH v2 2/2 drm/buddy: Add a testcase to verify the multiroot fini
- Added a testcase to verify the multiroot force merge fini.
- Added a new field in_use to track the mm freed status.
v2:(Matthew)
- Add kunit_fail_current_test() when WARN_ON is true.
--- drivers/gpu/drm/drm_buddy.c | 6 +++++- drivers/gpu/drm/tests/drm_buddy_test.c | 29 ++++++++++++++++++-------- 2 files changed, 25 insertions(+), 10 deletions(-)
drivers/gpu/drm/drm_buddy.c +5 -1
@@ -3,6 +3,8 @@* Copyright © 2021 Intel Corporation */ +#include <kunit/test-bug.h> +#include <linux/kmemleak.h> #include <linux/module.h> #include <linux/sizes.h>
@@ -335,7 +337,9 @@ void drm_buddy_fini(struct drm_buddy *mm) start =drm_buddy_block_offset (mm->roots[i]);__force_merge (mm, start, start + size, order); -WARN_ON (!drm_buddy_block_is_free (mm->roots[i])); +if (WARN_ON (!drm_buddy_block_is_free (mm->roots[i]))) +kunit_fail_current_test ("buddy_fini() root" ); +drm_block_free (mm, mm->roots[i]); root_size = mm->chunk_size << order;
drivers/gpu/drm/tests/drm_buddy_test.c +20 -9
@@ -385,17 +385,28 @@ static void drm_test_buddy_alloc_clear(struct kunit *test)drm_buddy_fini (&mm);/* -* Create a new mm with a non power-of-two size. Allocate a random size, free as -* cleared and then call fini. This will ensure the multi-root force merge during -* fini. +* Create a new mm with a non power-of-two size. Allocate a random size from each +* root, free as cleared and then call fini. This will ensure the multi-root +* force merge during fini. */ - mm_size =12 *SZ_4K ; - size =max (round_up (prandom_u32_state (&prng) % mm_size, ps), ps); + mm_size = (SZ_4K << max_order) + (SZ_4K << (max_order -2 )); +KUNIT_EXPECT_FALSE (test,drm_buddy_init (&mm, mm_size, ps)); -KUNIT_ASSERT_FALSE_MSG (test,drm_buddy_alloc_blocks (&mm,0 , mm_size, - size, ps, &allocated, -DRM_BUDDY_TOPDOWN_ALLOCATION ), -"buddy_alloc hit an error size=%u\n" , size); +KUNIT_EXPECT_EQ (test, mm.max_order, max_order); +KUNIT_ASSERT_FALSE_MSG (test,drm_buddy_alloc_blocks (&mm,0 ,SZ_4K << max_order, +4 * ps, ps, &allocated, +DRM_BUDDY_RANGE_ALLOCATION ), +"buddy_alloc hit an error size=%lu\n" ,4 * ps); +drm_buddy_free_list (&mm, &allocated,DRM_BUDDY_CLEARED ); +KUNIT_ASSERT_FALSE_MSG (test,drm_buddy_alloc_blocks (&mm,0 ,SZ_4K << max_order, +2 * ps, ps, &allocated, +DRM_BUDDY_CLEAR_ALLOCATION ), +"buddy_alloc hit an error size=%lu\n" ,2 * ps); +drm_buddy_free_list (&mm, &allocated,DRM_BUDDY_CLEARED ); +KUNIT_ASSERT_FALSE_MSG (test,drm_buddy_alloc_blocks (&mm,SZ_4K << max_order, mm_size, + ps, ps, &allocated, +DRM_BUDDY_RANGE_ALLOCATION ), +"buddy_alloc hit an error size=%lu\n" , ps);drm_buddy_free_list (&mm, &allocated,DRM_BUDDY_CLEARED );drm_buddy_fini (&mm); }
Signature · 1 line
2.25.1
Re: [PATCH v2 2/2] drm/buddy: Add a testcase to verify the multiroot fini
Quoted 2 lines · Arunpravin Paneer Selvam
- Added a testcase to verify the multiroot force merge fini.
- Added a new fieldin_useto track the mm freed status.
I guess this is out of date now?
Quoted 6 lines
v2:(Matthew)
- Addkunit_fail_current_test()whenWARN_ONis true.Signed-off-by Arunpravin Paneer Selvam <[email protected]>Signed-off-by Lin.Cao <[email protected]>
Paneer Selvam, Arunpravin
maintainerRe: [PATCH v2 2/2] drm/buddy: Add a testcase to verify the multiroot fini
In reply to Arunpravin Paneer SelvamHi Matthew,
Ping?
Regards,
Arun.
Quoted 79 lines · Arunpravin Paneer Selvam
- Added a testcase to verify the multiroot force merge fini.
- Added a new fieldin_useto track the mm freed status.v2:(Matthew)
- Addkunit_fail_current_test()whenWARN_ONis true.Signed-off-by Arunpravin Paneer Selvam <[email protected]>Signed-off-by Lin.Cao <[email protected]>--- drivers/gpu/drm/drm_buddy.c | 6 +++++- drivers/gpu/drm/tests/drm_buddy_test.c | 29 ++++++++++++++++++-------- 2 files changed, 25 insertions(+), 10 deletions(-)drivers/gpu/drm/drm_buddy.c +5
-1@@ -3,6 +3,8 @@* Copyright © 2021 Intel Corporation */ +#include <kunit/test-bug.h> +#include <linux/kmemleak.h> #include <linux/module.h> #include <linux/sizes.h> @@ -335,7 +337,9 @@ void drm_buddy_fini(struct drm_buddy *mm) start =drm_buddy_block_offset (mm->roots[i]);__force_merge (mm, start, start + size, order); -WARN_ON (!drm_buddy_block_is_free (mm->roots[i])); +if (WARN_ON (!drm_buddy_block_is_free (mm->roots[i]))) +kunit_fail_current_test ("buddy_fini() root" ); +drm_block_free (mm, mm->roots[i]); root_size = mm->chunk_size << order;drivers/gpu/drm/tests/drm_buddy_test.c +20
-9@@ -385,17 +385,28 @@ static void drm_test_buddy_alloc_clear(struct kunit *test)drm_buddy_fini (&mm);/* -* Create a new mm with a non power-of-two size. Allocate a random size, free as -* cleared and then call fini. This will ensure the multi-root force merge during -* fini. +* Create a new mm with a non power-of-two size. Allocate a random size from each +* root, free as cleared and then call fini. This will ensure the multi-root +* force merge during fini. */ - mm_size =12 *SZ_4K ; - size =max (round_up (prandom_u32_state (&prng) % mm_size, ps), ps); + mm_size = (SZ_4K << max_order) + (SZ_4K << (max_order -2 )); +KUNIT_EXPECT_FALSE (test,drm_buddy_init (&mm, mm_size, ps)); -KUNIT_ASSERT_FALSE_MSG (test,drm_buddy_alloc_blocks (&mm,0 , mm_size, - size, ps, &allocated, -DRM_BUDDY_TOPDOWN_ALLOCATION ), -"buddy_alloc hit an error size=%u\n" , size); +KUNIT_EXPECT_EQ (test, mm.max_order, max_order); +KUNIT_ASSERT_FALSE_MSG (test,drm_buddy_alloc_blocks (&mm,0 ,SZ_4K << max_order, +4 * ps, ps, &allocated, +DRM_BUDDY_RANGE_ALLOCATION ), +"buddy_alloc hit an error size=%lu\n" ,4 * ps); +drm_buddy_free_list (&mm, &allocated,DRM_BUDDY_CLEARED ); +KUNIT_ASSERT_FALSE_MSG (test,drm_buddy_alloc_blocks (&mm,0 ,SZ_4K << max_order, +2 * ps, ps, &allocated, +DRM_BUDDY_CLEAR_ALLOCATION ), +"buddy_alloc hit an error size=%lu\n" ,2 * ps); +drm_buddy_free_list (&mm, &allocated,DRM_BUDDY_CLEARED ); +KUNIT_ASSERT_FALSE_MSG (test,drm_buddy_alloc_blocks (&mm,SZ_4K << max_order, mm_size, + ps, ps, &allocated, +DRM_BUDDY_RANGE_ALLOCATION ), +"buddy_alloc hit an error size=%lu\n" , ps);drm_buddy_free_list (&mm, &allocated,DRM_BUDDY_CLEARED );drm_buddy_fini (&mm); }
Matthew Auld
maintainerRe: [PATCH v2 2/2] drm/buddy: Add a testcase to verify the multiroot fini
Hey,
Quoted 3 lines · Arunpravin
Hi Matthew,
Ping?
Just got back from time off. I already slapped an r-b here: https://lore.kernel.org/dri-devel/[email protected]/
Quoted 89 lines
Regards,
Arun.Quoted 83 lines · Arunpravin Paneer Selvam
- Added a testcase to verify the multiroot force merge fini.
- Added a new fieldin_useto track the mm freed status.v2:(Matthew)
- Addkunit_fail_current_test()whenWARN_ONis true.Signed-off-by Arunpravin Paneer Selvam <[email protected]>Signed-off-by Lin.Cao <[email protected]>---
drivers/gpu/drm/drm_buddy.c | 6 +++++-drivers/gpu/drm/tests/drm_buddy_test.c| 29 ++++++++++++++++++--------2 files changed, 25 insertions(+), 10 deletions(-)drivers/gpu/drm/drm_buddy.c +5
-1@@ -3,6 +3,8 @@* Copyright © 2021 Intel Corporation */ +#include <kunit/test-bug.h> + #include <linux/kmemleak.h> #include <linux/module.h> #include <linux/sizes.h>@@ -335,7 +337,9 @@ void drm_buddy_fini(struct drm_buddy *mm) start = drm_buddy_block_offset(mm->roots[i]); __force_merge(mm, start, start + size, order); - WARN_ON(!drm_buddy_block_is_free(mm->roots[i])); + if (WARN_ON(!drm_buddy_block_is_free(mm->roots[i]))) + kunit_fail_current_test("buddy_fini() root"); + drm_block_free(mm, mm->roots[i]); root_size = mm->chunk_size << order;drivers/gpu/drm/tests/drm_buddy_test.c +0
-1@@ -385,17 +385,28 @@ static void drm_test_buddy_alloc_clear(struct kunit *test) drm_buddy_fini(&mm); /* -* Create a new mm with a non power-of-two size. Allocate a random size, free as
- * cleared and then call fini. This will ensure the multi-root force merge during
- * fini.
+ * Create a new mm with a non power-of-two size. Allocate a random size from each
+ * root, free as cleared and then call fini. This will ensure the multi-root
+ * force merge during fini.
*/
-mm_size= 12 *SZ_4K;
- size =max(round_up(prandom_u32_state(&prng) % mm_size, ps), ps); +mm_size= (SZ_4K<<max_order) + (SZ_4K<< (max_order- 2)); +
KUNIT_EXPECT_FALSE(test, drm_buddy_init(&mm, mm_size, ps)); - KUNIT_ASSERT_FALSE_MSG(test, drm_buddy_alloc_blocks(&mm, 0,mm_size, - size, ps, &allocated,
-DRM_BUDDY_TOPDOWN_ALLOCATION), - "buddy_allochit an error size=%u\n", size); +KUNIT_EXPECT_EQ(test, mm.max_order, max_order);
+ KUNIT_ASSERT_FALSE_MSG(test, drm_buddy_alloc_blocks(&mm, 0,SZ_4K<<max_order,
+ 4 * ps, ps, &allocated,
+DRM_BUDDY_RANGE_ALLOCATION), + "buddy_allochit an error size=%lu\n", 4 * ps); +drm_buddy_free_list(&mm, &allocated, DRM_BUDDY_CLEARED); + KUNIT_ASSERT_FALSE_MSG(test, drm_buddy_alloc_blocks(&mm, 0,SZ_4K<<max_order,
+ 2 * ps, ps, &allocated,
+DRM_BUDDY_CLEAR_ALLOCATION), + "buddy_allochit an error size=%lu\n", 2 * ps); +drm_buddy_free_list(&mm, &allocated, DRM_BUDDY_CLEARED); + KUNIT_ASSERT_FALSE_MSG(test, drm_buddy_alloc_blocks(&mm,SZ_4K<<max_order,mm_size,
+ ps, ps, &allocated,
+DRM_BUDDY_RANGE_ALLOCATION), + "buddy_allochit an error size=%lu\n", ps);drm_buddy_free_list(&mm, &allocated, DRM_BUDDY_CLEARED);drm_buddy_fini(&mm);
}
Re: [PATCH v2 2/2] drm/buddy: Add a testcase to verify the multiroot fini
In reply to Arunpravin Paneer SelvamQuoted 5 lines · Arunpravin Paneer Selvam
- Added a testcase to verify the multiroot force merge fini.
- Added a new fieldin_useto track the mm freed status.v2:(Matthew)
- Addkunit_fail_current_test()whenWARN_ONis true.
This i.e. commit 8cb3a1e2b350 ("drm/buddy: Add a testcase to verify the multiroot fini") fails drm-tip build for me with:
In file included from ../drivers/gpu/drm/tests/drm_buddy_test.c:15:../drivers/gpu/drm/tests/drm_buddy_test.c: In function ‘drm_test_buddy_alloc_clear’:../drivers/gpu/drm/tests/drm_buddy_test.c:264:23: error: unused variable ‘prng’ [-Werror=unused-variable]
264 | DRM_RND_STATE(prng, random_seed);
| ^~~~../drivers/gpu/drm/tests/../lib/drm_random.h:18:26: note: in definition of macro ‘DRM_RND_STATE’
18 | struct rnd_state name__ = DRM_RND_STATE_INITIALIZER(seed__)
| ^~~~~~
cc1: all warnings being treated as errors
BR,
Jani.
Quoted 74 lines
Signed-off-by Arunpravin Paneer Selvam <[email protected]>Signed-off-by Lin.Cao <[email protected]>--- drivers/gpu/drm/drm_buddy.c | 6 +++++- drivers/gpu/drm/tests/drm_buddy_test.c | 29 ++++++++++++++++++-------- 2 files changed, 25 insertions(+), 10 deletions(-)drivers/gpu/drm/drm_buddy.c +5
-1@@ -3,6 +3,8 @@* Copyright © 2021 Intel Corporation */ +#include <kunit/test-bug.h> +#include <linux/kmemleak.h> #include <linux/module.h> #include <linux/sizes.h> @@ -335,7 +337,9 @@ void drm_buddy_fini(struct drm_buddy *mm) start =drm_buddy_block_offset (mm->roots[i]);__force_merge (mm, start, start + size, order); -WARN_ON (!drm_buddy_block_is_free (mm->roots[i])); +if (WARN_ON (!drm_buddy_block_is_free (mm->roots[i]))) +kunit_fail_current_test ("buddy_fini() root" ); +drm_block_free (mm, mm->roots[i]); root_size = mm->chunk_size << order;drivers/gpu/drm/tests/drm_buddy_test.c +20
-9@@ -385,17 +385,28 @@ static void drm_test_buddy_alloc_clear(struct kunit *test)drm_buddy_fini (&mm);/* -* Create a new mm with a non power-of-two size. Allocate a random size, free as -* cleared and then call fini. This will ensure the multi-root force merge during -* fini. +* Create a new mm with a non power-of-two size. Allocate a random size from each +* root, free as cleared and then call fini. This will ensure the multi-root +* force merge during fini. */ - mm_size =12 *SZ_4K ; - size =max (round_up (prandom_u32_state (&prng) % mm_size, ps), ps); + mm_size = (SZ_4K << max_order) + (SZ_4K << (max_order -2 )); +KUNIT_EXPECT_FALSE (test,drm_buddy_init (&mm, mm_size, ps)); -KUNIT_ASSERT_FALSE_MSG (test,drm_buddy_alloc_blocks (&mm,0 , mm_size, - size, ps, &allocated, -DRM_BUDDY_TOPDOWN_ALLOCATION ), -"buddy_alloc hit an error size=%u\n" , size); +KUNIT_EXPECT_EQ (test, mm.max_order, max_order); +KUNIT_ASSERT_FALSE_MSG (test,drm_buddy_alloc_blocks (&mm,0 ,SZ_4K << max_order, +4 * ps, ps, &allocated, +DRM_BUDDY_RANGE_ALLOCATION ), +"buddy_alloc hit an error size=%lu\n" ,4 * ps); +drm_buddy_free_list (&mm, &allocated,DRM_BUDDY_CLEARED ); +KUNIT_ASSERT_FALSE_MSG (test,drm_buddy_alloc_blocks (&mm,0 ,SZ_4K << max_order, +2 * ps, ps, &allocated, +DRM_BUDDY_CLEAR_ALLOCATION ), +"buddy_alloc hit an error size=%lu\n" ,2 * ps); +drm_buddy_free_list (&mm, &allocated,DRM_BUDDY_CLEARED ); +KUNIT_ASSERT_FALSE_MSG (test,drm_buddy_alloc_blocks (&mm,SZ_4K << max_order, mm_size, + ps, ps, &allocated, +DRM_BUDDY_RANGE_ALLOCATION ), +"buddy_alloc hit an error size=%lu\n" , ps);drm_buddy_free_list (&mm, &allocated,DRM_BUDDY_CLEARED );drm_buddy_fini (&mm); }
Signature · 1 line
Jani Nikula, Intel
Paneer Selvam, Arunpravin
maintainerRe: [PATCH v2 2/2] drm/buddy: Add a testcase to verify the multiroot fini
Hi Jani,
I merged the below patch into drm-misc-next, Please try rebuilding the drm-tip.
https://cgit.freedesktop.org/drm/drm-misc/commit/?id=00728273bdf1001f8d2f7b65bc398000d7defe0b
Thanks,
Arun.
Quoted 97 lines · Jani Nikula
Quoted 5 lines · Arunpravin Paneer Selvam
- Added a testcase to verify the multiroot force merge fini.
- Added a new fieldin_useto track the mm freed status.v2:(Matthew)
- Addkunit_fail_current_test()whenWARN_ONis true.This i.e. commit
8cb3a1e2b350("drm/buddy: Add a testcase to verify the multiroot fini") fails drm-tip build for me with:In file included from
../drivers/gpu/drm/tests/drm_buddy_test.c:15:../drivers/gpu/drm/tests/drm_buddy_test.c: In function ‘drm_test_buddy_alloc_clear’:../drivers/gpu/drm/tests/drm_buddy_test.c:264:23: error: unused variable ‘prng’ [-Werror=unused-variable]
264 |DRM_RND_STATE(prng, random_seed);
| ^~~~../drivers/gpu/drm/tests/../lib/drm_random.h:18:26: note: in definition of macro ‘DRM_RND_STATE’
18 | structrnd_statename__=DRM_RND_STATE_INITIALIZER(seed__)
| ^~~~~~
cc1: all warnings being treated as errorsBR,
Jani.Quoted 73 lines
Signed-off-by Arunpravin Paneer Selvam <[email protected]>Signed-off-by Lin.Cao <[email protected]>--- drivers/gpu/drm/drm_buddy.c | 6 +++++- drivers/gpu/drm/tests/drm_buddy_test.c | 29 ++++++++++++++++++-------- 2 files changed, 25 insertions(+), 10 deletions(-)drivers/gpu/drm/drm_buddy.c +5
-1@@ -3,6 +3,8 @@* Copyright © 2021 Intel Corporation */ +#include <kunit/test-bug.h> +#include <linux/kmemleak.h> #include <linux/module.h> #include <linux/sizes.h> @@ -335,7 +337,9 @@ void drm_buddy_fini(struct drm_buddy *mm) start =drm_buddy_block_offset (mm->roots[i]);__force_merge (mm, start, start + size, order); -WARN_ON (!drm_buddy_block_is_free (mm->roots[i])); +if (WARN_ON (!drm_buddy_block_is_free (mm->roots[i]))) +kunit_fail_current_test ("buddy_fini() root" ); +drm_block_free (mm, mm->roots[i]); root_size = mm->chunk_size << order;drivers/gpu/drm/tests/drm_buddy_test.c +20
-9@@ -385,17 +385,28 @@ static void drm_test_buddy_alloc_clear(struct kunit *test)drm_buddy_fini (&mm);/* -* Create a new mm with a non power-of-two size. Allocate a random size, free as -* cleared and then call fini. This will ensure the multi-root force merge during -* fini. +* Create a new mm with a non power-of-two size. Allocate a random size from each +* root, free as cleared and then call fini. This will ensure the multi-root +* force merge during fini. */ - mm_size =12 *SZ_4K ; - size =max (round_up (prandom_u32_state (&prng) % mm_size, ps), ps); + mm_size = (SZ_4K << max_order) + (SZ_4K << (max_order -2 )); +KUNIT_EXPECT_FALSE (test,drm_buddy_init (&mm, mm_size, ps)); -KUNIT_ASSERT_FALSE_MSG (test,drm_buddy_alloc_blocks (&mm,0 , mm_size, - size, ps, &allocated, -DRM_BUDDY_TOPDOWN_ALLOCATION ), -"buddy_alloc hit an error size=%u\n" , size); +KUNIT_EXPECT_EQ (test, mm.max_order, max_order); +KUNIT_ASSERT_FALSE_MSG (test,drm_buddy_alloc_blocks (&mm,0 ,SZ_4K << max_order, +4 * ps, ps, &allocated, +DRM_BUDDY_RANGE_ALLOCATION ), +"buddy_alloc hit an error size=%lu\n" ,4 * ps); +drm_buddy_free_list (&mm, &allocated,DRM_BUDDY_CLEARED ); +KUNIT_ASSERT_FALSE_MSG (test,drm_buddy_alloc_blocks (&mm,0 ,SZ_4K << max_order, +2 * ps, ps, &allocated, +DRM_BUDDY_CLEAR_ALLOCATION ), +"buddy_alloc hit an error size=%lu\n" ,2 * ps); +drm_buddy_free_list (&mm, &allocated,DRM_BUDDY_CLEARED ); +KUNIT_ASSERT_FALSE_MSG (test,drm_buddy_alloc_blocks (&mm,SZ_4K << max_order, mm_size, + ps, ps, &allocated, +DRM_BUDDY_RANGE_ALLOCATION ), +"buddy_alloc hit an error size=%lu\n" , ps);drm_buddy_free_list (&mm, &allocated,DRM_BUDDY_CLEARED );drm_buddy_fini (&mm); }
Re: [v2,2/2] drm/buddy: Add a testcase to verify the multiroot fini
In reply to Arunpravin Paneer SelvamHi!
Quoted 8 lines · Arunpravin Paneer Selvam
- Added a testcase to verify the multiroot force merge fini.
- Added a new fieldin_useto track the mm freed status.v2:(Matthew)
- Addkunit_fail_current_test()whenWARN_ONis true.Signed-off-by: Arunpravin Paneer Selvam
<[email protected]>
Quoted 7 lines
Signed-off-by Lin.Cao <[email protected]>Reviewed-by Matthew Auld <[email protected]>---
drivers/gpu/drm/drm_buddy.c | 6 +++++-drivers/gpu/drm/tests/drm_buddy_test.c| 29 ++++++++++++++++++------ --2 files changed, 25 insertions(+), 10 deletions(-)
It appears this patch breaks drm-tip:
drivers/gpu/drm/tests/drm_buddy_test.c: In function ‘drm_test_buddy_alloc_clear’:drivers/gpu/drm/tests/drm_buddy_test.c:264:23: error: unused variable ‘prng’ [-Werror=unused-variable]
264 | DRM_RND_STATE(prng, random_seed);
| ^~~~drivers/gpu/drm/tests/../lib/drm_random.h:18:26: note: in definition of macro ‘DRM_RND_STATE’
18 | struct rnd_state name__ =DRM_RND_STATE_INITIALIZER(seed__)
| ^~~~~~
Thanks,
Thomas
Quoted 92 lines
drivers/gpu/drm/drm_buddy.c +0
-0@@ -3,6 +3,8 @@* Copyright © 2021 Intel Corporation */ drivers/gpu/drm/drm_buddy.c +2
-0+#include <kunit/test-bug.h> +#include <
linux/kmemleak.h>
#include <linux/module.h>
#include <linux/sizes.h>drivers/gpu/drm/drm_buddy.c +0
-0@@ -335,7 +337,9 @@ void drm_buddy_fini(struct drm_buddy *mm) start = drm_buddy_block_offset(mm->roots[i]); __force_merge(mm, start, start + size, order);drivers/gpu/drm/drm_buddy.c +2
-1-WARN_ON (!drm_buddy_block_is_free (mm->roots[i])); +if (WARN_ON (!drm_buddy_block_is_free (mm->roots[i]))) + kunit_fail_current_test("buddy_fini()root");
+
drm_block_free(mm, mm->roots[i]);
root_size=mm->chunk_size<< order;drivers/gpu/drm/tests/drm_buddy_test.c +0
-0@@ -385,17 +385,28 @@ static void drm_test_buddy_alloc_clear(struct kunit *test) drm_buddy_fini(&mm);
/*drivers/gpu/drm/tests/drm_buddy_test.c +0
-1-* Create a new mm with a non power-of-two size. Allocate a random size, free as
drivers/gpu/drm/tests/drm_buddy_test.c +0
-1-* cleared and then call fini. This will ensure the multi- root force merge during
drivers/gpu/drm/tests/drm_buddy_test.c +1
-1-* fini. +* Create a new mm with a non power-of-two size. Allocate a random size from each
drivers/gpu/drm/tests/drm_buddy_test.c +1
-0+* root, free as cleared and then call fini. This will ensure the multi-root
drivers/gpu/drm/tests/drm_buddy_test.c +1
-0+* force merge during fini. */
drivers/gpu/drm/tests/drm_buddy_test.c +0
-2- mm_size =12 *SZ_4K ; - size = max(round_up(prandom_u32_state(&prng) % mm_size, ps),ps);
drivers/gpu/drm/tests/drm_buddy_test.c +2
-0+ mm_size = (SZ_4K << max_order) + (SZ_4K << (max_order -2 )); +
KUNIT_EXPECT_FALSE(test, drm_buddy_init(&mm, mm_size, ps));drivers/gpu/drm/tests/drm_buddy_test.c +0
-1- KUNIT_ASSERT_FALSE_MSG(test, drm_buddy_alloc_blocks(&mm, 0,
mm_size,drivers/gpu/drm/tests/drm_buddy_test.c +0
-1- size,ps, &allocated,
drivers/gpu/drm/tests/drm_buddy_test.c +0
-1-
DRM_BUDDY_TOPDOWN_ALLOCATION),drivers/gpu/drm/tests/drm_buddy_test.c +0
-1- "buddy_alloc hit an errorsize=%u\n", size);
drivers/gpu/drm/tests/drm_buddy_test.c +2
-0+KUNIT_EXPECT_EQ (test, mm.max_order, max_order); + KUNIT_ASSERT_FALSE_MSG(test, drm_buddy_alloc_blocks(&mm, 0,
SZ_4K<<max_order,drivers/gpu/drm/tests/drm_buddy_test.c +1
-0+ 4 * ps,ps, &allocated,
drivers/gpu/drm/tests/drm_buddy_test.c +1
-0+
DRM_BUDDY_RANGE_ALLOCATION),drivers/gpu/drm/tests/drm_buddy_test.c +1
-0+ "buddy_alloc hit an errorsize=%lu\n", 4 * ps);
drivers/gpu/drm/tests/drm_buddy_test.c +2
-0+drm_buddy_free_list (&mm, &allocated,DRM_BUDDY_CLEARED ); + KUNIT_ASSERT_FALSE_MSG(test, drm_buddy_alloc_blocks(&mm, 0,
SZ_4K<<max_order,drivers/gpu/drm/tests/drm_buddy_test.c +1
-0+ 2 * ps,ps, &allocated,
drivers/gpu/drm/tests/drm_buddy_test.c +1
-0+
DRM_BUDDY_CLEAR_ALLOCATION),drivers/gpu/drm/tests/drm_buddy_test.c +1
-0+ "buddy_alloc hit an errorsize=%lu\n", 2 * ps);
drivers/gpu/drm/tests/drm_buddy_test.c +2
-0+drm_buddy_free_list (&mm, &allocated,DRM_BUDDY_CLEARED ); + KUNIT_ASSERT_FALSE_MSG(test, drm_buddy_alloc_blocks(&mm,
SZ_4K<<max_order,mm_size,drivers/gpu/drm/tests/drm_buddy_test.c +1
-0+ ps, ps,&allocated,
drivers/gpu/drm/tests/drm_buddy_test.c +1
-0+
DRM_BUDDY_RANGE_ALLOCATION),drivers/gpu/drm/tests/drm_buddy_test.c +1
-0+ "buddy_alloc hit an errorsize=%lu\n", ps);
drm_buddy_free_list(&mm, &allocated, DRM_BUDDY_CLEARED);drm_buddy_fini(&mm);
}