Re: [PATCH v4] x86/setup: get ramdisk parameters only once

From: Ingo Molnar
Date: Wed Feb 17 2016 - 03:26:06 EST



* Alexander Kuleshov <kuleshovmail@xxxxxxxxx> wrote:

> void __init setup_arch(char **cmdline_p)
> {
> + struct ramdisk ramdisk_image = {
> + .start_addr = get_ramdisk_image(),
> + .size = get_ramdisk_size(),
> + .reserve_ramdisk = true
> + };
> +
> + /* Assume only end is not page aligned */
> + ramdisk_image.end_addr = PAGE_ALIGN(ramdisk_image.start_addr + ramdisk_image.size),
> +
> memblock_reserve(__pa_symbol(_text),
> (unsigned long)__bss_stop - (unsigned long)_text);
>
> - early_reserve_initrd();
> + if (!boot_params.hdr.type_of_loader || !ramdisk_image.start_addr
> + || !ramdisk_image.size)

Don't do pointless line breaks.

> + ramdisk_image.reserve_ramdisk = false; /* No initrd provided by bootloader */
> + else
> + memblock_reserve(ramdisk_image.start_addr,
> + ramdisk_image.end_addr - ramdisk_image.start_addr);

There's a simpler way to write that line ...

> /*
> * At this point everything still needed from the boot loader
> @@ -1135,7 +1137,8 @@ void __init setup_arch(char **cmdline_p)
> /* Allocate bigger log buffer */
> setup_log_buf(1);
>
> - reserve_initrd();
> + if (ramdisk_image.reserve_ramdisk)
> + reserve_initrd(&ramdisk_image);

It's cleaner to make that check inside reserve_initrd() ...

Thanks,

Ingo