From patchwork Wed Apr 20 12:28:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yixuan Cao X-Patchwork-Id: 12820164 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 8AF74C433EF for ; Wed, 20 Apr 2022 12:28:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B383A6B0071; Wed, 20 Apr 2022 08:28:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AE51A6B0073; Wed, 20 Apr 2022 08:28:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9D4E16B0074; Wed, 20 Apr 2022 08:28:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.a.hostedemail.com [64.99.140.24]) by kanga.kvack.org (Postfix) with ESMTP id 8E6506B0071 for ; Wed, 20 Apr 2022 08:28:40 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 58EAF62C44 for ; Wed, 20 Apr 2022 12:28:40 +0000 (UTC) X-FDA: 79377186000.06.DD9FD8E Received: from smtpbg154.qq.com (smtpbg154.qq.com [15.184.224.54]) by imf30.hostedemail.com (Postfix) with ESMTP id 6388580017 for ; Wed, 20 Apr 2022 12:28:36 +0000 (UTC) X-QQ-mid: bizesmtp62t1650457710ty2nusha Received: from wuhui-virtual-machine.localdoma ( [202.96.137.248]) by bizesmtp.qq.com (ESMTP) with id ; Wed, 20 Apr 2022 20:28:21 +0800 (CST) X-QQ-SSF: 01400000002000D0P000B00A0000000 X-QQ-FEAT: HoyAXBWgskmb17xLThAO/UhE8ApA9rt87o1wacSgeMqyxZibQ/RpRqM3EHV9Z GM/uuS1cZ15adninUBggPpwOc6QRJ6uVDWYxtQt73VXOrICzRUwohhtKlo7dTHk7WmzE5M5 zB5k+l6H9OHjl3BKq9bQE5bkWRSGnTP25GMRH/oTKbN+91Ux7BiuMv0W5NaD4RTiEg7y6uN wo63Em96OEdlBu0Q3lOsKgEcObO1KCJ/RtQbD8swt+ONskLFM9s/oJcgrtx/7XEDlFnKG1l 6PRfWJ9AE8J3w7hJLIAsc4CRylljOZQeSzbxsetpKpy7VXDn9wBgzXU+6+o1EYckjfoLBU/ 6GRReIYqKnYmJgREv7bIXRY3l6How== X-QQ-GoodBg: 2 From: Yixuan Cao To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, zhangyinan2019@email.szu.edu.cn, yejiajian2018@email.szu.edu.cn, hanshenghong2019@email.szu.edu.cn, zhaochongxi2019@email.szu.edu.cn, Yixuan Cao Subject: [PATCH] mm/page_owner.c: use get_task_comm() to record task command name with the protection of task_lock() Date: Wed, 20 Apr 2022 20:28:17 +0800 Message-Id: <20220420122817.67181-1-caoyixuan2019@email.szu.edu.cn> X-Mailer: git-send-email 2.17.1 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:email.szu.edu.cn:qybgforeign:qybgforeign8 X-QQ-Bgrelay: 1 X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 6388580017 X-Stat-Signature: kczqhd88r3xiry6gju1qyf4euh65sdwd Authentication-Results: imf30.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=email.szu.edu.cn; spf=pass (imf30.hostedemail.com: domain of caoyixuan2019@email.szu.edu.cn designates 15.184.224.54 as permitted sender) smtp.mailfrom=caoyixuan2019@email.szu.edu.cn X-Rspam-User: X-HE-Tag: 1650457716-181199 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000002, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: I noticed that it is advised to access task command name with [gs]et_task_comm() in the comment of task_struct->comm, which is safer with the protection of task_lock(). Relative comment in include/linux/sched.h is as follows: /* * executable name, excluding path. * * - normally initialized setup_new_exec() * - access it with [gs]et_task_comm() * - lock it with task_lock() */ Signed-off-by: Yixuan Cao --- mm/page_owner.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mm/page_owner.c b/mm/page_owner.c index 2743062e92c2..bda8fe2660c0 100644 --- a/mm/page_owner.c +++ b/mm/page_owner.c @@ -171,8 +171,7 @@ static inline void __set_page_owner_handle(struct page_ext *page_ext, page_owner->pid = current->pid; page_owner->tgid = current->tgid; page_owner->ts_nsec = local_clock(); - strlcpy(page_owner->comm, current->comm, - sizeof(page_owner->comm)); + get_task_comm(page_owner->comm, current); __set_bit(PAGE_EXT_OWNER, &page_ext->flags); __set_bit(PAGE_EXT_OWNER_ALLOCATED, &page_ext->flags);