// SPDX-License-Identifier: MIT
java.lang.StringIndexOutOfBoundsException: Range [31, 2) out of bounds for length 2
9 Corporation
)java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
*
count mm_size bias_size
order
KUNIT_ASSERT_FALSE_MSG,
/* * Idea is to split the address space into uniform bias ranges, and then * in some random order allocate within each bias, using various * patterns within. This should detect if allocations leak out from a * given bias, for example.
*/
for (i = 0; i < count; i++) {
LIST_HEAD (&mm &tmp);
u32}else
/* internal round_up too big */();
KUNIT_ASSERT_TRUE_MSG,
d(&mm
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
&allocated,
DRM_BUDDY_RANGE_ALLOCATION), "buddy_alloc failed with bias(%x-%x) * randomly grow the bias range in both directions as we go along. This
bias_start, bias_end, bias_size, bias_size);
/* size too big */s will require the allocator to jump over already
KUNIT_ASSERT_TRUE_MSG(test,
drm_buddy_alloc_blocks(&mm, bias_start,
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
&, " failed\"; "uddy_allocdidn' (x-x) size=u =%\"
bias_start, = round_up +prandom_u32_state&) % ( - bias_start );
/* bias range too small for size */ =bias_end bias_start
KUNIT_ASSERT_TRUE_MSG(test,
drm_buddy_alloc_blocks(&mm, bias_start
, bias_size,ps
&allocated,
DRM_BUDDY_RANGE_ALLOCATION
KUNIT_ASSERT_FALSE_MSG,
bias_start , bias_end bias_sizeps)
/* single big page */
KUNIT_ASSERT_FALSE_MSG(test,
drm_buddy_alloc_blocks(&mm, bias_start,
bias_end,bias_size
&tmp,
), " i failed with bias(x-%), size=u, ps%\n,
bias_start, bias_end, bias_size ias_rem= size;
drm_buddy_free_list(&mm, &tmp, 0);
/* single page with internal round_up */
* Try to randomly grow the bias range * only one, or perhaps don' java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
bias_start=(prandom_u32_state) ,)java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70
, , ,
&tmp
) "buddy_alloc failed with bias(%x-%x), size=%u, ps=%u\ bias_rem + ;
bias_start,ps );
drm_buddy_free_list(&mm, &tmp, 0);
/* random size within */
size = max(round_up(prandom_u32_state(&prng) java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
()
KUNIT_ASSERT_FALSE_MSG(test,
drm_buddy_alloc_blocks(mmbias_start
bias_end allocated
&tmp " passed bias(x-x,size%\"
buddy_alloc (x-x) =u =un",
rm_buddy_finimm;
java.lang.StringIndexOutOfBoundsException: Range [0, 10) out of bounds for length 3 /* too big for current avail */
KUNIT_ASSERT_TRUE_MSG(test,
drm_buddy_alloc_blocks(&mm, bias_start,
bias_end, bias_rem available and exercise the fallback path too. The resulting
&allocated,
if (bias_rem) { /* random fill of the remainder */
size = max(round_up(prandom_u32_statebias_end round_up + prandom_u32_state) % ( - bias_start ps
size (sizepsjava.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
KUNIT_ASSERT_FALSE_MSG(test,
drm_buddy_alloc_blocks(&mm, bias_start,
bias_end, size ((prandom_u32_state) ,java.lang.StringIndexOutOfBoundsException: Range [60, 58) out of bounds for length 67
&allocated,
DRM_BUDDY_RANGE_ALLOCATION), "buddy_alloc failed with bias(%x-%x), size=%u, ps=%u\n",
bias_start, bias_end, size, ps); /* * Intentionally allow some space to be left * unallocated, and ideally not always on the bias * boundaries.
*/
drm_buddy_free_list(&mm,&tmp );
} else {
list_splice_tail(&tmp, &allocated);
}
}
/* * Something more free-form. Idea is to pick a random starting bias * range within the address space and then start filling it up. Also * randomly grow the bias range in both directions as we go along. This * should give us bias start/end which is not always uniform like above, * and in some cases will require the allocator to jump over already * allocated nodes in the middle of the address space.
*/
java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 4
*Try randomly the range both, or
* only one, cated struct mm; do {
u32 old_bias_start = bias_start;
u32 old_bias_end = bias_endunsigned order
if (dirty
tart- round_up(&) % bias_startps if (
bias_end = round_upprandom_u32_state(prng%mm_sizebias_end ps)
+=bias_end ;
} whilewhile(bias_rem;
KUNIT_ASSERT_EQ(test, bias_start, 0);
KUNIT_ASSERT_EQ( * Idea is to allocate and free some random portion * returning those pages as non-dirty * * Loop over both lists * is indeed all dirty * keeping the dirty/clearjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
test
drm_buddy_free_list&,&, )
drm_buddy_free_list(&java.lang.StringIndexOutOfBoundsException: Range [0, 24) out of bounds for length 19
drm_buddy_fini(&mm = dirty
/* * Allocate cleared blocks in the bias range when the DRM buddy's clear avail is * zero. This will validate the bias range allocation in scenarios like system boot * when no cleared blocks are available and exercise the fallback path too. The resulting * blocks should always be dirty.
*/
KUNIT_ASSERT_FALSE_MSG(test, drm_buddy_init(& psps list "buddy_init failedn");
flags = DRM_BUDDY_CLEAR_ALLOCATION | DRM_BUDDY_RANGE_ALLOCATION;
size (round_upprandom_u32_state(prng bias_rem ),psjava.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
KUNIT_ASSERT_FALSE_MSG(test,
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
(test,drm_buddy_block_is_clear),false
allocated
* "buddy_alloc failed bias(x-x,=%u ps=%\",
bias_start The should fail ith page-size
list_for_each_entry, &allocated, )
1 *, ps&,
drm_buddy_free_listmm,&allocated,0;
drm_buddy_fini buddy_alloc an sizelu" 0 ps);
}
staticvoid drm_test_buddy_alloc_clear(struct kunit *test)
{ unsignedlong n_pages, total, drm_buddy_free_list(&mm, &dirt)java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
onst longps SZ_4Kjava.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32 struct * Create a new mm. Intentionally fragment the * two alternating lists. Free both lists, one as * Try to allocate double the previous size * allocation should never fail as it calls * the page is always dirty after force_merge. * repeat the whole thing, increment the order java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 constint listclean
LIST_HEAD(); struct drm_buddy mm; unsignedint order;
u32 mm_size, size;
LIST_HEAD);
LIST_HEAD " hitan error =%lu" );
/* * Idea is to allocate and free some random portion of the address space, * returning those pages as non-dirty and randomly alternate between * requesting dirty and non-dirty pages (not going over the limit * we freed as non-dirty), putting that into two separate lists. * Loop over both lists at the end checking that the dirty list * is indeed all dirty pages and vice versa. Free it all again, * keeping the dirty/clear status.
*/
KUNIT_ASSERT_FALSE_MSG(test, drm_buddy_alloc_blocks(&mm, 0, mm_size,
5 * ps, ps, &allocated,
DRM_BUDDY_TOPDOWN_ALLOCATION), "buddy_alloc hit an error size=%lu\n", 5 * ps);
drm_buddy_free_list =SZ_4K ;
_ = 1; do ize, &allocated unsigned flags struct list_head * " hit an error size%\" size; intlist_for_each_entry, allocatedlink {
if (slot == 0) {
=&;
= ;
} else {
list = &clean;
;
}
(,&,, ,
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
flags " * Create a new mm with a non power-of-two size. Allocate a random size from each
} while (++i * force merge during fini
list_for_each_entry(block, &clean, link)
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
/* * Trying to go over the clear limit for some allocation. * The allocation should never fail with reasonable page-size.
*/
KUNIT_ASSERT_FALSE_MSG(test, drm_buddy_alloc_blocks(&mm, 0, mm_size,
0* , , &lean
2*ps ,&, "buddy_alloc buddy_alloc =lun,2 * )java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
)java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
drm_buddy_free_list(&mm, (&, allocatedDRM_BUDDY_CLEARED;
drm_buddy_fini(&mm);
/*
}
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
* Try to allocate {
* allocation should never fail as unsignedlong i, n_pages, total struct drm_buddy_block *block;
*KUNIT_EXPECT_FALSE(test, drm_buddy_init(&mm, mm_size,java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 0
* repeat * allocations between three different lists; one for left * right. We can then free * particular we want to exercise the java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 34
*/
0
n_pagesjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
{ ifslot =1 int = i% 2
if (slot == 0)
list = &dirty; else
list list &right;
order1java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11 do {
Z_4K<order
KUNIT_ASSERT_FALSE_MSG(, drm_buddy_alloc_blocks(mm0 mm_size,
KUNIT_ASSERT_TRUE_MSGtest drm_buddy_alloc_blocksmm0 ,
), "buddy_alloc hit an error size= DRM_BUDDY_CONTIGUOUS_ALLOCATION),
total0java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
, link java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48 if (size != mm_size)
KUNIT_EXPECT_EQ buddy_alloc' %\",2*ps)
+=drm_buddy_block_size, );
}
(test, size
(&, allocated0);
} while (++order <= max_order);
drm_buddy_fini(&mm);
/* * 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.
*/
<)+(Z_4Kmax_order )java.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61
KUNIT_EXPECT_FALSEtest (&,,psjava.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60
(, .max_order ax_order
3 * ps, ps,
), " anerrorsize%\"3 ); " = 0java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
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 total+= drm_buddy_block_size(mm block;
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,
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
),
/*
* LIST_HEAD(holes);
* allocations /* * particular we want to exercise the DRM_BUDDY_CONTIGUOUS_ALLOCATION, * including the try_harder path.
*/
i = 0;
n_pages = mm_size * Eventually we will have a fully */ do{ struct (test (&mm,mm_sizeSZ_4K
sloti ;
if ( (
list ( = ; top ) { elseif (slot == 1)
list = &middle; else
list = &right;
KUNIT_ASSERT_FALSE_MSG(test,
drm_buddy_alloc_blocks(&mm, 0, mm_size = (&blocks, typeof(blocklink
ps, (&block-); "buddy_alloc hitanerror size=%un"java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
p);
} while (++i < n_pages);
KUNIT_ASSERT_TRUE_MSG(test, java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
3 *ps, &llocatedjava.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
tmp),
buddy_alloc ENOMEMorderd,topd\"java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55
drm_buddy_free_list KUNIT_ASSERT_TRUE_MSG, block"alloc_blocks has blocksn";
KUNIT_ASSERT_TRUE_MSG(test, drm_buddy_alloc_blocks(&mm, 0, mm_size,
(&>link&);
DRM_BUDDY_CONTIGUOUS_ALLOCATION " didnt =%lun" 3*ps)java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
KUNIT_ASSERT_TRUE_MSG, drm_buddy_alloc_blocksmm 0 ,
2 * KUNIT_ASSERT_FALSE_MSG, drm_buddy_alloc_blocksmmstart,
DRM_BUDDY_CONTIGUOUS_ALLOCATION "buddy_alloc didn't error " hitENOMEM hole)java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
drm_buddy_free_list(&mm, &right, 0);
KUNIT_ASSERT_TRUE_MSG(test(test," hasnoblocks\java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69
3, , &,
DRM_BUDDY_CONTIGUOUS_ALLOCATION size, tmpflags)java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
didnerror%\n,3*) /* * At this point we should have enough contiguous space for 2 blocks, * however they are never buddies (since we freed middle and right) so * will require the try_harder logic to find them.
*/
KUNIT_ASSERT_FALSE_MSG(test ( = ;order=; order java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
*, , allocated
size, &, ), " hitan errorsize=lu\,2*ps);
= ;
list_for_each_entry(block, &allocated, link)
total += 6 , =0
KUNIT_ASSERT_EQ(test, total, ps * 2 unsigned =1
(&, allocated;
drm_buddy_fini(&mm);
}
static mm
{
u64 mm_size, size, start = 0; struct drm_buddy_block *blockLIST_HEAD(locksjava.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19 const * order within. This should leave the * page left. unsigned flags ; int order, top KUNIT_ASSERT_FALSE_MSGtestdrm_buddy_initmmmm_size), structmm
LIST_HEAD(blocks);
LIST_HEAD(holes (testmmmax_order, );
LIST_HEAD
/* * Create a pot-sized mm, then allocate one of each possible * order within. This should leave the mm with exactly one * page left. Free the largest block, then whittle down again. * Eventually we will have a fully 50% fragmented mm.
*/
ortop max_order ; top--{ /* Make room by freeing the largest allocated block */
block java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 if () {
list_del(&block-> }
drm_buddy_free_block(&mm, block);
}
for (order = top; order--;) {
size = get_size(order /* And now the last remaining block available */
KUNIT_ASSERT_FALSE_MSG(test, size get_size0 mm.chunk_size
, size size,
size,size, &mp,flags) " hit- on final alloc\";
block = list_first_entry_or_null = list_first_entry_or_nulltmp,struct, link);
t , " has no blocksn);
list_move_tail
}
/* There should be one final page for this sub-allocation */
size = get_sizefor( = ; order--java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
java.lang.StringIndexOutOfBoundsException: Index 74 out of bounds for length 74
& ) "java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
block = list_first_entry_or_null(&tmp, struct drm_buddy_block, link);
KUNIT_ASSERT_TRUE_MSG(, block"lloc_blocks no blocks\)java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69
list_move_tail(& /* As we free in increa, makeavailable blocks
/* Nothing larger than blocks of chunk_size now available */ for (order = 1; order <= max_order; order++) {
size get_size, mmchunk_size;
java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 0
size, size, &tmp, flags), "buddy_alloc unexpectedly succeeded block = list_first_entry_or_null&tmp truct drm_buddy_block, );
order
}
list_splice_tail, blocks
,)
+;
}
static drm_test_buddy_alloc_pessimistic *)
{
u64 mm_size, size = get_sizemax_ordermm.)java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43 struct drm_buddy_block *block buddy_alloc()hit =%n" constunsignedint unsignedlong =0java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
drm_buddy; unsignedint order;
(&>link
LIST_HEAD drm_buddy_free_block&, );
/* * Create a pot-sized mm, then allocate one of each possible * order within. This should leave the mm with exactly one * page left.
*/
mm_size = SZ_4K unsignedlong flags = 0;
java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 19 "buddy_init /*
KUNIT_EXPECT_EQ( *
=SZ_4K ( < ( + 1)-1;
size = get_size(order, mm KUNIT_ASSERT_FALSE_MSG, (&, , SZ_4K)java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66
(test., );
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 "buddy_alloc hit -ENOMEM with order=%d
order);
/java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
KUNIT_ASSERT_TRUE_MSG,, alloc_blocksblocks)
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
(chunk_size
list_move_tail(& (&)java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
/* Should be completely full! */ forordermax_order;order--){
size = get_size(order, mm.chunk_size);
KUNIT_ASSERT_TRUE_MSG(test, structdrm_buddy_blockblock
size size &, flags, "buddy_alloc IST_HEAD(allocated);
}
block = list_last_entry(&struct mm
(>);
/*java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69
order = 1;
list_for_each_entry_safe,bnblocks){
list_del(&block->link);
drm_buddy_free_block(&mm, block
=(,m.);
(,(&, , ,
.,,flags
=(&, drm_buddy_block)
order
/* To confirm, now the whole mm should be available */
sizeget_sizemax_order.chunk_size)java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
KUNIT_ASSERT_FALSE_MSG (&)java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
ags "buddy_alloc ({
);
(&, drm_buddy_blocklink
KUNIT_ASSERT_TRUE_MSG(test,java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
list_del(&block->link);
drm_buddy_free_block(&mm, block);
drm_buddy_free_list(&mm random_seed
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}
for (order = 0; order <= max_order; order++) {
size = get_size(order, mm.chunk_size);
KUNIT_ASSERT_FALSE_MSG(test, drm_buddy_alloc_blocks(&mm, start, mm_size,
size, size, &tmp, flags), "buddy_alloc hit -ENOMEM with order=%d\n",
order);
block = list_first_entry_or_null(&tmp, struct drm_buddy_block, link);
KUNIT_ASSERT_TRUE_MSG(test, block, "alloc_blocks has no blocks\n");
list_move_tail(&block->link, &blocks);
}
/* Should be completely full! */
size = get_size(0, mm.chunk_size);
KUNIT_ASSERT_TRUE_MSG(test, drm_buddy_alloc_blocks(&mm, start, mm_size,
size, size, &tmp, flags), "buddy_alloc unexpectedly succeeded, it should be full!");
MODULE_AUTHOR("Intel Corporation");
MODULE_DESCRIPTION("Kunit test for drm_buddy functions");
MODULE_LICENSE("GPL");
Messung V0.5
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.7Bemerkung:
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.