public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Daniel Gomez <da.gomez@samsung.com>
To: "minchan@kernel.org" <minchan@kernel.org>,
	"senozhatsky@chromium.org" <senozhatsky@chromium.org>,
	"axboe@kernel.dk" <axboe@kernel.dk>,
	"djwong@kernel.org" <djwong@kernel.org>,
	"willy@infradead.org" <willy@infradead.org>,
	"hughd@google.com" <hughd@google.com>,
	"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
	"mcgrof@kernel.org" <mcgrof@kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-block@vger.kernel.org" <linux-block@vger.kernel.org>,
	"linux-xfs@vger.kernel.org" <linux-xfs@vger.kernel.org>,
	"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>
Cc: "gost.dev@samsung.com" <gost.dev@samsung.com>,
	Pankaj Raghav <p.raghav@samsung.com>,
	Daniel Gomez <da.gomez@samsung.com>
Subject: [RFC PATCH 06/11] shmem: trace shmem_add_to_page_cache folio order
Date: Sat, 28 Oct 2023 21:15:44 +0000	[thread overview]
Message-ID: <20231028211518.3424020-7-da.gomez@samsung.com> (raw)
In-Reply-To: <20231028211518.3424020-1-da.gomez@samsung.com>

To be able to trace and account for order of the folio.

Based on include/trace/filemap.h.

Update MAINTAINERS file list for SHMEM.

Signed-off-by: Daniel Gomez <da.gomez@samsung.com>
---
 MAINTAINERS                  |  1 +
 include/trace/events/shmem.h | 52 ++++++++++++++++++++++++++++++++++++
 mm/shmem.c                   |  4 +++
 3 files changed, 57 insertions(+)
 create mode 100644 include/trace/events/shmem.h

diff --git a/MAINTAINERS b/MAINTAINERS
index bdc4638b2df5..befa63e7cb28 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -21923,6 +21923,7 @@ M:	Hugh Dickins <hughd@google.com>
 L:	linux-mm@kvack.org
 S:	Maintained
 F:	include/linux/shmem_fs.h
+F:	include/trace/events/shmem.h
 F:	mm/shmem.c
 
 TOMOYO SECURITY MODULE
diff --git a/include/trace/events/shmem.h b/include/trace/events/shmem.h
new file mode 100644
index 000000000000..223f78f11457
--- /dev/null
+++ b/include/trace/events/shmem.h
@@ -0,0 +1,52 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM shmem
+
+#if !defined(_TRACE_SHMEM_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_SHMEM_H
+
+#include <linux/types.h>
+#include <linux/tracepoint.h>
+
+DECLARE_EVENT_CLASS(mm_shmem_op_page_cache,
+
+	TP_PROTO(struct folio *folio),
+
+	TP_ARGS(folio),
+
+	TP_STRUCT__entry(
+		__field(unsigned long, pfn)
+		__field(unsigned long, i_ino)
+		__field(unsigned long, index)
+		__field(dev_t, s_dev)
+		__field(unsigned char, order)
+	),
+
+	TP_fast_assign(
+		__entry->pfn = folio_pfn(folio);
+		__entry->i_ino = folio->mapping->host->i_ino;
+		__entry->index = folio->index;
+		if (folio->mapping->host->i_sb)
+			__entry->s_dev = folio->mapping->host->i_sb->s_dev;
+		else
+			__entry->s_dev = folio->mapping->host->i_rdev;
+		__entry->order = folio_order(folio);
+	),
+
+	TP_printk("dev %d:%d ino %lx pfn=0x%lx ofs=%lu order=%u",
+		MAJOR(__entry->s_dev), MINOR(__entry->s_dev),
+		__entry->i_ino,
+		__entry->pfn,
+		__entry->index << PAGE_SHIFT,
+		__entry->order)
+);
+
+DEFINE_EVENT(mm_shmem_op_page_cache, mm_shmem_add_to_page_cache,
+	TP_PROTO(struct folio *folio),
+	TP_ARGS(folio)
+	);
+
+#endif /* _TRACE_SHMEM_H */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>
diff --git a/mm/shmem.c b/mm/shmem.c
index ab31d2880e5d..e2893cf2287f 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -84,6 +84,9 @@ static struct vfsmount *shm_mnt __ro_after_init;
 
 #include "internal.h"
 
