Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 91814E66880 for ; Fri, 19 Dec 2025 17:23:03 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.1190923.1511126 (Exim 4.92) (envelope-from ) id 1vWeBk-0007PX-3z; Fri, 19 Dec 2025 17:22:48 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 1190923.1511126; Fri, 19 Dec 2025 17:22:48 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vWeBk-0007PQ-0H; Fri, 19 Dec 2025 17:22:48 +0000 Received: by outflank-mailman (input) for mailman id 1190923; Fri, 19 Dec 2025 17:22:46 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vWeBi-0007PK-DX for xen-devel@lists.xenproject.org; Fri, 19 Dec 2025 17:22:46 +0000 Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [2a00:1450:4864:20::535]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 54fa47aa-dcff-11f0-b15b-2bf370ae4941; Fri, 19 Dec 2025 18:22:45 +0100 (CET) Received: by mail-ed1-x535.google.com with SMTP id 4fb4d7f45d1cf-640a0812658so3274629a12.0 for ; Fri, 19 Dec 2025 09:22:45 -0800 (PST) Received: from [192.168.1.6] (user-109-243-71-38.play-internet.pl. [109.243.71.38]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-64b916b3b35sm2743384a12.30.2025.12.19.09.22.43 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 19 Dec 2025 09:22:43 -0800 (PST) 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: 54fa47aa-dcff-11f0-b15b-2bf370ae4941 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1766164964; x=1766769764; darn=lists.xenproject.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=U6mZvMyHh0Q/356NIXF4FwU1znnqona4e6GQ+jsYG1Y=; b=jpjKXV7DejxcoiCXot4t6YiI2VJPmXxI6Gs4titbsXONQ1wgI5hkqmDNqbMmdz59Fh mAf52CEjl1EY8OL7LeMrGwHeSYKvWIus75SAFP+pw3TPqGXonVORR15Ku5rKggoJLCIv ITOJr+OErePTs6Zgts9FTp3Ao6b8QRHpo5DrxchSYuu5D/9Tq7BLdCjn3/hnINrpNVID LHD12sMX+1a/Z8MC/dKQc7DSVf1maNIyRI+yPa5bcWO5AAetYn9k/kOM1SUSMvvsUwac CvT5CHKoFk1lZcQcjjyi40bMJ5K0IaV3wVF7i+Hg9JG0ac1769vZIN1psG55rXJP4d8j L7tQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766164964; x=1766769764; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=U6mZvMyHh0Q/356NIXF4FwU1znnqona4e6GQ+jsYG1Y=; b=mR6qtXCDa9/dQVvyx+yDL3p6x1P5oY1Xx708rDNYO0nPfEvWG3FSbrBqHpkrzmbfaY NgmeTYqTwPqjWyddXcIZNsmfMZCOWgnoPp5O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Hwo4ssYL20TuuqAwzNXdg== X-Received: by 2002:a05:6402:2115:b0:64d:170:79a3 with SMTP id 4fb4d7f45d1cf-64d01707b55mr293997a12.20.1766164964272; Fri, 19 Dec 2025 09:22:44 -0800 (PST) Message-ID: Date: Fri, 19 Dec 2025 18:22:43 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 1/4] xen/arm: optimize the size of struct vcpu To: Jan Beulich Cc: Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk , Andrew Cooper , xen-devel@lists.xenproject.org References: <946a1c2cfaf4157074470a653bba5baa8561ebbf.1766053253.git.oleksii.kurochko@gmail.com> <290b8d4d-f853-418a-ae01-aea2f62b4f56@gmail.com> <8b045139-10dc-4b07-9ef6-d3b9c8b1efbb@suse.com> Content-Language: en-US From: Oleksii Kurochko In-Reply-To: <8b045139-10dc-4b07-9ef6-d3b9c8b1efbb@suse.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 12/19/25 3:16 PM, Jan Beulich wrote: > On 19.12.2025 14:32, Oleksii Kurochko wrote: >> On 12/18/25 7:15 PM, Andrew Cooper wrote: >>>> int vcpu_vgic_free(struct vcpu *v) >>>> { >>>> - xfree(v->arch.vgic.private_irqs); >>>> + xfree(v->arch.vgic->private_irqs); >>>> + xfree(v->arch.vgic); >>>> + >>>> return 0; >>>> } >>> Free functions should be idempotent.  This was buggy before, even moreso >>> now. >> Was it really buggy before in terms of idempotent. >> >> It seems like xfree() can handle the case when v->arch.vgic.private_irqs is NULL. >> Should I still have: >> if ( v->arch.vgic->private_irqs ) >> XFREE(v->arch.vgic->private_irqs); >> ? > No, and iirc Andrew also didn't ask for this. Andrew wrote: ``` Free functions should be idempotent.  This was buggy before, even moreso now.  It wants to be: void vcpu_vgic_free(struct vcpu *v) {     if ( v->arch.vgic )     {         XFREE(v->arch.vgic->private_irqs);         XFREE(v->arch.vgic);     } } Given the type change, this probably wants splitting out into an earlier patch. Given the fact that the single caller doesn't even check the return value, you're fixing a MISRA violation by making it void. ``` It isn't clear what "This was buggy before" means. In my changes it will be an issue if vcpu_vgic_free() would be called twice because without "if ( v->arch.vgic )" we will have NULL pointer dereference XFREE(v->arch.vgic->private_irqs) here. But considering that before it was just: int vcpu_vgic_free(struct vcpu *v) { xfree(v->arch.vgic.private_irqs); return 0; } In that case, it seems that calling|vcpu_vgic_free()| twice would not cause anything serious to happen. Am I misunderstanding what was buggy in the original code, or probably I'm misunderstanding what is idempotent? ~ Oleksii