From: Tejun Heo <htejun@gmail.com>
To: axboe@suse.de
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH Linux 2.6.12-rc4-mm2 02/03] cfq: cfq_io_context leak fix
Date: Wed, 25 May 2005 01:35:29 +0900 (KST) [thread overview]
Message-ID: <20050524163518.233BF525@htj.dyndns.org> (raw)
In-Reply-To: <20050524163518.0DA61D6C@htj.dyndns.org>
02_cfq_ioc_leak_fix.patch
When a process has more than one cic's associated with it,
only the first one was kmem_cache_free'd in the original code.
This patch frees all cic's in cfq_free_io_context().
While at it, remove unnecessary refcounting from cic's to ioc.
This reference is created when each cic is created and removed
altogether when the ioc is exited, and, thus, serves no
purpose.
Signed-off-by: Tejun Heo <htejun@gmail.com>
cfq-iosched.c | 19 ++++++++++---------
1 files changed, 10 insertions(+), 9 deletions(-)
Index: blk-fixes/drivers/block/cfq-iosched.c
===================================================================
--- blk-fixes.orig/drivers/block/cfq-iosched.c 2005-05-25 01:35:16.000000000 +0900
+++ blk-fixes/drivers/block/cfq-iosched.c 2005-05-25 01:35:16.000000000 +0900
@@ -1238,6 +1238,14 @@ cfq_find_cfq_hash(struct cfq_data *cfqd,
static void cfq_free_io_context(struct cfq_io_context *cic)
{
+ struct cfq_io_context *__cic;
+ struct list_head *entry, *next;
+
+ list_for_each_safe(entry, next, &cic->list) {
+ __cic = list_entry(entry, struct cfq_io_context, list);
+ kmem_cache_free(cfq_ioc_pool, __cic);
+ }
+
kmem_cache_free(cfq_ioc_pool, cic);
}
@@ -1260,7 +1268,6 @@ static void cfq_exit_single_io_context(s
cfq_put_queue(cic->cfqq);
cic->cfqq = NULL;
- put_io_context(cic->ioc);
spin_unlock(q->queue_lock);
}
@@ -1271,7 +1278,7 @@ static void cfq_exit_single_io_context(s
static void cfq_exit_io_context(struct cfq_io_context *cic)
{
struct cfq_io_context *__cic;
- struct list_head *entry, *nxt;
+ struct list_head *entry;
unsigned long flags;
local_irq_save(flags);
@@ -1279,10 +1286,8 @@ static void cfq_exit_io_context(struct c
/*
* put the reference this task is holding to the various queues
*/
- list_for_each_safe(entry, nxt, &cic->list) {
+ list_for_each(entry, &cic->list) {
__cic = list_entry(entry, struct cfq_io_context, list);
-
- list_del(&__cic->list);
cfq_exit_single_io_context(__cic);
}
@@ -1471,8 +1476,6 @@ cfq_get_io_context(struct cfq_data *cfqd
ioc->cic = cic;
ioc->set_ioprio = cfq_ioc_set_ioprio;
cic->ioc = ioc;
- atomic_inc(&ioc->refcount);
-
cic->key = cfqd;
atomic_inc(&cfqd->ref);
} else {
@@ -1509,8 +1512,6 @@ cfq_get_io_context(struct cfq_data *cfqd
goto err;
__cic->ioc = ioc;
- atomic_inc(&ioc->refcount);
-
__cic->key = cfqd;
atomic_inc(&cfqd->ref);
list_add(&__cic->list, &cic->list);
next prev parent reply other threads:[~2005-05-24 16:39 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-05-24 16:35 [PATCH Linux 2.6.12-rc4-mm2 00/03] cfq: various fixes Tejun Heo
2005-05-24 16:35 ` [PATCH Linux 2.6.12-rc4-mm2 01/03] cfq: cfq ELEVATOR_INSERT_BACK fix Tejun Heo
2005-05-24 16:35 ` Tejun Heo [this message]
2005-05-24 16:35 ` [PATCH Linux 2.6.12-rc4-mm2 03/03] cfq: remove serveral unused fields from cfq data structures Tejun Heo
2005-05-25 7:34 ` [PATCH Linux 2.6.12-rc4-mm2 00/03] cfq: various fixes Jens Axboe
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=20050524163518.233BF525@htj.dyndns.org \
--to=htejun@gmail.com \
--cc=axboe@suse.de \
--cc=linux-kernel@vger.kernel.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
all inboxes | Powered by JetHome®