aboutsummaryrefslogtreecommitdiffstats
path: root/block
diff options
context:
space:
mode:
authorChristoph Lameter <clameter@sgi.com>2007-07-17 07:03:29 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-17 13:23:02 -0400
commit94f6030ca792c57422f04a73e7a872d8325946d3 (patch)
tree0197f24d82b1706f1b0521f2cf68feeff64123df /block
parent81cda6626178cd55297831296ba8ecedbfd8b52d (diff)
Slab allocators: Replace explicit zeroing with __GFP_ZERO
kmalloc_node() and kmem_cache_alloc_node() were not available in a zeroing variant in the past. But with __GFP_ZERO it is possible now to do zeroing while allocating. Use __GFP_ZERO to remove the explicit clearing of memory via memset whereever we can. Signed-off-by: Christoph Lameter <clameter@sgi.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'block')
-rw-r--r--block/as-iosched.c3
-rw-r--r--block/cfq-iosched.c18
-rw-r--r--block/deadline-iosched.c3
-rw-r--r--block/elevator.c3
-rw-r--r--block/genhd.c8
-rw-r--r--block/ll_rw_blk.c4
6 files changed, 18 insertions, 21 deletions
diff --git a/block/as-iosched.c b/block/as-iosched.c
index 109e91b91ffa..3e316dd72529 100644
--- a/block/as-iosched.c
+++ b/block/as-iosched.c
@@ -1322,10 +1322,9 @@ static void *as_init_queue(request_queue_t *q)
1322{ 1322{
1323 struct as_data *ad; 1323 struct as_data *ad;
1324 1324
1325 ad = kmalloc_node(sizeof(*ad), GFP_KERNEL, q->node); 1325 ad = kmalloc_node(sizeof(*ad), GFP_KERNEL | __GFP_ZERO, q->node);
1326 if (!ad) 1326 if (!ad)
1327 return NULL; 1327 return NULL;
1328 memset(ad, 0, sizeof(*ad));
1329 1328
1330 ad->q = q; /* Identify what queue the data belongs to */ 1329 ad->q = q; /* Identify what queue the data belongs to */
1331 1330
diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c
index e0aa4dad6742..9755a3cfad26 100644
--- a/block/cfq-iosched.c
+++ b/block/cfq-iosched.c
@@ -1251,9 +1251,9 @@ cfq_alloc_io_context(struct cfq_data *cfqd, gfp_t gfp_mask)
1251{ 1251{
1252 struct cfq_io_context *cic; 1252 struct cfq_io_context *cic;
1253 1253
1254 cic = kmem_cache_alloc_node(cfq_ioc_pool, gfp_mask, cfqd->queue->node); 1254 cic = kmem_cache_alloc_node(cfq_ioc_pool, gfp_mask | __GFP_ZERO,
1255 cfqd->queue->node);
1255 if (cic) { 1256 if (cic) {
1256 memset(cic, 0, sizeof(*cic));
1257 cic->last_end_request = jiffies; 1257 cic->last_end_request = jiffies;
1258 INIT_LIST_HEAD(&cic->queue_list); 1258 INIT_LIST_HEAD(&cic->queue_list);
1259 cic->dtor = cfq_free_io_context; 1259 cic->dtor = cfq_free_io_context;
@@ -1376,17 +1376,19 @@ retry:
1376 * free memory. 1376 * free memory.
1377 */ 1377 */
1378 spin_unlock_irq(cfqd->queue->queue_lock); 1378 spin_unlock_irq(cfqd->queue->queue_lock);
1379 new_cfqq = kmem_cache_alloc_node(cfq_pool, gfp_mask|__GFP_NOFAIL, cfqd->queue->node); 1379 new_cfqq = kmem_cache_alloc_node(cfq_pool,
1380 gfp_mask | __GFP_NOFAIL | __GFP_ZERO,
1381 cfqd->queue->node);
1380 spin_lock_irq(cfqd->queue->queue_lock); 1382 spin_lock_irq(cfqd->queue->queue_lock);
1381 goto retry; 1383 goto retry;
1382 } else { 1384 } else {
1383 cfqq = kmem_cache_alloc_node(cfq_pool, gfp_mask, cfqd->queue->node); 1385 cfqq = kmem_cache_alloc_node(cfq_pool,
1386 gfp_mask | __GFP_ZERO,
1387 cfqd->queue->node);
1384 if (!cfqq) 1388 if (!cfqq)
1385 goto out; 1389 goto out;
1386 } 1390 }
1387 1391
1388 memset(cfqq, 0, sizeof(*cfqq));
1389
1390 RB_CLEAR_NODE(&cfqq->rb_node); 1392 RB_CLEAR_NODE(&cfqq->rb_node);
1391 INIT_LIST_HEAD(&cfqq->fifo); 1393 INIT_LIST_HEAD(&cfqq->fifo);
1392 1394
@@ -2079,12 +2081,10 @@ static void *cfq_init_queue(request_queue_t *q)
2079{ 2081{
2080 struct cfq_data *cfqd; 2082 struct cfq_data *cfqd;
2081 2083
2082 cfqd = kmalloc_node(sizeof(*cfqd), GFP_KERNEL, q->node); 2084 cfqd = kmalloc_node(sizeof(*cfqd), GFP_KERNEL | __GFP_ZERO, q->node);
2083 if (!cfqd) 2085 if (!cfqd)
2084 return NULL; 2086 return NULL;
2085 2087
2086 memset(cfqd, 0, sizeof(*cfqd));
2087
2088 cfqd->service_tree = CFQ_RB_ROOT; 2088 cfqd->service_tree = CFQ_RB_ROOT;
2089 INIT_LIST_HEAD(&cfqd->cic_list); 2089 INIT_LIST_HEAD(&cfqd->cic_list);
2090 2090
diff --git a/block/deadline-iosched.c b/block/deadline-iosched.c
index 6d673e938d3e..87ca02ac84cb 100644
--- a/block/deadline-iosched.c
+++ b/block/deadline-iosched.c
@@ -360,10 +360,9 @@ static void *deadline_init_queue(request_queue_t *q)
360{ 360{
361 struct deadline_data *dd; 361 struct deadline_data *dd;
362 362
363 dd = kmalloc_node(sizeof(*dd), GFP_KERNEL, q->node); 363 dd = kmalloc_node(sizeof(*dd), GFP_KERNEL | __GFP_ZERO, q->node);
364 if (!dd) 364 if (!dd)
365 return NULL; 365 return NULL;
366 memset(dd, 0, sizeof(*dd));
367 366
368 INIT_LIST_HEAD(&dd->fifo_list[READ]); 367 INIT_LIST_HEAD(&dd->fifo_list[READ]);
369 INIT_LIST_HEAD(&dd->fifo_list[WRITE]); 368 INIT_LIST_HEAD(&dd->fifo_list[WRITE]);
diff --git a/block/elevator.c b/block/elevator.c
index 4769a25d7037..d265963d1ed3 100644
--- a/block/elevator.c
+++ b/block/elevator.c
@@ -177,11 +177,10 @@ static elevator_t *elevator_alloc(request_queue_t *q, struct elevator_type *e)
177 elevator_t *eq; 177 elevator_t *eq;
178 int i; 178 int i;
179 179
180 eq = kmalloc_node(sizeof(elevator_t), GFP_KERNEL, q->node); 180 eq = kmalloc_node(sizeof(elevator_t), GFP_KERNEL | __GFP_ZERO, q->node);
181 if (unlikely(!eq)) 181 if (unlikely(!eq))
182 goto err; 182 goto err;
183 183
184 memset(eq, 0, sizeof(*eq));
185 eq->ops = &e->ops; 184 eq->ops = &e->ops;
186 eq->elevator_type = e; 185 eq->elevator_type = e;
187 kobject_init(&eq->kobj); 186 kobject_init(&eq->kobj);
diff --git a/block/genhd.c b/block/genhd.c
index 863a8c0623ed..b321cadd6e65 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -726,21 +726,21 @@ struct gendisk *alloc_disk_node(int minors, int node_id)
726{ 726{
727 struct gendisk *disk; 727 struct gendisk *disk;
728 728
729 disk = kmalloc_node(sizeof(struct gendisk), GFP_KERNEL, node_id); 729 disk = kmalloc_node(sizeof(struct gendisk),
730 GFP_KERNEL | __GFP_ZERO, node_id);
730 if (disk) { 731 if (disk) {
731 memset(disk, 0, sizeof(struct gendisk));
732 if (!init_disk_stats(disk)) { 732 if (!init_disk_stats(disk)) {
733 kfree(disk); 733 kfree(disk);
734 return NULL; 734 return NULL;
735 } 735 }
736 if (minors > 1) { 736 if (minors > 1) {
737 int size = (minors - 1) * sizeof(struct hd_struct *); 737 int size = (minors - 1) * sizeof(struct hd_struct *);
738 disk->part = kmalloc_node(size, GFP_KERNEL, node_id); 738 disk->part = kmalloc_node(size,
739 GFP_KERNEL | __GFP_ZERO, node_id);
739 if (!disk->part) { 740 if (!disk->part) {
740 kfree(disk); 741 kfree(disk);
741 return NULL; 742 return NULL;
742 } 743 }
743 memset(disk->part, 0, size);
744 } 744 }
745 disk->minors = minors; 745 disk->minors = minors;
746 kobj_set_kset_s(disk,block_subsys); 746 kobj_set_kset_s(disk,block_subsys);
diff --git a/block/ll_rw_blk.c b/block/ll_rw_blk.c
index 11e4235d0b0c..d7cadf304168 100644
--- a/block/ll_rw_blk.c
+++ b/block/ll_rw_blk.c
@@ -1829,11 +1829,11 @@ request_queue_t *blk_alloc_queue_node(gfp_t gfp_mask, int node_id)
1829{ 1829{
1830 request_queue_t *q; 1830 request_queue_t *q;
1831 1831
1832 q = kmem_cache_alloc_node(requestq_cachep, gfp_mask, node_id); 1832 q = kmem_cache_alloc_node(requestq_cachep,
1833 gfp_mask | __GFP_ZERO, node_id);
1833 if (!q) 1834 if (!q)
1834 return NULL; 1835 return NULL;
1835 1836
1836 memset(q, 0, sizeof(*q));
1837 init_timer(&q->unplug_timer); 1837 init_timer(&q->unplug_timer);
1838 1838
1839 snprintf(q->kobj.name, KOBJ_NAME_LEN, "%s", "queue"); 1839 snprintf(q->kobj.name, KOBJ_NAME_LEN, "%s", "queue");