+#define CREATE_TRACE_POINTS
+#include <trace/events/shmem.h>
+
 #define VM_ACCT(size)    (PAGE_ALIGN(size) >> PAGE_SHIFT)
 
 /* Pretend that each entry is of this size in directory's i_size */
@@ -1726,6 +1729,7 @@ static struct folio *shmem_alloc_and_add_folio(gfp_t gfp,
 		}
 	}
 
+	trace_mm_shmem_add_to_page_cache(folio);
 	shmem_recalc_inode(inode, pages, 0);
 	folio_add_lru(folio);
 	return folio;
-- 
2.39.2

  parent reply	other threads:[~2023-10-28 21:15 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20230919135546eucas1p1181b8914fb5eceda5f08068802941358@eucas1p1.samsung.com>
2023-09-19 13:55 ` [PATCH v2 0/6] shmem: high order folios support in write path Daniel Gomez
2023-09-19 13:55   ` [PATCH v2 1/6] shmem: drop BLOCKS_PER_PAGE macro Daniel Gomez
2023-09-19 13:55   ` [PATCH v2 2/6] shmem: return freed pages in shmem_free_swap Daniel Gomez
2023-09-19 14:56     ` Matthew Wilcox
2023-09-19 13:55   ` [PATCH v2 3/6] shmem: account for large order folios Daniel Gomez
2023-09-19 13:55   ` [PATCH v2 4/6] shmem: add order parameter support to shmem_alloc_folio Daniel Gomez
2023-09-19 13:55   ` [PATCH v2 5/6] shmem: add file length in shmem_get_folio path Daniel Gomez
2023-09-19 13:55   ` [PATCH v2 6/6] shmem: add large folios support to the write path Daniel Gomez
2023-09-19 15:01     ` Matthew Wilcox
2023-09-19 16:28       ` Daniel Gomez
2023-10-28 21:15   ` [RFC PATCH 00/11] shmem: high order folios support in " Daniel Gomez
2023-10-28 21:15     ` [RFC PATCH 01/11] XArray: add cmpxchg order test Daniel Gomez
2023-10-29 20:11       ` Matthew Wilcox
2023-11-03 23:12         ` Daniel Gomez
2023-10-28 21:15     ` [RFC PATCH 02/11] test_xarray: add tests for advanced multi-index use Daniel Gomez
2023-10-28 21:15     ` [RFC PATCH 03/11] shmem: drop BLOCKS_PER_PAGE macro Daniel Gomez
2023-10-28 21:15     ` [RFC PATCH 04/11] shmem: return number of pages beeing freed in shmem_free_swap Daniel Gomez
2023-10-28 21:15     ` [RFC PATCH 05/11] shmem: account for large order folios Daniel Gomez
2023-10-29 20:40       ` Matthew Wilcox
2023-10-28 21:15     ` Daniel Gomez [this message]
2023-10-29 23:14       ` [RFC PATCH 06/11] shmem: trace shmem_add_to_page_cache folio order Matthew Wilcox
2023-10-28 21:15     ` [RFC PATCH 07/11] shmem: remove huge arg from shmem_alloc_and_add_folio() Daniel Gomez
2023-10-29 23:17       ` Matthew Wilcox
2023-10-28 21:15     ` [RFC PATCH 08/11] shmem: add file length arg in shmem_get_folio() path Daniel Gomez
2023-10-28 21:15     ` [RFC PATCH 09/11] shmem: add order arg to shmem_alloc_folio() Daniel Gomez
2023-10-31  7:04       ` Hannes Reinecke
2023-10-28 21:15     ` [RFC PATCH 10/11] shmem: add large folio support to the write path Daniel Gomez
2023-10-29 23:32       ` Matthew Wilcox
2023-10-28 21:15     ` [RFC PATCH 11/11] shmem: add per-block uptodate tracking Daniel Gomez
2023-10-29 20:43     ` [RFC PATCH 00/11] shmem: high order folios support in write path Matthew Wilcox

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=20231028211518.3424020-7-da.gomez@samsung.com \
    --to=da.gomez@samsung.com \
    --cc=akpm@linux-foundation.org \
    --cc=axboe@kernel.dk \
    --cc=djwong@kernel.org \
    --cc=gost.dev@samsung.com \
    --cc=hughd@google.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=mcgrof@kernel.org \
    --cc=minchan@kernel.org \
    --cc=p.raghav@samsung.com \
    --cc=senozhatsky@chromium.org \
    --cc=willy@infradead.org \
    /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