mn = mas_get_alloc(ms);
if (cnt == 1) {
ms->alloc = NULL;
- } else if (cnt <= 16) {
+ } else if (cnt <= MAPLE_NODE_SLOTS + 1) {
cnt -= 2;
smn = mn->slot[cnt];
mn->slot[cnt] = NULL;
mn = smn;
- } else if (cnt > 16) {
+ } else if (cnt > MAPLE_NODE_SLOTS + 1) {
cnt -= 2;
- smn = mn->slot[(cnt / 15) - 1];
- mn = smn->slot[(cnt % 15)];
- smn->slot[cnt % 15] = NULL;
+ smn = mn->slot[(cnt / MAPLE_NODE_SLOTS) - 1];
+ mn = smn->slot[(cnt % MAPLE_NODE_SLOTS)];
+ smn->slot[cnt % MAPLE_NODE_SLOTS] = NULL;
}
return mn;
cnt = mas_get_alloc_cnt(mas);
if (cnt == 0) {
mas->alloc = reuse;
- } else if (cnt <= 15) {
+ } else if (cnt <= MAPLE_NODE_SLOTS) {
cnt--;
node->slot[cnt] = reuse;
} else {
struct maple_node *smn;
cnt--;
- smn = node->slot[(cnt/15) - 1];
- smn->slot[cnt % 15] = reuse;
+ smn = node->slot[(cnt/MAPLE_NODE_SLOTS) - 1];
+ smn->slot[cnt % MAPLE_NODE_SLOTS] = reuse;
}
cnt = mas_get_alloc_cnt(mas);
{
struct maple_node *mn, *smn;
- int cnt = 0;
+ int i, j, total, full_slots, cnt = 0;
MA_STATE(mas, mt, 0, 0);
mas_nomem(&mas, GFP_KERNEL);
// Set allocation request to 127.
- mas_node_cnt(&mas, 127);
- // Drop the lock and allocate 3 nodes.
+ total = 127;
+ full_slots = (total - MAPLE_NODE_SLOTS) / MAPLE_NODE_SLOTS;
+ mas_node_cnt(&mas, total);
+ // Drop the lock and allocate 127 nodes.
mas_nomem(&mas, GFP_KERNEL);
mn = mas_get_alloc(&mas);
MT_BUG_ON(mt, mn == NULL);
cnt++;
- for (int i = 0; i < 7; i++) {
+ for (i = 0; i < MAPLE_NODE_SLOTS; i++) {
+ j = 0;
smn = mn->slot[i];
MT_BUG_ON(mt, smn == NULL);
cnt++;
- for (int j = 0; j < 15; j++) {
+ while ((i < full_slots) && (j < MAPLE_NODE_SLOTS)) {
MT_BUG_ON(mt, smn->slot[j] == NULL);
cnt++;
+ j++;
}
}
-
- smn = mn->slot[7];
- cnt++;
- MT_BUG_ON(mt, smn == NULL);
- for (int j = 0; j < 6; j++) {
- MT_BUG_ON(mt, smn->slot[j] == NULL);
- cnt++;
- }
-
- for (int i = 8; i < 15; i++) {
- MT_BUG_ON(mt, mn->slot[i] == NULL);
- cnt++;
- }
-
MT_BUG_ON(mt, mas_get_alloc_cnt(&mas) != 127);
mas_nomem(&mas, GFP_KERNEL); // Free.
- MT_BUG_ON(mt, mas_get_alloc_cnt(&mas) != 0);
- for (int i = 1; i < 128; i++) {
- int j;
+ MT_BUG_ON(mt, mas_get_alloc_cnt(&mas) != 0);
+ for (i = 1; i < 128; i++) {
mas_node_cnt(&mas, i); // Request
mas_nomem(&mas, GFP_KERNEL); // Fill request
MT_BUG_ON(mt, mas_get_alloc_cnt(&mas) != i); // check request filled
}
MT_BUG_ON(mt, mas_get_alloc_cnt(&mas) != 0);
}
- for (int i = 1; i < 128; i++) {
- int j;
+ for (i = 1; i < 128; i++) {
MA_STATE(mas2, mt, 0, 0);
mas_node_cnt(&mas, i); // Request
mas_nomem(&mas, GFP_KERNEL); // Fill request