From patchwork Fri Mar 25 01:09:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 12791112 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 C1290C43219 for ; Fri, 25 Mar 2022 01:09:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4EC868D0005; Thu, 24 Mar 2022 21:09:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 49EF36B0078; Thu, 24 Mar 2022 21:09:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 364708D0005; Thu, 24 Mar 2022 21:09:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0232.hostedemail.com [216.40.44.232]) by kanga.kvack.org (Postfix) with ESMTP id 2606E6B0071 for ; Thu, 24 Mar 2022 21:09:14 -0400 (EDT) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id D43A58249980 for ; Fri, 25 Mar 2022 01:09:13 +0000 (UTC) X-FDA: 79281124986.22.2D2530B Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf06.hostedemail.com (Postfix) with ESMTP id 5D966180007 for ; Fri, 25 Mar 2022 01:09:13 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7E5EE617B4; Fri, 25 Mar 2022 01:09:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D531DC340ED; Fri, 25 Mar 2022 01:09:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1648170551; bh=UKh0e02Rcyjz8mPR3OrTSiPGi5iSzsujvyZNy46XUG4=; h=Date:To:From:In-Reply-To:Subject:From; b=0d9WPI6IDtaHv1oJwJI0hsuBei/1jSdvIEZ8IUA3fNmLZTvtIOrTBjITV19c7aN1l vXkR2DRUB0xjB2pWkJsQbxpS6IFCRkaNElFfC7o9e9uBaXsk8bON6hhrH8KeisIjz1 EkevZCRTRj+//KDyqV1/J5CTaAZOIi+TTjmNMB20= Date: Thu, 24 Mar 2022 18:09:11 -0700 To: vdavydov.dev@gmail.com,senozhatsky@chromium.org,rppt@kernel.org,rostedt@goodmis.org,roman.gushchin@linux.dev,rientjes@google.com,pmladek@suse.com,mhocko@kernel.org,linux@rasmusvillemoes.dk,ira.weiny@intel.com,hannes@cmpxchg.org,aquini@redhat.com,andriy.shevchenko@linux.intel.com,longman@redhat.com,akpm@linux-foundation.org,patches@lists.linux.dev,linux-mm@kvack.org,mm-commits@vger.kernel.org,torvalds@linux-foundation.org,akpm@linux-foundation.org From: Andrew Morton In-Reply-To: <20220324180758.96b1ac7e17675d6bc474485e@linux-foundation.org> Subject: [patch 012/114] mm/page_owner: record task command name Message-Id: <20220325010911.D531DC340ED@smtp.kernel.org> X-Rspam-User: X-Stat-Signature: 6pyhne7n4koxdqht4hh11x3eqi18oofk Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=0d9WPI6I; spf=pass (imf06.hostedemail.com: domain of akpm@linux-foundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 5D966180007 X-HE-Tag: 1648170553-999175 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: From: Waiman Long Subject: mm/page_owner: record task command name The page_owner information currently includes the pid of the calling task. That is useful as long as the task is still running. Otherwise, the number is meaningless. To have more information about the allocating tasks that had exited by the time the page_owner information is retrieved, we need to store the command name of the task. Add a new comm field into page_owner structure to store the command name and display it when the page_owner information is retrieved. Link: https://lkml.kernel.org/r/20220202203036.744010-5-longman@redhat.com Signed-off-by: Waiman Long Acked-by: Rafael Aquini Cc: Andy Shevchenko Cc: David Rientjes Cc: Ira Weiny Cc: Johannes Weiner Cc: Michal Hocko Cc: Mike Rapoport Cc: Petr Mladek Cc: Rasmus Villemoes Cc: Roman Gushchin Cc: Sergey Senozhatsky Cc: Steven Rostedt (Google) Cc: Vladimir Davydov Signed-off-by: Andrew Morton --- mm/page_owner.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) --- a/mm/page_owner.c~mm-page_owner-record-task-command-name +++ a/mm/page_owner.c @@ -29,6 +29,7 @@ struct page_owner { depot_stack_handle_t free_handle; u64 ts_nsec; u64 free_ts_nsec; + char comm[TASK_COMM_LEN]; pid_t pid; }; @@ -165,6 +166,8 @@ static inline void __set_page_owner_hand page_owner->last_migrate_reason = -1; page_owner->pid = current->pid; page_owner->ts_nsec = local_clock(); + strlcpy(page_owner->comm, current->comm, + sizeof(page_owner->comm)); __set_bit(PAGE_EXT_OWNER, &page_ext->flags); __set_bit(PAGE_EXT_OWNER_ALLOCATED, &page_ext->flags); @@ -232,6 +235,7 @@ void __folio_copy_owner(struct folio *ne new_page_owner->pid = old_page_owner->pid; new_page_owner->ts_nsec = old_page_owner->ts_nsec; new_page_owner->free_ts_nsec = old_page_owner->ts_nsec; + strcpy(new_page_owner->comm, old_page_owner->comm); /* * We don't clear the bit on the old folio as it's going to be freed @@ -379,10 +383,11 @@ print_page_owner(char __user *buf, size_ return -ENOMEM; ret = scnprintf(kbuf, count, - "Page allocated via order %u, mask %#x(%pGg), pid %d, ts %llu ns, free_ts %llu ns\n", + "Page allocated via order %u, mask %#x(%pGg), pid %d (%s), ts %llu ns, free_ts %llu ns\n", page_owner->order, page_owner->gfp_mask, &page_owner->gfp_mask, page_owner->pid, - page_owner->ts_nsec, page_owner->free_ts_nsec); + page_owner->comm, page_owner->ts_nsec, + page_owner->free_ts_nsec); /* Print information relevant to grouping pages by mobility */ pageblock_mt = get_pageblock_migratetype(page); @@ -449,9 +454,10 @@ void __dump_page_owner(const struct page else pr_alert("page_owner tracks the page as freed\n"); - pr_alert("page last allocated via order %u, migratetype %s, gfp_mask %#x(%pGg), pid %d, ts %llu, free_ts %llu\n", + pr_alert("page last allocated via order %u, migratetype %s, gfp_mask %#x(%pGg), pid %d (%s), ts %llu, free_ts %llu\n", page_owner->order, migratetype_names[mt], gfp_mask, &gfp_mask, - page_owner->pid, page_owner->ts_nsec, page_owner->free_ts_nsec); + page_owner->pid, page_owner->comm, page_owner->ts_nsec, + page_owner->free_ts_nsec); handle = READ_ONCE(page_owner->handle); if (!handle)