linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Yixuan Cao <caoyixuan2019@email.szu.edu.cn>
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 <caoyixuan2019@email.szu.edu.cn>
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	[thread overview]
Message-ID: <20220420122817.67181-1-caoyixuan2019@email.szu.edu.cn> (raw)

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 <caoyixuan2019@email.szu.edu.cn>
---
 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);
 
-- 
2.17.1





             reply	other threads:[~2022-04-20 12:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-20 12:28 Yixuan Cao [this message]
2022-04-21 13:40 ` Qian Cai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220420122817.67181-1-caoyixuan2019@email.szu.edu.cn \
    --to=caoyixuan2019@email.szu.edu.cn \
    --cc=akpm@linux-foundation.org \
    --cc=hanshenghong2019@email.szu.edu.cn \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=yejiajian2018@email.szu.edu.cn \
    --cc=zhangyinan2019@email.szu.edu.cn \
    --cc=zhaochongxi2019@email.szu.edu.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox