From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (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 BA35D3E5EEB for ; Wed, 27 May 2026 09:18:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779873529; cv=none; b=nRy1JBHT2mkxyyZoOH70k2NRZycFs4TVG4TuBFewdgISWQWdb6ltUPcW2G6NxULn7trf/4Q6G8PHALPiaOy3bVSIlsk8h8vrNDPUkhYYltzbplo6/AgxKGHsoA2fXdBibq8HrwsqHOnwiNIYi3cYg9keHbiEg5p31HbYHytiFug= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779873529; c=relaxed/simple; bh=hqlhFFjMJuWuM6S6vZ8SCY5V5cKRhZoHzm25OC+blk0=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MFhVLT3uzHcI75UUzWz34ihgo5SOirnZZ1m5RKDtyKT8kSfuXrHkCdxVSh6AWk4gVyI13sab4QkeaWSdTrnPIUzuKW7f4kILiGoBPcBbMfMaXHxvHeTe9XcSsqgK5F3RoCMfPguJZ5nfaCp861T7VvxEwyeFQup8VXYNddzKCj4= 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=Gby5aBUa; arc=none smtp.client-ip=209.85.128.45 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="Gby5aBUa" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-49056b9f04aso51323365e9.0 for ; Wed, 27 May 2026 02:18:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779873524; x=1780478324; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=hqlhFFjMJuWuM6S6vZ8SCY5V5cKRhZoHzm25OC+blk0=; b=Gby5aBUaNneyv46GmPg5ehUw+x6e6nppJQ+uhvcmTYmy1B/dlMyBZqF0mBM+TfSguM HvziBBSIvGYGn4VuRaNk6wRnVuLp21Quv9c8jfJAW4M5CCL2m0Hs+yQvZ1xrW8lpyYA/ 9c0HsW1ihkQ7hmmnc0bCx9CRKavMRIkPII++83gAfNJRSIV8DoXxmWM/q8LeUd/Ls8Hf KifL1Z7LXBpHzL69rlo99O1foj0tDyujWJSBKt8Dbdfcjxa4deH/TIGhoecQv89xwNWb Ltp7nryEr9v7HnAsc7m5AKw6UIjRsywRMRA8jM/yASoOE3GXq00sCoX3UU4dKqQSWE9s 25Dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779873524; x=1780478324; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=hqlhFFjMJuWuM6S6vZ8SCY5V5cKRhZoHzm25OC+blk0=; b=sX6Z2nTdu+Nob02pw3bVCMNakil4c4U8QdQoUrHlxAsPIBpPq7N73lQrX1MI05xC9q +C9R2/icXuqamGq0j/45GOcPlv7WwrfYfYBM7e9kapGSvOBHpC2mZJKd3iLQ2NjHRObx /m1dWFi2tuOV3lM+mCCx8Jc4Eh9BJ1IWg0ypeEjF+a+j2EHkBGZu1xYYp5YPLCPqpPBu eXSDf8zgbJWertdJAcnUCLfwYjL2F5POl46GhE+CujCbai2z6s1GWxr1xZKzlIPGxrCU 9sD7cAiMurMVyqOqM6lGgFxXh2ZoV15sRdi8KfKO39PxsjF0TurOHvEwpmeI5Mi24IyJ 4KJQ== X-Forwarded-Encrypted: i=1; AFNElJ+GZbzt+vZA2ueD/x2CsZq65x3yJ3XSCQrqRs/5IMR84BXAMgu8S3s2yfCJUO/s/95zDVyVcR0sS0lAcAU=@vger.kernel.org X-Gm-Message-State: AOJu0Yyow/2sG+1EPRoCg3lsHhdVIZL/Rou3u1HSov3Tec4LoHtxDBpZ vg3OmuooQCo83OyQOt9kLiT1Q3sGUCoyB5lWrQvKc6ncdjzkiYG6mDKX X-Gm-Gg: Acq92OERjijkXC8nSNMKnT3kNJ31uGlNLc6Bs+IZoWGt60+t3NA5zFdQhDrDfseN1+z pEik6gDHEBtx7scO9x7ErIYF2p0lcuoTpHutp+WZjKS+PM//uhN/kYmDplx/MOwJm7oylEQ47BL rLq3KBSTT2nQjWcz8k0XZ0c6xZtKXKoLxtLK7dow09J4A7Wb999i4XdhpU2aCCgt7tp4y6nNgEs f3zLmO6PSD03yEfDMXsGFuN6adRmD+0XgAiJ/+y8LjsDdLePTM9EQlIe9nqBQaxzqvifebNC302 mevgzMot8KdKFOG4EtJYREl6qKagq8v5hduwHc58lxtkXKIiAmR3UWACnFXGrS4BDV/3w84zycU KtvL1TStJwLQ1+JnpSHQ0pkhNwCaOXBBxmodmGrTDDvHfLd2QBMxULjficeasI6wX/RHkIJ42U+ JcuRNtRDFJ6OTgnQNgD9Vn3LT2HExi1MfXcQySXOtyy/Ld5jpBgLXEx0KmmAuVsfhvjaLxa+QM+ V0= X-Received: by 2002:a05:600c:4f8f:b0:490:7136:ad02 with SMTP id 5b1f17b1804b1-4907136ae51mr128868725e9.7.1779873523995; Wed, 27 May 2026 02:18:43 -0700 (PDT) Received: from pumpkin (82-69-66-36.dsl.in-addr.zen.co.uk. [82.69.66.36]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4907eae9898sm18844735e9.4.2026.05.27.02.18.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 May 2026 02:18:43 -0700 (PDT) Date: Wed, 27 May 2026 10:18:42 +0100 From: David Laight To: Steven Rostedt Cc: =?UTF-8?B?QW5kcsOp?= Almeida , Peter Zijlstra , Juri Lelli , Vincent Guittot , Christian Brauner , Kees Cook , Shuah Khan , willy@infradead.org, mathieu.desnoyers@efficios.com, Linus Torvalds , akpm@linux-foundation.org, Yafang Shao , andrii.nakryiko@gmail.com, arnaldo.melo@gmail.com, Petr Mladek , linux-kernel@vger.kernel.org, kernel-dev@igalia.com, linux-mm@kvack.org, linux-api@vger.kernel.org Subject: Re: [PATCH v2 3/6] treewide: Replace memcpy(..., current->comm) with strscpy() Message-ID: <20260527101842.376d567f@pumpkin> In-Reply-To: <20260526190625.3f4aca0a@gandalf.local.home> References: <20260524-tonyk-long_name-v2-0-332f6bd041c4@igalia.com> <20260524-tonyk-long_name-v2-3-332f6bd041c4@igalia.com> <20260526190625.3f4aca0a@gandalf.local.home> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; arm-unknown-linux-gnueabihf) 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 May 2026 19:06:25 -0400 Steven Rostedt wrote: > On Sun, 24 May 2026 19:38:53 -0300 > Andr=C3=A9 Almeida wrote: >=20 > > In order to increase the size of current->comm[] and to avoid breaking = any > > existing code, replace memcpy() with strscpy(). The later function makes > > sure that the copy is NUL terminated. This is crucial given that the > > source buffer might be larger than the destination buffer and could > > truncate the NUL character out of it. ... > As tracing now slows it down by 3.9% which is a significant increase from= 2.7% >=20 > I really rather keep memcpy() here. I suspect the copies could/should be replaced by a copy_task_comm() function that can perform optimisations that strscpy[_pad]() can't do because it can (for example) assume that the source is terminated. When the src and dst are the same size it can also degenerate to memcpy() - which should get inlined. The cost of copying 64 bytes might still be rather more than copying just 16. A compromise of 32 may be better. -- David >=20 > -- Steve