From patchwork Thu Dec 19 02:34:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 13914395 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 C927AE7718A for ; Thu, 19 Dec 2024 02:35:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 625D16B0096; Wed, 18 Dec 2024 21:35:30 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5AF776B0098; Wed, 18 Dec 2024 21:35:30 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 429E56B0099; Wed, 18 Dec 2024 21:35:30 -0500 (EST) 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 2043A6B0096 for ; Wed, 18 Dec 2024 21:35:30 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id D0FF681354 for ; Thu, 19 Dec 2024 02:35:29 +0000 (UTC) X-FDA: 82910140824.03.6B717FF Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.179]) by imf02.hostedemail.com (Postfix) with ESMTP id CC3B48000E for ; Thu, 19 Dec 2024 02:34:25 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=EniI6gij; spf=pass (imf02.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.210.179 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734575713; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=7lFqN6P61Vcxg60EP2migAvtPpkWX8ZEoCx5nNg3/cM=; b=Fs4BW2VhYOSf2SBnnDTcYpOQb9WKaBKYZ8jyXjIm0erCIr1WrgIuy0qArjzX/HpVF6Z7Mt tutbHyYOEA9+gfOaWqV2JcSuWRixdRoSEmXfM85eYQZonFXoQXZrOKLBX3uu+y8SEeoR5G /JCmjoweyhS9sXEHk7WSQOP4dHDbBaI= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=EniI6gij; spf=pass (imf02.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.210.179 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734575713; a=rsa-sha256; cv=none; b=WvrTsia5rrW6evH4jYxaqcPoe2cM+BOAfGrwGT6v6YhUfXRcAaJ6T3d7ddLTSwY7u6vT5w UsTYbk9DaUFAsVtG10z3uj/Lt8xS76sN7xO4lQBzeod3ZFvfa8wv2UddLHdJ6QJrHaUlrq ccyrR4HCqZxsgwPIdKoOfO+kn0Ma6EM= Received: by mail-pf1-f179.google.com with SMTP id d2e1a72fcca58-725ce7b82cbso400319b3a.0 for ; Wed, 18 Dec 2024 18:35:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734575727; x=1735180527; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7lFqN6P61Vcxg60EP2migAvtPpkWX8ZEoCx5nNg3/cM=; b=EniI6gijVAEHs00IJ2XYmsm5CrCpFfydvJXWRnCx0s89VbyBDXHavEQcPUAKwkT293 J/KkUr33J1zFQoxsj5nRrIOCgy4laNWe4VeKH3IwxOK3Ht82GD0cTddNUxSHX7tSWgA1 mH6ymnedF2BlolGY9U9HnTDQCiNyzUtvgbmtXv0hkVx2e42irhwaxYJudAlAjp9O7w6L Uuk2f24X/wvAmfp9tqqj8C4aXoCIZ+udMAr+eIaODzSb2Fv8OWIZIjfJxGQPey1hi1Y8 ih21Jr/oGgZtIXbkiHsb7qrzCs7kDWnJBc5WPifNThNSvwFokme6CSSm95LQDo4iotXC mBKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734575727; x=1735180527; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7lFqN6P61Vcxg60EP2migAvtPpkWX8ZEoCx5nNg3/cM=; b=RXX+VnPxLvQlUYpTkOUwhsACOekJ+dHk4PZvCRWu3Wvj2ZFKtHFlF/e7fsaCLuMcAF DIbcT16BUfwxCZB4g5+nXdrhFBnI94fCIuv0o4xAdPJt+h606z9l93Xf4KO9Wtnq+hl1 Q8CrQeit/JXZeQ+paqtXPrjoxBLFXJ0jlmM6nQe51ZEH14fQRac7G1ApRmjNIFjVKiPs evdhDVuVCkQ86XfGxZEmRR89zBes6DCf/nXVswanXKg+JuX3eX8ZDG2PIuFVbfui7At0 xHXrPefaPyDOr38uN+nmyp8tngdkEKC0UMQ+4u3Ssn+8APpq6R+IR1fix52GfqzGFmXj OOwg== X-Forwarded-Encrypted: i=1; AJvYcCWXOSF+njtQ1XGdymm+SyRYrIVpE9iFaLUaauydCvqVoda6CcNlaCHCYVjw5PU3b1dJo4noU49zKQ==@kvack.org X-Gm-Message-State: AOJu0Yx98eM3HnQqo0h8FQ3zPlFtauuGDe5oSoerCTIb6UsUL5YSiHV7 Ws7//pDdhD0q4t1JtbZTGfUGaI6suKqcSqAX3j7sdZUVb1IYD9Tg X-Gm-Gg: ASbGnctdK8VmHPSGjGlI4GfihTDKoII4WkIy2CgNned4bEfJFql7g/W/cSMc1FilVeg g1sejmN2KIHfYMmDiMt9kmHrJhpdI/egRFz5ONNW7CJ/wdJIZkaTgaslR4wAtGDswsruNbEUQC0 U4IpMdAMrGRYkEN4QbYPl12O8W2CXVwqZlnZbkXRXAaKPy5wKbWC5b/Mtg/iKDb2tRcfXobMDgP M7Y09vYjmXQ46+zxZGEBT6iazioO6kE/V3zmZY+o6N4cfmPRJU+55jpTGQawywfgpOSaAVuyqwn jLp4mMM= X-Google-Smtp-Source: AGHT+IEASYTltYbmKh5ZDA03zBv0Z8CD36/wkPvI28CV3U8CPosE7HG5sfVxRVIBm8iQbfYV7EQNzQ== X-Received: by 2002:a05:6a21:788c:b0:1e1:b727:181a with SMTP id adf61e73a8af0-1e5c763cc43mr2386992637.24.1734575726666; Wed, 18 Dec 2024 18:35:26 -0800 (PST) Received: from localhost.localdomain ([180.159.118.224]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-842b821da83sm142163a12.40.2024.12.18.18.35.20 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 18 Dec 2024 18:35:26 -0800 (PST) From: Yafang Shao To: akpm@linux-foundation.org Cc: torvalds@linux-foundation.org, pmladek@suse.com, kvalo@kernel.org, bp@alien8.de, andriy.shevchenko@linux.intel.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, x86@kernel.org, linux-snps-arc@lists.infradead.org, linux-wireless@vger.kernel.org, intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org, nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org, ocfs2-devel@lists.linux.dev, Yafang Shao , Jiri Slaby , Lyude Paul , Oded Gabbay , Jani Nikula , Rodrigo Vivi , Joonas Lahtinen , Tvrtko Ursulin , David Airlie , Simona Vetter , Karol Herbst , Danilo Krummrich , Greg Kroah-Hartman Subject: [PATCH v2 5/5] drivers: Remove get_task_comm() and print task comm directly Date: Thu, 19 Dec 2024 10:34:52 +0800 Message-Id: <20241219023452.69907-6-laoar.shao@gmail.com> X-Mailer: git-send-email 2.37.1 (Apple Git-137.1) In-Reply-To: <20241219023452.69907-1-laoar.shao@gmail.com> References: <20241219023452.69907-1-laoar.shao@gmail.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: CC3B48000E X-Stat-Signature: ie1cchwhkb5q7onn8utey93ft4ytzhiw X-Rspam-User: X-Rspamd-Server: rspam11 X-HE-Tag: 1734575665-348218 X-HE-Meta: U2FsdGVkX1/xgC5jIMY+TTZdyE/VRZga3Xy2nhjVM8ZRmIjqT56sQQpKKrDYkcCXcgEgksV3L7v25txTSXby1yp7Dw87fGu3jW1UEgpDPV/Q+qsf5aRmFWWmVNwUD26sqoQuGnHOf6QFBdDiL+BXp4q7qRJRyJzr8ndS9sGx1OB0yeV6YiVx27Yoz3qBMoNypBbU/IvguxkNS+ocwZZMEmM8oiTPX0/o4ZqWIAV8TUtBbHzk+5DHLAgfAItxEDgzHLZp55zlTMOUeeGZSQyMuLPAbEAxblgTw9wBLSkYbdFs83/yP7UTjSh1CdoPf7YQ0Fgy00VSpOlJGkO6UdpVKldJLpO2BsSoVhuMnTE/Ylw7wYcI/vZU8v0weaKO1/tWGf+ZeyzVsWhHfisxBDwQEqUBewNBOsAewH16kJ0sRBcds6TpHfCB9YuNpSSB2kwvGr/b4Y+5LyyUcmLzHMbLIgTxddCVpC+KoZDuJZzzMWHauu15hxxNtGkaJD80xxIEO2wx1nmJMzCPyNiMX97b+qX27B81if2ieFrK8DKpIG3v7HSy1vmGKt5nP9PCkqzJ8tpF4SfANfsmCqEthfmxcK4QyOFcDtz+4S9P0sUguhLfRhhxUgpqc35SzLB3LqwuPittDlQf2jH7NccQcDHc6xKQZPTgbiGEuViLd4kvxbisUW+s7+e8iERpFJJFqcHNgqpseqAkK4KYYHk3utFfiuiy0y8YCSwrzPdwTqVMfa7H5dzkR3wQPHFTftXojdYpmK0ZtDMMTdGADwsht8wgjN4qE5X8GJoW0dTk070hkkPELSRk1a+AXXtzGsCKeFXPgdbPAbKIEFaYeatNHMbDWNlnRhFgV8tChrKcS1AXk7nuTuh6Kfx+GhsDVcdLM4WtjNJlxsfke0TVoifF0/OiTyW93Za4xOIhnyQ6J3+i2LG+cPdWOJ3dAKfn2BJatntGaf9a2QKRNs81FZZ900e xIAdDIB8 n9NZ3RhuyDUwNHOL0vyHXRYSlRpWZIg6+jIjG6A7TDhedju9+FIIc+JXZk2Tzgb0yLJELFvZHYTiSZK4fjvK6oI+zG57CU24nOiL3FVgvtnGFix0Gs5QXhsYVqO3tbR7tjDCqEcqJAk3V8/yTLSzueutQFMThca/fLWIU3GQhg6QzTRC7KuCDp5NGFXdicFiTMdEUPGTpgjbhf31jWjTCyybTvZPzro4wB/ytnxoGuzr1SHfE7NFhy/8WSNWaX77Ln/DAwnC3w/JyC55X0MTplY0oaALRQAD0Kl8vYm3/A6BIgPyFTYeMsbpIMJE1HmCZxUyLqc1ZQT32Y6/XqCo/WQ7agd3yH5ICCRAauOzwKxpZ2fELUKbrzXyxTwGrrAhF08dO5gm1XuZXMue0to/mZ/Iq22eVFdlplo8BHljD7L1Os1ocbewZabvkUZS3C9aTV3UIEDdTywE5+Zjl4A4Rv1sHqmRMGpmhJPMeqf932oGuwvSlKi2WjRkKbR/8f2ugTWHPKcYhOCHMA/7epTVC0n+xqbyKEmQHZVj8OzqAHoJ2htp7Hgzb1Oxwz7XXKwyhoufvqDBvKsh3rg96Kz9P08OhV+ppSJucTwwJLvi2iSksGFAxRxcYyWdQJWh2vNJmxf1hUKsC0P4c1r5Z9CLAYxBGQArSa/+LpXKUrxLuTJbTbeuTY/E2BwEOUnflnasNujHZxWcw5b0Sg8wvJk8B2+ZwEA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000007, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Since task->comm is guaranteed to be NUL-terminated, we can print it directly without the need to copy it into a separate buffer. This simplifies the code and avoids unnecessary operations. Signed-off-by: Yafang Shao Reviewed-by: Jiri Slaby (For tty) Reviewed-by: Lyude Paul (For nouveau) Cc: Oded Gabbay Cc: Jani Nikula Cc: Rodrigo Vivi Cc: Joonas Lahtinen Cc: Tvrtko Ursulin Cc: David Airlie Cc: Simona Vetter Cc: Karol Herbst Cc: Lyude Paul Cc: Danilo Krummrich Cc: Greg Kroah-Hartman Cc: Jiri Slaby --- drivers/accel/habanalabs/common/context.c | 3 +-- drivers/accel/habanalabs/common/habanalabs_ioctl.c | 11 +++-------- drivers/gpu/drm/i915/display/intel_display_driver.c | 6 ++---- drivers/gpu/drm/nouveau/nouveau_chan.c | 4 +--- drivers/gpu/drm/nouveau/nouveau_drm.c | 5 ++--- drivers/tty/tty_io.c | 3 +-- 6 files changed, 10 insertions(+), 22 deletions(-) diff --git a/drivers/accel/habanalabs/common/context.c b/drivers/accel/habanalabs/common/context.c index b83141f58319..9f212b17611a 100644 --- a/drivers/accel/habanalabs/common/context.c +++ b/drivers/accel/habanalabs/common/context.c @@ -199,7 +199,6 @@ int hl_ctx_create(struct hl_device *hdev, struct hl_fpriv *hpriv) int hl_ctx_init(struct hl_device *hdev, struct hl_ctx *ctx, bool is_kernel_ctx) { - char task_comm[TASK_COMM_LEN]; int rc = 0, i; ctx->hdev = hdev; @@ -272,7 +271,7 @@ int hl_ctx_init(struct hl_device *hdev, struct hl_ctx *ctx, bool is_kernel_ctx) mutex_init(&ctx->ts_reg_lock); dev_dbg(hdev->dev, "create user context, comm=\"%s\", asid=%u\n", - get_task_comm(task_comm, current), ctx->asid); + current->comm, ctx->asid); } return 0; diff --git a/drivers/accel/habanalabs/common/habanalabs_ioctl.c b/drivers/accel/habanalabs/common/habanalabs_ioctl.c index 1dd6e23172ca..8729a0c57d78 100644 --- a/drivers/accel/habanalabs/common/habanalabs_ioctl.c +++ b/drivers/accel/habanalabs/common/habanalabs_ioctl.c @@ -1279,13 +1279,10 @@ static long _hl_ioctl(struct hl_fpriv *hpriv, unsigned int cmd, unsigned long ar retcode = -EFAULT; out_err: - if (retcode) { - char task_comm[TASK_COMM_LEN]; - + if (retcode) dev_dbg_ratelimited(dev, "error in ioctl: pid=%d, comm=\"%s\", cmd=%#010x, nr=%#04x\n", - task_pid_nr(current), get_task_comm(task_comm, current), cmd, nr); - } + task_pid_nr(current), current->comm, cmd, nr); if (kdata != stack_kdata) kfree(kdata); @@ -1308,11 +1305,9 @@ long hl_ioctl_control(struct file *filep, unsigned int cmd, unsigned long arg) if (nr == _IOC_NR(DRM_IOCTL_HL_INFO)) { ioctl = &hl_ioctls_control[nr - HL_COMMAND_START]; } else { - char task_comm[TASK_COMM_LEN]; - dev_dbg_ratelimited(hdev->dev_ctrl, "invalid ioctl: pid=%d, comm=\"%s\", cmd=%#010x, nr=%#04x\n", - task_pid_nr(current), get_task_comm(task_comm, current), cmd, nr); + task_pid_nr(current), current->comm, cmd, nr); return -ENOTTY; } diff --git a/drivers/gpu/drm/i915/display/intel_display_driver.c b/drivers/gpu/drm/i915/display/intel_display_driver.c index 56b78cf6b854..62596424a9aa 100644 --- a/drivers/gpu/drm/i915/display/intel_display_driver.c +++ b/drivers/gpu/drm/i915/display/intel_display_driver.c @@ -391,7 +391,6 @@ void intel_display_driver_resume_access(struct drm_i915_private *i915) */ bool intel_display_driver_check_access(struct drm_i915_private *i915) { - char comm[TASK_COMM_LEN]; char current_task[TASK_COMM_LEN + 16]; char allowed_task[TASK_COMM_LEN + 16] = "none"; @@ -400,12 +399,11 @@ bool intel_display_driver_check_access(struct drm_i915_private *i915) return true; snprintf(current_task, sizeof(current_task), "%s[%d]", - get_task_comm(comm, current), - task_pid_vnr(current)); + current->comm, task_pid_vnr(current)); if (i915->display.access.allowed_task) snprintf(allowed_task, sizeof(allowed_task), "%s[%d]", - get_task_comm(comm, i915->display.access.allowed_task), + i915->display.access.allowed_task->comm, task_pid_vnr(i915->display.access.allowed_task)); drm_dbg_kms(&i915->drm, diff --git a/drivers/gpu/drm/nouveau/nouveau_chan.c b/drivers/gpu/drm/nouveau/nouveau_chan.c index 2cb2e5675807..cd659b9fd1d9 100644 --- a/drivers/gpu/drm/nouveau/nouveau_chan.c +++ b/drivers/gpu/drm/nouveau/nouveau_chan.c @@ -279,7 +279,6 @@ nouveau_channel_ctor(struct nouveau_cli *cli, bool priv, u64 runm, const u64 plength = 0x10000; const u64 ioffset = plength; const u64 ilength = 0x02000; - char name[TASK_COMM_LEN]; int cid, ret; u64 size; @@ -338,8 +337,7 @@ nouveau_channel_ctor(struct nouveau_cli *cli, bool priv, u64 runm, chan->userd = &chan->user; } - get_task_comm(name, current); - snprintf(args.name, sizeof(args.name), "%s[%d]", name, task_pid_nr(current)); + snprintf(args.name, sizeof(args.name), "%s[%d]", current->comm, task_pid_nr(current)); ret = nvif_object_ctor(&device->object, "abi16ChanUser", 0, hosts[cid].oclass, &args, sizeof(args), &chan->user); diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c index 107f63f08bd9..ea7206484d22 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drm.c +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c @@ -1159,7 +1159,7 @@ nouveau_drm_open(struct drm_device *dev, struct drm_file *fpriv) { struct nouveau_drm *drm = nouveau_drm(dev); struct nouveau_cli *cli; - char name[32], tmpname[TASK_COMM_LEN]; + char name[32]; int ret; /* need to bring up power immediately if opening device */ @@ -1169,10 +1169,9 @@ nouveau_drm_open(struct drm_device *dev, struct drm_file *fpriv) return ret; } - get_task_comm(tmpname, current); rcu_read_lock(); snprintf(name, sizeof(name), "%s[%d]", - tmpname, pid_nr(rcu_dereference(fpriv->pid))); + current->comm, pid_nr(rcu_dereference(fpriv->pid))); rcu_read_unlock(); if (!(cli = kzalloc(sizeof(*cli), GFP_KERNEL))) { diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index 9771072da177..102e31f62f76 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c @@ -2622,14 +2622,13 @@ static int tty_tiocgicount(struct tty_struct *tty, void __user *arg) static int tty_set_serial(struct tty_struct *tty, struct serial_struct *ss) { - char comm[TASK_COMM_LEN]; int flags; flags = ss->flags & ASYNC_DEPRECATED; if (flags) pr_warn_ratelimited("%s: '%s' is using deprecated serial flags (with no effect): %.8x\n", - __func__, get_task_comm(comm, current), flags); + __func__, current->comm, flags); if (!tty->ops->set_serial) return -ENOTTY;