Message ID | 20231117131824.1977792-1-david.marchand@redhat.com (mailing list archive) |
---|---|
Headers |
Return-Path: <dev-bounces@dpdk.org> X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0081243354; Fri, 17 Nov 2023 14:18:39 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B7ED840ED1; Fri, 17 Nov 2023 14:18:39 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id A2C1C40648 for <dev@dpdk.org>; Fri, 17 Nov 2023 14:18:38 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700227118; h=from:from: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; bh=ejdJVGFd2Yo8zd7FxsR95jz369X1XEXAIoK1GqKaGos=; b=D05ucExsDpkm1n7mXnJIj6Z6E1BsWsJyA27UC2fUCQt77ciHEzw9JpKnGzjxid0sbV+ClT vtJMGc4HElpA0wqKd6JMEAVh57fxV2tIQtL2TxMO4zyA7zEs4mR+wo4U4KwdOoL3ukUim7 aFus0bqxdA4nPfKc4DbGw3TgxF0M+oo= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-58-_pFRmqsgM9mVBzKZtT6RjA-1; Fri, 17 Nov 2023 08:18:34 -0500 X-MC-Unique: _pFRmqsgM9mVBzKZtT6RjA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 60926101A52D; Fri, 17 Nov 2023 13:18:34 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.226.112]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3D1001121306; Fri, 17 Nov 2023 13:18:33 +0000 (UTC) From: David Marchand <david.marchand@redhat.com> To: dev@dpdk.org Cc: thomas@monjalon.net, ferruh.yigit@amd.com, bruce.richardson@intel.com, stephen@networkplumber.org Subject: [RFC 0/3] Detect superfluous newline in logs Date: Fri, 17 Nov 2023 14:18:21 +0100 Message-ID: <20231117131824.1977792-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions <dev.dpdk.org> List-Unsubscribe: <https://mails.dpdk.org/options/dev>, <mailto:dev-request@dpdk.org?subject=unsubscribe> List-Archive: <http://mails.dpdk.org/archives/dev/> List-Post: <mailto:dev@dpdk.org> List-Help: <mailto:dev-request@dpdk.org?subject=help> List-Subscribe: <https://mails.dpdk.org/listinfo/dev>, <mailto:dev-request@dpdk.org?subject=subscribe> Errors-To: dev-bounces@dpdk.org |
Series |
Detect superfluous newline in logs
|
|
Message
David Marchand
Nov. 17, 2023, 1:18 p.m. UTC
Getting readable and consistent logs is important when running a DPDK application, especially when troubleshooting. A common issue with logs is when a DPDK change do not add (or on the contrary add too many \n) in the format string. This issue would only get noticed when actually hitting this log (which may be something difficult to do). This series proposes to introduce a new RTE_LOG helper that is responsible for logging a one line message and spews a build error (with gcc) if any \n is part of the format string. Note: - the first patch is intentionnally sent as a single block: splitting it into per library commits with correct Fixes: tags is a tedious work. I would split it for a non RFC series. For now, it is enough to show case the idea. - the last patch shows how an existing log macro is converted,
Comments
On Fri, Nov 17, 2023 at 02:18:21PM +0100, David Marchand wrote: > Getting readable and consistent logs is important when running a DPDK > application, especially when troubleshooting. > A common issue with logs is when a DPDK change do not add (or on the > contrary add too many \n) in the format string. > > This issue would only get noticed when actually hitting this log (which > may be something difficult to do). > > This series proposes to introduce a new RTE_LOG helper that is > responsible for logging a one line message and spews a build error (with > gcc) if any \n is part of the format string. > > > Note: > - the first patch is intentionnally sent as a single block: splitting it > into per library commits with correct Fixes: tags is a tedious work. > I would split it for a non RFC series. For now, it is enough to show > case the idea. > - the last patch shows how an existing log macro is converted, > > very nice. I definitely think this should be implemented for 24.03 Thanks, /Bruce PS: I'm not even sure that the first patch needs to be split. I think it's fairly clear as-is.
> From: David Marchand [mailto:david.marchand@redhat.com] > Sent: Friday, 17 November 2023 14.18 > > Getting readable and consistent logs is important when running a DPDK > application, especially when troubleshooting. > A common issue with logs is when a DPDK change do not add (or on the > contrary add too many \n) in the format string. > > This issue would only get noticed when actually hitting this log (which > may be something difficult to do). > > This series proposes to introduce a new RTE_LOG helper that is > responsible for logging a one line message and spews a build error > (with gcc) if any \n is part of the format string. > The new helper's name is RTE_LOG_LINE, not RTE_LOG. As far as I can see, RTE_LOG continues working as before - allowing one line of log message to span multiple lines of RTE_LOG() calls with \n in the last of them. Which is good. Anyway, I like the concept. And it solves a real problem. If you want other names, e.g. RTE_LOG for a complete line (appending \n in the macro itself), and RTE_LOG_PART (or similar) for an incomplete line, I wouldn't object. But that would probably break the API. > > Note: > - the first patch is intentionnally sent as a single block: splitting > it > into per library commits with correct Fixes: tags is a tedious work. > I would split it for a non RFC series. For now, it is enough to show > case the idea. > - the last patch shows how an existing log macro is converted,
On Fri, Nov 17, 2023 at 2:27 PM Bruce Richardson <bruce.richardson@intel.com> wrote: > > On Fri, Nov 17, 2023 at 02:18:21PM +0100, David Marchand wrote: > > Getting readable and consistent logs is important when running a DPDK > > application, especially when troubleshooting. > > A common issue with logs is when a DPDK change do not add (or on the > > contrary add too many \n) in the format string. > > > > This issue would only get noticed when actually hitting this log (which > > may be something difficult to do). > > > > This series proposes to introduce a new RTE_LOG helper that is > > responsible for logging a one line message and spews a build error (with > > gcc) if any \n is part of the format string. > > > > > > Note: > > - the first patch is intentionnally sent as a single block: splitting it > > into per library commits with correct Fixes: tags is a tedious work. > > I would split it for a non RFC series. For now, it is enough to show > > case the idea. > > - the last patch shows how an existing log macro is converted, > > > > > very nice. I definitely think this should be implemented for 24.03 I am still wondering how this idea should evolve... Some points I have in mind but for which I am not sure what is the best. Some log helpers were exposed to applications and had no explicit requirement wrt \n. Applications may have used those helpers with multiline messages. So maybe existing *exposed* helpers should be left untouched... and a new helper would need to be introduced. IOW with an example, cryptodev (missing a RTE_ prefix) CDEV_LOG_ERR macro is publicly exposed. A CDEV_LOG_LINE_ERR may be needed to avoid breaking external users. There are a lot of other log macros that let it to the callers to add a trailing \n. Should we convert them? Converting the *whole* DPDK code to the new helper (with some exceptions for people who like multiline logs..) would be nice to close this topic once and for all. But it would likely be a nightmare for later fixes that contain logs and which could introduce regressions in such logs if the backport does not take care of re-adding a \n.
On Fri, Nov 17, 2023 at 2:47 PM Morten Brørup <mb@smartsharesystems.com> wrote: > > > From: David Marchand [mailto:david.marchand@redhat.com] > > Sent: Friday, 17 November 2023 14.18 > > > > Getting readable and consistent logs is important when running a DPDK > > application, especially when troubleshooting. > > A common issue with logs is when a DPDK change do not add (or on the > > contrary add too many \n) in the format string. > > > > This issue would only get noticed when actually hitting this log (which > > may be something difficult to do). > > > > This series proposes to introduce a new RTE_LOG helper that is > > responsible for logging a one line message and spews a build error > > (with gcc) if any \n is part of the format string. > > > > The new helper's name is RTE_LOG_LINE, not RTE_LOG. Sorry, wrong completion. > > As far as I can see, RTE_LOG continues working as before - allowing one line of log message to span multiple lines of RTE_LOG() calls with \n in the last of them. Which is good. Indeed, we can't break / change RTE_LOG api. This API is too old, that would be a nightmare. > > Anyway, I like the concept. And it solves a real problem. > > If you want other names, e.g. RTE_LOG for a complete line (appending \n in the macro itself), and RTE_LOG_PART (or similar) for an incomplete line, I wouldn't object. But that would probably break the API. No API breaking allowed :-).
On Fri, Nov 17, 2023 at 02:48:25PM +0100, David Marchand wrote: > On Fri, Nov 17, 2023 at 2:27 PM Bruce Richardson > <bruce.richardson@intel.com> wrote: > > > > On Fri, Nov 17, 2023 at 02:18:21PM +0100, David Marchand wrote: > > > Getting readable and consistent logs is important when running a DPDK > > > application, especially when troubleshooting. > > > A common issue with logs is when a DPDK change do not add (or on the > > > contrary add too many \n) in the format string. > > > > > > This issue would only get noticed when actually hitting this log (which > > > may be something difficult to do). > > > > > > This series proposes to introduce a new RTE_LOG helper that is > > > responsible for logging a one line message and spews a build error (with > > > gcc) if any \n is part of the format string. > > > > > > > > > Note: > > > - the first patch is intentionnally sent as a single block: splitting it > > > into per library commits with correct Fixes: tags is a tedious work. > > > I would split it for a non RFC series. For now, it is enough to show > > > case the idea. > > > - the last patch shows how an existing log macro is converted, > > > > > > > > very nice. I definitely think this should be implemented for 24.03 > > I am still wondering how this idea should evolve... > > Some points I have in mind but for which I am not sure what is the best. > > Some log helpers were exposed to applications and had no explicit > requirement wrt \n. > Applications may have used those helpers with multiline messages. > So maybe existing *exposed* helpers should be left untouched... and a > new helper would need to be introduced. And the existing helpers deprecated. Internal log helpers should not be exposed to apps. > IOW with an example, cryptodev (missing a RTE_ prefix) CDEV_LOG_ERR > macro is publicly exposed. > A CDEV_LOG_LINE_ERR may be needed to avoid breaking external users. > RTE_CDEV_LOG_ERR should be available, though, right? :-) > > There are a lot of other log macros that let it to the callers to add > a trailing \n. > Should we convert them? I would think that, ideally, yes we should. > Converting the *whole* DPDK code to the new helper (with some > exceptions for people who like multiline logs..) would be nice to > close this topic once and for all. > But it would likely be a nightmare for later fixes that contain logs > and which could introduce regressions in such logs if the backport > does not take care of re-adding a \n. Good point. I wonder how many backports add new logs, or modify existing ones? Are there any automated checks, or a checklist for backports to enable us to catch these sort of things? Naming could be a problem, but we could look to move over existing logs by using new log macro names, which should help us to catch these. Even if the log names are a bit awkward, if they are kept internal-only, it shouldn't matter much. [Plus we would always be free to do a mass-rename back to the original name in future, once the backport issues are reduced]. /Bruce
> From: David Marchand [mailto:david.marchand@redhat.com] > Sent: Friday, 17 November 2023 15.10 > > On Fri, Nov 17, 2023 at 2:47 PM Morten Brørup > <mb@smartsharesystems.com> wrote: > > > > > From: David Marchand [mailto:david.marchand@redhat.com] > > > Sent: Friday, 17 November 2023 14.18 > > > > > > Getting readable and consistent logs is important when running a > DPDK > > > application, especially when troubleshooting. > > > A common issue with logs is when a DPDK change do not add (or on > the > > > contrary add too many \n) in the format string. > > > > > > This issue would only get noticed when actually hitting this log > (which > > > may be something difficult to do). > > > > > > This series proposes to introduce a new RTE_LOG helper that is > > > responsible for logging a one line message and spews a build error > > > (with gcc) if any \n is part of the format string. > > > > > > > The new helper's name is RTE_LOG_LINE, not RTE_LOG. > > Sorry, wrong completion. > > > > > As far as I can see, RTE_LOG continues working as before - allowing > one line of log message to span multiple lines of RTE_LOG() calls with > \n in the last of them. Which is good. > > Indeed, we can't break / change RTE_LOG api. > This API is too old, that would be a nightmare. > > > > > Anyway, I like the concept. And it solves a real problem. > > > > If you want other names, e.g. RTE_LOG for a complete line (appending > \n in the macro itself), and RTE_LOG_PART (or similar) for an > incomplete line, I wouldn't object. But that would probably break the > API. > > No API breaking allowed :-). OK, then: Series-acked-by: Morten Brørup <mb@smartsharesystems.com>
On Fri, Nov 17, 2023 at 3:11 PM Bruce Richardson <bruce.richardson@intel.com> wrote: > > On Fri, Nov 17, 2023 at 02:48:25PM +0100, David Marchand wrote: > > On Fri, Nov 17, 2023 at 2:27 PM Bruce Richardson > > <bruce.richardson@intel.com> wrote: > > > > > > On Fri, Nov 17, 2023 at 02:18:21PM +0100, David Marchand wrote: > > > > Getting readable and consistent logs is important when running a DPDK > > > > application, especially when troubleshooting. > > > > A common issue with logs is when a DPDK change do not add (or on the > > > > contrary add too many \n) in the format string. > > > > > > > > This issue would only get noticed when actually hitting this log (which > > > > may be something difficult to do). > > > > > > > > This series proposes to introduce a new RTE_LOG helper that is > > > > responsible for logging a one line message and spews a build error (with > > > > gcc) if any \n is part of the format string. > > > > > > > > > > > > Note: > > > > - the first patch is intentionnally sent as a single block: splitting it > > > > into per library commits with correct Fixes: tags is a tedious work. > > > > I would split it for a non RFC series. For now, it is enough to show > > > > case the idea. > > > > - the last patch shows how an existing log macro is converted, > > > > > > > > > > > very nice. I definitely think this should be implemented for 24.03 > > > > I am still wondering how this idea should evolve... > > > > Some points I have in mind but for which I am not sure what is the best. > > > > Some log helpers were exposed to applications and had no explicit > > requirement wrt \n. > > Applications may have used those helpers with multiline messages. > > So maybe existing *exposed* helpers should be left untouched... and a > > new helper would need to be introduced. > > And the existing helpers deprecated. Internal log helpers should not be > exposed to apps. I agree. > > > IOW with an example, cryptodev (missing a RTE_ prefix) CDEV_LOG_ERR > > macro is publicly exposed. > > A CDEV_LOG_LINE_ERR may be needed to avoid breaking external users. > > > > RTE_CDEV_LOG_ERR should be available, though, right? :-) Err, yes, but if we make it private, we don't need the RTE_ prefix ? :-) > > > > > There are a lot of other log macros that let it to the callers to add > > a trailing \n. > > Should we convert them? > > I would think that, ideally, yes we should. > > > Converting the *whole* DPDK code to the new helper (with some > > exceptions for people who like multiline logs..) would be nice to > > close this topic once and for all. > > But it would likely be a nightmare for later fixes that contain logs > > and which could introduce regressions in such logs if the backport > > does not take care of re-adding a \n. > > Good point. I wonder how many backports add new logs, or modify existing > ones? Are there any automated checks, or a checklist for backports to Touching logs in backport happens often afaics. (to simplify I added a vXX.11.0 tag pointing at vXX.11) $ for i in $(seq 0 4); do echo v21.11.${i}..v21.11.$((i + 1)) $(git diff v21.11.${i}..v21.11.$((i + 1)) | grep -c ^\+.*LOG); done v21.11.0..v21.11.1 122 v21.11.1..v21.11.2 40 v21.11.2..v21.11.3 43 v21.11.3..v21.11.4 30 v21.11.4..v21.11.5 24 $ for i in $(seq 0 2); do echo v22.11.${i}..v22.11.$((i + 1)) $(git diff v22.11.${i}..v22.11.$((i + 1)) | grep -c ^\+.*LOG); done v22.11.0..v22.11.1 0 v22.11.1..v22.11.2 37 v22.11.2..v22.11.3 106 I don't think there are checks on this topic (and to be fair, I don't see which check could be done). > enable us to catch these sort of things? > Naming could be a problem, but we could look to move over existing logs by > using new log macro names, which should help us to catch these. Even if the > log names are a bit awkward, if they are kept internal-only, it shouldn't > matter much. [Plus we would always be free to do a mass-rename back to the > original name in future, once the backport issues are reduced]. This is the way I had in mind.