Received: by 2002:ab2:f03:0:b0:1ef:ffd0:ce49 with SMTP id i3csp37551lqf; Tue, 26 Mar 2024 13:33:12 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV5rPtZDgNbeD3ECdBeQt3R1zWoZqOK1RZoCz5J6Lbg83k/+1Ivbt0Trt0QD2+C8cVz6I7ltc9J3WJDXmPnnzgjz9+4BqRykgPQhxvG8g== X-Google-Smtp-Source: AGHT+IGy8LcfM0TSL4whxVQA1em/C2JuK34CZFu3jTKUf0Py9APW1drU2w6DUWHnR8r3xRuoP24G X-Received: by 2002:a17:902:f68a:b0:1e1:214:1b7d with SMTP id l10-20020a170902f68a00b001e102141b7dmr879904plg.61.1711485192610; Tue, 26 Mar 2024 13:33:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711485192; cv=pass; d=google.com; s=arc-20160816; b=IF5RvOcx3sEAofylkc7gImGLBworhQ1Mw5sCGGt1EVxBpcuLDLsQjIPmNTNTSUcr+X D1iHXqlXU/RQDg7jQ1vLDb9hDWiaB4VO4Azw+amLdSJrXWSug2pzF/Zmq9dgz30UqyQM 64KZLas6xFDRA8OizubZwELkIdtfpoEKw9GnD3Lnkbt87lrmyzGPoQ/vdvbtM3VUQqkR kg2oaNSjW9VytTZ8OyrB8xN6WgTj6Ovasjy04ITP5Xs0vfIRAgK8QmB8d38D7EMFGCt2 mzGaRqTHXxo/mo0BIx0ilp7r8vbvWC8SdarcCEB5OR8MCFhBB/i9LojqROGEH+RdTuP0 dtsQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date; bh=T6V+z2f4RbkNIldmMqHI7T24VhNTpEAr+hnQZvCDNts=; fh=zAUkigIGTTE7dxx1DJDd9oZxIPWaYZ/TEN69uW81kbs=; b=l56olu2u0wB3gw40yCJk/lvfY6BqLlhOWXYDe9osB9bUOU9X+Pf13QP2GNecN9ajl8 Jkg4ZUKFMLmfVU4I/R2HcCvGYREGR0HjDe6IosIf0yYfDy3EZGpJM5K+BltjQbAWnqr5 GJzbEhs1swc3eXFTzQ4hJSWih5/BEvJQLMYAhPbIk5C0+5x3M90VlwLd67VhHifYcK7Q FfjYI55uJKJwgFaetsGjlN+JDtYUSZs0pkPR2VtF+clTV1fKfsNKJbXavD811puEOCd3 E2qpjhEdQnvt7Pc8tkXICSO2pfuYlW+GigzKzrywBxMZBFXFkda7ViuvxD/zksYBFPj7 LO4Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-119908-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-119908-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id q17-20020a170902e31100b001dd8be49c72si1287907plc.292.2024.03.26.13.33.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Mar 2024 13:33:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-119908-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-119908-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-119908-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 4D77E3280F6 for ; Tue, 26 Mar 2024 20:33:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9B4D213D61B; Tue, 26 Mar 2024 20:26:01 +0000 (UTC) Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 1374F13D50C; Tue, 26 Mar 2024 20:26:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711484761; cv=none; b=AoijNudTy9rZsP0zbATLSPzXzVnCvPL5rp99TK8EsAaiFux7Fq9AGWZKpdjIOdxFc18N6hEquTfhlwyWsbdEOgxvpHFy5H7Nq0acIRFuG0NElp5Ba+Dglnw3MqJgJmCn1RTqzBo+g2rxJrw3RXAW2fT1jX1hqBQaCCf471h0Zpc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711484761; c=relaxed/simple; bh=igWGdcldAz0/c8YIfnVQ/TAEd2nFNJDirYyjzqHgGRc=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=oPqmV6J0yUqzhTM/zCbgVgRDjDw6Ur/kDROTx+0rsf4fmLVAvsmMuty4urcOHk1HOrS1+or9hFp+4YTpXAdkvXEYQLqKi5mi98ohgFRZJ6LZTIblzWzpU/Wn2tZsZGyXe1kvHs8L2imcfgz1sS8eNQH+YwwTO1QyRGAyObrLsnY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 49A2CC433F1; Tue, 26 Mar 2024 20:25:59 +0000 (UTC) Date: Tue, 26 Mar 2024 16:28:38 -0400 From: Steven Rostedt To: Nikita Kiryushin Cc: "Paul E. McKenney" , Frederic Weisbecker , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Mathieu Desnoyers , Lai Jiangshan , Zqiang , rcu@vger.kernel.org, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org Subject: Re: [PATCH] rcu-tasks: Update show_rcu_tasks_trace_gp_kthread buffer size Message-ID: <20240326162838.14da4a7c@gandalf.local.home> In-Reply-To: <4b3e239d-ab87-4a37-ac1d-af49e1f8f3ee@ancud.ru> References: <20240326174839.487582-1-kiryushin@ancud.ru> <20240326152230.3e692d83@gandalf.local.home> <4b3e239d-ab87-4a37-ac1d-af49e1f8f3ee@ancud.ru> X-Mailer: Claws Mail 3.19.1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Tue, 26 Mar 2024 22:55:29 +0300 Nikita Kiryushin wrote: > On 3/26/24 22:22, Steven Rostedt wrote: > > Why 87? as it's not even word size, and this is on the stack. > > =20 > Got 87 as maximal used buffer length (result of > sprintf(buf, "N%lu h:%lu/%lu/%lu", > =C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 (unsigned long int) -1, > =C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 (unsigned long int) -1, > =C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 (unsigned long int) -1, > =C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 (unsigned long int) -1); > +1 for terminator. >=20 > Is word-size alignment a thing in this case? I thought that char buffers > are ok to be aligned by 1? Because it's on the stack, which will likely reserve data in word size. Thus, buf[87] reserves as much data on the stack as buf[88]. > > Better yet, why not just use snprintf()? > > =20 > Seems like a better idea indeed, as if fixes overflows for unpractical ca= ses, > without added overhead to common cases. The only concern is possible trun= cation > of data, that may break some automation (if output is parsed by someone, > without accounting on it being cut, who knows). But again, it is for pret= ty unpractical > values. >=20 > Will make a v2 patch with snprintf() with buffer length. >=20 > Genuinely look forward to being educated about aspects of aligning array = sizes, as > I do not really understand the limitations. It's because it's on the stack, but it's always good to align. For instance, kmalloc() will allocate things in 32 byte chunks. -- Steve