From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 46C1DC282EC for ; Tue, 18 Mar 2025 18:07:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 163C3280002; Tue, 18 Mar 2025 14:07:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0EE8E280001; Tue, 18 Mar 2025 14:07:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EA878280002; Tue, 18 Mar 2025 14:07:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id C7280280001 for ; Tue, 18 Mar 2025 14:07:08 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 1405012041C for ; Tue, 18 Mar 2025 18:07:10 +0000 (UTC) X-FDA: 83235453420.07.CB5DC9A Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf26.hostedemail.com (Postfix) with ESMTP id F2505140025 for ; Tue, 18 Mar 2025 18:07:06 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=DBzlswaw; spf=pass (imf26.hostedemail.com: domain of bhsharma@igalia.com designates 178.60.130.6 as permitted sender) smtp.mailfrom=bhsharma@igalia.com; dmarc=pass (policy=none) header.from=igalia.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1742321228; h=from:from:sender: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:dkim-signature; bh=xi5z/098n3s55drfJnQC0KGieJT8vR+QHgsSyHMCSwc=; b=hMjHvNXhVXKToxUjRY5ILw6+3bQTVEKijfuArcNYC0Vs6HFzFXXn6b1iHnUrDrNymZHtQT xN9iAnxP2ONxboQeo5IvhxGsEQUynhvlkKDSTGnpQwsdtMHe5ichfdZvMIVDUvTmb4MRe7 JDn3CCV4bpg+0Gq5baqDjyWF4Zj58vA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1742321228; a=rsa-sha256; cv=none; b=fT+PAp1WTaN2zFMIaOjIPPIogaD7WVWGESAKhqLnTbsSGW0TPvaaZYw06+p8wgF/LSWj9I O3mG1KXIwREMBNwGoeBxq1wY8jVqT+xLqRAUV7HcZZd2KMRU+zd4SKkubCrMZ4qWOEHiW7 UPmLTK7Wg2sfXgAUf3N4EAqxShb2rdk= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=DBzlswaw; spf=pass (imf26.hostedemail.com: domain of bhsharma@igalia.com designates 178.60.130.6 as permitted sender) smtp.mailfrom=bhsharma@igalia.com; dmarc=pass (policy=none) header.from=igalia.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:From: References:Cc:To:Subject:MIME-Version:Date:Message-ID:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=xi5z/098n3s55drfJnQC0KGieJT8vR+QHgsSyHMCSwc=; b=DBzlswawCpcdwZoCIaLOvmz4bR f0qEhXAdTinfikQUSQKatFmc4DOOS06n8K1sJFrOSNcUeLsXDHdJtNOOqIoE8tMVCawIxhjr7V0il wj7gIb8Wa/bOAL4CwOk29espYzdobGhMYvbkCHF6VHxQtcfoa7ax0Pyk3HAHtUSu/fg/xTpJm1xTt IiNOB4hK2IvroqdJaIkKfy3UKumgrzzhUswjeq0+prccirjOKyNlc3/hOJZX8zgnN5eKsjqjMl02e ARHGKMUHhTSXc/fvmwe4vsdSRTzB13/2bXVwzUV6PAVlRDiOf2K221sWXTZQAwmOS33ro4q6Qysbs /dIdWobg==; Received: from [223.233.76.123] (helo=[192.168.1.12]) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_128_GCM:128) (Exim) id 1tubKz-002s83-Kp; Tue, 18 Mar 2025 19:06:49 +0100 Message-ID: <24766119-3aa2-fe88-878a-90a2794cca8f@igalia.com> Date: Tue, 18 Mar 2025 23:36:40 +0530 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.0 Subject: Re: [PATCH RFC 0/2] Dynamically allocate memory to store task's full name Content-Language: en-US To: Kees Cook Cc: Andres Rodriguez , Bhupesh , akpm@linux-foundation.org, kernel-dev@igalia.com, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, oliver.sang@intel.com, lkp@intel.com, laoar.shao@gmail.com, pmladek@suse.com, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, arnaldo.melo@gmail.com, alexei.starovoitov@gmail.com, andrii.nakryiko@gmail.com, mirq-linux@rere.qmqm.pl, peterz@infradead.org, willy@infradead.org, david@redhat.com, viro@zeniv.linux.org.uk, ebiederm@xmission.com, brauner@kernel.org, jack@suse.cz, mingo@redhat.com, juri.lelli@redhat.com, bsegall@google.com, mgorman@suse.de, vschneid@redhat.com References: <20250314052715.610377-1-bhupesh@igalia.com> <202503141420.37D605B2@keescook> <8b11d5f6-bb16-7af6-8377-bb0951fcfb60@igalia.com> <202503180846.EAB79290D@keescook> From: Bhupesh Sharma In-Reply-To: <202503180846.EAB79290D@keescook> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: F2505140025 X-Stat-Signature: r4irptpr43gnf4kukbzq5jhjzd9e31kb X-HE-Tag: 1742321226-16216 X-HE-Meta: U2FsdGVkX185jJJBvGAU1vJYV6I0zhFy2xKqbwRxUwQ/2h2j1WznMwbw3YUBWQ3kZcbl03WpxQXDIlqYhFXc5SWIMQ2+5gKYgx80Ha7jhdl5Eu7XCyzymM8+qE1g/7632yxe3mTdFp7YpgoEohclvMxn7Cvt2fJ1M3vsSznyQ1I7LhjdXTFUDjPrb23tz0y4ZKbYeBQB2MneFb6Iopk8f5ZiyUpCWc5prvbTA17ETSKS0yP+PmDVLNHgBax4IrdoQQBukOk71qee+vwaqc6h2DdFiLFKZbwmza6Cn8rQpYwb4chNHLJfnbt2yaavsob4Ie9zmtJC/Mop1T4ZtOkbwbw6DmcfxQJM7AjhKfCDbh4l0Hvshc343pcREpzP7I9ylYsgWTMGrXZZdHfbLFhBcs84Lph7ZVDa4k4HZy4YCqyLxYe+v0KcglaqupsYCLT4jPi744rxQubVlCrLIkPN3JS9T7S4u3LOIvG9xaPdx1kkZVT80lS/y90SqwM/r6wL9tka2tmovJweczEYvGLvxwEL2MGVEYMP9DqUZF5N4ajo4st4rKkRNM6uMBVtIib90Op3krINxrfUeMcZV22zegSzUVUq5UNQI0v/ZNcwnt3qsyQiJcMb7IgtRvSuM3WkD9hbi78eWBThNSKg5lREuxzVvOZ2cnLnrJP/D0vTceC/QPNRPlJmNoWOILHCVh9ZUkYvb7FTmbwscad3rCz9gJFagB4w9yywXGQiLQk9HCi1hHM/wUSLPwOFDs0n+0GbDa23IZ1bOkvErv5EvbodhwS2Qa7fuN0Ws8+FOcbaWmcikTLfaQqs82GWF2w5hZAHFnk9zHe6Ie2g4uDluaoK+2TzZ5E2wuo0Ia1cd2uYsBXf2wB5DVAmx5p6lXHhe/69zOVwfxKPKCM9dvUFGi1yNwkt7Htary0OEuyll3Cn8596puHd5yTbtoQCwgAmixnnVR0NpRwnohhzzEKjOua zm6w0Aud 6q9DbrbIvwLpM781h+OZvwfrpfgVH950azMV+4aXJxSV9d0UaIM/XvwQmBUWd3t3OvgwTmEGSXITBcewvLSwKN3wadktSiByymCYVn5Uf1iyzyATRjbaB1Nr4PK2pwwryU1od4KR+iuWI77Kwzqk8DZuDYDhCm8+4c36nSmlhqs9WEBigabBROS7KMseZJ3ZqHvcWAO9RiJ4vvcZcmuyKl77UFd8NTTQxMAVrt7mNKlO2eZw/GZJSMglzP8Bl6MYul9fRDGjHgujamDTLcECWDw6UrwmemKJbRSdNLhyrEDyKOdaz6wlMBtc1r5rYsityqz9C X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Hi Kees, On 3/18/25 9:21 PM, Kees Cook wrote: > On Tue, Mar 18, 2025 at 04:49:28PM +0530, Bhupesh Sharma wrote: >> On 3/15/25 1:13 PM, Andres Rodriguez wrote: >>> On 3/14/25 14:25, Kees Cook wrote: >>>> On Fri, Mar 14, 2025 at 10:57:13AM +0530, Bhupesh wrote: >>>>> While working with user-space debugging tools which work especially >>>>> on linux gaming platforms, I found that the task name is truncated due >>>>> to the limitation of TASK_COMM_LEN. >>>>> >>>>> For example, currently running 'ps', the task->comm value of a long >>>>> task name is truncated due to the limitation of TASK_COMM_LEN. >>>>>      create_very_lon >>>>> >>>>> This leads to the names passed from userland via pthread_setname_np() >>>>> being truncated. >>>> So there have been long discussions about "comm", and it mainly boils >>>> down to "leave it alone". For the /proc-scraping tools like "ps" and >>>> "top", they check both "comm" and "cmdline", depending on mode. The more >>>> useful (and already untruncated) stuff is in "cmdline", so I suspect it >>>> may make more sense to have pthread_setname_np() interact with that >>>> instead. Also TASK_COMM_LEN is basically considered userspace ABI at >>>> this point and we can't sanely change its length without breaking the >>>> world. >>>> >>> Completely agree that comm is best left untouched. TASK_COMM_LEN is >>> embedded into the kernel and the pthread ABI changes here should be >>> avoided. >>> >> So, basically my approach _does not_ touch TASK_COMM_LEN at all. The normal >> 'TASK_COMM_LEN' 16byte design remains untouched. >> Which means that all the legacy / existing ABi which uses 'task->comm' and >> hence are designed / written to handle 'TASK_COMM_LEN' 16-byte name, >> continue to work as before using '/proc/$pid/task/$tid/comm'. >> >> This change-set only adds a _parallel_ dynamically allocated >> 'task->full_name' which can be used by interested users via >> '/proc/$pid/task/$tid/full_name'. > I don't want to add this to all processes at exec time as the existing > solution works for those processes: read /proc/$pid/cmdline. > > That said, adding another pointer to task_struct isn't to bad I guess, > and it could be updated by later calls. Maybe by default it just points > to "comm". Sure. > >> I am fine with adding either '/proc/$pid/task/$tid/full_name' or >> '/proc/$pid/task/$tid/debug_name' (actually both of these achieve the same). >> The new / modified users (especially the debug applications you listed >> above) can switch easily to using '/proc/$pid/task/$tid/full_name' instead >> of ''/proc/$pid/task/$tid/comm' >> >> AFAIK we already achieved for the kthreads using d6986ce24fc00 ("kthread: >> dynamically allocate memory to store kthread's full name"), which adds >> 'full_name' in parallel to 'comm' for kthread names. > If we do this for task_struct, we should remove "full_name" from kthread > and generalize it for all processes. > Got it. Ok, let me rework the series so that we have a unified 'full_name' inside 'task_struct' and have kthread use it as well. I will send a v2 accordingly. Thanks, Bhupesh