Skip to content

Commit e04d320

Browse files
committed
percpu: indent the population block in pcpu_alloc()
The next patch will conditionalize the population block in pcpu_alloc() which will end up making a rather large indentation change obfuscating the actual logic change. This patch puts the block under "if (true)" so that the next patch can avoid indentation changes. The defintions of the local variables which are used only in the block are moved into the block. This patch is purely cosmetic. Signed-off-by: Tejun Heo <[email protected]>
1 parent a16037c commit e04d320

File tree

1 file changed

+21
-17
lines changed

1 file changed

+21
-17
lines changed

mm/percpu.c

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,6 @@ static void __percpu *pcpu_alloc(size_t size, size_t align, bool reserved)
742742
struct pcpu_chunk *chunk;
743743
const char *err;
744744
int slot, off, new_alloc, cpu, ret;
745-
int page_start, page_end, rs, re;
746745
unsigned long flags;
747746
void __percpu *ptr;
748747

@@ -847,27 +846,32 @@ static void __percpu *pcpu_alloc(size_t size, size_t align, bool reserved)
847846
spin_unlock_irqrestore(&pcpu_lock, flags);
848847

849848
/* populate if not all pages are already there */
850-
mutex_lock(&pcpu_alloc_mutex);
851-
page_start = PFN_DOWN(off);
852-
page_end = PFN_UP(off + size);
849+
if (true) {
850+
int page_start, page_end, rs, re;
853851

854-
pcpu_for_each_unpop_region(chunk, rs, re, page_start, page_end) {
855-
WARN_ON(chunk->immutable);
852+
mutex_lock(&pcpu_alloc_mutex);
856853

857-
ret = pcpu_populate_chunk(chunk, rs, re);
854+
page_start = PFN_DOWN(off);
855+
page_end = PFN_UP(off + size);
858856

859-
spin_lock_irqsave(&pcpu_lock, flags);
860-
if (ret) {
861-
mutex_unlock(&pcpu_alloc_mutex);
862-
pcpu_free_area(chunk, off);
863-
err = "failed to populate";
864-
goto fail_unlock;
857+
pcpu_for_each_unpop_region(chunk, rs, re, page_start, page_end) {
858+
WARN_ON(chunk->immutable);
859+
860+
ret = pcpu_populate_chunk(chunk, rs, re);
861+
862+
spin_lock_irqsave(&pcpu_lock, flags);
863+
if (ret) {
864+
mutex_unlock(&pcpu_alloc_mutex);
865+
pcpu_free_area(chunk, off);
866+
err = "failed to populate";
867+
goto fail_unlock;
868+
}
869+
bitmap_set(chunk->populated, rs, re - rs);
870+
spin_unlock_irqrestore(&pcpu_lock, flags);
865871
}
866-
bitmap_set(chunk->populated, rs, re - rs);
867-
spin_unlock_irqrestore(&pcpu_lock, flags);
868-
}
869872

870-
mutex_unlock(&pcpu_alloc_mutex);
873+
mutex_unlock(&pcpu_alloc_mutex);
874+
}
871875

872876
/* clear the areas and return address relative to base address */
873877
for_each_possible_cpu(cpu)

0 commit comments

Comments
 (0)