From patchwork Thu Apr 8 12:21:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 12190897 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DCD3DC433B4 for ; Thu, 8 Apr 2021 12:22:08 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A3C386115B for ; Thu, 8 Apr 2021 12:22:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A3C386115B Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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 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 = NULL; + struct elf_notes { + Elf_Note first; + unsigned char more[]; + } *notes = NULL; int ret = 0; int nr_bytes = 0; @@ -477,7 +480,8 @@ static int kexec_init_cpu_notes(const un /* If we dont care about the position of allocation, malloc. */ if ( low_crashinfo_mode == LOW_CRASHINFO_NONE ) - note = xzalloc_bytes(nr_bytes); + notes = xzalloc_flex_struct(struct elf_notes, more, + nr_bytes - sizeof(notes->first)); /* Protect the write into crash_notes[] with a spinlock, as this function * 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 = alloc_from_crash_heap(nr_bytes); + notes = alloc_from_crash_heap(nr_bytes); - crash_notes[cpu].start = note; + crash_notes[cpu].start = ¬es->first; crash_notes[cpu].size = nr_bytes; spin_unlock(&crash_notes_lock); /* If the allocation failed, and another CPU did not beat us, give * up with ENOMEM. */ - if ( ! note ) + if ( ! notes ) ret = -ENOMEM; /* else all is good so lets set up the notes. */ else { + Elf_Note *note = ¬es->first; + /* Set up CORE note. */ setup_note(note, "CORE", NT_PRSTATUS, sizeof(ELF_Prstatus)); note = ELFNOTE_NEXT(note);