From patchwork Thu Apr 8 12:16:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 12190879 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 40799C433B4 for ; Thu, 8 Apr 2021 12:17:01 +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 C48BF610F8 for ; Thu, 8 Apr 2021 12:17:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C48BF610F8 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.107229.204965 (Exim 4.92) (envelope-from ) id 1lUTab-0003My-W3; Thu, 08 Apr 2021 12:16:49 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 107229.204965; Thu, 08 Apr 2021 12:16:49 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lUTab-0003Mr-SN; Thu, 08 Apr 2021 12:16:49 +0000 Received: by outflank-mailman (input) for mailman id 107229; Thu, 08 Apr 2021 12:16:49 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lUTab-0003Mm-2R for xen-devel@lists.xenproject.org; Thu, 08 Apr 2021 12:16:49 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id d25c10aa-527d-42d8-b670-624b41a06f87; Thu, 08 Apr 2021 12:16:48 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 3BCCDB2D3; Thu, 8 Apr 2021 12:16:47 +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: d25c10aa-527d-42d8-b670-624b41a06f87 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=1617884207; 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=eDvHAwIF6mX0AlxLLrgGKEgwtN3OOz7sw/+4M1PC1Ao=; b=Jh10VdM3VM36k/09nhklM42jup0OlzVtOlN26h+O5CKp2dy9zekrqWlkFkZxhrAdMVXPE+ wtv8awxlYvw/qGHwnGaDtc+1jY3Q9k1hYsKGcYeLlClgLGHL/LdjhEWsDd1uInPxEiJvxf ScWViD8W3wCUgazRsQwS7IgsQ2lTt7g= Subject: [PATCH 01/11] x86/HVM: avoid effectively open-coding xzalloc_flex_struct() From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , George Dunlap , Wei Liu , =?utf-8?q?R?= =?utf-8?q?oger_Pau_Monn=C3=A9?= References: Message-ID: Date: Thu, 8 Apr 2021 14:16:47 +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 Drop hvm_irq_size(), which exists for just this purpose. 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 Acked-by: Andrew Cooper --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -642,7 +642,8 @@ int hvm_domain_initialise(struct domain d->arch.hvm.params = xzalloc_array(uint64_t, HVM_NR_PARAMS); d->arch.hvm.io_handler = xzalloc_array(struct hvm_io_handler, NR_IO_HANDLERS); - d->arch.hvm.irq = xzalloc_bytes(hvm_irq_size(nr_gsis)); + d->arch.hvm.irq = xzalloc_flex_struct(struct hvm_irq, + gsi_assert_count, nr_gsis); rc = -ENOMEM; if ( !d->arch.hvm.pl_time || !d->arch.hvm.irq || --- a/xen/include/asm-x86/hvm/irq.h +++ b/xen/include/asm-x86/hvm/irq.h @@ -98,7 +98,6 @@ struct hvm_irq { #define hvm_pci_intx_link(dev, intx) \ (((dev) + (intx)) & 3) #define hvm_domain_irq(d) ((d)->arch.hvm.irq) -#define hvm_irq_size(cnt) offsetof(struct hvm_irq, gsi_assert_count[cnt]) #define hvm_isa_irq_to_gsi(isa_irq) ((isa_irq) ? : 2) From patchwork Thu Apr 8 12:17:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 12190883 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 CD912C433B4 for ; Thu, 8 Apr 2021 12:17:44 +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 79394610F8 for ; Thu, 8 Apr 2021 12:17:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 79394610F8 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.107234.204977 (Exim 4.92) (envelope-from ) id 1lUTbI-0003Tk-94; Thu, 08 Apr 2021 12:17:32 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 107234.204977; Thu, 08 Apr 2021 12:17:32 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lUTbI-0003Tc-5e; Thu, 08 Apr 2021 12:17:32 +0000 Received: by outflank-mailman (input) for mailman id 107234; Thu, 08 Apr 2021 12:17:31 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lUTbH-0003TX-Hf for xen-devel@lists.xenproject.org; Thu, 08 Apr 2021 12:17:31 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 456238ae-2933-4aa1-acc3-7110983556ff; Thu, 08 Apr 2021 12:17:30 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 1E70AB007; Thu, 8 Apr 2021 12:17:30 +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: 456238ae-2933-4aa1-acc3-7110983556ff 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=1617884250; 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=YjgoyLYt7SHX0fU/jqnJ8hiIG5x4umZdD9kaKSbikg8=; b=GYTsYqOJBinstoNn4WhvIEOkGgCSezGloEwIGC1ui32JB78W4p+cc9o36UXx+Seqoty3tL 3NLFyLAT8EHVE3fdK8iPzzBcQazKeYCkd6WjwxqVc1hMkCNefnmbw5A0MKxvPkcLHp357c E1SsFGrAAdOSfgzJHogeITPGkV8mxvs= Subject: [PATCH 02/11] x86/vPMU: avoid effectively open-coding xzalloc_flex_struct() From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , George Dunlap , Wei Liu , =?utf-8?q?R?= =?utf-8?q?oger_Pau_Monn=C3=A9?= , Boris Ostrovsky References: Message-ID: Date: Thu, 8 Apr 2021 14:17:29 +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 Acked-by: Andrew Cooper --- a/xen/arch/x86/cpu/vpmu_intel.c +++ b/xen/arch/x86/cpu/vpmu_intel.c @@ -461,10 +461,10 @@ static int core2_vpmu_alloc_resource(str goto out_err; } - core2_vpmu_cxt = xzalloc_bytes(sizeof(*core2_vpmu_cxt) + - sizeof(uint64_t) * fixed_pmc_cnt + - sizeof(struct xen_pmu_cntr_pair) * - arch_pmc_cnt); + core2_vpmu_cxt = xzalloc_flex_struct(struct xen_pmu_intel_ctxt, regs, + fixed_pmc_cnt + arch_pmc_cnt * + (sizeof(struct xen_pmu_cntr_pair) / + sizeof(*core2_vpmu_cxt->regs))); p = xzalloc(uint64_t); if ( !core2_vpmu_cxt || !p ) goto out_err; From patchwork Thu Apr 8 12:17:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 12190885 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 9019DC433ED for ; Thu, 8 Apr 2021 12:18:13 +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 4E99561041 for ; Thu, 8 Apr 2021 12:18:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4E99561041 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.107237.204989 (Exim 4.92) (envelope-from ) id 1lUTbl-0003Zz-IA; Thu, 08 Apr 2021 12:18:01 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 107237.204989; Thu, 08 Apr 2021 12:18:01 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lUTbl-0003Zs-EL; Thu, 08 Apr 2021 12:18:01 +0000 Received: by outflank-mailman (input) for mailman id 107237; Thu, 08 Apr 2021 12:17:59 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lUTbj-0003ZO-T4 for xen-devel@lists.xenproject.org; Thu, 08 Apr 2021 12:17:59 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 90761739-f7d3-4dd4-80d1-076cba7ebca2; Thu, 08 Apr 2021 12:17:59 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 4EF1FB090; Thu, 8 Apr 2021 12:17:58 +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: 90761739-f7d3-4dd4-80d1-076cba7ebca2 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=1617884278; 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=QnmG9k8Zw1WTHYZkvL1RP6b1ZHGImCYwyft4ku4C/6U=; b=jARlKgxxgKd+LvB/iXqHR4JKLtrBD7/3V9FIdXlHV+vniPp/MLLCibRxuHF+WQxNFcZbdp SzojpNL3PZBmLmiHV7drDOaPWnEAJXsTNHahdvT7+/kC2vPdpEym1XinF+WcujsqSjmbSl 5s1M7h/eHRv274C0zjtxNc5RT3sLpM8= Subject: [PATCH 03/11] x86/MCE: avoid effectively open-coding xmalloc_array() From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , George Dunlap , Wei Liu , =?utf-8?q?R?= =?utf-8?q?oger_Pau_Monn=C3=A9?= References: Message-ID: <47101cea-a856-3921-dd19-89ce766aaaeb@suse.com> Date: Thu, 8 Apr 2021 14:17:58 +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: xmalloc_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/arch/x86/cpu/mcheck/mctelem.c +++ b/xen/arch/x86/cpu/mcheck/mctelem.c @@ -345,7 +345,7 @@ void __init mctelem_init(unsigned int da if ((mctctl.mctc_elems = xmalloc_array(struct mctelem_ent, MC_NENT)) == NULL || - (datarr = xmalloc_bytes(MC_NENT * datasz)) == NULL) { + (datarr = xmalloc_array(char, MC_NENT * datasz)) == NULL) { xfree(mctctl.mctc_elems); printk("Allocations for MCA telemetry failed\n"); return; From patchwork Thu Apr 8 12:18:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 12190887 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,URIBL_BLOCKED, 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 B274DC433ED for ; Thu, 8 Apr 2021 12:18:43 +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 730B861106 for ; Thu, 8 Apr 2021 12:18:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 730B861106 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.107241.205001 (Exim 4.92) (envelope-from ) id 1lUTcF-0003g8-Q9; Thu, 08 Apr 2021 12:18:31 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 107241.205001; Thu, 08 Apr 2021 12:18:31 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lUTcF-0003g1-My; Thu, 08 Apr 2021 12:18:31 +0000 Received: by outflank-mailman (input) for mailman id 107241; Thu, 08 Apr 2021 12:18:30 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lUTcE-0003fC-Jo for xen-devel@lists.xenproject.org; Thu, 08 Apr 2021 12:18:30 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 671d1e7e-cda6-48b3-b1d9-f225f71af49d; Thu, 08 Apr 2021 12:18:27 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 30EAFAFCC; Thu, 8 Apr 2021 12:18:26 +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: 671d1e7e-cda6-48b3-b1d9-f225f71af49d 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=1617884306; 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=rkX7CzUIHm8zyEM9IisY4rl2NOQycbZjijQaZgGhueY=; b=A3qqKzk4yj5DecWdzpWMWiGjXBkAHG2eQY9GoPQ8YZEw6TRe+qSR08w6Ug3tvkEQhsbE4x EzYLTROyPEv05yU8bKXTtkYiNrgU6+O1Ewny+iB4p8Xk8T9DHCE/WRpowrMHklYsWYGhei +tCHFYTufSnVc/TH+AzQnazB0tjlNYY= Subject: [PATCH 04/11] x86/HVM: avoid effectively open-coding xmalloc_array() From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , George Dunlap , Wei Liu , =?utf-8?q?R?= =?utf-8?q?oger_Pau_Monn=C3=A9?= , Paul Durrant References: Message-ID: Date: Thu, 8 Apr 2021 14:18:25 +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: xmalloc_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/arch/x86/hvm/emulate.c +++ b/xen/arch/x86/hvm/emulate.c @@ -1924,7 +1924,7 @@ static int hvmemul_rep_movs( dgpa -= bytes - bytes_per_rep; /* Allocate temporary buffer. Fall back to slow emulation if this fails. */ - buf = xmalloc_bytes(bytes); + buf = xmalloc_array(char, bytes); if ( buf == NULL ) return X86EMUL_UNHANDLEABLE; @@ -2037,7 +2037,7 @@ static int hvmemul_rep_stos( for ( ; ; ) { bytes = *reps * bytes_per_rep; - buf = xmalloc_bytes(bytes); + buf = xmalloc_array(char, bytes); if ( buf || *reps <= 1 ) break; *reps >>= 1; From patchwork Thu Apr 8 12:19:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 12190889 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 8AED6C433ED for ; Thu, 8 Apr 2021 12:19:49 +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 2B08D61106 for ; Thu, 8 Apr 2021 12:19:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2B08D61106 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.107245.205013 (Exim 4.92) (envelope-from ) id 1lUTd8-0003q3-6E; Thu, 08 Apr 2021 12:19:26 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 107245.205013; Thu, 08 Apr 2021 12:19:26 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lUTd8-0003pw-14; Thu, 08 Apr 2021 12:19:26 +0000 Received: by outflank-mailman (input) for mailman id 107245; Thu, 08 Apr 2021 12:19:24 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lUTd6-0003oQ-GC for xen-devel@lists.xenproject.org; Thu, 08 Apr 2021 12:19:24 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id c266e007-5997-4fca-af7d-9cfc84cc26d0; Thu, 08 Apr 2021 12:19:23 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id CBFC6B005; Thu, 8 Apr 2021 12:19:22 +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: c266e007-5997-4fca-af7d-9cfc84cc26d0 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=1617884362; 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=CDQ3ZAFyCDWafzng7hnKKPU/+/S54DwWZulXulR1ydM=; b=vQsXBPZTT3RHR7jNPNRXX/InSms8SVvQnJDnyqhayLkd4PSiomA1yr/n7vqHKih8rdyZkr jjM6gr3zpnxkD1MbvUNS6ZxqZNtHS0Zo0pckqiUvK3BddXL7EqfQEChgSe2k+pIbZWD+jr BPsztQ/SoIJW1femb3OISs04rfV9UHg= Subject: [PATCH 05/11] x86/oprofile: avoid effectively open-coding xmalloc_array() From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , George Dunlap , Wei Liu , =?utf-8?q?R?= =?utf-8?q?oger_Pau_Monn=C3=A9?= References: Message-ID: <029d1c22-332a-a1bf-489b-fdee70d8974e@suse.com> Date: Thu, 8 Apr 2021 14:19:22 +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: xmalloc_bytes() forces SMP_CACHE_BYTES alignment. I think we not only don't need this here, but actually don't want it. While at it also use XFREE() instead of open-coding it and change loop induction variable types. Signed-off-by: Jan Beulich --- a/xen/arch/x86/oprofile/nmi_int.c +++ b/xen/arch/x86/oprofile/nmi_int.c @@ -142,30 +142,29 @@ static void nmi_save_registers(void * du static void free_msrs(void) { - int i; + unsigned int i; + for (i = 0; i < nr_cpu_ids; ++i) { - xfree(cpu_msrs[i].counters); - cpu_msrs[i].counters = NULL; - xfree(cpu_msrs[i].controls); - cpu_msrs[i].controls = NULL; + XFREE(cpu_msrs[i].counters); + XFREE(cpu_msrs[i].controls); } } static int allocate_msrs(void) { + unsigned int i; int success = 1; - size_t controls_size = sizeof(struct op_msr) * model->num_controls; - size_t counters_size = sizeof(struct op_msr) * model->num_counters; - int i; for_each_online_cpu (i) { - cpu_msrs[i].counters = xmalloc_bytes(counters_size); + cpu_msrs[i].counters = xmalloc_array(struct op_msr, + model->num_counters); if (!cpu_msrs[i].counters) { success = 0; break; } - cpu_msrs[i].controls = xmalloc_bytes(controls_size); + cpu_msrs[i].controls = xmalloc_array(struct op_msr, + model->num_controls); if (!cpu_msrs[i].controls) { success = 0; break; From patchwork Thu Apr 8 12:20:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 12190891 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 215F2C433ED for ; Thu, 8 Apr 2021 12:20:39 +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 CB11261041 for ; Thu, 8 Apr 2021 12:20:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CB11261041 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.107252.205037 (Exim 4.92) (envelope-from ) id 1lUTe8-0004hh-TW; Thu, 08 Apr 2021 12:20:28 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 107252.205037; Thu, 08 Apr 2021 12:20:28 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lUTe8-0004ha-QT; Thu, 08 Apr 2021 12:20:28 +0000 Received: by outflank-mailman (input) for mailman id 107252; Thu, 08 Apr 2021 12:20:28 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lUTe7-0004hC-Td for xen-devel@lists.xenproject.org; Thu, 08 Apr 2021 12:20:27 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 1d3974a3-264d-4372-88fd-dc6326da25d9; Thu, 08 Apr 2021 12:20:27 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 4B643B0E6; Thu, 8 Apr 2021 12:20:26 +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: 1d3974a3-264d-4372-88fd-dc6326da25d9 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=1617884426; 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=dQLFBbZwmFP7/XJISrFVWgSoZI+0nr2VJyf5BHmRMeA=; b=RQDKsL8zp4IN2ANmpnNqpG1LhduC6Z/nnT4q7+7JgHelBGhZIr6M0yByjuuC8Ph7W8mJ9V oPV3r7z7s+N1Q0dkGgzcX2sB1ANp69zW0VJJJ4Nr961S+nvIq2jY5IKHJhAjJO6+tw+Knh t3+gkgweDp2Qwj4X+28vF2CmHkiiiXo= Subject: [PATCH 06/11] x86/IRQ: avoid over-alignment in alloc_pirq_struct() From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , George Dunlap , Wei Liu , =?utf-8?q?R?= =?utf-8?q?oger_Pau_Monn=C3=A9?= References: Message-ID: <75885e8f-fd0a-5ac1-b194-7f8858320874@suse.com> Date: Thu, 8 Apr 2021 14:20:26 +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 In particular in the PV case xzalloc_bytes() forcing SMP_CACHE_BYTES alignment is counterproductive, as the allocation size there is only 40 bytes. Signed-off-by: Jan Beulich --- a/xen/arch/x86/irq.c +++ b/xen/arch/x86/irq.c @@ -1313,9 +1313,12 @@ void cleanup_domain_irq_mapping(struct d struct pirq *alloc_pirq_struct(struct domain *d) { - size_t sz = is_hvm_domain(d) ? sizeof(struct pirq) : - offsetof(struct pirq, arch.hvm); - struct pirq *pirq = xzalloc_bytes(sz); + union pirq_pv { + char space[offsetof(struct pirq, arch.hvm)]; + void *align; + }; + struct pirq *pirq = is_hvm_domain(d) ? xzalloc(struct pirq) + : (void *)xzalloc(union pirq_pv); if ( pirq ) { From patchwork Thu Apr 8 12:20:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 12190893 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=-14.4 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, UNWANTED_LANGUAGE_BODY,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 EF4E3C433ED for ; Thu, 8 Apr 2021 12:21:03 +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 B40F561106 for ; Thu, 8 Apr 2021 12:21:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B40F561106 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.107260.205048 (Exim 4.92) (envelope-from ) id 1lUTeW-0004qp-7i; Thu, 08 Apr 2021 12:20:52 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 107260.205048; Thu, 08 Apr 2021 12:20:52 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lUTeW-0004qh-48; Thu, 08 Apr 2021 12:20:52 +0000 Received: by outflank-mailman (input) for mailman id 107260; Thu, 08 Apr 2021 12:20:51 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lUTeU-0004qS-U4 for xen-devel@lists.xenproject.org; Thu, 08 Apr 2021 12:20:50 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id feb7a45f-91cb-4bde-abe5-e9a11b935368; Thu, 08 Apr 2021 12:20:49 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 0FB44B090; Thu, 8 Apr 2021 12:20:49 +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: feb7a45f-91cb-4bde-abe5-e9a11b935368 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=1617884449; 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=rlkZ2gHfa7wMnDFvJ4VBlthgmsqLlVSVbOIY+whHTZo=; b=BhdG0F4k+a1SrcQc+iLOYzWIB53zUhsgnWZVWNX85ywHaGPxfHby4HFyTmGSZpBKQ1XyqN emDXLzzH6vmysdgphmEjjAw5j9I0pNzB9bvXbCiZxjsvjFHXxbu2SPdJNZ0Mz/XkqmzTVP UEJA/T9/sDpwxrb0Ob/A1aB0oR9t4n4= Subject: [PATCH 07/11] EFI/runtime: avoid effectively open-coding xmalloc_array() From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , George Dunlap , Ian Jackson , Julien Grall , Stefano Stabellini , Wei Liu , =?utf-8?q?Roger_Pau_Monn=C3=A9?= References: Message-ID: <154a423e-ede1-b799-c616-a0022b815606@suse.com> Date: Thu, 8 Apr 2021 14:20:48 +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: xmalloc_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/efi/runtime.c +++ b/xen/common/efi/runtime.c @@ -486,7 +486,7 @@ int efi_runtime_call(struct xenpf_efi_ru size = op->u.get_variable.size; if ( size ) { - data = xmalloc_bytes(size); + data = xmalloc_array(unsigned char, size); if ( !data ) { xfree(name); @@ -536,7 +536,7 @@ int efi_runtime_call(struct xenpf_efi_ru return -EIO; } - data = xmalloc_bytes(op->u.set_variable.size); + data = xmalloc_array(unsigned char, op->u.set_variable.size); if ( !data ) rc = -ENOMEM; else if ( copy_from_guest(data, op->u.set_variable.data, @@ -571,7 +571,7 @@ int efi_runtime_call(struct xenpf_efi_ru return -EINVAL; size = op->u.get_next_variable_name.size; - name.raw = xzalloc_bytes(size); + name.raw = xzalloc_array(unsigned char, size); if ( !name.raw ) return -ENOMEM; if ( copy_from_guest(name.raw, op->u.get_next_variable_name.name, From patchwork Thu Apr 8 12:21:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 12190895 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 6090BC433ED for ; Thu, 8 Apr 2021 12:21:27 +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 1EEFD61041 for ; Thu, 8 Apr 2021 12:21:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1EEFD61041 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.107266.205061 (Exim 4.92) (envelope-from ) id 1lUTet-0004zy-HC; Thu, 08 Apr 2021 12:21:15 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 107266.205061; Thu, 08 Apr 2021 12:21:15 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lUTet-0004zr-DT; Thu, 08 Apr 2021 12:21:15 +0000 Received: by outflank-mailman (input) for mailman id 107266; Thu, 08 Apr 2021 12:21:15 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lUTes-0004zj-Vc for xen-devel@lists.xenproject.org; Thu, 08 Apr 2021 12:21:15 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 76f69303-e529-4e9f-be2a-5819f072873d; Thu, 08 Apr 2021 12:21:14 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 783CCB005; Thu, 8 Apr 2021 12:21:13 +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: 76f69303-e529-4e9f-be2a-5819f072873d 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=1617884473; 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=95K+5XUUtlkYqbXmQ6a5fXeN2FQDprpFs5vXWIcZVZg=; b=S9waDlL3HqvdRuOGtWJksVXo0t/AWmRdrboRuIw4xSAqDnTOnG4ob4TDErr4RliklvWgG6 Yh8WAQ13IqaSkqp3oq9jBS/nvNHXRAkAnud4v2DXIrkCfaZibMILpLSFjF/k/Xbyk8q+wF o03tS4X5ymR8WENgliRv5EGkTKWLmho= Subject: [PATCH 08/11] hypfs: avoid effectively open-coding xzalloc_array() From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , George Dunlap , Ian Jackson , Julien Grall , Stefano Stabellini , Wei Liu , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Juergen Gross References: Message-ID: Date: Thu, 8 Apr 2021 14:21:13 +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. To avoid the need to add a cast, do away with the only forward-declared struct hypfs_dyndata. Signed-off-by: Jan Beulich Reviewed-by: Juergen Gross --- a/xen/common/hypfs.c +++ b/xen/common/hypfs.c @@ -72,7 +72,7 @@ enum hypfs_lock_state { hypfs_write_locked }; static DEFINE_PER_CPU(enum hypfs_lock_state, hypfs_locked); -static DEFINE_PER_CPU(struct hypfs_dyndata *, hypfs_dyndata); +static DEFINE_PER_CPU(void *, hypfs_dyndata); static DEFINE_PER_CPU(const struct hypfs_entry *, hypfs_last_node_entered); @@ -160,19 +160,19 @@ static void node_exit_all(void) void *hypfs_alloc_dyndata(unsigned long size) { unsigned int cpu = smp_processor_id(); - struct hypfs_dyndata **dyndata = &per_cpu(hypfs_dyndata, cpu); + void **dyndata = &per_cpu(hypfs_dyndata, cpu); ASSERT(per_cpu(hypfs_locked, cpu) != hypfs_unlocked); ASSERT(*dyndata == NULL); - *dyndata = xzalloc_bytes(size); + *dyndata = xzalloc_array(unsigned char, size); return *dyndata; } void *hypfs_get_dyndata(void) { - struct hypfs_dyndata *dyndata = this_cpu(hypfs_dyndata); + void *dyndata = this_cpu(hypfs_dyndata); ASSERT(dyndata); @@ -181,7 +181,7 @@ void *hypfs_get_dyndata(void) void hypfs_free_dyndata(void) { - struct hypfs_dyndata **dyndata = &this_cpu(hypfs_dyndata); + void **dyndata = &this_cpu(hypfs_dyndata); XFREE(*dyndata); } 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); From patchwork Thu Apr 8 12:22:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 12190911 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 23838C433ED for ; Thu, 8 Apr 2021 12:22:32 +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 BA3136115B for ; Thu, 8 Apr 2021 12:22:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BA3136115B 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.107273.205085 (Exim 4.92) (envelope-from ) id 1lUTfw-0005Hb-3w; Thu, 08 Apr 2021 12:22:20 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 107273.205085; Thu, 08 Apr 2021 12:22:20 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lUTfw-0005HU-08; Thu, 08 Apr 2021 12:22:20 +0000 Received: by outflank-mailman (input) for mailman id 107273; Thu, 08 Apr 2021 12:22:18 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lUTfu-0005HE-H6 for xen-devel@lists.xenproject.org; Thu, 08 Apr 2021 12:22:18 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id bf8f449f-9a86-476a-9037-856b12ccccfc; Thu, 08 Apr 2021 12:22:17 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 2243BB005; Thu, 8 Apr 2021 12:22:17 +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: bf8f449f-9a86-476a-9037-856b12ccccfc 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=1617884537; 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=yw8CWbx2pQJIEiz3GQW/HJc3UcPF7hTPHrhYjaL9Afc=; b=fbV0ORejrfI1vC5N37glstyj2ieCvn/yvOHuDv1Xs0lZN1N00myO81LBoMF/qK8VwJgWoR dgkQ3MlPeCrUPgN+hB+ca1Ffktw4CI0tZXFfHPurVvRrbKCRbgx+PCNtOAjn6026/4ZWCg BxTCN3wWIcg1YJsXoj0eO/55k9U1FjU= Subject: [PATCH 10/11] video/lfb: avoid effectively open-coding xzalloc_array() From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , George Dunlap , Ian Jackson , Julien Grall , Stefano Stabellini , Wei Liu , =?utf-8?q?Roger_Pau_Monn=C3=A9?= References: Message-ID: Date: Thu, 8 Apr 2021 14:22:16 +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/drivers/video/lfb.c +++ b/xen/drivers/video/lfb.c @@ -147,8 +147,9 @@ int __init lfb_init(struct lfb_prop *lfb { lfb.lfbp = *lfbp; - lfb.lbuf = xmalloc_bytes(lfb.lfbp.bytes_per_line); - lfb.text_buf = xzalloc_bytes(lfb.lfbp.text_columns * lfb.lfbp.text_rows); + lfb.lbuf = xmalloc_array(unsigned char, lfb.lfbp.bytes_per_line); + lfb.text_buf = xzalloc_array(unsigned char, + lfb.lfbp.text_columns * lfb.lfbp.text_rows); lfb.line_len = xzalloc_array(unsigned int, lfb.lfbp.text_columns); if ( !lfb.lbuf || !lfb.text_buf || !lfb.line_len ) From patchwork Thu Apr 8 12:23:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 12190913 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 A0AC7C433B4 for ; Thu, 8 Apr 2021 12:23:31 +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 59C3761130 for ; Thu, 8 Apr 2021 12:23:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 59C3761130 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.107281.205096 (Exim 4.92) (envelope-from ) id 1lUTgt-0005Qi-EX; Thu, 08 Apr 2021 12:23:19 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 107281.205096; Thu, 08 Apr 2021 12:23:19 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lUTgt-0005Qb-BU; Thu, 08 Apr 2021 12:23:19 +0000 Received: by outflank-mailman (input) for mailman id 107281; Thu, 08 Apr 2021 12:23:18 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lUTgs-0005QT-3c for xen-devel@lists.xenproject.org; Thu, 08 Apr 2021 12:23:18 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 66e728ea-9180-45a9-85a9-512230029e86; Thu, 08 Apr 2021 12:23:17 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 7EAB4B090; Thu, 8 Apr 2021 12:23:16 +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: 66e728ea-9180-45a9-85a9-512230029e86 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=1617884596; 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=JP7NYsf4fopqSVgYCDwHxKC3KJzvwiy4UDKP6yZkCFM=; b=laMkxHER7aSZu5M4s+gxNOdm+jcWdCLLVomCWwYt1NdHxvK6yRNallue1mMBvk3ePmgZ/s R4bV6pdtiW9iWN8d44dqOpx1L2HNAvdRV6EfXVopbCy3BUw2Qt3nprT3UEV2kf6R5cBt2x Orhi2dsrZGsJUITGPFWVzSE726abFvU= Subject: [PATCH 11/11] Arm/optee: don't open-code xzalloc_flex_struct() From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: George Dunlap , Julien Grall , Stefano Stabellini , Volodymyr Babchuk References: Message-ID: Date: Thu, 8 Apr 2021 14:23:16 +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/arch/arm/tee/optee.c +++ b/xen/arch/arm/tee/optee.c @@ -529,8 +529,7 @@ static struct optee_shm_buf *allocate_op while ( unlikely(old != atomic_cmpxchg(&ctx->optee_shm_buf_pages, old, new)) ); - optee_shm_buf = xzalloc_bytes(sizeof(struct optee_shm_buf) + - pages_cnt * sizeof(struct page *)); + optee_shm_buf = xzalloc_flex_struct(struct optee_shm_buf, pages, pages_cnt); if ( !optee_shm_buf ) { err_code = -ENOMEM;