From nobody Sat Nov 30 12:50:40 2024 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 98D1517DFE3; Mon, 9 Sep 2024 17:27:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725902868; cv=none; b=MBI+01HHh65is03vRTpe3V0F6x9fIqeS3GoGwMRBnOQBGEeHcwe3qHyTAES85+FSU5UjQCOv9RMsqUHIN8ywOc/5w4PrR5kYt3NSofnURgow9OWaxcyPDGL6xQiUmxYGS+7wiq2Cjbfzzj1MTQxXyBPZlyNykl9D4EEcUY3aTKI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725902868; c=relaxed/simple; bh=wVBfxbk7Nn5baMWpEZcb5hX3LHhRxyJjSuy0c8zXC4k=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=GoDIiYGYDaM/CamByTu7KJ1JGsjS82hUKyaYHs2ksZLHLZzAnN7VXWmPUvUXqql7NXKZekrbS74M0TC8Qp+rp8buCZOcYH/guK2qeX/GdgL9qis8/IN30gS7ROQIWN/H3cgn0jJgbQiaY+9uAbhETuTZ67haYgYNRnxOTf0xgbE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=Yase9QV7; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=PFL/mvve; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Yase9QV7"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="PFL/mvve" Date: Mon, 09 Sep 2024 17:27:44 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1725902864; h=from:from:sender:sender:reply-to:reply-to:subject:subject: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=OOsKS2zXCt1tT7uCsp3cPkfkb+PJ2oUsEnNszYtkKZM=; b=Yase9QV7AaYh3qXjcyPkdnFgjBQwCiJF3Al3S5OVdkt4I9djl4RVuqZ82vJTDpBsUU7gav FG+acVdGdMMwSs8OzoIbHKatrMtc3w2Zlekpkv5nGGV+GvD1SAg+0fk2MiXP48l8NKXzJt uLFsknkuAlFkh1zr8o/G4yjMB/gb1UYBwNMpfN5EHB2zufAuDWZToQtephUmiP4AtyIJxI wILzhDoX1aBDAAU9I8aj6Kv4R2imE47u/mjjdBsL8jgo2v1YS3jbVzhhGsJnuce3KirwoJ FihnNFxqd5yqseVlCALhtettyKvgrGI7Y99PfspYeTn9DBYLN2LhXAsUD/5Y4Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1725902864; h=from:from:sender:sender:reply-to:reply-to:subject:subject: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=OOsKS2zXCt1tT7uCsp3cPkfkb+PJ2oUsEnNszYtkKZM=; b=PFL/mvveCPs+r73aQrXScpCGBK7Pqa3OdvbkoJvB/238K/f10A9XWvrQuakivSeyFc/Bt1 F2Mk0+/equMLIyDQ== From: "tip-bot2 for John Ogness" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/rt] printk: Provide helper for message prepending Cc: John Ogness , Petr Mladek , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20240904120536.115780-11-john.ogness@linutronix.de> References: <20240904120536.115780-11-john.ogness@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <172590286416.2215.17952690301915150002.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the sched/rt branch of tip: Commit-ID: 75d430372abba5210fbc56a813d2515c001a4f45 Gitweb: https://git.kernel.org/tip/75d430372abba5210fbc56a813d2515c0= 01a4f45 Author: John Ogness AuthorDate: Wed, 04 Sep 2024 14:11:29 +02:06 Committer: Petr Mladek CommitterDate: Wed, 04 Sep 2024 15:56:32 +02:00 printk: Provide helper for message prepending In order to support prepending different texts to printk messages, split out the prepending code into a helper function. Signed-off-by: John Ogness Reviewed-by: Petr Mladek Link: https://lore.kernel.org/r/20240904120536.115780-11-john.ogness@linutr= onix.de Signed-off-by: Petr Mladek --- kernel/printk/printk.c | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 149c3e0..e945856 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -2843,30 +2843,31 @@ static void __console_unlock(void) #ifdef CONFIG_PRINTK =20 /* - * Prepend the message in @pmsg->pbufs->outbuf with a "dropped message". T= his - * is achieved by shifting the existing message over and inserting the dro= pped - * message. + * Prepend the message in @pmsg->pbufs->outbuf. This is achieved by shifti= ng + * the existing message over and inserting the scratchbuf message. * - * @pmsg is the printk message to prepend. - * - * @dropped is the dropped count to report in the dropped message. + * @pmsg is the original printk message. + * @fmt is the printf format of the message which will prepend the existin= g one. * - * If the message text in @pmsg->pbufs->outbuf does not have enough space = for - * the dropped message, the message text will be sufficiently truncated. + * If there is not enough space in @pmsg->pbufs->outbuf, the existing + * message text will be sufficiently truncated. * * If @pmsg->pbufs->outbuf is modified, @pmsg->outbuf_len is updated. */ -void console_prepend_dropped(struct printk_message *pmsg, unsigned long dr= opped) +__printf(2, 3) +static void console_prepend_message(struct printk_message *pmsg, const cha= r *fmt, ...) { struct printk_buffers *pbufs =3D pmsg->pbufs; const size_t scratchbuf_sz =3D sizeof(pbufs->scratchbuf); const size_t outbuf_sz =3D sizeof(pbufs->outbuf); char *scratchbuf =3D &pbufs->scratchbuf[0]; char *outbuf =3D &pbufs->outbuf[0]; + va_list args; size_t len; =20 - len =3D scnprintf(scratchbuf, scratchbuf_sz, - "** %lu printk messages dropped **\n", dropped); + va_start(args, fmt); + len =3D vscnprintf(scratchbuf, scratchbuf_sz, fmt, args); + va_end(args); =20 /* * Make sure outbuf is sufficiently large before prepending. @@ -2889,6 +2890,19 @@ void console_prepend_dropped(struct printk_message *= pmsg, unsigned long dropped) } =20 /* + * Prepend the message in @pmsg->pbufs->outbuf with a "dropped message". + * @pmsg->outbuf_len is updated appropriately. + * + * @pmsg is the printk message to prepend. + * + * @dropped is the dropped count to report in the dropped message. + */ +void console_prepend_dropped(struct printk_message *pmsg, unsigned long dr= opped) +{ + console_prepend_message(pmsg, "** %lu printk messages dropped **\n", drop= ped); +} + +/* * Read and format the specified record (or a later record if the specified * record is not available). *