lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <1314059823.29510.19.camel@sli10-conroe>
Date:	Tue, 23 Aug 2011 08:37:03 +0800
From:	Shaohua Li <shaohua.li@...el.com>
To:	Andrew Morton <akpm@...ux-foundation.org>
Cc:	linux-mm <linux-mm@...ck.org>, lkml <linux-kernel@...r.kernel.org>,
	cl@...ux.com, penberg@...nel.org, "Shi, Alex" <alex.shi@...el.com>,
	"Chen, Tim C" <tim.c.chen@...el.com>
Subject: [patch 2/2]slub: add a type for slab partial list position

Adding slab to partial list head/tail is sensentive to performance.
So adding a type to document it to avoid we get it wrong.

Signed-off-by: Shaohua Li <shli@...nel.org>
Signed-off-by: Shaohua Li <shaohua.li@...el.com>
---
 mm/slub.c |   20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

Index: linux/mm/slub.c
===================================================================
--- linux.orig/mm/slub.c	2011-08-23 08:20:24.000000000 +0800
+++ linux/mm/slub.c	2011-08-23 08:34:29.000000000 +0800
@@ -1525,16 +1525,21 @@ static void discard_slab(struct kmem_cac
 	free_slab(s, page);
 }
 
+enum partial_list_position {
+	PARTIAL_LIST_HEAD,
+	PARTIAL_LIST_TAIL,
+};
+
 /*
  * Management of partially allocated slabs.
  *
  * list_lock must be held.
  */
 static inline void add_partial(struct kmem_cache_node *n,
-				struct page *page, int tail)
+			struct page *page, enum partial_list_position tail)
 {
 	n->nr_partial++;
-	if (tail)
+	if (tail == PARTIAL_LIST_TAIL)
 		list_add_tail(&page->lru, &n->partial);
 	else
 		list_add(&page->lru, &n->partial);
@@ -1781,13 +1786,13 @@ static void deactivate_slab(struct kmem_
 	enum slab_modes l = M_NONE, m = M_NONE;
 	void *freelist;
 	void *nextfree;
-	int tail = 0;
+	enum partial_list_position tail = PARTIAL_LIST_HEAD;
 	struct page new;
 	struct page old;
 
 	if (page->freelist) {
 		stat(s, DEACTIVATE_REMOTE_FREES);
-		tail = 1;
+		tail = PARTIAL_LIST_TAIL;
 	}
 
 	c->tid = next_tid(c->tid);
@@ -1893,7 +1898,8 @@ redo:
 		if (m == M_PARTIAL) {
 
 			add_partial(n, page, tail);
-			stat(s, tail ? DEACTIVATE_TO_TAIL : DEACTIVATE_TO_HEAD);
+			stat(s, tail == PARTIAL_LIST_TAIL ? DEACTIVATE_TO_TAIL
+				: DEACTIVATE_TO_HEAD);
 
 		} else if (m == M_FULL) {
 
@@ -2377,7 +2383,7 @@ static void __slab_free(struct kmem_cach
 		 */
 		if (unlikely(!prior)) {
 			remove_full(s, page);
-			add_partial(n, page, 1);
+			add_partial(n, page, PARTIAL_LIST_TAIL);
 			stat(s, FREE_ADD_PARTIAL);
 		}
 	}
@@ -2695,7 +2701,7 @@ static void early_kmem_cache_node_alloc(
 	init_kmem_cache_node(n, kmem_cache_node);
 	inc_slabs_node(kmem_cache_node, node, page->objects);
 
-	add_partial(n, page, 0);
+	add_partial(n, page, PARTIAL_LIST_HEAD);
 }
 
 static void free_kmem_cache_nodes(struct kmem_cache *s)


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