From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 1359643354; Fri, 17 Nov 2023 15:22:14 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D8C1A410FB; Fri, 17 Nov 2023 15:22:13 +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 72BBC40ED1 for ; Fri, 17 Nov 2023 15:22:12 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700230932; 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: in-reply-to:in-reply-to:references:references; bh=JXszC80WDY3BUonjB0gXvidYTSlymJEwfzqW5YQwR0Q=; b=GXJwwSMMAY6bXnrV8psRRqy8n9m8rYtJxvijLni8sZ90js7Q5wE5IMTxf86hseTFWN4GKS ylazjkw98/h7QwPtH2uYHC49Y9Z+Zf6nc+oZ31laQ7wp9bYcJz3G2C/enbkk1H+YUr6ieA hdkU1XHZZ13mktSDwEYX3Tu0bPag5V4= Received: from mail-lj1-f200.google.com (mail-lj1-f200.google.com [209.85.208.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-120-E8wZ_kc0MtSHeTm5jfWziA-1; Fri, 17 Nov 2023 09:22:10 -0500 X-MC-Unique: E8wZ_kc0MtSHeTm5jfWziA-1 Received: by mail-lj1-f200.google.com with SMTP id 38308e7fff4ca-2c6ff798010so12369091fa.0 for ; Fri, 17 Nov 2023 06:22:10 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700230929; x=1700835729; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JXszC80WDY3BUonjB0gXvidYTSlymJEwfzqW5YQwR0Q=; b=UhoqWo/CRpY0Syi+0S4k49DUiM8bbDEm1d1eDtTaAGn+ninRhiOIUpzG9QM3xhx3vD m/cWa7+aNsG8SMHIord4LRUl+iR8MQrfDUUuTEi1W5+h8Qgzt5Pb6X50ILbe+Kte5KMq f7gjefShzQQbpeNawRpGrpwDOzz3+zymFNSM30QWToUe3+v5zRX7uPigRH66xAoILTNF 76tJH4ZJrNR5iwunpGLbQ/nX3U+WCIwkIEDJQNw65Jn8JAtWQRoIsMYp/pDph04tcO7+ +NCo7kdz3hTuuVnaHORlF20ZGoaaZUVCfGYVgyv1flkNC0QJu9THiZTP55nhA26OBVH4 ORQQ== X-Gm-Message-State: AOJu0Yx9djAbiIh6g+8+Fz6HkJQz1PtOqe81JFLDijs/pgBYHOLROGKv OuI8mQ+2wBIUlpH+i6b+xjvggzquYcJPc/JFOsvK7x1gneEVXedZrdnBEJ1qQcVGfU7epaOKcZ4 xuoW4tXebJ/F6aqcqHks= X-Received: by 2002:a05:651c:1183:b0:2c1:7e15:dca6 with SMTP id w3-20020a05651c118300b002c17e15dca6mr1871609ljo.0.1700230929237; Fri, 17 Nov 2023 06:22:09 -0800 (PST) X-Google-Smtp-Source: AGHT+IEtX39+DmPskBYEkLPASyC8yFvWCGfi5aCdJd3JXxDfG7Z53F+6nedioJq7S3wSPQizt4+UNayfY0xpn7wIsz0= X-Received: by 2002:a05:651c:1183:b0:2c1:7e15:dca6 with SMTP id w3-20020a05651c118300b002c17e15dca6mr1871594ljo.0.1700230928806; Fri, 17 Nov 2023 06:22:08 -0800 (PST) MIME-Version: 1.0 References: <20231117131824.1977792-1-david.marchand@redhat.com> In-Reply-To: From: David Marchand Date: Fri, 17 Nov 2023 15:21:57 +0100 Message-ID: Subject: Re: [RFC 0/3] Detect superfluous newline in logs To: Bruce Richardson Cc: dev@dpdk.org, thomas@monjalon.net, ferruh.yigit@amd.com, stephen@networkplumber.org, =?UTF-8?Q?Morten_Br=C3=B8rup?= , Luca Boccassi , Kevin Traynor , "Xueming(Steven) Li" X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On Fri, Nov 17, 2023 at 3:11=E2=80=AFPM Bruce Richardson wrote: > > On Fri, Nov 17, 2023 at 02:48:25PM +0100, David Marchand wrote: > > On Fri, Nov 17, 2023 at 2:27=E2=80=AFPM Bruce Richardson > > wrote: > > > > > > On Fri, Nov 17, 2023 at 02:18:21PM +0100, David Marchand wrote: > > > > Getting readable and consistent logs is important when running a DP= DK > > > > application, especially when troubleshooting. > > > > A common issue with logs is when a DPDK change do not add (or on th= e > > > > contrary add too many \n) in the format string. > > > > > > > > This issue would only get noticed when actually hitting this log (w= hich > > > > 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: splitti= ng it > > > > into per library commits with correct Fixes: tags is a tedious wo= rk. > > > > I would split it for a non RFC series. For now, it is enough to s= how > > > > 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 b= y > using new log macro names, which should help us to catch these. Even if t= he > 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 th= e > original name in future, once the backport issues are reduced]. This is the way I had in mind. --=20 David Marchand