From nobody Wed May 8 00:17:22 2024 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=1619016984; cv=none; d=zohomail.com; s=zohoarc; b=AI2j+XUh10y0mJvkHmxaRHmzofI9ZwZDZWeebYif5dVhhcVwjaYkkrxubGlnJGWfMkNiMInnG95rn904sM/FUFWyDd/6YSL+ACgMkG0098nP/xJBtnADtHV2FkSwhc5P7qm3puxZf3iYRzvmzTUWOzLhsto2fbNN6/EGExDhfZ0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619016984; 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=dn8xizhAj6dt285tHoUKq6uKJm2JGhL8Ej0gFCwHguo=; b=nsLdSdO1td+P4cabdy27Jy+r2AVoPmqPkKuP1tOpfQCfBN+u7DtQBV3Xr9lJizqFP1lXcNppuImaDimwUhcci5V9gmJvIIV7gopJreKr6W5hjCTJu+0uDFiXsoMjmzr/o1Jb3xTXNImM3P2Fp1+j2OpmOsePJc13cEJXRJXWUYw= 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 161901698484859.413285995218644; Wed, 21 Apr 2021 07:56:24 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.114783.218794 (Exim 4.92) (envelope-from ) id 1lZEGs-0007qo-So; Wed, 21 Apr 2021 14:56:06 +0000 Received: by outflank-mailman (output) from mailman id 114783.218794; Wed, 21 Apr 2021 14:56:06 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lZEGs-0007qh-Pc; Wed, 21 Apr 2021 14:56:06 +0000 Received: by outflank-mailman (input) for mailman id 114783; Wed, 21 Apr 2021 14:56:05 +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 1lZEGr-0007qX-K6 for xen-devel@lists.xenproject.org; Wed, 21 Apr 2021 14:56:05 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id a8511cc5-5931-4b24-a74b-bace21e8a439; Wed, 21 Apr 2021 14:56:04 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id DB6ACB4D6; Wed, 21 Apr 2021 14:56:03 +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: a8511cc5-5931-4b24-a74b-bace21e8a439 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=1619016964; 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=dn8xizhAj6dt285tHoUKq6uKJm2JGhL8Ej0gFCwHguo=; b=MFnylNO45EvnvRMzxksM5Fj45ojdxak99ir226m0Ju+/3yvh6yz0UsCVdKEE6fcy3yRZ76 /rJNBrC4FS+iqh2KstFVCIJ4jY8H4wsTijEUAp9XmnKJujciIV6ZeZxvWxzzGYAF/xdxqt HbhqV09TBt5LgFr+8NrCfib/zBiaePw= Subject: [PATCH v2 1/8] 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?Roger_Pau_Monn=c3=a9?= References: <091b4b91-712f-3526-78d1-80d31faf8e41@suse.com> Message-ID: <631d4b11-cfc5-c609-6169-28ba08aa978c@suse.com> Date: Wed, 21 Apr 2021 16:56:03 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.10.0 MIME-Version: 1.0 In-Reply-To: <091b4b91-712f-3526-78d1-80d31faf8e41@suse.com> 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: xmalloc_bytes() forces SMP_CACHE_BYTES alignment. But if code really cared about such higher than default alignment, it should request so explicitly rather than using a type-unsafe interface. And if e.g. cache line sharing was a concern, the allocator itself should arrange to avoid such. 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 =20 if ((mctctl.mctc_elems =3D xmalloc_array(struct mctelem_ent, MC_NENT)) =3D=3D NULL || - (datarr =3D xmalloc_bytes(MC_NENT * datasz)) =3D=3D NULL) { + (datarr =3D xmalloc_array(char, MC_NENT * datasz)) =3D=3D NULL) { xfree(mctctl.mctc_elems); printk("Allocations for MCA telemetry failed\n"); return; From nobody Wed May 8 00:17:22 2024 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=1619017011; cv=none; d=zohomail.com; s=zohoarc; b=MDmPMVkYOG3OynJTy7qgVuhnmDrBtukl8Yg2VW/YQQkcr6HNyGbh2VS18AbHEBKbNSYSU1GRwO2dCT7VDg4QtU1pxNLJX5NW5sKqQlpzVkA9DisRoMcXgoEbyAkOizfkkqPAOGyoH+z5iVSxO2nMnwzjBL+ItgfDskhZwEYzBf8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619017011; 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=0hiOnsYBKJJyY/OKqVdi3PZ5qXRAtnLxQ2fMzsttxVs=; b=LzrQi8g0tmL2km4T5zWTRHZ/gIVsFPQSE2yYd2ju8VaQRx5Duho4fnUVU5qbQ6KbZDbdleK1iIZbsTwLdr+T50i3GIob6cFnccum0mJ6TbHDrLnylaifxDZGSymwHLSheJVyZyyuhxBsOxitvjqJ4GbPx+CoSPbzbq4ug3X+dpI= 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 1619017011182827.8913250900093; Wed, 21 Apr 2021 07:56:51 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.114788.218809 (Exim 4.92) (envelope-from ) id 1lZEHN-0007yc-BH; Wed, 21 Apr 2021 14:56:37 +0000 Received: by outflank-mailman (output) from mailman id 114788.218809; Wed, 21 Apr 2021 14:56:37 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lZEHN-0007yU-88; Wed, 21 Apr 2021 14:56:37 +0000 Received: by outflank-mailman (input) for mailman id 114788; Wed, 21 Apr 2021 14:56:35 +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 1lZEHL-0007yG-92 for xen-devel@lists.xenproject.org; Wed, 21 Apr 2021 14:56:35 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id eaf0465f-6f39-4fa3-85b3-2b310311ebfc; Wed, 21 Apr 2021 14:56:34 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 995EBAD8A; Wed, 21 Apr 2021 14:56:33 +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: eaf0465f-6f39-4fa3-85b3-2b310311ebfc 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=1619016993; 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=0hiOnsYBKJJyY/OKqVdi3PZ5qXRAtnLxQ2fMzsttxVs=; b=YkEJ7t+xIMGDyZM7Qp7QFZv3vodtNbLlNSZYSXvVpEYHO46U2S3Z6z4eDDf3OAjDnTbFV2 F6aQxPtgPTvLPKJ6d2rBJhCT2TrgEws68wp5UerVuPqURgfDgiG3IW6+PXdn1y/12MlBkZ KYSrxY/mV1tKcV0Bj22ueyqCJ8IN3vA= Subject: [PATCH v2 2/8] 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?Roger_Pau_Monn=c3=a9?= , Paul Durrant References: <091b4b91-712f-3526-78d1-80d31faf8e41@suse.com> Message-ID: <1c3d573d-051f-3d18-cd63-6ccad5911786@suse.com> Date: Wed, 21 Apr 2021 16:56:33 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.10.0 MIME-Version: 1.0 In-Reply-To: <091b4b91-712f-3526-78d1-80d31faf8e41@suse.com> 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: xmalloc_bytes() forces SMP_CACHE_BYTES alignment. But if code really cared about such higher than default alignment, it should request so explicitly rather than using a type-unsafe interface. And if e.g. cache line sharing was a concern, the allocator itself should arrange to avoid such. 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 -=3D bytes - bytes_per_rep; =20 /* Allocate temporary buffer. Fall back to slow emulation if this fail= s. */ - buf =3D xmalloc_bytes(bytes); + buf =3D xmalloc_array(char, bytes); if ( buf =3D=3D NULL ) return X86EMUL_UNHANDLEABLE; =20 @@ -2037,7 +2037,7 @@ static int hvmemul_rep_stos( for ( ; ; ) { bytes =3D *reps * bytes_per_rep; - buf =3D xmalloc_bytes(bytes); + buf =3D xmalloc_array(char, bytes); if ( buf || *reps <=3D 1 ) break; *reps >>=3D 1; From nobody Wed May 8 00:17:22 2024 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=1619017041; cv=none; d=zohomail.com; s=zohoarc; b=KnXBOC5s0P5vL1PcMbubpZ92Pw3S2AQltgMoXeXJpFM9VPL5dptm55yXhgIg5bkOXFPQQaK6dKsLgbGiNinr1vUCskpED6HalHw3vr9NvAYXloTcMwUYtcGgpDGNP9gVB0Nq7KY1EvTdKEAtDjkw2K8t2gb+G84cf6yzbepahbM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619017041; 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=7k33TZjSiUsbN7zoExMERbIp8QvBpYbbwHsyd9tlzWs=; b=JvNygxhug+43qn5H0PLoZR2tOTayj9bU3oE5zLIYX/cqYF6kuUPm574zbOaTrFnLLMUAmInEbGWT55I9LnDT/UgsZ1c0Pmn8Gyf2XILTujK0PI3r5SWerjFjkvQGTmwpVYvujOt4VMQ4vgJz4UfT2hHNNf/lePz9VfZjQ0v23O4= 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 1619017041699994.3532152148927; Wed, 21 Apr 2021 07:57:21 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.114793.218821 (Exim 4.92) (envelope-from ) id 1lZEHr-00085f-M4; Wed, 21 Apr 2021 14:57:07 +0000 Received: by outflank-mailman (output) from mailman id 114793.218821; Wed, 21 Apr 2021 14:57:07 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lZEHr-00085Y-Ie; Wed, 21 Apr 2021 14:57:07 +0000 Received: by outflank-mailman (input) for mailman id 114793; Wed, 21 Apr 2021 14:57:06 +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 1lZEHq-00085T-Or for xen-devel@lists.xenproject.org; Wed, 21 Apr 2021 14:57:06 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id a3adcfe3-4c17-47e2-9d9f-80c4a6a969d6; Wed, 21 Apr 2021 14:57:06 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 38E00B2E8; Wed, 21 Apr 2021 14:57:05 +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: a3adcfe3-4c17-47e2-9d9f-80c4a6a969d6 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=1619017025; 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=7k33TZjSiUsbN7zoExMERbIp8QvBpYbbwHsyd9tlzWs=; b=q62m4aOxX+wB5j9D8t4usjgr7KIKvIjEuq5NvNqiaFHPtt66/72eiimjnj/CCMUqqEu5cg 94JZAoer9V0u0xTHI9kbF7AD6/PkZcv5SLEZP1q8IU/+ZYWzwEctQqBivgBC/4LD0JLGTv WuDguSwlqagj676qs4vl8Se+OICWBaQ= Subject: [PATCH v2 3/8] 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?Roger_Pau_Monn=c3=a9?= References: <091b4b91-712f-3526-78d1-80d31faf8e41@suse.com> Message-ID: Date: Wed, 21 Apr 2021 16:57:04 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.10.0 MIME-Version: 1.0 In-Reply-To: <091b4b91-712f-3526-78d1-80d31faf8e41@suse.com> 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: xmalloc_bytes() forces SMP_CACHE_BYTES alignment. But if code really cared about such higher than default alignment, it should request so explicitly rather than using a type-unsafe interface. And if e.g. cache line sharing was a concern, the allocator itself should arrange to avoid such. 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 =20 static void free_msrs(void) { - int i; + unsigned int i; + for (i =3D 0; i < nr_cpu_ids; ++i) { - xfree(cpu_msrs[i].counters); - cpu_msrs[i].counters =3D NULL; - xfree(cpu_msrs[i].controls); - cpu_msrs[i].controls =3D NULL; + XFREE(cpu_msrs[i].counters); + XFREE(cpu_msrs[i].controls); } } =20 =20 static int allocate_msrs(void) { + unsigned int i; int success =3D 1; - size_t controls_size =3D sizeof(struct op_msr) * model->num_controls; - size_t counters_size =3D sizeof(struct op_msr) * model->num_counters; =20 - int i; for_each_online_cpu (i) { - cpu_msrs[i].counters =3D xmalloc_bytes(counters_size); + cpu_msrs[i].counters =3D xmalloc_array(struct op_msr, + model->num_counters); if (!cpu_msrs[i].counters) { success =3D 0; break; } - cpu_msrs[i].controls =3D xmalloc_bytes(controls_size); + cpu_msrs[i].controls =3D xmalloc_array(struct op_msr, + model->num_controls); if (!cpu_msrs[i].controls) { success =3D 0; break; From nobody Wed May 8 00:17:22 2024 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=1619017066; cv=none; d=zohomail.com; s=zohoarc; b=FE/WTjBIq2u9nkkGWV5AycXVrPTf4DPSvtZ/wZ48Zv8h3vZZhMuAOYjBrrTy/I9t6Ww1aRXHmmXRwv6I2H0N2KGGY1/CM++Eb147mkIL36GVUHJhtwaQWjx5J3wtkKGfC3jGqjH6/1TsTEa4qVoyixULekKKvosBKDtGLaljBWY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619017066; 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=RGVbQa+GqVgOa2I76yheTEF5apAHeScJZb/syJB8fWc=; b=BMI5AyxCtY5L8ibIZgkTUgqljZWjupuhPXvJbEpX+KWhqDaEGPJJ/3V0/K3esBSiNWRHfFGBCuJFq48tfp7Zz7JfBE+8AxrU7+bXZrcuPI9WIU2SeNjzElcqU9Y+n8O1aTKGxqoYmlZfvH63QFkeD5d+XbokU1w6ATxtALeWnSc= 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 1619017066160432.01270411693747; Wed, 21 Apr 2021 07:57:46 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.114796.218832 (Exim 4.92) (envelope-from ) id 1lZEIG-0008Cg-Uy; Wed, 21 Apr 2021 14:57:32 +0000 Received: by outflank-mailman (output) from mailman id 114796.218832; Wed, 21 Apr 2021 14:57: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 1lZEIG-0008CY-Rk; Wed, 21 Apr 2021 14:57:32 +0000 Received: by outflank-mailman (input) for mailman id 114796; Wed, 21 Apr 2021 14:57:32 +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 1lZEIG-0008C3-2j for xen-devel@lists.xenproject.org; Wed, 21 Apr 2021 14:57:32 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 4d6531b3-bb27-4ca8-b846-0279e2bc27c4; Wed, 21 Apr 2021 14:57:28 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 15918B2E8; Wed, 21 Apr 2021 14:57:28 +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: 4d6531b3-bb27-4ca8-b846-0279e2bc27c4 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=1619017048; 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=RGVbQa+GqVgOa2I76yheTEF5apAHeScJZb/syJB8fWc=; b=iCbgVqwxeyO8ueX3j8mD4gW5zxPGiIyrUDdwtYTpofx/l22VMOn7HAi8CArS2cP8VVHSXN xB0bdA86HaYqMjXByGH2jU7ZQMpcSZ0/jnRBc2PoisRihq18wEIHL/VEBSWswZmB7XEZhc zls4CFd5rPloiko0Z6H+waDyELBxx5w= Subject: [PATCH v2 4/8] 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?Roger_Pau_Monn=c3=a9?= References: <091b4b91-712f-3526-78d1-80d31faf8e41@suse.com> Message-ID: <8906088c-d76a-12ac-31d3-1375016a2148@suse.com> Date: Wed, 21 Apr 2021 16:57:27 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.10.0 MIME-Version: 1.0 In-Reply-To: <091b4b91-712f-3526-78d1-80d31faf8e41@suse.com> Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) Content-Type: text/plain; charset="utf-8" In particular in the PV case xzalloc_bytes() forcing SMP_CACHE_BYTES alignment is counterproductive, as the allocation size there is only 40 bytes. And if the code really cared about such higher than default alignment, it should request so explicitly rather than using a type- unsafe interface. Plus if e.g. cache line sharing was a concern, the allocator itself should arrange to avoid such. 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 =20 struct pirq *alloc_pirq_struct(struct domain *d) { - size_t sz =3D is_hvm_domain(d) ? sizeof(struct pirq) : - offsetof(struct pirq, arch.hvm); - struct pirq *pirq =3D xzalloc_bytes(sz); + union pirq_pv { + char space[offsetof(struct pirq, arch.hvm)]; + void *align; + }; + struct pirq *pirq =3D is_hvm_domain(d) ? xzalloc(struct pirq) + : (void *)xzalloc(union pirq_pv); =20 if ( pirq ) { From nobody Wed May 8 00:17:22 2024 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=1619017108; cv=none; d=zohomail.com; s=zohoarc; b=EgwvFCunUK/iJe7pb4y9yEasXktzn2XRPRZCZVx/r3sDZ7nEpTPSgIrfBOqVPjHHqfais25qwhLpWCMr4BvVPWHGIhBytvAyzNLRW9gPYRkqEmfPaUmpwhnpig54dmGwKFxUi+Nk/MbwnnpZmHg/bnBRP5qgzo196CrbMqAXMUs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619017108; 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=PW+XxMcrclQ3Woj7YTyYCjraRWb4WLw8fXwPv9OBWoI=; b=nEA0lbHObYiCWCXN/opBCUlrOiFfSfnAmA1zWukRv5JuMOj6OwmNHmQMhbj7KIsfF+SM6yfdswYMFdeW/1epsXpn8JFCWmGoQLae1QBTGTQbcnOVw2isRyhRPGlvatvoBS1eDwhXw2FWTXwbwQIdEQv+e/cGhyNRbGJW+/2twMY= 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 1619017108621639.6614073565322; Wed, 21 Apr 2021 07:58:28 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.114799.218845 (Exim 4.92) (envelope-from ) id 1lZEIw-0008Ju-7u; Wed, 21 Apr 2021 14:58:14 +0000 Received: by outflank-mailman (output) from mailman id 114799.218845; Wed, 21 Apr 2021 14:58:14 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lZEIw-0008Jn-4G; Wed, 21 Apr 2021 14:58:14 +0000 Received: by outflank-mailman (input) for mailman id 114799; Wed, 21 Apr 2021 14:58:13 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lZEIv-0008Jg-8h for xen-devel@lists.xenproject.org; Wed, 21 Apr 2021 14:58:13 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id fd55a24a-ca85-42bd-bf69-2fd0fdeb40ff; Wed, 21 Apr 2021 14:58:12 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 91783B4F5; Wed, 21 Apr 2021 14:58:11 +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: fd55a24a-ca85-42bd-bf69-2fd0fdeb40ff 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=1619017091; 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=PW+XxMcrclQ3Woj7YTyYCjraRWb4WLw8fXwPv9OBWoI=; b=C5iUJDEKmDytH3E/JE6ybsGGTSClh2t7iobc0KwmwvYv+5WL05v1VfGIUSQAMmz/6WqY9B uiXjCRaTDs+8sxk1K1Y9KBK+9lm3Iz2ezOGyOjR/0OTHEwcqz6br8qb8VyD6xI4If6Dlr3 U/A1gnd2nudemy02NM7BHM6W0ArZmPM= Subject: [PATCH v2 5/8] EFI/runtime: avoid effectively open-coding x{m,z}alloc_array() From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , George Dunlap , Ian Jackson , Julien Grall , Stefano Stabellini , Wei Liu References: <091b4b91-712f-3526-78d1-80d31faf8e41@suse.com> Message-ID: Date: Wed, 21 Apr 2021 16:58:11 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.10.0 MIME-Version: 1.0 In-Reply-To: <091b4b91-712f-3526-78d1-80d31faf8e41@suse.com> 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: x{m,z}alloc_bytes() forces SMP_CACHE_BYTES alignment. But if code really cared about such higher than default alignment, it should request so explicitly rather than using a type-unsafe interface. And if e.g. cache line sharing was a concern, the allocator itself should arrange to avoid such. 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 =3D op->u.get_variable.size; if ( size ) { - data =3D xmalloc_bytes(size); + data =3D xmalloc_array(unsigned char, size); if ( !data ) { xfree(name); @@ -536,7 +536,7 @@ int efi_runtime_call(struct xenpf_efi_ru return -EIO; } =20 - data =3D xmalloc_bytes(op->u.set_variable.size); + data =3D xmalloc_array(unsigned char, op->u.set_variable.size); if ( !data ) rc =3D -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; =20 size =3D op->u.get_next_variable_name.size; - name.raw =3D xzalloc_bytes(size); + name.raw =3D xzalloc_array(unsigned char, size); if ( !name.raw ) return -ENOMEM; if ( copy_from_guest(name.raw, op->u.get_next_variable_name.name, From nobody Wed May 8 00:17:22 2024 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=1619017144; cv=none; d=zohomail.com; s=zohoarc; b=ImuvrEYvWAGNYPXW52/oBR9T31OYZ/h3TAk6Vq8c6p1o34Gbca6h0OhMRrK9z+Ihju3GP4vZbbIzbMZt8K8iu12H5CCLQFDigCKDzrtHPD4SryNHtOdo05MmEN0rZOD25uq/wXiEdcud4X9X0lrY4pzLN4rtR2zLbYoOsAGnzAI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619017144; 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=TEBD/fYXGTJrgtLtgU6ekKg6T1yeMv6RYI14JcXg8j8=; b=NGPRKRfsDdzHULzo+RUYfwgmcsL0iBlyJ5a6S1WQUgdqIz7FNz8wDJrhsw+Av3HfxAa4GbzqD7DRnC9a1Zc0ePTmayWi8wAW7gTQSlYNxqmzt8JXnfLx4cQAfxlCtjtog6L02ToH/MkAAEpZnCFFFiOjOvZfv5KyhIaLUdxt0Yg= 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 1619017144349600.59779639628; Wed, 21 Apr 2021 07:59:04 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.114802.218857 (Exim 4.92) (envelope-from ) id 1lZEJX-0008Rg-GL; Wed, 21 Apr 2021 14:58:51 +0000 Received: by outflank-mailman (output) from mailman id 114802.218857; Wed, 21 Apr 2021 14:58:51 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lZEJX-0008RZ-DD; Wed, 21 Apr 2021 14:58:51 +0000 Received: by outflank-mailman (input) for mailman id 114802; Wed, 21 Apr 2021 14:58:49 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lZEJV-0008RJ-R6 for xen-devel@lists.xenproject.org; Wed, 21 Apr 2021 14:58:49 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id ec5dbab9-d98d-48be-ae11-d491971b14e5; Wed, 21 Apr 2021 14:58:49 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 4E330B4D5; Wed, 21 Apr 2021 14:58:48 +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: ec5dbab9-d98d-48be-ae11-d491971b14e5 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=1619017128; 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=TEBD/fYXGTJrgtLtgU6ekKg6T1yeMv6RYI14JcXg8j8=; b=c1iQM0N8Kr/7EMMA3fDMO/lAq3vlxDYh+Qu+6yeO5vSsNcW3uc5pvAUBgKtyuudjrWINRx 9XEv1TLdeMKPxZeZCZD19wWaF0rINC3StebQxVMf3rY7UawdDIgHWZoBZHqSxeTFvEe5Yc FbDBohSc2bSuuFNvyT4cwW4HRj88EDw= Subject: [PATCH v2 6/8] kexec: avoid effectively open-coding xzalloc_flex_struct() From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , George Dunlap References: <091b4b91-712f-3526-78d1-80d31faf8e41@suse.com> Message-ID: <7d6c30d8-c121-11f5-4ac9-49bad43a2a19@suse.com> Date: Wed, 21 Apr 2021 16:58:48 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.10.0 MIME-Version: 1.0 In-Reply-To: <091b4b91-712f-3526-78d1-80d31faf8e41@suse.com> 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. But if code really cared about such higher than default alignment, it should request so explicitly rather than using a type-unsafe interface. And if e.g. cache line sharing was a concern, the allocator itself should arrange to avoid such. 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); From nobody Wed May 8 00:17:22 2024 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=1619017180; cv=none; d=zohomail.com; s=zohoarc; b=EFa4Y5DKRX5KJsYGyDBVP09ha1zmbZYXFEPQDmIrPgIXap7awWHr+8Ocq25mJqKOs7/hYfRuGIwo8oD3uHy0fiAV3kykMHgypXDxo9JrRqun/HBNzo3tmA105Y4WkyN29nbFKPJxsopSJuRc2TwHx92FqruURDp4NUDVDKYAowU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619017180; 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=nhFCzQarQALIvmpTT7NHPYBbPtP6KFRVyXEIq1mQnM0=; b=ZI7M+be9SJec2aGUZeTssyojnzVG3ge+a08/Ob+9QZ16Zo8jbjUxxK02JKEiD5gqRnAG1BVCH67F4YJHNLQeqFwb3JKV/xklpnr4MBT5FXrud02NTfLVyMwuC85+jRqI2ZR4CBI1/FFRt4bTDiJKVc2LClh3gFy9W1uIukt4Skk= 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 161901718035974.35105282197526; Wed, 21 Apr 2021 07:59:40 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.114807.218869 (Exim 4.92) (envelope-from ) id 1lZEK5-00007f-Pl; Wed, 21 Apr 2021 14:59:25 +0000 Received: by outflank-mailman (output) from mailman id 114807.218869; Wed, 21 Apr 2021 14:59:25 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lZEK5-00007Y-Mj; Wed, 21 Apr 2021 14:59:25 +0000 Received: by outflank-mailman (input) for mailman id 114807; Wed, 21 Apr 2021 14:59:24 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lZEK4-00007P-2L for xen-devel@lists.xenproject.org; Wed, 21 Apr 2021 14:59:24 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id eb545c1f-b181-4c0d-8095-121634ccc030; Wed, 21 Apr 2021 14:59:23 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 96707B2E8; Wed, 21 Apr 2021 14:59:22 +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: eb545c1f-b181-4c0d-8095-121634ccc030 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=1619017162; 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=nhFCzQarQALIvmpTT7NHPYBbPtP6KFRVyXEIq1mQnM0=; b=GhiK152G4eeoBnhZPFiTgN3IYWdzhp+HZSNtN1UyFJWY5l6C8SAUjYkEptpyyJ2dS5g7Uc LcXzQsB1yhXfBrT7CIwcOvepJKqoFbEQghzv7QF94iqB6axNI320hTjXexsPSdZHihUjeg eub1OGxUWCoWwRywXgpTSJ+G+CVWRV8= Subject: [PATCH v2 7/8] 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 References: <091b4b91-712f-3526-78d1-80d31faf8e41@suse.com> Message-ID: <73db0f74-438e-d99f-35d7-76679df75e40@suse.com> Date: Wed, 21 Apr 2021 16:59:22 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.10.0 MIME-Version: 1.0 In-Reply-To: <091b4b91-712f-3526-78d1-80d31faf8e41@suse.com> 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. But if code really cared about such higher than default alignment, it should request so explicitly rather than using a type-unsafe interface. And if e.g. cache line sharing was a concern, the allocator itself should arrange to avoid such. 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 =3D *lfbp; =20 - lfb.lbuf =3D xmalloc_bytes(lfb.lfbp.bytes_per_line); - lfb.text_buf =3D xzalloc_bytes(lfb.lfbp.text_columns * lfb.lfbp.text_r= ows); + lfb.lbuf =3D xmalloc_array(unsigned char, lfb.lfbp.bytes_per_line); + lfb.text_buf =3D xzalloc_array(unsigned char, + lfb.lfbp.text_columns * lfb.lfbp.text_row= s); lfb.line_len =3D xzalloc_array(unsigned int, lfb.lfbp.text_columns); =20 if ( !lfb.lbuf || !lfb.text_buf || !lfb.line_len ) From nobody Wed May 8 00:17:22 2024 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=1619017278; cv=none; d=zohomail.com; s=zohoarc; b=aP33BYU3qRaSdC0AZRdav8t0OQ9UKIBX9kcl6XvcO7LQU4SlG2yo79sZ+kgbhUg+dm+2geMt1Uu6xaBn7W0IAXtiFwYK3YEuR8UyE2sxa8oEkPE8rymKmNeQtSFrhZM7onebfo4F1mD3mbZnr3nLPIKBpbJ3zppIxZNHRRcJ7S4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619017278; 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=pHhwX5kEIhnRT5ymp9VtnAWZvoeCZfwBmTwU5SVmNWE=; b=I6WTAymG6RrfmHXwHkHnDkjrQMY7xyMS1AYa32WTVxJZ3JOaZlF6Nrzc8LflD+NQTEBlxcDDVlXl51BoecNE2U1e1GQ84AxGRrKJ1SV/rL8H2T9xn8hgvVcslk+96p5SrzTqJkgu5MZYVPFmlXmTxXOjHj6b0/+kz6kTCUynsFM= 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 1619017278105701.6713373290783; Wed, 21 Apr 2021 08:01:18 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.114812.218881 (Exim 4.92) (envelope-from ) id 1lZEKf-0000FJ-3Q; Wed, 21 Apr 2021 15:00:01 +0000 Received: by outflank-mailman (output) from mailman id 114812.218881; Wed, 21 Apr 2021 15:00: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 1lZEKe-0000FC-W3; Wed, 21 Apr 2021 15:00:00 +0000 Received: by outflank-mailman (input) for mailman id 114812; Wed, 21 Apr 2021 15:00:00 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lZEKe-0000F4-ED for xen-devel@lists.xenproject.org; Wed, 21 Apr 2021 15:00:00 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 83f04db8-4b6e-4d95-a421-393bab35cd72; Wed, 21 Apr 2021 14:59:59 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id DC8D2B4D6; Wed, 21 Apr 2021 14:59:58 +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: 83f04db8-4b6e-4d95-a421-393bab35cd72 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=1619017199; 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=pHhwX5kEIhnRT5ymp9VtnAWZvoeCZfwBmTwU5SVmNWE=; b=b+LZks+synfdec+zvPWSzh2ua/VRk7fxpTdmfsCVAE518Ko5xFyviQme1dI5d/B2v44Fv9 m4F8/GhNNv8ZM99nt7gyFH9FUVF90cBDMRW3Zqr6tTr80TyqDZhEBngiwkopiKUvUu4W5Z c/JBIUeQyEw7Cr1b61W6UNOTpEkFZM4= Subject: [PATCH v2 8/8] 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 References: <091b4b91-712f-3526-78d1-80d31faf8e41@suse.com> Message-ID: <5fa042ac-9609-eab7-b14d-a59782ef4141@suse.com> Date: Wed, 21 Apr 2021 16:59:58 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.10.0 MIME-Version: 1.0 In-Reply-To: <091b4b91-712f-3526-78d1-80d31faf8e41@suse.com> Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) Content-Type: text/plain; charset="utf-8" The current use of xzalloc_bytes() in optee is nearly an open-coded version of xzalloc_flex_struct(), which was introduced after the driver was merged. The main difference is xzalloc_bytes() will also force the allocation to be SMP_CACHE_BYTES aligned and therefore avoid sharing the cache line. While sharing the cache line can have an impact on the performance, this is also true for most of the other users of x*alloc(), x*alloc_array(), and x*alloc_flex_struct(). So if we want to prevent sharing cache lines, arranging for this should be done in the allocator itself. In this case, we don't need stricter alignment than what the allocator=20 provides. Hence replace the call to xzalloc_bytes() with one of xzalloc_flex_struct(). Signed-off-by: Jan Beulich Signed-off-by: Julien Grall Acked-by: Volodymyr Babchuk --- v2: Use commit message very close to what was suggested by Julien. --- 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 !=3D atomic_cmpxchg(&ctx->optee_shm_buf_pages, old, new)) ); =20 - optee_shm_buf =3D xzalloc_bytes(sizeof(struct optee_shm_buf) + - pages_cnt * sizeof(struct page *)); + optee_shm_buf =3D xzalloc_flex_struct(struct optee_shm_buf, pages, pag= es_cnt); if ( !optee_shm_buf ) { err_code =3D -ENOMEM;