Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1646751

[PATCH] mm: Define KB, MB, GB, TB in core VM

From Anshuman Khandual <khandual@linux.vnet.ibm.com>
Newsgroups linux.kernel
Subject [PATCH] mm: Define KB, MB, GB, TB in core VM
Date 2017-05-22 13:20 +0200
Message-ID <tJTxw-50U-7@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View 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

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH] mm: Define KB, MB, GB, TB in core VM Anshuman Khandual <khandual@linux.vnet.ibm.com> - 2017-05-22 13:20 +0200
  Re: [PATCH] mm: Define KB, MB, GB, TB in core VM Andrew Morton <akpm@linux-foundation.org> - 2017-05-22 23:20 +0200
    Re: [PATCH] mm: Define KB, MB, GB, TB in core VM Christoph Hellwig <hch@infradead.org> - 2017-05-23 09:10 +0200
      Re: [PATCH] mm: Define KB, MB, GB, TB in core VM Vlastimil Babka <vbabka@suse.cz> - 2017-05-23 10:40 +0200
        Re: [PATCH] mm: Define KB, MB, GB, TB in core VM Christoph Hellwig <hch@infradead.org> - 2017-05-23 10:50 +0200
        Re: [PATCH] mm: Define KB, MB, GB, TB in core VM Anshuman Khandual <khandual@linux.vnet.ibm.com> - 2017-05-23 13:30 +0200
          Re: [PATCH] mm: Define KB, MB, GB, TB in core VM Anshuman Khandual <khandual@linux.vnet.ibm.com> - 2017-05-24 08:50 +0200
            Re: [PATCH] mm: Define KB, MB, GB, TB in core VM Michal Hocko <mhocko@kernel.org> - 2017-05-24 16:40 +0200
    Re: [PATCH] mm: Define KB, MB, GB, TB in core VM Anshuman Khandual <khandual@linux.vnet.ibm.com> - 2017-05-23 13:20 +0200
  Re: [PATCH] mm: Define KB, MB, GB, TB in core VM kbuild test robot <lkp@intel.com> - 2017-05-23 08:50 +0200

csiph-web