linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Karolina Drobnik <karolinadrobnik@gmail.com>
To: linux-mm@kvack.org
Cc: akpm@linux-foundation.org, mike.rapoport@gmail.com,
	linux-kernel@vger.kernel.org,
	Karolina Drobnik <karolinadrobnik@gmail.com>
Subject: [PATCH 05/16] tools/include: Add mm.h file
Date: Thu, 27 Jan 2022 14:21:23 +0100	[thread overview]
Message-ID: <09f20db2ce4fa1dde0c397b0b6f8f8887af1078b.1643206612.git.karolinadrobnik@gmail.com> (raw)
In-Reply-To: <cover.1643206612.git.karolinadrobnik@gmail.com>

Add a stubbed mm.h file with dummy page-related definitions,
memory alignment and physical to virtual address conversions,
so they can be used in testing.

Signed-off-by: Karolina Drobnik <karolinadrobnik@gmail.com>
---
 tools/include/linux/mm.h | 42 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
 create mode 100644 tools/include/linux/mm.h

diff --git a/tools/include/linux/mm.h b/tools/include/linux/mm.h
new file mode 100644
index 000000000000..a03d9bba5151
--- /dev/null
+++ b/tools/include/linux/mm.h
@@ -0,0 +1,42 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _TOOLS_LINUX_MM_H
+#define _TOOLS_LINUX_MM_H
+
+#include <linux/mmzone.h>
+#include <uapi/linux/const.h>
+
+#define PAGE_SHIFT		12
+#define PAGE_SIZE		(_AC(1, UL) << PAGE_SHIFT)
+#define PAGE_MASK		(~(PAGE_SIZE - 1))
+
+#define PHYS_ADDR_MAX	(~(phys_addr_t)0)
+
+#define __ALIGN_KERNEL(x, a)		__ALIGN_KERNEL_MASK(x, (typeof(x))(a) - 1)
+#define __ALIGN_KERNEL_MASK(x, mask)	(((x) + (mask)) & ~(mask))
+#define ALIGN(x, a)			__ALIGN_KERNEL((x), (a))
+#define ALIGN_DOWN(x, a)		__ALIGN_KERNEL((x) - ((a) - 1), (a))
+
+#define PAGE_ALIGN(addr) ALIGN(addr, PAGE_SIZE)
+
+#define __va(x) ((void *)((unsigned long)(x)))
+#define __pa(x) ((unsigned long)(x))
+
+#define pfn_to_page(pfn) ((void *)((pfn) * PAGE_SIZE))
+
+#define phys_to_virt phys_to_virt
+static inline void *phys_to_virt(unsigned long address)
+{
+	return __va(address);
+}
+
+void reserve_bootmem_region(phys_addr_t start, phys_addr_t end);
+
+static inline void totalram_pages_inc(void)
+{
+}
+
+static inline void totalram_pages_add(long count)
+{
+}
+
+#endif
--
2.30.2



  parent reply	other threads:[~2022-01-27 13:22 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-27 13:21 [PATCH 00/16] Introduce memblock simulator Karolina Drobnik
2022-01-27 13:21 ` [PATCH 01/16] tools: Move gfp.h and slab.h from radix-tree to lib Karolina Drobnik
2022-01-27 13:28   ` Matthew Wilcox
2022-01-28 11:00     ` Karolina Drobnik
2022-01-27 13:36   ` Matthew Wilcox
2022-01-28 11:02     ` Karolina Drobnik
2022-01-28 17:30       ` Karolina Drobnik
2022-01-27 13:21 ` [PATCH 02/16] tools/include: Add phys_addr_t to types.h Karolina Drobnik
2022-01-27 13:21 ` [PATCH 03/16] tools/include: Add _RET_IP_ and math definitions to kernel.h Karolina Drobnik
2022-01-27 13:54   ` Matthew Wilcox
2022-01-28 11:05     ` Karolina Drobnik
2022-01-27 13:21 ` [PATCH 04/16] tools/include: Update atomic.h header Karolina Drobnik
2022-01-27 13:56   ` Matthew Wilcox
2022-01-28 11:08     ` Karolina Drobnik
2022-01-27 13:21 ` Karolina Drobnik [this message]
2022-01-27 13:21 ` [PATCH 06/16] tools/include: Add cache.h stub Karolina Drobnik
2022-01-27 14:00   ` Matthew Wilcox
2022-01-28 11:13     ` Karolina Drobnik
2022-01-28 13:10       ` Matthew Wilcox
2022-01-27 13:21 ` [PATCH 07/16] tools/include: Add io.h stub Karolina Drobnik
2022-01-27 14:09   ` Matthew Wilcox
2022-01-28 11:21     ` Karolina Drobnik
2022-01-30 16:10       ` Mike Rapoport
2022-01-30 17:53         ` Matthew Wilcox
2022-01-30 19:00           ` Mike Rapoport
2022-01-31 10:55           ` Karolina Drobnik
2022-01-31 13:30           ` Arnd Bergmann
2022-01-31 15:18             ` Mike Rapoport
2022-01-31 16:26               ` Arnd Bergmann
2022-01-31 10:54         ` Karolina Drobnik
2022-01-27 13:21 ` [PATCH 08/16] tools/include: Add pfn.h stub Karolina Drobnik
2022-01-27 13:21 ` [PATCH 09/16] tools/include: Add debugfs.h stub Karolina Drobnik
2022-01-27 13:21 ` [PATCH 10/16] memblock tests: Add skeleton of the memblock simulator Karolina Drobnik
2022-01-27 14:02   ` Matthew Wilcox
2022-01-27 14:06   ` Matthew Wilcox
2022-01-28 11:25     ` Karolina Drobnik
2022-01-28 13:11       ` Matthew Wilcox
2022-01-27 13:21 ` [PATCH 11/16] memblock tests: Add memblock reset function Karolina Drobnik
2022-01-27 13:21 ` [PATCH 12/16] memblock tests: Add memblock_add tests Karolina Drobnik
2022-01-27 13:21 ` [PATCH 13/16] memblock tests: Add memblock_reserve tests Karolina Drobnik
2022-01-27 13:21 ` [PATCH 14/16] memblock tests: Add memblock_remove tests Karolina Drobnik
2022-01-27 13:21 ` [PATCH 15/16] memblock tests: Add memblock_add_node test Karolina Drobnik
2022-01-27 13:21 ` [PATCH 16/16] memblock tests: Add memblock_free tests Karolina Drobnik

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=09f20db2ce4fa1dde0c397b0b6f8f8887af1078b.1643206612.git.karolinadrobnik@gmail.com \
    --to=karolinadrobnik@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mike.rapoport@gmail.com \
    /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;
as well as URLs for NNTP newsgroup(s).