Re: [PATCH v3] x86/setup: get ramdisk parameters only once
From: Ingo Molnar
Date: Tue Feb 09 2016 - 08:13:34 EST
* Alexander Kuleshov <kuleshovmail@xxxxxxxxx> wrote:
> +/*
> + * ramdisk setup
> + */
> +struct ramdisk {
> + u64 image;
> + u64 size;
> + u64 end;
> +};
So what exactly are 'image' and 'end'? The names are not self-descriptory. Please
add comments that describe them and use the opportunity to rename the fields to
more self-descriptory names.
> +static void __init relocate_initrd(struct ramdisk ramdisk)
Why pass by value, why not by address?
> {
> + u64 area_size = PAGE_ALIGN(ramdisk.size);
Why introduce a local variable here? Also, isn't ramdisk.size already page
aligned?
> +static void __init early_reserve_initrd(struct ramdisk ramdisk)
> {
> + memblock_reserve(ramdisk.image, ramdisk.end - ramdisk.image);
> }
Looks like a pretty pointless function now - can be expanded into its call site.
> void __init setup_arch(char **cmdline_p)
> {
> + struct ramdisk ramdisk_image = {
> + .image = get_ramdisk_image(),
> + .size = get_ramdisk_size(),
> + /* Assume only end is not page aligned */
> + .end = PAGE_ALIGN(ramdisk_image.image + ramdisk_image.size)
> + };
> + bool reserve_ramdisk = true;
Why not merge 'reserve_ramdisk' into the ramdisk state structure as well?
> - early_reserve_initrd();
> + if (!boot_params.hdr.type_of_loader || !ramdisk_image.image
> + || !ramdisk_image.size) {
> + reserve_ramdisk = false;
> + return; /* No initrd provided by bootloader */
> + } else
> + early_reserve_initrd(ramdisk_image);
Curly braces should be balanced.
Thanks,
Ingo