From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756007AbcBIMKX (ORCPT ); Tue, 9 Feb 2016 07:10:23 -0500 Received: from mail-wm0-f65.google.com ([74.125.82.65]:35118 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750781AbcBIMKU (ORCPT ); Tue, 9 Feb 2016 07:10:20 -0500 Date: Tue, 9 Feb 2016 13:10:16 +0100 From: Ingo Molnar To: Alexander Kuleshov Cc: Ingo Molnar , Thomas Gleixner , "H . Peter Anvin" , Borislav Petkov , Joerg Roedel , Dave Young , Andrew Morton , Jiri Kosina , Baoquan He , Paolo Bonzini , Mark Salter , LKML , the arch/x86 maintainers Subject: Re: [PATCH v2] x86/setup: Merge {early_,}reserve_initrd() to one function Message-ID: <20160209121016.GD500@gmail.com> References: <1454954546-23074-1-git-send-email-kuleshovmail@gmail.com> <20160209091626.GA12570@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Alexander Kuleshov wrote: > Hello Ingo, > > On Tue, Feb 9, 2016 at 3:16 PM, Ingo Molnar wrote: > > > > So I don't think the code got easier to understand - in particular the > > memblock_reserve()/free() pattern, depending on a flag value, is confusing. > > > > The duplication is there - but please factor it out into a helper structure > > ('struct ramdisk') and a helper function that sets up the structure. > > What if instead of `struct ramdisk`, we will move all definitions/check from > the early_reserve_initrd to the setup_arch() and than will pass these values > to the reserve_initrd()? There's too many of them, putting them into 'struct ramdisk' cleans up and documents the whole code. And yes, 'struct ramdisk' state should be defined in setup_arch(), that way it does not have to be calculated twice: so the patch becomes not just a code size reduction but a (small) runtime reduction as well. Should be tested with a real ramdisk, to make sure everything still works fine. Thanks, Ingo