From: Anshuman Khandual <khandual@linux.vnet.ibm.com>
To: linux-mm@kvack.org, linux-kernel@vger.kernel.org
Cc: akpm@linux-foundation.org
Subject: [PATCH] mm: Define KB, MB, GB, TB in core VM
Date: Mon, 22 May 2017 16:47:42 +0530 [thread overview]
Message-ID: <20170522111742.29433-1-khandual@linux.vnet.ibm.com> (raw)
There are many places where we define size either left shifting integers
or multiplying 1024s without any generic definition to fall back on. But
there are couples of (powerpc and lz4) attempts to define these standard
memory sizes. Lets move these definitions to core VM to make sure that
all new usage come from these definitions eventually standardizing it
across all places.
Signed-off-by: Anshuman Khandual <khandual@linux.vnet.ibm.com>
---
arch/powerpc/mm/hash_utils_64.c | 4 ----
include/linux/mm.h | 5 +++++
lib/lz4/lz4defs.h | 5 +----
3 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/arch/powerpc/mm/hash_utils_64.c b/arch/powerpc/mm/hash_utils_64.c
index f2095ce..ef64040 100644
--- a/arch/powerpc/mm/hash_utils_64.c
+++ b/arch/powerpc/mm/hash_utils_64.c
@@ -74,10 +74,6 @@
#define DBG_LOW(fmt...)
#endif
-#define KB (1024)
-#define MB (1024*KB)
-#define GB (1024L*MB)
-
/*
* Note: pte --> Linux PTE
* HPTE --> PowerPC Hashed Page Table Entry
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 7cb17c6..9f5779f 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -2549,5 +2549,10 @@ static inline bool page_is_guard(struct page *page)
static inline void setup_nr_node_ids(void) {}
#endif
+#define KB (1UL << 10)
+#define MB (1UL << 20)
+#define GB (1UL << 30)
+#define TB (1UL << 40)
+
#endif /* __KERNEL__ */
#endif /* _LINUX_MM_H */
diff --git a/lib/lz4/lz4defs.h b/lib/lz4/lz4defs.h
index 00a0b58..67a0f6d 100644
--- a/lib/lz4/lz4defs.h
+++ b/lib/lz4/lz4defs.h
@@ -37,6 +37,7 @@
#include <asm/unaligned.h>
#include <linux/string.h> /* memset, memcpy */
+#include <linux/mm.h>
#define FORCE_INLINE __always_inline
@@ -81,10 +82,6 @@
#define HASH_UNIT sizeof(size_t)
-#define KB (1 << 10)
-#define MB (1 << 20)
-#define GB (1U << 30)
-
#define MAXD_LOG 16
#define MAX_DISTANCE ((1 << MAXD_LOG) - 1)
#define STEPSIZE sizeof(size_t)
--
1.8.5.2
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next reply other threads:[~2017-05-22 11:18 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-22 11:17 Anshuman Khandual [this message]
2017-05-22 21:11 ` [PATCH] mm: Define KB, MB, GB, TB in core VM Andrew Morton
2017-05-23 7:02 ` Christoph Hellwig
2017-05-23 8:38 ` Vlastimil Babka
2017-05-23 8:40 ` Christoph Hellwig
2017-05-23 11:19 ` Anshuman Khandual
2017-05-24 6:40 ` Anshuman Khandual
2017-05-24 14:31 ` Michal Hocko
2017-05-29 10:55 ` Michael Ellerman
2017-06-09 2:54 ` Anshuman Khandual
2017-05-29 11:07 ` Geert Uytterhoeven
2017-05-23 11:13 ` Anshuman Khandual
2017-05-23 6:41 ` kbuild test robot
2017-05-23 7:24 ` kbuild test robot
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=20170522111742.29433-1-khandual@linux.vnet.ibm.com \
--to=khandual@linux.vnet.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.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;
as well as URLs for NNTP newsgroup(s).