diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2014-03-06 21:08:24 -0500 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2014-03-07 07:52:26 -0500 |
commit | 706c16f2372316a0a8af3be6e2bd6e391c073ca0 (patch) | |
tree | 136c7fc3bb7df6503448351d9677c0b45a300a2c /mm | |
parent | 0f0ca14386e0431fbedaae5efc550d46cf93b9cf (diff) |
perpcu: fold pcpu_split_block() into the only caller
... and simplify the results a bit. Makes the next step easier
to deal with - we will be changing the data representation for
chunk->map[] and it's easier to do if the code in question is
not split between pcpu_alloc_area() and pcpu_split_block().
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'mm')
-rw-r--r-- | mm/percpu.c | 63 |
1 files changed, 16 insertions, 47 deletions
diff --git a/mm/percpu.c b/mm/percpu.c index 036cfe07050f..592f289819b7 100644 --- a/mm/percpu.c +++ b/mm/percpu.c | |||
@@ -418,48 +418,6 @@ out_unlock: | |||
418 | } | 418 | } |
419 | 419 | ||
420 | /** | 420 | /** |
421 | * pcpu_split_block - split a map block | ||
422 | * @chunk: chunk of interest | ||
423 | * @i: index of map block to split | ||
424 | * @head: head size in bytes (can be 0) | ||
425 | * @tail: tail size in bytes (can be 0) | ||
426 | * | ||
427 | * Split the @i'th map block into two or three blocks. If @head is | ||
428 | * non-zero, @head bytes block is inserted before block @i moving it | ||
429 | * to @i+1 and reducing its size by @head bytes. | ||
430 | * | ||
431 | * If @tail is non-zero, the target block, which can be @i or @i+1 | ||
432 | * depending on @head, is reduced by @tail bytes and @tail byte block | ||
433 | * is inserted after the target block. | ||
434 | * | ||
435 | * @chunk->map must have enough free slots to accommodate the split. | ||
436 | * | ||
437 | * CONTEXT: | ||
438 | * pcpu_lock. | ||
439 | */ | ||
440 | static void pcpu_split_block(struct pcpu_chunk *chunk, int i, | ||
441 | int head, int tail) | ||
442 | { | ||
443 | int nr_extra = !!head + !!tail; | ||
444 | |||
445 | BUG_ON(chunk->map_alloc < chunk->map_used + nr_extra); | ||
446 | |||
447 | /* insert new subblocks */ | ||
448 | memmove(&chunk->map[i + nr_extra], &chunk->map[i], | ||
449 | sizeof(chunk->map[0]) * (chunk->map_used - i)); | ||
450 | chunk->map_used += nr_extra; | ||
451 | |||
452 | if (head) { | ||
453 | chunk->map[i + 1] = chunk->map[i] - head; | ||
454 | chunk->map[i++] = head; | ||
455 | } | ||
456 | if (tail) { | ||
457 | chunk->map[i++] -= tail; | ||
458 | chunk->map[i] = tail; | ||
459 | } | ||
460 | } | ||
461 | |||
462 | /** | ||
463 | * pcpu_alloc_area - allocate area from a pcpu_chunk | 421 | * pcpu_alloc_area - allocate area from a pcpu_chunk |
464 | * @chunk: chunk of interest | 422 | * @chunk: chunk of interest |
465 | * @size: wanted size in bytes | 423 | * @size: wanted size in bytes |
@@ -524,14 +482,25 @@ static int pcpu_alloc_area(struct pcpu_chunk *chunk, int size, int align) | |||
524 | 482 | ||
525 | /* split if warranted */ | 483 | /* split if warranted */ |
526 | if (head || tail) { | 484 | if (head || tail) { |
527 | pcpu_split_block(chunk, i, head, tail); | 485 | int nr_extra = !!head + !!tail; |
486 | |||
487 | /* insert new subblocks */ | ||
488 | memmove(&chunk->map[i + nr_extra], &chunk->map[i], | ||
489 | sizeof(chunk->map[0]) * (chunk->map_used - i)); | ||
490 | chunk->map_used += nr_extra; | ||
491 | |||
528 | if (head) { | 492 | if (head) { |
529 | i++; | 493 | chunk->map[i + 1] = chunk->map[i] - head; |
494 | chunk->map[i] = head; | ||
530 | off += head; | 495 | off += head; |
531 | max_contig = max(chunk->map[i - 1], max_contig); | 496 | i++; |
497 | max_contig = max(head, max_contig); | ||
498 | } | ||
499 | if (tail) { | ||
500 | chunk->map[i] -= tail; | ||
501 | chunk->map[i + 1] = tail; | ||
502 | max_contig = max(tail, max_contig); | ||
532 | } | 503 | } |
533 | if (tail) | ||
534 | max_contig = max(chunk->map[i + 1], max_contig); | ||
535 | } | 504 | } |
536 | 505 | ||
537 | /* update hint and mark allocated */ | 506 | /* update hint and mark allocated */ |