linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/page_owner.c: use get_task_comm() to record task command name with the protection of task_lock()
@ 2022-04-20 12:28 Yixuan Cao
  2022-04-21 13:40 ` Qian Cai
  0 siblings, 1 reply; 2+ messages in thread
From: Yixuan Cao @ 2022-04-20 12:28 UTC (permalink / raw)
  To: akpm
  Cc: linux-mm, linux-kernel, zhangyinan2019, yejiajian2018,
	hanshenghong2019, zhaochongxi2019, Yixuan Cao

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





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-04-21 13:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-20 12:28 [PATCH] mm/page_owner.c: use get_task_comm() to record task command name with the protection of task_lock() Yixuan Cao
2022-04-21 13:40 ` Qian Cai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox