From nobody Fri Apr 17 07:44:39 2026 Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 83EF6344D81 for ; Mon, 23 Feb 2026 04:00:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771819227; cv=none; b=Q2YH072oM47MmxZzIdsdeoe3qjDrOp4oCm/NPo3Rujuh31dVuE5S39wwr6zLE1RY8xJBZlmko96xSNyJRxJ+FDpg8oU2qu6sjkqu3P0KmqyHB2EjfvCgeoMgFAkcKe9/lr6NV4Xu3V1OrjUiIxAvZTXMcJo+oJpmUgIDV83dNgY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771819227; c=relaxed/simple; bh=A2RBAhrr7xTGSyxRwuuLd4qyJw7pBlEzDVDnqD5i9JM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QigAEsyvbepdbOnoTfrBj1aqjx4DL3HiRj/MU+OXfG94rR1NOtZ6/ITXP0m0zzgGuFu9TYGniAvHLGTZiYQX4vM5zxPG89H0JJwBm5dqyuWR2D5jYmJtQiYrsh7E2X7j6U7BaMty2/DTzF0N/XbsItyujZFcm+dRc4XsCXpd4Ao= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=EkgPc7Pt; arc=none smtp.client-ip=209.85.214.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="EkgPc7Pt" Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-2aae146b604so27419345ad.3 for ; Sun, 22 Feb 2026 20:00:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1771819225; x=1772424025; darn=vger.kernel.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; bh=EN0mfDp/QZElBEfP3tNMIksTqD408vDWdPSyBV3TRyc=; b=EkgPc7PtCdxNz0Uze1wYtqF9x/EVlcVPVI4Yznrgc2/z0j6ANahRXdJxyUYmqwlygN 5Jhx0cfontUEXOWzgtW038SlvwSntwicJ/m+1HzHe4+KLUkjZAmkRwQzP7xHiXdSxtIT ca/UjCBk97pwGrTCQfXrl+plV7TKwiaWCDtFLSlza8wk3yLhHP20H/JAz4DIFKvZlyUY EItE46T5XGCcq5zsZ6LIzROUwveKTw526FQcCpTf4I+eqha8P5ra2bHBIU4onMkbbJdK OxSn+BGVv49JPx6AtTsi22y8l6kky+EnrzY6Y2TAHlt1ZLfi22ApqDG8S5CXKbDKuYbt 3srA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771819225; x=1772424025; 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; bh=EN0mfDp/QZElBEfP3tNMIksTqD408vDWdPSyBV3TRyc=; b=s9OO51jYd/IHifnntQpNHnneVCT7oHbllBJUMFapy+lurNHE/zezInlfhTR9dovam8 NTwvJF6EZenxEScq/FbJXI4lgOqQDyW+8kJIa01w/z4Nk4VYX4SgIRaifQ0k5t4ULk/w Q7hGlprunBKPM3Ex3kOLOcMeCHCc9FRoCsDJ541HBeBET5pmaXTPnaVCmFvWj71T8VuP IeMx+n3rgUb74AsD3+S2LJ/TDUKZz1gvVjoL25GAaAESu6xbmgwzsn1Q+2BGnUNQzLDW 4iINinGcZl3k/X9NRG+SPiQIotl4aUUDxQkXf9jEIwueMdGlFZgFgxr5fraF3qBahZ0G jGAA== X-Forwarded-Encrypted: i=1; AJvYcCVy0dPxQOStFyTqgvuHsoUoEPOoIEJFOW8gJjJhcrmUiJ7QLz1/cijw6ZMiL7oyh1s0jFxLZ+Z0gh53MC8=@vger.kernel.org X-Gm-Message-State: AOJu0YyIsoMSL4FYqdbTFqOq3lvZ79kmQqK211SYmzs12+sFXOKFwmMM MUDCxFJt3W2WqpSNErEXy7uTlmOVuxAV+l2LkFova531OEjAQTLAnuraep2RpD0S X-Gm-Gg: ATEYQzzIdVbrEiZgbMMhfWGXLzjSi0aseU1Bh+CU2fnzCet//6a/3b3NyLGzNw0aRyM 7pl/erJR8Sl6kcRGT+ndJurK/J66RYA1wZYxMtXuUHiLQRGs2PaHbaSOTvWVR5uDo5ma40FH5FG DmAegU8jooWTTzh35RoqQAG68NaPUtD6T4wQeAPzecC9Zx1hP7C2QHPUnJR78uFVVd74qMsg7Br 2loQUsGah8k8+av/NcxkbHZ8VG23scnmiS8O6pUd2UCu+iqqSz/cRWfL52cAIheuKr+w9gWSCvB YFumg+HVm/NiV/vgRDzepHo1Q4Q1gB2nwrXYVFUzozVTplrunEi1M+o/PibuKH4hMzbR26Qnl3I JDhtwfRicUZby991bniavdqIkdeW3pC0tgs/9a+Q5UJUM605YfU+ALkpNXE9klw5ApjGiIaER+t 15vhMpD4rehahZmetTtd8sIUsLMBxaLJJMiF1ZAfur9I0= X-Received: by 2002:a17:903:1212:b0:2a0:cccf:9d24 with SMTP id d9443c01a7336-2ad744280cfmr63335885ad.16.1771819224686; Sun, 22 Feb 2026 20:00:24 -0800 (PST) Received: from localhost.localdomain ([103.235.0.217]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2ad74e35088sm58644465ad.11.2026.02.22.20.00.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Feb 2026 20:00:24 -0800 (PST) From: Rio To: akpm@linux-foundation.org Cc: feng.tang@linux.alibaba.com, joel.granados@kernel.org, linux-kernel@vger.kernel.org, pmladek@suse.com, pnina.feder@mobileye.com, wangjinchao600@gmail.com, Rio Subject: [PATCHv3] kernel/panic: mark init_taint_buf as __initdata and panic instead of warning in alloc_taint_buf() Date: Mon, 23 Feb 2026 09:29:14 +0530 Message-ID: <20260223035914.4033-1-rioo.tsukatsukii@gmail.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260222140804.22225-1-rioo.tsukatsukii@gmail.com> References: <20260222140804.22225-1-rioo.tsukatsukii@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" On Sun, Feb 22, 2026 at 11:25:52AM -0800, Andrew Morton wrote: > However there's a convention of assuming that __init-time allocations > cannot fail. Because if a kmalloc() were to fail at this time, the > kernel is hopelessly messed up anyway. > So we could simply panic() if that kmalloc failed, then make that > 350-byte buffer __initdata. Ah, got it. I made it __initdata, and replaced the warn with panic. > That saves about $100 per machine with current DRAM prices ;) Haha, saving every bit counts huh Signed-off-by: Rio --- V2 -> V3: Mark initial buffer as __initdata and panic if allocation fails V1 -> V2: Allocate taint string buffer dynamically during init v2: https://lore.kernel.org/all/20260222140804.22225-1-rioo.tsukatsukii@gma= il.com/ v1: https://lore.kernel.org/all/20260220151500.13585-1-rioo.tsukatsukii@gma= il.com/ kernel/panic.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/kernel/panic.c b/kernel/panic.c index 5d498ff8a18b..20feada5319d 100644 --- a/kernel/panic.c +++ b/kernel/panic.c @@ -865,8 +865,8 @@ static void print_tainted_seq(struct seq_buf *s, bool v= erbose) */ #define INIT_TAINT_BUF_MAX 350 =20 -static char init_taint_buf[INIT_TAINT_BUF_MAX]; -static char *taint_buf =3D init_taint_buf; +static char init_taint_buf[INIT_TAINT_BUF_MAX] __initdata; +static char *taint_buf __refdata =3D init_taint_buf; static size_t taint_buf_size =3D INIT_TAINT_BUF_MAX; =20 static __init int alloc_taint_buf(void) @@ -887,11 +887,7 @@ static __init int alloc_taint_buf(void) buf =3D kmalloc(size, GFP_KERNEL); =20 if (!buf) { - /* Allocation may fail; this warning explains possibly - * truncated taint strings - */ - pr_warn_once("taint string buffer allocation failed, using fallback buff= er\n"); - return 0; + panic("Failed to allocate taint string buffer"); } =20 taint_buf =3D buf; --=20 2.52.0