Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

maple_tree: simplify mas_push_node()

When count is not 0, we know head is valid. So we can put the assignment
in if (count) instead of checking the head pointer again.

Also count represents current total, we can assign the new total by
increasing the count by one.

Link: https://lkml.kernel.org/r/20241015120746.15850-4-richard.weiyang@gmail.com
Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
Reviewed-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
Cc: Sidhartha Kumar <sidhartha.kumar@oracle.com>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Wei Yang and committed by
Andrew Morton
908378a3 4223dd93

+7 -9
+7 -9
lib/maple_tree.c
··· 1207 1207 1208 1208 reuse->request_count = 0; 1209 1209 reuse->node_count = 0; 1210 - if (count && (head->node_count < MAPLE_ALLOC_SLOTS)) { 1211 - head->slot[head->node_count++] = reuse; 1212 - head->total++; 1213 - goto done; 1214 - } 1215 - 1216 - reuse->total = 1; 1217 - if ((head) && !((unsigned long)head & 0x1)) { 1210 + if (count) { 1211 + if (head->node_count < MAPLE_ALLOC_SLOTS) { 1212 + head->slot[head->node_count++] = reuse; 1213 + head->total++; 1214 + goto done; 1215 + } 1218 1216 reuse->slot[0] = head; 1219 1217 reuse->node_count = 1; 1220 - reuse->total += head->total; 1221 1218 } 1222 1219 1220 + reuse->total = count + 1; 1223 1221 mas->alloc = reuse; 1224 1222 done: 1225 1223 if (requested > 1)