From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-178.mta0.migadu.com (out-178.mta0.migadu.com [91.218.175.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 28A2C1FE44A for ; Thu, 30 Jul 2026 14:45:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785422746; cv=none; b=FDM1PMbvPn94y08wyWw5zk70AqEnjFd58dg9PCEGA19FIPqyzaVm+x4yB43JIKXSF7ok6W4m/+dFMJfrX/r+6NJjU8dKxny6sciC1dnAn9X3STzs7pTRgdp+oSE3OLNdDAunJm9nFQPHTX6WRqID83blC4usXhcnMF8Jp3IMHJg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785422746; c=relaxed/simple; bh=Z3u8m4p3hreZsk0ZV/wYnmP4qGpuN35zsKEW5ZfUmmE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=I9ziD/CH2LVbTVpXf5AzTnHhHvv1HbftjuP1wnUO4VHUMidCi+K7x07ekIBFsL2nSDd489NIMZOA2NDrOrKyehD94HssAyax/J84Qr4+o9P0TJ9btOn7Oq+j5PL5O9OhzvZjwvJ6HXKKcLqhr4zUygwuhvfc0YqT8gcTtSkTOKA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=UJYSMRJW; arc=none smtp.client-ip=91.218.175.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="UJYSMRJW" Date: Thu, 30 Jul 2026 16:45:37 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1785422742; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=i3evynFgbV7bMOKE00Gd+z/kFZkYvHbchKCORhppOB0=; b=UJYSMRJW6tcxIkzfcX3hz3D4FKxoMVt1eHV7uvfryJVmD+XNPe4W1tGzTucYzikFoGPmbo +eEqdZyoXbd2cZvjz8ohpQwz8hHpQifRui1hs54xrd9/B5RfLZwf8W04Ifz9KTLsCwgldQ Sz98khpi7TupirpfzjeXcjncb7V8vCU= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Thorsten Blum To: "Christophe Leroy (CS GROUP)" Cc: Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Sourabh Jain , Aditya Gupta , Hari Bathini , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] powerpc/kexec: Simplify kdump_extra_elfcorehdr_size() Message-ID: References: <20260730131940.597739-2-thorsten.blum@linux.dev> <42ab7c21-25cd-4ed1-b43f-b155e82db1a0@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <42ab7c21-25cd-4ed1-b43f-b155e82db1a0@kernel.org> X-Migadu-Flow: FLOW_OUT On Thu, Jul 30, 2026 at 04:33:18PM +0200, Christophe Leroy (CS GROUP) wrote: > Le 30/07/2026 à 15:19, Thorsten Blum a écrit : > > Return the size directly and drop the extra_sz variable to simplify > > kdump_extra_elfcorehdr_size(). The two warning paths now fall through > > to the existing return 0 at the end of the function. > > > > Signed-off-by: Thorsten Blum > > --- > > arch/powerpc/kexec/file_load_64.c | 6 +----- > > 1 file changed, 1 insertion(+), 5 deletions(-) > > > > diff --git a/arch/powerpc/kexec/file_load_64.c b/arch/powerpc/kexec/file_load_64.c > > index c3503d698428..d0c544079e03 100644 > > --- a/arch/powerpc/kexec/file_load_64.c > > +++ b/arch/powerpc/kexec/file_load_64.c > > @@ -377,16 +377,12 @@ static int load_backup_segment(struct kimage *image, struct kexec_buf *kbuf) > > static unsigned int kdump_extra_elfcorehdr_size(struct crash_mem *cmem) > > { > > #if defined(CONFIG_CRASH_HOTPLUG) && defined(CONFIG_MEMORY_HOTPLUG) > > - unsigned int extra_sz = 0; > > - > > if (CONFIG_CRASH_MAX_MEMORY_RANGES > (unsigned int)PN_XNUM) > > pr_warn("Number of Phdrs %u exceeds max\n", CONFIG_CRASH_MAX_MEMORY_RANGES); > > else if (cmem->nr_ranges >= CONFIG_CRASH_MAX_MEMORY_RANGES) > > pr_warn("Configured crash mem ranges may not be enough\n"); > > else > > - extra_sz = (CONFIG_CRASH_MAX_MEMORY_RANGES - cmem->nr_ranges) * sizeof(Elf64_Phdr); > > - > > - return extra_sz; > > + return (CONFIG_CRASH_MAX_MEMORY_RANGES - cmem->nr_ranges) * sizeof(Elf64_Phdr); > > I don't understand. > > Previously, when cmem->nr_ranges >= CONFIG_CRASH_MAX_MEMORY_RANGES you would > return 0. Now you will return something different. For instance if > cmem->nr_ranges is (CONFIG_CRASH_MAX_MEMORY_RANGES + 1) you will return > (unsigned int)(-1 * sizeof(Elf64_Phdr)) It still returns 0. When cmem->nr_ranges >= CONFIG_CRASH_MAX_MEMORY_RANGES, the else if branch prints the warning and then falls through to the return 0 at the end of the function. The final else branch is not entered in that case. No functional changes are intended. > > #endif > > return 0; > > } >