From nobody Wed Aug 26 07:28:15 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1786582296; cv=none; d=zohomail.com; s=zohoarc; b=kq9Hzw2YMIWI8QLhJk6uSZ2MgrWuuIonICehALVuzGuStC9lItmSEIfxLx/zZXsuXjqdXZdN1BwEgFo2DkfHlBGUK1KC9T3L4xSQ05RVqnExMhvm2AqvRIgMQe6cYOHRzbsGk+A/49YSM3HiprHu0XJciQDMcKcqcdpQpArZ07A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1786582296; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=SCXkWU/s60xpywRTk/5Sry/P+FxBjxNAN7j/OIwaN8c=; b=AeVSeo0gNayoiLrOIMnMKnvY7uBffEtvkCnRsTYVhqXPzTNJGlETrwRnpDp+VVyDweGtO12ULEk3a1htEFL3UjoAEKjlLBHCY9LYMVN98hT9b+MZGVF3sWFRBhfdt94NAV6LaAca5+DK8WVfoovkeomGTyJjzqe61mSN52IutwA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1786582296747347.90460615500626; Wed, 12 Aug 2026 17:51:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wuJea-0000dY-Mq; Wed, 12 Aug 2026 20:50:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wuJeY-0000cR-89 for qemu-devel@nongnu.org; Wed, 12 Aug 2026 20:50:38 -0400 Received: from mail-pj1-x1033.google.com ([2607:f8b0:4864:20::1033]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wuJeV-000400-C4 for qemu-devel@nongnu.org; Wed, 12 Aug 2026 20:50:37 -0400 Received: by mail-pj1-x1033.google.com with SMTP id 98e67ed59e1d1-384930ca5e2so244853a91.3 for ; Wed, 12 Aug 2026 17:50:34 -0700 (PDT) Received: from stoup.. (174-21-93-59.tukw.qwest.net. [174.21.93.59]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3931ca612e7sm1259918a91.0.2026.08.12.17.50.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Aug 2026 17:50:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1786582234; x=1787187034; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=SCXkWU/s60xpywRTk/5Sry/P+FxBjxNAN7j/OIwaN8c=; b=AXOJ7ClcUMZqXyjx3RXkCCiZ/ahh+5ZgU/rhzNvwatpAIWWUL/e84UwJ1UnDqWNxGo OLBaiAOTVu79W7rZT1OjHpcspTL7w1AZGbb1XsdZWD0iz/UfOsycb2TzjATlc87IvKFk eJjmaeRknnKsf02Jayz0FDvuznsePnCpDQHHQugtb+OqKo4ojufVk/OPAbNhuO25iHYx +q3P8uYn0aMLs5Vw0B7lz7cmBSp/LFILdlTFtmqyodxWcp1L7bMSn4IaQ9tBhzGI8wwl JnokVUue8OSNUs66CHPaiDvEvIk/W0iyPGrZY6D+De2a4HQiIfuCpmhvKMcc4sNPPJfW ynqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786582234; x=1787187034; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=SCXkWU/s60xpywRTk/5Sry/P+FxBjxNAN7j/OIwaN8c=; b=JokuT0zPaTYC8jOsV9Mrr3P2IxAHHBpwRtsLg821BIy6EEc4d0cdhDfp1rmFNGLOrK OKDJUE+v2GGe98Iziv17wExlrO8pYC8EZjQk58UfKPXu2Ch7jY2I5X5JHCTG3xX2iBDz ZXYjsVdGXOHxnw+XcgoqIAn/L9euGGtIwqSadru0mECbFLyzV2AaKDsGp3OCoxGXUZnk cEjg3YQhTuZL0e7jtGnn7rvNaUCvmRn6OcCJwuVaAR0/1vJzN7tZGsj6hL/mzSutro9G XBK31aCzZ+Q3v4tEcjCmJYRrhNo8D9qzpq2wPqp+oV1aTKXUI0XqzUk0kkfAYQxZBQ0a 1Wrw== X-Gm-Message-State: AOJu0Ywa9oOZ14edQRclHJpYs8KhTw7QDThzObr8IYud+wzI94a68JZR jLF+263Z2RgnyqSFOYZeEKJTFV7ujmyC3MFmajMXwCgi8yw8hRRuu7wPiK586pig1fl2XW3rQGo FJSYF X-Gm-Gg: AR+sD12t/JgXZ3RtGrlOC0pj5sg4Qee4Cl4KSkEEtssXKG/fPUyjubD5fMoKpbpq6S7 x51k50Ly0yDsqk/62E/Qnrqox5VK/2zG3obF7A1ksf3M+jRT0FatqUkrXV4/u3iQKaJeNAH8zPs 6+XfZnXsiRQ7LZXyZq/ptRwUG/KOQVhIIYkpQdyTp3b5Sbpn6wtfMuZcXzH35u2dQk0yprcWmT3 EwpAxqHlZqpGFaply0GLzuOoXGmxBJ5PofF1j/13Eby7KkwEgkW8tzzfBZ2nQgdkWRsiUB8jL+T Z4aNDxsS96Tp72Qp17JyAz8kCVleOEUmRmRXR2hP+75rCY/Jmgw4U8cpCj94PzEyILIWTvHqyUK guBlfK4rAlUUDAKh3Lz8xtOUl+GGWlHDUoNjkeF2FPAOF1jUYzzfmuBVhmdA5w0XQDV4Y1JMjS8 GgKIRWHN6sGe0hQ4pYuUG/22dNfhxYeM/HspN7iGME3TJLdmI+/2lY0cjTtwTIDJjxxg5PBVFDY kXY1JOy5eaGdf8VzjZN8p1i7pi/YTk= X-Received: by 2002:a17:90b:2750:b0:38e:7f1b:efa with SMTP id 98e67ed59e1d1-3931e25efacmr2574172a91.11.1786582233621; Wed, 12 Aug 2026 17:50:33 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: yvyas1991@gmail.com, qemu-ppc@nongnu.org, rathc@linux.ibm.com, anushree.mathur@linux.ibm.com, npiggin@gmail.com, harshpb@linux.ibm.com Subject: [PATCH v2 1/3] tcg: Return success from tcg_region_alloc__locked Date: Wed, 12 Aug 2026 17:50:29 -0700 Message-ID: <20260813005031.518387-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260813005031.518387-1-richard.henderson@linaro.org> References: <20260813005031.518387-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::1033; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1033.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1786582301106158500 Content-Type: text/plain; charset="utf-8" Invert the sense of the boolean result from 'error' to 'success'. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Yogesh Vyas Tested-by: Yogesh Vyas --- tcg/region.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tcg/region.c b/tcg/region.c index 5d4be1453b..2161d961d9 100644 --- a/tcg/region.c +++ b/tcg/region.c @@ -360,11 +360,11 @@ static void tcg_region_assign(TCGContext *s, size_t c= urr_region) static bool tcg_region_alloc__locked(TCGContext *s) { if (region.current =3D=3D region.n) { - return true; + return false; } tcg_region_assign(s, region.current); region.current++; - return false; + return true; } =20 /* @@ -373,17 +373,17 @@ static bool tcg_region_alloc__locked(TCGContext *s) */ bool tcg_region_alloc(TCGContext *s) { - bool err; + bool ok; /* read the region size now; alloc__locked will overwrite it on succes= s */ size_t size_full =3D s->code_gen_buffer_size; =20 qemu_mutex_lock(®ion.lock); - err =3D tcg_region_alloc__locked(s); - if (!err) { + ok =3D tcg_region_alloc__locked(s); + if (ok) { region.agg_size_full +=3D size_full - TCG_HIGHWATER; } qemu_mutex_unlock(®ion.lock); - return err; + return !ok; } =20 /* @@ -392,8 +392,8 @@ bool tcg_region_alloc(TCGContext *s) */ static void tcg_region_initial_alloc__locked(TCGContext *s) { - bool err =3D tcg_region_alloc__locked(s); - g_assert(!err); + bool ok =3D tcg_region_alloc__locked(s); + g_assert(ok); } =20 void tcg_region_initial_alloc(TCGContext *s) --=20 2.43.0 From nobody Wed Aug 26 07:28:15 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1786582320; cv=none; d=zohomail.com; s=zohoarc; b=KIzItrm0ezL25I2hxugrdc2aN1kc7+L8Tq6d0gC0zO/M/K0MBM/FBCawUMq4XltoV9zoSPPbc4rvrtJso3aTTprh9Z2EGEGXgV3pF/UcP3t+sxDljkfPkS/yB8CS58KKJKfIKekErIjRbe1Kf73csE75YQg2wYUNteNJN6riIOk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1786582320; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=NaQE6f2Pc9mTVAO9MpVP9WM3c+ia7jvor2cvLmY6xZY=; b=dz4jrMDvys+omlYLlctG/1VFxpGM+amf0NhlB/jMasDqO0Ja2tiTsrlzQQp2T7+9nWdHTFwVY7yPpzY6HhT/MLIA5bZpYcuw34gyrlfZdX4uH8So4D2RSlVq91mpIL1nDZ1UJCDGwWluSTiL+H3N7ML9cidoNDaaM+yjG8SFABs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 178658232000627.302224761152388; Wed, 12 Aug 2026 17:52:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wuJev-0000g0-SZ; Wed, 12 Aug 2026 20:51:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wuJeY-0000cT-Aq for qemu-devel@nongnu.org; Wed, 12 Aug 2026 20:50:38 -0400 Received: from mail-pj1-x1036.google.com ([2607:f8b0:4864:20::1036]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wuJeV-00040F-UV for qemu-devel@nongnu.org; Wed, 12 Aug 2026 20:50:38 -0400 Received: by mail-pj1-x1036.google.com with SMTP id 98e67ed59e1d1-38f0f132f56so432596a91.0 for ; Wed, 12 Aug 2026 17:50:35 -0700 (PDT) Received: from stoup.. (174-21-93-59.tukw.qwest.net. [174.21.93.59]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3931ca612e7sm1259918a91.0.2026.08.12.17.50.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Aug 2026 17:50:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1786582234; x=1787187034; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=NaQE6f2Pc9mTVAO9MpVP9WM3c+ia7jvor2cvLmY6xZY=; b=UIAARrgDF8MY1QcWv7Jc9pWLS5JceoeutFCsT1a0+Q/SP8v5xZKKS4LUz46Dv6AvK0 ljt1I1b/LLPFFKBKz54Nt6+5GG4o/UQPK96nWC6K7evec3XL4VqAiPT677IMqiWqJZRo 7db7PMe4zG29+rKStqlC0FRwjL0CDByf3KHP7E4jQ808qsgENGmE27Pn0lxpmULYcmbX dCv6bkg82ZlTzBMAqkKVNlDi73pmtjysyKI5orcNN7oDuGOlZ1P8BKDgIemAjy56yzux R/P3SM05Gm3CjRsBbZBlG+12p+K/h8Egw4bOjZ1wqfYDbTvZNSO6wF2wGhjPQEL0dD+R aSbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786582234; x=1787187034; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=NaQE6f2Pc9mTVAO9MpVP9WM3c+ia7jvor2cvLmY6xZY=; b=Zb1Ty6f1B8c2N4DV4hX63BZCpBvisaSnvqFUl9GZpUZIL8KruYP12Y9CRUV30TsE0Y kLtzLsfw9qHAsoUjjttnuYhiv6yzmxsU4dYhbhD8oyLQaYLl4GE1p3e1osA1FMCET4kX JMIYqlrj0lz1aFOOahkG5BOy+KGBc7k/etX55PFIwWn2xHya4DIYTezmwt4rT8YWd1Pl x0IBT91CEec+u9XcdWc8M9aM1r/dqMFIvL7OtZD3iA4buxTtEWcYPWkitXOjpGUmA3hU 6oRd8shMFFvYsCwV5bX2KObwOIGro2flmAdPkG3foGbALcF1LuWe/zvssQN8U20oq+cn hylg== X-Gm-Message-State: AOJu0YwAA/PrDYBlZTwY+NIt31s8zJBhu0EMHQ3lPAwadYPGqiWfXYne A9dxGjE+bzUXCZ83FMlgoDqVY3opGMSPm20+MtQUP3G5NeHIDk712WOPbe9THnyr3uoy4dK7VMx fjd8L X-Gm-Gg: AR+sD10pJ9yrfhHf9YTEO1JYzYfydlDqtviOoJMDDeH8Z93idh64ZuG1ImQ6O8g4gXg gzOlefaG7cE0K0lftR+m/rymiRnsuq7Ab+w2HoM0VjF3GzjK0y5pMm8zq9+Ys+bpMOE9FPjdb3Z TX+FQ+zemL6MuH4mOZN3Sd4aNySR22ykLGEtRp94MQs/8a+sDbCTH52vtK9mLd3ymSe6+3HX/Re WoYdcd8XCPMYBQV8AOetqZuMru+snEXlESZ24g6hwlIttIa/VK96+wLRZ4RzVxc9SfN34YWCbmY JMLygjd4fMDrgA65Ozgke5Qo/HkAew601ML9exknFZbW9ZCwGjoqeZoL0RbH7Pgl4fUNiZRDqzW gUj4gfD19ZxoTpAFXDCQg6h3W2bR0neRVQ07ZmNb3jglpjOzHJg7JRc+5RREZMJchWsT2H5e3oU +EA1D/IF4y/BAmthNmWHYm20xiRuY33lEo6jKifisjN170fWwO3PTgwx0VtVKRWKlj9Kowg9VXC /XwgF+6aiBcKYPQDXLIz6AGVj7X7q0= X-Received: by 2002:a17:90b:1cc7:b0:386:ca4b:16a9 with SMTP id 98e67ed59e1d1-3931f959a78mr705080a91.16.1786582234432; Wed, 12 Aug 2026 17:50:34 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: yvyas1991@gmail.com, qemu-ppc@nongnu.org, rathc@linux.ibm.com, anushree.mathur@linux.ibm.com, npiggin@gmail.com, harshpb@linux.ibm.com Subject: [PATCH v2 2/3] tcg: Return success from tcg_region_alloc Date: Wed, 12 Aug 2026 17:50:30 -0700 Message-ID: <20260813005031.518387-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260813005031.518387-1-richard.henderson@linaro.org> References: <20260813005031.518387-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::1036; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1036.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1786582323728158500 Content-Type: text/plain; charset="utf-8" Invert the sense of the boolean result from 'error' to 'success'. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Yogesh Vyas Tested-by: Yogesh Vyas --- tcg/region.c | 2 +- tcg/tcg.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tcg/region.c b/tcg/region.c index 2161d961d9..8ee8c39c43 100644 --- a/tcg/region.c +++ b/tcg/region.c @@ -383,7 +383,7 @@ bool tcg_region_alloc(TCGContext *s) region.agg_size_full +=3D size_full - TCG_HIGHWATER; } qemu_mutex_unlock(®ion.lock); - return !ok; + return ok; } =20 /* diff --git a/tcg/tcg.c b/tcg/tcg.c index 1e77f2365a..af15c3d63e 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -1835,7 +1835,7 @@ TranslationBlock *tcg_tb_alloc(TCGContext *s) next =3D (void *)ROUND_UP((uintptr_t)(tb + 1), align); =20 if (unlikely(next > s->code_gen_highwater)) { - if (tcg_region_alloc(s)) { + if (!tcg_region_alloc(s)) { return NULL; } goto retry; --=20 2.43.0 From nobody Wed Aug 26 07:28:15 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1786582320; cv=none; d=zohomail.com; s=zohoarc; b=G8V9nhBacoVt0w97GkFW6uO1Jv8NuTXSociqEWvleikdJhPigmkXhe4GwldqeG5XA6mvcmw/kcOaeQlXdQcv+x2UO9F3TDMC8qdzQ3E/RaGscvKgX2RFxxyJKCuF9xiQQOvkZkokT0i8tUrSTOhri8ExHE7Uq0eolsRc4HNwQXM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1786582320; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=DG5KrInoOA5BiWClGx6mfaAAm5PtanUYXY9qfC53y7k=; b=E4U4xyrV8tmlYGQRTypiBFHmVxgN2qXTxRA7G+LgsZsxv//Ht/t6dcf6LXDJI9A4LPmL2eLqS2CUBYCivrq7xILnrRZ/5kFBTdqVRBX/3hSrahicQkLql6wuuXnYMcsbmgB5vPHpsghRrfJ49XWM3KiTHqPmz7+8JNyXQgauSEI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1786582320128969.9223359470166; Wed, 12 Aug 2026 17:52:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wuJev-0000fx-R4; Wed, 12 Aug 2026 20:51:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wuJeZ-0000dD-PG for qemu-devel@nongnu.org; Wed, 12 Aug 2026 20:50:39 -0400 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wuJeW-00040O-RF for qemu-devel@nongnu.org; Wed, 12 Aug 2026 20:50:39 -0400 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-2cfbbdfa60bso15779035ad.3 for ; Wed, 12 Aug 2026 17:50:36 -0700 (PDT) Received: from stoup.. (174-21-93-59.tukw.qwest.net. [174.21.93.59]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3931ca612e7sm1259918a91.0.2026.08.12.17.50.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Aug 2026 17:50:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1786582235; x=1787187035; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=DG5KrInoOA5BiWClGx6mfaAAm5PtanUYXY9qfC53y7k=; b=Uy2lsfpPYKfcTb15ioNxhJinHhO2jluqv48hpyUmHEf4MvJ+BLTQl46UjH1TJvjtFI KojZYHOLZ/z+vBvnWixpwiNJWrLkOZLVRxh5tV3+9WUZ+Thy/b8V10St3Q02+jFzqN9Y pugSdYVRuEV8La3jzyWOTfOyQwDS3eJqi1ylwJLnkR/KEQ8qinMaOkhau4L5dpXsW0a+ aQshIn8qMgy169dr0tkA9wspTe9cLw+UbFD8Uz4GMVo6qRR6Y0PRNNYFB48h6LyMjojp rMzjLIPBXe14UbMR2sUQ9WwC92IhY1mJjs1iZchK3diVxW+bqK54IVekFc2b5jP6Z/tb Nakg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786582235; x=1787187035; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=DG5KrInoOA5BiWClGx6mfaAAm5PtanUYXY9qfC53y7k=; b=qVMZ1FARUkmtovyu5bZUML6UKc0wEisnj4avidQNDJAe3cLF4ZLair4kaTVbhnbxv/ jLdOhz1CmuVqdshtc6TQF0ZGbLvBxVuvIfNyXjJk+GGxMSVe40YjFEeaCKrmuZTa/dB3 qsx4I8xiBp2lpvTmuc0pkwTuhaW8/UKRi+FzhOcE730boJ5AT1b/b/xJ8DT+MhoH709c DTjfBLhj0nOkXxgbGw7RTqCvUeRd5wj11UWLpqN5Xu1L9VPzEcOqdcdOwaT9f8zxZUdb y+Rw+1Af/jx/tDuGDpV9EnjkQwfe68CNmAR+0+uPW9Udvsnyx7VYDzKDDZJgXNXQVYd7 M3CA== X-Gm-Message-State: AOJu0Yz5ZC8zPca/3KP2DZL3XJw/F+1K5RnoXwdL63L6UYhEPIRnZR+4 UhIbj+aX+hds8b3TeKn2aFCkoUBKJ+hbMY8n/vAmsEE85yNMNIEa4720fQ+VG7/M5KptK86ak8w xNPeT X-Gm-Gg: AR+sD114SPP8TfkqXUBw/SRTbHKSO865WwOE0jAwC8PNmmTbdf8CgKpr+2VjAJZx5sV hc9KT8wPeWz7T4ZMr+/e5Wr9h4+h+h3G/6fzCEKdyloA47f2KzkWiBO6ZF7vLqDELKNCVsQ/XId 3AlPMeTEVBUItuat0gLWFL0Z6nIXow5XILI5safCPlbnbzGzu9A1ORWabdSJDbzb7drmO2YgIbV w+xlX3EaLMxS1iaB/WavF2X+0Dqa2NTIw6Sn89zXSbKQDRM/NJY0ixMicqxAgL42QNOQoS09g++ 1d82kDKI+KCfPbvkSGavqi9/LWj7VBIMxgxgF69Vss9zgCKjOmNDaOjnxFn5fJ5T89+cIsL8q5C XATXpbwD475ZrOHeekqUiTgk5vb0tdwh5J/nr0dEQUEg/cA0M54is88lZHyvzbIWAk4KBKv2f/K YGAT3wYMl8UvR1iE8fWaHYhw8ASAMQ6hlH+AQpvVEVKJKCzje9UoX2Y27N8PK8nGtuu+eHnbG2V jkLu2YmRXTMcCKQ/x0X X-Received: by 2002:a17:90b:5444:b0:38f:efed:5445 with SMTP id 98e67ed59e1d1-3931e02a45emr2673776a91.4.1786582235226; Wed, 12 Aug 2026 17:50:35 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: yvyas1991@gmail.com, qemu-ppc@nongnu.org, rathc@linux.ibm.com, anushree.mathur@linux.ibm.com, npiggin@gmail.com, harshpb@linux.ibm.com Subject: [PATCH v2 3/3] tcg: Defer tb_flush when initial thread region alloc fails Date: Wed, 12 Aug 2026 17:50:31 -0700 Message-ID: <20260813005031.518387-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260813005031.518387-1-richard.henderson@linaro.org> References: <20260813005031.518387-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::636; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x636.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1786582321927158500 Content-Type: text/plain; charset="utf-8" A vCPU hotplug may happen at any time. When the new thread is started, the region pool may be exhausted. Do not abort. Rename tcg_region_thread_initial_alloc to differentiate it from tcg_region_initial_alloc__locked. The renamed function now uses tcg_region_alloc__locked and is prepared for failure. In tcg_tb_alloc, allow code_gen_ptr to be NULL. Treat that as any other region exhaustion. Reorg with while instead of goto. Reported-by: Anushree Mathur Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/2984 Signed-off-by: Richard Henderson Reviewed-by: Yogesh Vyas Tested-by: Yogesh Vyas --- tcg/tcg-internal.h | 2 +- tcg/region.c | 24 ++++++++++++++++++++++-- tcg/tcg.c | 22 ++++++++++++++-------- 3 files changed, 37 insertions(+), 11 deletions(-) diff --git a/tcg/tcg-internal.h b/tcg/tcg-internal.h index c0997ab224..e35440dc8c 100644 --- a/tcg/tcg-internal.h +++ b/tcg/tcg-internal.h @@ -42,7 +42,7 @@ extern unsigned int tcg_max_ctxs; =20 void tcg_region_init(size_t tb_size, int splitwx, unsigned max_threads); bool tcg_region_alloc(TCGContext *s); -void tcg_region_initial_alloc(TCGContext *s); +void tcg_region_thread_initial_alloc(TCGContext *s); void tcg_region_prologue_set(TCGContext *s); =20 static inline void *tcg_call_func(TCGOp *op) diff --git a/tcg/region.c b/tcg/region.c index 8ee8c39c43..8bd378b212 100644 --- a/tcg/region.c +++ b/tcg/region.c @@ -396,11 +396,31 @@ static void tcg_region_initial_alloc__locked(TCGConte= xt *s) g_assert(ok); } =20 -void tcg_region_initial_alloc(TCGContext *s) +void tcg_region_thread_initial_alloc(TCGContext *s) { + bool ok; + qemu_mutex_lock(®ion.lock); - tcg_region_initial_alloc__locked(s); + ok =3D tcg_region_alloc__locked(s); qemu_mutex_unlock(®ion.lock); + + /* + * A vCPU hotplug may happen at any time. When the new thread is + * started, the region pool may be exhausted. At this point in + * the new thread call stack, we are not in a position to fix this. + * Leave code_gen_ptr NULL, so that this thread's first call to + * tcg_tb_alloc() returns NULL, so that the translator performs + * a tb_flush() and retry. + * + * During the tb_flush(), tcg_region_reset_all() will assign a + * new region to all contexts, including this one. + */ + if (!ok) { + s->code_gen_buffer =3D NULL; + s->code_gen_ptr =3D NULL; + s->code_gen_buffer_size =3D 0; + s->code_gen_highwater =3D NULL; + } } =20 /* Call from a safe-work context */ diff --git a/tcg/tcg.c b/tcg/tcg.c index af15c3d63e..db43589fa2 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -1279,7 +1279,7 @@ void tcg_register_thread(void) qatomic_set(&tcg_ctxs[n], s); =20 if (n > 0) { - tcg_region_initial_alloc(s); + tcg_region_thread_initial_alloc(s); } =20 tcg_ctx =3D s; @@ -1830,18 +1830,24 @@ TranslationBlock *tcg_tb_alloc(TCGContext *s) TranslationBlock *tb; void *next; =20 - retry: - tb =3D (void *)ROUND_UP((uintptr_t)s->code_gen_ptr, align); - next =3D (void *)ROUND_UP((uintptr_t)(tb + 1), align); + while (1) { + tb =3D (void *)ROUND_UP((uintptr_t)s->code_gen_ptr, align); =20 - if (unlikely(next > s->code_gen_highwater)) { + /* + * Note that code_gen_ptr can be NULL after vCPU hotplug. + * See tcg_region_thread_initial_alloc. + */ + if (tb) { + next =3D (void *)ROUND_UP((uintptr_t)(tb + 1), align); + if (next <=3D s->code_gen_highwater) { + qatomic_set(&s->code_gen_ptr, next); + return tb; + } + } if (!tcg_region_alloc(s)) { return NULL; } - goto retry; } - qatomic_set(&s->code_gen_ptr, next); - return tb; } =20 void tcg_prologue_init(void) --=20 2.43.0