From nobody Mon Jun 29 15:59:42 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D1BC2C3527C for ; Tue, 8 Feb 2022 01:07:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235393AbiBHBG5 (ORCPT ); Mon, 7 Feb 2022 20:06:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343912AbiBHAGH (ORCPT ); Mon, 7 Feb 2022 19:06:07 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5616CC061A73 for ; Mon, 7 Feb 2022 16:06:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644278765; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EpG/a8UGSgxQkJKVhwJeqMQ36JzcPE9kOn8DL2mEYFQ=; b=T4M3f8zni9eTM5JJIhhkFXkcc2N0gpLPm8vJaAWffQgPxW+Da8LtUQ7NdJw9D9Z2vyuPhV U2Fs4ZxROqWQKm+EJa8V63HdXhpOw2f55RggckP4R2B4WqctdlMNpfXTIVWqIN2Ie/BGWp 5At/h9hqvISgIHHWAkMUUfpfrRrJQgQ= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-613-NqDoYO8jPY-zlN6dzI7rmQ-1; Mon, 07 Feb 2022 19:06:02 -0500 X-MC-Unique: NqDoYO8jPY-zlN6dzI7rmQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id ADEFD18397A7; Tue, 8 Feb 2022 00:05:59 +0000 (UTC) Received: from llong.com (unknown [10.22.32.15]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0498B5C2EF; Tue, 8 Feb 2022 00:05:57 +0000 (UTC) From: Waiman Long To: Johannes Weiner , Michal Hocko , Vladimir Davydov , Andrew Morton , Petr Mladek , Steven Rostedt , Sergey Senozhatsky , Andy Shevchenko , Rasmus Villemoes Cc: linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-mm@kvack.org, Ira Weiny , Mike Rapoport , David Rientjes , Roman Gushchin , Rafael Aquini , Waiman Long , Mike Rapoport Subject: [PATCH v5 1/4] lib/vsprintf: Avoid redundant work with 0 size Date: Mon, 7 Feb 2022 19:05:29 -0500 Message-Id: <20220208000532.1054311-2-longman@redhat.com> In-Reply-To: <20220208000532.1054311-1-longman@redhat.com> References: <20220208000532.1054311-1-longman@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" For *scnprintf(), vsnprintf() is always called even if the input size is 0. That is a waste of time, so just return 0 in this case. Note that vsnprintf() will never return -1 to indicate an error. So skipping the call to vsnprintf() when size is 0 will have no functional impact at all. Signed-off-by: Waiman Long Acked-by: David Rientjes Reviewed-by: Sergey Senozhatsky Acked-by: Roman Gushchin Acked-by: Mike Rapoport --- lib/vsprintf.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 3b8129dd374c..d419154b47bb 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -2895,13 +2895,15 @@ int vscnprintf(char *buf, size_t size, const char *= fmt, va_list args) { int i; =20 + if (unlikely(!size)) + return 0; + i =3D vsnprintf(buf, size, fmt, args); =20 if (likely(i < size)) return i; - if (size !=3D 0) - return size - 1; - return 0; + + return size - 1; } EXPORT_SYMBOL(vscnprintf); =20 --=20 2.27.0 From nobody Mon Jun 29 15:59:42 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CEB30C4332F for ; Tue, 8 Feb 2022 01:07:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238882AbiBHBHB (ORCPT ); Mon, 7 Feb 2022 20:07:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50242 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343917AbiBHAGL (ORCPT ); Mon, 7 Feb 2022 19:06:11 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5F7F1C061355 for ; Mon, 7 Feb 2022 16:06:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644278769; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ARpUf0IirgM+NjOFiLN9kgiVvRtzmNfHi46LW66TM0Q=; b=UnqOYMtHOi4mNI6oftcM/R9dY4MBP4MvNHMngWAn8y0YJ+tpL+pe6kSwg6syxjrzWYpIj2 U3zH2IoUuOjIrSujJ/MzLv8lxPOJ4IzGkr82WvC4nYWEekNufimZk+cblOL0CKKyEJlAxj IM+b91UIm6nIBVZ64pFNegcNTjt1N0Y= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-608-UwoFt0qcNrqvMjJbZo_NBA-1; Mon, 07 Feb 2022 19:06:04 -0500 X-MC-Unique: UwoFt0qcNrqvMjJbZo_NBA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7BBDE100C660; Tue, 8 Feb 2022 00:06:01 +0000 (UTC) Received: from llong.com (unknown [10.22.32.15]) by smtp.corp.redhat.com (Postfix) with ESMTP id D29C85C2EF; Tue, 8 Feb 2022 00:05:59 +0000 (UTC) From: Waiman Long To: Johannes Weiner , Michal Hocko , Vladimir Davydov , Andrew Morton , Petr Mladek , Steven Rostedt , Sergey Senozhatsky , Andy Shevchenko , Rasmus Villemoes Cc: linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-mm@kvack.org, Ira Weiny , Mike Rapoport , David Rientjes , Roman Gushchin , Rafael Aquini , Waiman Long , Mike Rapoport Subject: [PATCH v5 2/4] mm/page_owner: Use scnprintf() to avoid excessive buffer overrun check Date: Mon, 7 Feb 2022 19:05:30 -0500 Message-Id: <20220208000532.1054311-3-longman@redhat.com> In-Reply-To: <20220208000532.1054311-1-longman@redhat.com> References: <20220208000532.1054311-1-longman@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The snprintf() function can return a length greater than the given input size. That will require a check for buffer overrun after each invocation of snprintf(). scnprintf(), on the other hand, will never return a greater length. By using scnprintf() in selected places, we can avoid some buffer overrun checks except after stack_depot_snprint() and after the last snprintf(). Signed-off-by: Waiman Long Acked-by: David Rientjes Reviewed-by: Sergey Senozhatsky Acked-by: Mike Rapoport --- mm/page_owner.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/mm/page_owner.c b/mm/page_owner.c index 99e360df9465..28dac73e0542 100644 --- a/mm/page_owner.c +++ b/mm/page_owner.c @@ -338,19 +338,16 @@ print_page_owner(char __user *buf, size_t count, unsi= gned long pfn, if (!kbuf) return -ENOMEM; =20 - ret =3D snprintf(kbuf, count, + ret =3D scnprintf(kbuf, count, "Page allocated via order %u, mask %#x(%pGg), pid %d, 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); =20 - if (ret >=3D count) - goto err; - /* Print information relevant to grouping pages by mobility */ pageblock_mt =3D get_pageblock_migratetype(page); page_mt =3D gfp_migratetype(page_owner->gfp_mask); - ret +=3D snprintf(kbuf + ret, count - ret, + ret +=3D scnprintf(kbuf + ret, count - ret, "PFN %lu type %s Block %lu type %s Flags %pGp\n", pfn, migratetype_names[page_mt], @@ -358,19 +355,14 @@ print_page_owner(char __user *buf, size_t count, unsi= gned long pfn, migratetype_names[pageblock_mt], &page->flags); =20 - if (ret >=3D count) - goto err; - ret +=3D stack_depot_snprint(handle, kbuf + ret, count - ret, 0); if (ret >=3D count) goto err; =20 if (page_owner->last_migrate_reason !=3D -1) { - ret +=3D snprintf(kbuf + ret, count - ret, + ret +=3D scnprintf(kbuf + ret, count - ret, "Page has been migrated, last migrate reason: %s\n", migrate_reason_names[page_owner->last_migrate_reason]); - if (ret >=3D count) - goto err; } =20 ret +=3D snprintf(kbuf + ret, count - ret, "\n"); --=20 2.27.0 From nobody Mon Jun 29 15:59:42 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4F9FEC43217 for ; Tue, 8 Feb 2022 01:07:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240468AbiBHBHG (ORCPT ); Mon, 7 Feb 2022 20:07:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241033AbiBHAGn (ORCPT ); Mon, 7 Feb 2022 19:06:43 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A1937C0612A4 for ; Mon, 7 Feb 2022 16:06:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644278801; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PV5Mmr2VlS4HwOkDqkagpZEdfNnA+PNHZfxNlSNeOwY=; b=GC6E6xQHb4qhRiUBgAM/MTDp2yeJ1zGBTGApe1wdDvdlzv+gUYJ2LcPycAm/cgbsphhaZ6 OVwKfzG5yxDX8bggYF0/Tm+V9uykFfirsYvGrZv6OeHgDISLfAn5OuVuIqVHPOn0E8ig86 PYWpH2e1epIsvw5FLOJ4gzb6q0e2Rgg= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-211-_M34AWNBMSe7Z7hE3yHh8Q-1; Mon, 07 Feb 2022 19:06:38 -0500 X-MC-Unique: _M34AWNBMSe7Z7hE3yHh8Q-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id ECB0018397A7; Tue, 8 Feb 2022 00:06:35 +0000 (UTC) Received: from llong.com (unknown [10.22.32.15]) by smtp.corp.redhat.com (Postfix) with ESMTP id C63395C2F1; Tue, 8 Feb 2022 00:06:01 +0000 (UTC) From: Waiman Long To: Johannes Weiner , Michal Hocko , Vladimir Davydov , Andrew Morton , Petr Mladek , Steven Rostedt , Sergey Senozhatsky , Andy Shevchenko , Rasmus Villemoes Cc: linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-mm@kvack.org, Ira Weiny , Mike Rapoport , David Rientjes , Roman Gushchin , Rafael Aquini , Waiman Long , Mike Rapoport Subject: [PATCH v5 3/4] mm/page_owner: Print memcg information Date: Mon, 7 Feb 2022 19:05:31 -0500 Message-Id: <20220208000532.1054311-4-longman@redhat.com> In-Reply-To: <20220208000532.1054311-1-longman@redhat.com> References: <20220208000532.1054311-1-longman@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" It was found that a number of dying memcgs were not freed because they were pinned by some charged pages that were present. Even "echo 1 > /proc/sys/vm/drop_caches" wasn't able to free those pages. These dying but not freed memcgs tend to increase in number over time with the side effect that percpu memory consumption as shown in /proc/meminfo also increases over time. In order to find out more information about those pages that pin dying memcgs, the page_owner feature is extended to print memory cgroup information especially whether the cgroup is dying or not. RCU read lock is taken when memcg is being accessed to make sure that it won't be freed. Signed-off-by: Waiman Long Acked-by: David Rientjes Acked-by: Roman Gushchin Acked-by: Mike Rapoport --- mm/page_owner.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/mm/page_owner.c b/mm/page_owner.c index 28dac73e0542..d4c311455753 100644 --- a/mm/page_owner.c +++ b/mm/page_owner.c @@ -10,6 +10,7 @@ #include #include #include +#include #include =20 #include "internal.h" @@ -325,6 +326,47 @@ void pagetypeinfo_showmixedcount_print(struct seq_file= *m, seq_putc(m, '\n'); } =20 +/* + * Looking for memcg information and print it out + */ +static inline int print_page_owner_memcg(char *kbuf, size_t count, int ret, + struct page *page) +{ +#ifdef CONFIG_MEMCG + unsigned long memcg_data; + struct mem_cgroup *memcg; + bool dying; + + rcu_read_lock(); + memcg_data =3D READ_ONCE(page->memcg_data); + if (!memcg_data) + goto out_unlock; + + if (memcg_data & MEMCG_DATA_OBJCGS) + ret +=3D scnprintf(kbuf + ret, count - ret, + "Slab cache page\n"); + + memcg =3D page_memcg_check(page); + if (!memcg) + goto out_unlock; + + dying =3D (memcg->css.flags & CSS_DYING); + ret +=3D scnprintf(kbuf + ret, count - ret, + "Charged %sto %smemcg ", + PageMemcgKmem(page) ? "(via objcg) " : "", + dying ? "dying " : ""); + + /* Write cgroup name directly into kbuf */ + cgroup_name(memcg->css.cgroup, kbuf + ret, count - ret); + ret +=3D strlen(kbuf + ret); + ret +=3D scnprintf(kbuf + ret, count - ret, "\n"); +out_unlock: + rcu_read_unlock(); +#endif /* CONFIG_MEMCG */ + + return ret; +} + static ssize_t print_page_owner(char __user *buf, size_t count, unsigned long pfn, struct page *page, struct page_owner *page_owner, @@ -365,6 +407,8 @@ print_page_owner(char __user *buf, size_t count, unsign= ed long pfn, migrate_reason_names[page_owner->last_migrate_reason]); } =20 + ret =3D print_page_owner_memcg(kbuf, count, ret, page); + ret +=3D snprintf(kbuf + ret, count - ret, "\n"); if (ret >=3D count) goto err; --=20 2.27.0 From nobody Mon Jun 29 15:59:42 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E026DC4332F for ; Tue, 8 Feb 2022 01:07:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241033AbiBHBHO (ORCPT ); Mon, 7 Feb 2022 20:07:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343927AbiBHAGq (ORCPT ); Mon, 7 Feb 2022 19:06:46 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 07E81C061355 for ; Mon, 7 Feb 2022 16:06:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644278805; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qSeJD0brKmpckZLSCQ8ujFjUI9lZNWQ7mt4YwsrLwjM=; b=i1SiNLuRMdqmNL95ihW13+2EDTD3oQkc6Wm59AmdYTKaoTLX/vjVsmIiXwf9sOT8ivU/V9 9uc7abwYoqhStPpGuYDEZtTW6BzRwWM5q9OKmtccv+i9SbfidJPSL74tb7t/Oju6/4u9sj m/x//9ITAN4QaOGAHXNcvRMGwBsq0V0= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-615-FLVScr2gNwyjB6VhCJlrJA-1; Mon, 07 Feb 2022 19:06:40 -0500 X-MC-Unique: FLVScr2gNwyjB6VhCJlrJA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CA50D8143EF; Tue, 8 Feb 2022 00:06:37 +0000 (UTC) Received: from llong.com (unknown [10.22.32.15]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1AC0A5C2EF; Tue, 8 Feb 2022 00:06:36 +0000 (UTC) From: Waiman Long To: Johannes Weiner , Michal Hocko , Vladimir Davydov , Andrew Morton , Petr Mladek , Steven Rostedt , Sergey Senozhatsky , Andy Shevchenko , Rasmus Villemoes Cc: linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-mm@kvack.org, Ira Weiny , Mike Rapoport , David Rientjes , Roman Gushchin , Rafael Aquini , Waiman Long Subject: [PATCH v5 4/4] mm/page_owner: Record task command name Date: Mon, 7 Feb 2022 19:05:32 -0500 Message-Id: <20220208000532.1054311-5-longman@redhat.com> In-Reply-To: <20220208000532.1054311-1-longman@redhat.com> References: <20220208000532.1054311-1-longman@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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. Signed-off-by: Waiman Long --- mm/page_owner.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/mm/page_owner.c b/mm/page_owner.c index d4c311455753..0d2017ebe3d8 100644 --- a/mm/page_owner.c +++ b/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; }; =20 @@ -165,6 +166,8 @@ static inline void __set_page_owner_handle(struct page_= ext *page_ext, page_owner->last_migrate_reason =3D -1; page_owner->pid =3D current->pid; page_owner->ts_nsec =3D 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); =20 @@ -232,6 +235,7 @@ void __folio_copy_owner(struct folio *newfolio, struct = folio *old) new_page_owner->pid =3D old_page_owner->pid; new_page_owner->ts_nsec =3D old_page_owner->ts_nsec; new_page_owner->free_ts_nsec =3D old_page_owner->ts_nsec; + strcpy(new_page_owner->comm, old_page_owner->comm); =20 /* * We don't clear the bit on the old folio as it's going to be freed @@ -381,10 +385,11 @@ print_page_owner(char __user *buf, size_t count, unsi= gned long pfn, return -ENOMEM; =20 ret =3D 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); =20 /* Print information relevant to grouping pages by mobility */ pageblock_mt =3D get_pageblock_migratetype(page); @@ -451,9 +456,10 @@ void __dump_page_owner(const struct page *page) else pr_alert("page_owner tracks the page as freed\n"); =20 - 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); =20 handle =3D READ_ONCE(page_owner->handle); if (!handle) --=20 2.27.0