From nobody Mon Feb 9 19:52:16 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1617884535; cv=none; d=zohomail.com; s=zohoarc; b=jcuqgmc4CXDHvAME+IfndEQszMOCEdOANl3qNtDNrcz0pP4axuH8nHWc6rzWzWkNPnlBTdXfPEL8iXdN543tMjB0SGj0tvyw8MhZgvO9CEi8+fYRHn6uVueRlcxR+ppx3AK8cBubgzMnEPC4O8mnKwG2W+zyOShpa3qfdUbrEf0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617884535; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=LAS4slsq4qONsaHE0lyME1eabgS+LFpyRRMDvBlV5sc=; b=m0NpAWwaQH1TYNaTXr0e5Ue5E5j6BsJp27CpuTAWc/rRd6vmiXLJbGeIvdlga6rsSJ1qeQ5U/Qxnw2cpoEOZSfO77PujRg88Vfl+pcVVjMgCAEi2mLuyxEtaDkG+VDB60iFkqe3tKDgOyYwIGkkcJIKpw5+pnAPk6Yb7sWeMy2M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1617884535043649.2961897043515; Thu, 8 Apr 2021 05:22:15 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.107270.205073 (Exim 4.92) (envelope-from ) id 1lUTfa-0005BI-Rz; Thu, 08 Apr 2021 12:21:58 +0000 Received: by outflank-mailman (output) from mailman id 107270.205073; Thu, 08 Apr 2021 12:21:58 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lUTfa-0005BA-Np; Thu, 08 Apr 2021 12:21:58 +0000 Received: by outflank-mailman (input) for mailman id 107270; Thu, 08 Apr 2021 12:21:58 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lUTfa-0005B4-0O for xen-devel@lists.xenproject.org; Thu, 08 Apr 2021 12:21:58 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 6aeaeecf-1243-49ad-a7dc-c662847675c7; Thu, 08 Apr 2021 12:21:57 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 85B6CB11B; Thu, 8 Apr 2021 12:21:56 +0000 (UTC) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 6aeaeecf-1243-49ad-a7dc-c662847675c7 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1617884516; h=from:from:reply-to: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=LAS4slsq4qONsaHE0lyME1eabgS+LFpyRRMDvBlV5sc=; b=ZrFnoZpjK9Y19sBBy9uNVmzq4/dp0pOy9jaf3xnlZVefPiEcKfD2Qo9n+Gno76tar54dwW u1qS/04eB3ERc5WHo0iigppR1yQNUol2Eb85l6RKt32yLdonMupcF6BawOrle6hhSvMLZz mfGCVKdyxHYKdfTIZSRjwbs5X8uky3c= Subject: [PATCH 09/11] kexec: avoid effectively open-coding xzalloc_flex_struct() From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , George Dunlap References: Message-ID: <4ea9c4a3-74c0-1722-fa5d-3930be99ef4a@suse.com> Date: Thu, 8 Apr 2021 14:21:56 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.9.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) Content-Type: text/plain; charset="utf-8" There is a difference in generated code: xzalloc_bytes() forces SMP_CACHE_BYTES alignment. I think we not only don't need this here, but actually don't want it. Signed-off-by: Jan Beulich --- a/xen/common/kexec.c +++ b/xen/common/kexec.c @@ -463,7 +463,10 @@ static void * alloc_from_crash_heap(cons /* Allocate a crash note buffer for a newly onlined cpu. */ static int kexec_init_cpu_notes(const unsigned long cpu) { - Elf_Note * note =3D NULL; + struct elf_notes { + Elf_Note first; + unsigned char more[]; + } *notes =3D NULL; int ret =3D 0; int nr_bytes =3D 0; =20 @@ -477,7 +480,8 @@ static int kexec_init_cpu_notes(const un =20 /* If we dont care about the position of allocation, malloc. */ if ( low_crashinfo_mode =3D=3D LOW_CRASHINFO_NONE ) - note =3D xzalloc_bytes(nr_bytes); + notes =3D xzalloc_flex_struct(struct elf_notes, more, + nr_bytes - sizeof(notes->first)); =20 /* Protect the write into crash_notes[] with a spinlock, as this funct= ion * is on a hotplug path and a hypercall path. */ @@ -490,26 +494,28 @@ static int kexec_init_cpu_notes(const un spin_unlock(&crash_notes_lock); /* Always return ok, because whether we successfully allocated or = not, * another CPU has successfully allocated. */ - xfree(note); + xfree(notes); } else { /* If we care about memory possition, alloc from the crash heap, * also protected by the crash_notes_lock. */ if ( low_crashinfo_mode > LOW_CRASHINFO_NONE ) - note =3D alloc_from_crash_heap(nr_bytes); + notes =3D alloc_from_crash_heap(nr_bytes); =20 - crash_notes[cpu].start =3D note; + crash_notes[cpu].start =3D ¬es->first; crash_notes[cpu].size =3D nr_bytes; spin_unlock(&crash_notes_lock); =20 /* If the allocation failed, and another CPU did not beat us, give * up with ENOMEM. */ - if ( ! note ) + if ( ! notes ) ret =3D -ENOMEM; /* else all is good so lets set up the notes. */ else { + Elf_Note *note =3D ¬es->first; + /* Set up CORE note. */ setup_note(note, "CORE", NT_PRSTATUS, sizeof(ELF_Prstatus)); note =3D ELFNOTE_NEXT(note);