* [PATCH 0/1] mm: Use BIT macro in SLAB bitmaps
@ 2017-05-08 13:20 Igor Stoppa
2017-05-08 13:20 ` [PATCH 1/1] mm: Rework slab bitmasks Igor Stoppa
0 siblings, 1 reply; 3+ messages in thread
From: Igor Stoppa @ 2017-05-08 13:20 UTC (permalink / raw)
To: mhocko; +Cc: linux-mm, Igor Stoppa
The file include/linux/slab.h can be simplified by moving to use the
macro BIT() and making other bitmaps depend on their correspactive
master-toggle configuration option.
Igor Stoppa (1):
Rework slab bitmasks
include/linux/slab.h | 71 +++++++++++++++++++++++-----------------------------
1 file changed, 31 insertions(+), 40 deletions(-)
--
2.9.3
--
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>
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/1] mm: Rework slab bitmasks
2017-05-08 13:20 [PATCH 0/1] mm: Use BIT macro in SLAB bitmaps Igor Stoppa
@ 2017-05-08 13:20 ` Igor Stoppa
2017-05-08 20:48 ` kbuild test robot
0 siblings, 1 reply; 3+ messages in thread
From: Igor Stoppa @ 2017-05-08 13:20 UTC (permalink / raw)
To: mhocko; +Cc: linux-mm, Igor Stoppa
The bitmasks defined in the slab header can be made more readable by
using the BIT() macro.
Furthermore, several conditional definitions can be collapsed, by
expressing their value as a function of the configuration paramter that
controles them, using the macro IS_ENABLED().
Signed-off-by: Igor Stoppa <igor.stoppa@huawei.com>
---
include/linux/slab.h | 71 +++++++++++++++++++++++-----------------------------
1 file changed, 31 insertions(+), 40 deletions(-)
diff --git a/include/linux/slab.h b/include/linux/slab.h
index 3c37a8c..f7e55f0 100644
--- a/include/linux/slab.h
+++ b/include/linux/slab.h
@@ -15,18 +15,24 @@
#include <linux/types.h>
#include <linux/workqueue.h>
+#define __BIT_VAL(val, shift) (((unsigned long)(val != 0)) << (shift))
+#define BIT_VAL(val, shift) __BIT_VAL(val, shift)
+#define BIT_CFG(cfg, shift) __BIT_VAL(IS_ENABLED(CONFIG_##cfg), shift)
+#define BIT_DBG(dbg, shift) BIT_CFG(DEBUG_##dbg, shift)
+#define BIT_DBG_SLAB(shift) BIT_DBG(SLAB, shift)
/*
* Flags to pass to kmem_cache_create().
* The ones marked DEBUG are only valid if CONFIG_DEBUG_SLAB is set.
*/
-#define SLAB_CONSISTENCY_CHECKS 0x00000100UL /* DEBUG: Perform (expensive) checks on alloc/free */
-#define SLAB_RED_ZONE 0x00000400UL /* DEBUG: Red zone objs in a cache */
-#define SLAB_POISON 0x00000800UL /* DEBUG: Poison objects */
-#define SLAB_HWCACHE_ALIGN 0x00002000UL /* Align objs on cache lines */
-#define SLAB_CACHE_DMA 0x00004000UL /* Use GFP_DMA memory */
-#define SLAB_STORE_USER 0x00010000UL /* DEBUG: Store the last owner for bug hunting */
-#define SLAB_PANIC 0x00040000UL /* Panic if kmem_cache_create() fails */
+
+#define SLAB_CONSISTENCY_CHECKS BIT_DBG_SLAB(8) /* Perform (expensive) checks on alloc/free */
+#define SLAB_RED_ZONE BIT_DBG_SLAB(10) /* Red zone objs in a cache */
+#define SLAB_POISON BIT_DBG_SLAB(11) /* Poison objects */
+#define SLAB_HWCACHE_ALIGN BIT(13) /* Align objs on cache lines */
+#define SLAB_CACHE_DMA BIT(14) /* Use GFP_DMA memory */
+#define SLAB_STORE_USER BIT_DBG_SLAB(16) /* Store the last owner for bug hunting */
+#define SLAB_PANIC BIT(18) /* Panic if kmem_cache_create() fails */
/*
* SLAB_DESTROY_BY_RCU - **WARNING** READ THIS!
*
@@ -62,44 +68,29 @@
* rcu_read_lock before reading the address, then rcu_read_unlock after
* taking the spinlock within the structure expected at that address.
*/
-#define SLAB_DESTROY_BY_RCU 0x00080000UL /* Defer freeing slabs to RCU */
-#define SLAB_MEM_SPREAD 0x00100000UL /* Spread some memory over cpuset */
-#define SLAB_TRACE 0x00200000UL /* Trace allocations and frees */
+#define SLAB_DESTROY_BY_RCU BIT(19) /* Defer freeing slabs to RCU */
+#define SLAB_MEM_SPREAD BIT(20) /* Spread some memory over cpuset */
+#define SLAB_TRACE BIT(21) /* Trace allocations and frees */
/* Flag to prevent checks on free */
-#ifdef CONFIG_DEBUG_OBJECTS
-# define SLAB_DEBUG_OBJECTS 0x00400000UL
-#else
-# define SLAB_DEBUG_OBJECTS 0x00000000UL
-#endif
+# define SLAB_DEBUG_OBJECTS BIT_DBG(OBJECTS, 22)
-#define SLAB_NOLEAKTRACE 0x00800000UL /* Avoid kmemleak tracing */
+#define SLAB_NOLEAKTRACE BIT(23) /* Avoid kmemleak tracing */
/* Don't track use of uninitialized memory */
-#ifdef CONFIG_KMEMCHECK
-# define SLAB_NOTRACK 0x01000000UL
-#else
-# define SLAB_NOTRACK 0x00000000UL
-#endif
-#ifdef CONFIG_FAILSLAB
-# define SLAB_FAILSLAB 0x02000000UL /* Fault injection mark */
-#else
-# define SLAB_FAILSLAB 0x00000000UL
-#endif
-#if defined(CONFIG_MEMCG) && !defined(CONFIG_SLOB)
-# define SLAB_ACCOUNT 0x04000000UL /* Account to memcg */
-#else
-# define SLAB_ACCOUNT 0x00000000UL
-#endif
+# define SLAB_NOTRACK BIT_CFG(KMEMCHECK, 24)
-#ifdef CONFIG_KASAN
-#define SLAB_KASAN 0x08000000UL
-#else
-#define SLAB_KASAN 0x00000000UL
-#endif
+/* Fault injection mark */
+# define SLAB_FAILSLAB BIT_CFG(FAILSLAB, 25)
+
+/* Account to memcg */
+# define SLAB_ACCOUNT BIT_VAL(IS_ENABLED(CONFIG_MEMCG) && \
+ !IS_ENABLED(CONFIG_SLOB), 26)
+
+#define SLAB_KASAN BIT_CFG(KASAN, 27)
/* The following flags affect the page allocator grouping pages by mobility */
-#define SLAB_RECLAIM_ACCOUNT 0x00020000UL /* Objects are reclaimable */
+#define SLAB_RECLAIM_ACCOUNT BIT(17) /* Objects are reclaimable */
#define SLAB_TEMPORARY SLAB_RECLAIM_ACCOUNT /* Objects are short-lived */
/*
* ZERO_SIZE_PTR will be returned for zero sized kmalloc requests.
@@ -246,9 +237,9 @@ static inline const char *__check_heap_object(const void *ptr,
#endif
/* Maximum allocatable size */
-#define KMALLOC_MAX_SIZE (1UL << KMALLOC_SHIFT_MAX)
+#define KMALLOC_MAX_SIZE BIT(KMALLOC_SHIFT_MAX)
/* Maximum size for which we actually use a slab cache */
-#define KMALLOC_MAX_CACHE_SIZE (1UL << KMALLOC_SHIFT_HIGH)
+#define KMALLOC_MAX_CACHE_SIZE BIT(KMALLOC_SHIFT_HIGH)
/* Maximum order allocatable via the slab allocagtor */
#define KMALLOC_MAX_ORDER (KMALLOC_SHIFT_MAX - PAGE_SHIFT)
@@ -256,7 +247,7 @@ static inline const char *__check_heap_object(const void *ptr,
* Kmalloc subsystem.
*/
#ifndef KMALLOC_MIN_SIZE
-#define KMALLOC_MIN_SIZE (1 << KMALLOC_SHIFT_LOW)
+#define KMALLOC_MIN_SIZE BIT(KMALLOC_SHIFT_LOW)
#endif
/*
--
2.9.3
--
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>
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/1] mm: Rework slab bitmasks
2017-05-08 13:20 ` [PATCH 1/1] mm: Rework slab bitmasks Igor Stoppa
@ 2017-05-08 20:48 ` kbuild test robot
0 siblings, 0 replies; 3+ messages in thread
From: kbuild test robot @ 2017-05-08 20:48 UTC (permalink / raw)
To: Igor Stoppa; +Cc: kbuild-all, mhocko, linux-mm
[-- Attachment #1: Type: text/plain, Size: 3466 bytes --]
Hi Igor,
[auto build test WARNING on linus/master]
[also build test WARNING on v4.11]
[cannot apply to next-20170508]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Igor-Stoppa/mm-Rework-slab-bitmasks/20170508-214149
config: arm-allmodconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=arm
All warnings (new ones prefixed by >>):
>> drivers/gpu/drm/exynos/exynos5433_drm_decon.c:331:0: warning: "BIT_VAL" redefined
#define BIT_VAL(x, e, s) (((x) & ((1 << ((e) - (s) + 1)) - 1)) << (s))
In file included from include/drm/drmP.h:54:0,
from drivers/gpu/drm/exynos/exynos_drm_drv.h:18,
from drivers/gpu/drm/exynos/exynos5433_drm_decon.c:24:
include/linux/slab.h:19:0: note: this is the location of the previous definition
#define BIT_VAL(val, shift) __BIT_VAL(val, shift)
vim +/BIT_VAL +331 drivers/gpu/drm/exynos/exynos5433_drm_decon.c
b2192073 Andrzej Hajda 2015-10-20 315 decon_set_bits(ctx, DECON_SHADOWCON, SHADOWCON_Wx_PROTECT(win),
b2192073 Andrzej Hajda 2015-10-20 316 protect ? ~0 : 0);
c8466a91 Joonyoung Shim 2015-06-12 317 }
c8466a91 Joonyoung Shim 2015-06-12 318
d29c2c14 Marek Szyprowski 2016-01-05 319 static void decon_atomic_begin(struct exynos_drm_crtc *crtc)
cc5a7b35 Hyungwon Hwang 2015-08-27 320 {
cc5a7b35 Hyungwon Hwang 2015-08-27 321 struct decon_context *ctx = crtc->ctx;
d29c2c14 Marek Szyprowski 2016-01-05 322 int i;
cc5a7b35 Hyungwon Hwang 2015-08-27 323
7b6bb6ed Andrzej Hajda 2015-10-20 324 if (test_bit(BIT_SUSPENDED, &ctx->flags))
cc5a7b35 Hyungwon Hwang 2015-08-27 325 return;
cc5a7b35 Hyungwon Hwang 2015-08-27 326
d29c2c14 Marek Szyprowski 2016-01-05 327 for (i = ctx->first_win; i < WINDOWS_NR; i++)
d29c2c14 Marek Szyprowski 2016-01-05 328 decon_shadow_protect_win(ctx, i, true);
cc5a7b35 Hyungwon Hwang 2015-08-27 329 }
cc5a7b35 Hyungwon Hwang 2015-08-27 330
b8182832 Andrzej Hajda 2015-10-20 @331 #define BIT_VAL(x, e, s) (((x) & ((1 << ((e) - (s) + 1)) - 1)) << (s))
b8182832 Andrzej Hajda 2015-10-20 332 #define COORDINATE_X(x) BIT_VAL((x), 23, 12)
b8182832 Andrzej Hajda 2015-10-20 333 #define COORDINATE_Y(x) BIT_VAL((x), 11, 0)
b8182832 Andrzej Hajda 2015-10-20 334
1e1d1393 Gustavo Padovan 2015-08-03 335 static void decon_update_plane(struct exynos_drm_crtc *crtc,
1e1d1393 Gustavo Padovan 2015-08-03 336 struct exynos_drm_plane *plane)
c8466a91 Joonyoung Shim 2015-06-12 337 {
0114f404 Marek Szyprowski 2015-11-30 338 struct exynos_drm_plane_state *state =
0114f404 Marek Szyprowski 2015-11-30 339 to_exynos_plane_state(plane->base.state);
:::::: The code at line 331 was first introduced by commit
:::::: b8182832c5a9d9ce645d53be84e5db07f8aa5302 drm/exynos/decon5433: add support for DECON-TV
:::::: TO: Andrzej Hajda <a.hajda@samsung.com>
:::::: CC: Inki Dae <inki.dae@samsung.com>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 62197 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-05-08 20:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-08 13:20 [PATCH 0/1] mm: Use BIT macro in SLAB bitmaps Igor Stoppa
2017-05-08 13:20 ` [PATCH 1/1] mm: Rework slab bitmasks Igor Stoppa
2017-05-08 20:48 ` kbuild test robot
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.