* [PATCH 1/2] blk-throttle: Free up policy node associated with deleted rule
@ 2011-10-20 21:08 Vivek Goyal
2011-10-20 21:08 ` [PATCH 2/2] blk-throttle: Take blkcg->lock while traversing blkcg->policy_list Vivek Goyal
` (2 more replies)
0 siblings, 3 replies; 11+ messages in thread
From: Vivek Goyal @ 2011-10-20 21:08 UTC (permalink / raw)
To: linux-kernel, jaxboe; +Cc: vgoyal, tj
If a rule is being deleted, free up associated policy node. Otherwise
that memory is leaked.
Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
---
block/blk-cgroup.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index b596e54..4ddf11f 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -1085,6 +1085,7 @@ static int blkiocg_file_write(struct cgroup *cgrp, struct cftype *cft,
if (blkio_delete_rule_command(newpn)) {
blkio_policy_delete_node(pn);
+ kfree(pn);
spin_unlock_irq(&blkcg->lock);
goto update_io_group;
}
--
1.7.4.4
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 2/2] blk-throttle: Take blkcg->lock while traversing blkcg->policy_list
2011-10-20 21:08 [PATCH 1/2] blk-throttle: Free up policy node associated with deleted rule Vivek Goyal
@ 2011-10-20 21:08 ` Vivek Goyal
2011-10-20 21:11 ` Tejun Heo
2011-10-20 21:09 ` [PATCH 1/2] blk-throttle: Free up policy node associated with deleted rule Tejun Heo
2011-10-25 13:36 ` Vivek Goyal
2 siblings, 1 reply; 11+ messages in thread
From: Vivek Goyal @ 2011-10-20 21:08 UTC (permalink / raw)
To: linux-kernel, jaxboe; +Cc: vgoyal, tj
blkcg->policy_list is protected by blkcg->lock. Its not rcu protected
list. So even for readers, they need to take blkcg->lock. There are
few functions which were reading the list without taking lock. Fix it.
Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
---
block/blk-cgroup.c | 54 ++++++++++++++++++++++++++++++++++++++-------------
1 files changed, 40 insertions(+), 14 deletions(-)
diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index 4ddf11f..1b5d789 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -879,60 +879,86 @@ unsigned int blkcg_get_weight(struct blkio_cgroup *blkcg,
dev_t dev)
{
struct blkio_policy_node *pn;
+ unsigned long flags;
+ unsigned int weight;
+
+ spin_lock_irqsave(&blkcg->lock, flags);
pn = blkio_policy_search_node(blkcg, dev, BLKIO_POLICY_PROP,
BLKIO_PROP_weight_device);
if (pn)
- return pn->val.weight;
+ weight = pn->val.weight;
else
- return blkcg->weight;
+ weight = blkcg->weight;
+
+ spin_unlock_irqrestore(&blkcg->lock, flags);
+
+ return weight;
}
EXPORT_SYMBOL_GPL(blkcg_get_weight);
uint64_t blkcg_get_read_bps(struct blkio_cgroup *blkcg, dev_t dev)
{
struct blkio_policy_node *pn;
+ unsigned long flags;
+ uint64_t bps = -1;
+ spin_lock_irqsave(&blkcg->lock, flags);
pn = blkio_policy_search_node(blkcg, dev, BLKIO_POLICY_THROTL,
BLKIO_THROTL_read_bps_device);
if (pn)
- return pn->val.bps;
- else
- return -1;
+ bps = pn->val.bps;
+ spin_unlock_irqrestore(&blkcg->lock, flags);
+
+ return bps;
}
uint64_t blkcg_get_write_bps(struct blkio_cgroup *blkcg, dev_t dev)
{
struct blkio_policy_node *pn;
+ unsigned long flags;
+ uint64_t bps = -1;
+
+ spin_lock_irqsave(&blkcg->lock, flags);
pn = blkio_policy_search_node(blkcg, dev, BLKIO_POLICY_THROTL,
BLKIO_THROTL_write_bps_device);
if (pn)
- return pn->val.bps;
- else
- return -1;
+ bps = pn->val.bps;
+ spin_unlock_irqrestore(&blkcg->lock, flags);
+
+ return bps;
}
unsigned int blkcg_get_read_iops(struct blkio_cgroup *blkcg, dev_t dev)
{
struct blkio_policy_node *pn;
+ unsigned long flags;
+ unsigned int iops = -1;
+ spin_lock_irqsave(&blkcg->lock, flags);
pn = blkio_policy_search_node(blkcg, dev, BLKIO_POLICY_THROTL,
BLKIO_THROTL_read_iops_device);
if (pn)
- return pn->val.iops;
- else
- return -1;
+ iops = pn->val.iops;
+ spin_unlock_irqrestore(&blkcg->lock, flags);
+
+ return iops;
}
unsigned int blkcg_get_write_iops(struct blkio_cgroup *blkcg, dev_t dev)
{
struct blkio_policy_node *pn;
+ unsigned long flags;
+ unsigned int iops = -1;
+
+ spin_lock_irqsave(&blkcg->lock, flags);
pn = blkio_policy_search_node(blkcg, dev, BLKIO_POLICY_THROTL,
BLKIO_THROTL_write_iops_device);
if (pn)
- return pn->val.iops;
- else
- return -1;
+ iops = pn->val.iops;
+ spin_unlock_irqrestore(&blkcg->lock, flags);
+
+ return iops;
}
/* Checks whether user asked for deleting a policy rule */
--
1.7.4.4
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 1/2] blk-throttle: Free up policy node associated with deleted rule
2011-10-20 21:08 [PATCH 1/2] blk-throttle: Free up policy node associated with deleted rule Vivek Goyal
2011-10-20 21:08 ` [PATCH 2/2] blk-throttle: Take blkcg->lock while traversing blkcg->policy_list Vivek Goyal
@ 2011-10-20 21:09 ` Tejun Heo
2011-10-25 13:36 ` Vivek Goyal
2 siblings, 0 replies; 11+ messages in thread
From: Tejun Heo @ 2011-10-20 21:09 UTC (permalink / raw)
To: Vivek Goyal; +Cc: linux-kernel, jaxboe
Hello,
On Thu, Oct 20, 2011 at 05:08:25PM -0400, Vivek Goyal wrote:
> If a rule is being deleted, free up associated policy node. Otherwise
> that memory is leaked.
>
> Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
Heh, yeah, have the exactly same patch in my queue.
Acked-by: Tejun Heo <tj@kernel.org>
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 2/2] blk-throttle: Take blkcg->lock while traversing blkcg->policy_list
2011-10-20 21:08 ` [PATCH 2/2] blk-throttle: Take blkcg->lock while traversing blkcg->policy_list Vivek Goyal
@ 2011-10-20 21:11 ` Tejun Heo
2011-10-20 21:20 ` Vivek Goyal
0 siblings, 1 reply; 11+ messages in thread
From: Tejun Heo @ 2011-10-20 21:11 UTC (permalink / raw)
To: Vivek Goyal; +Cc: linux-kernel, jaxboe
Hello,
On Thu, Oct 20, 2011 at 05:08:26PM -0400, Vivek Goyal wrote:
> blkcg->policy_list is protected by blkcg->lock. Its not rcu protected
> list. So even for readers, they need to take blkcg->lock. There are
> few functions which were reading the list without taking lock. Fix it.
>
> Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
Acked-by: Tejun Heo <tj@kernel.org>
And yeap, some of rcu usages in cfq/iocg seem either incorrect or
unnecessary. Trying to clean up that now too.
Thank you.
--
tejun
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 2/2] blk-throttle: Take blkcg->lock while traversing blkcg->policy_list
2011-10-20 21:11 ` Tejun Heo
@ 2011-10-20 21:20 ` Vivek Goyal
2011-10-20 21:29 ` Tejun Heo
0 siblings, 1 reply; 11+ messages in thread
From: Vivek Goyal @ 2011-10-20 21:20 UTC (permalink / raw)
To: Tejun Heo; +Cc: linux-kernel, jaxboe
On Thu, Oct 20, 2011 at 02:11:40PM -0700, Tejun Heo wrote:
> Hello,
>
> On Thu, Oct 20, 2011 at 05:08:26PM -0400, Vivek Goyal wrote:
> > blkcg->policy_list is protected by blkcg->lock. Its not rcu protected
> > list. So even for readers, they need to take blkcg->lock. There are
> > few functions which were reading the list without taking lock. Fix it.
> >
> > Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
>
> Acked-by: Tejun Heo <tj@kernel.org>
>
> And yeap, some of rcu usages in cfq/iocg seem either incorrect or
> unnecessary. Trying to clean up that now too.
Cool. I am waiting for the patches as I am curious to know what's incorrect
or unnecessary.
I noticed above two problems while trying to figure out how can we cleanup
the device rules when devices goes away. One place could be.
blk_throtl_exit() {
blkiocg_del_blkio_group() {
delete_any_policy_nodes_associated_with_this device;
}
}
The only problem with this approach is that it will cleanup per device
weight rules also at elevator_exit() time which is not same as device
removal and one might device to bring CFQ back on device and we will
need the rules again.
cfq_exit_queue()
cfq_release_cfq_groups
cfq_blkiocg_del_blkio_group()
blkiocg_del_blkio_group()
Thanks
Vivek
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 2/2] blk-throttle: Take blkcg->lock while traversing blkcg->policy_list
2011-10-20 21:20 ` Vivek Goyal
@ 2011-10-20 21:29 ` Tejun Heo
2011-10-21 12:10 ` Vivek Goyal
0 siblings, 1 reply; 11+ messages in thread
From: Tejun Heo @ 2011-10-20 21:29 UTC (permalink / raw)
To: Vivek Goyal; +Cc: linux-kernel, jaxboe
Hello,
On Thu, Oct 20, 2011 at 05:20:21PM -0400, Vivek Goyal wrote:
> The only problem with this approach is that it will cleanup per device
> weight rules also at elevator_exit() time which is not same as device
> removal and one might device to bring CFQ back on device and we will
> need the rules again.
I actually think removoing those rules on elevator detach would be the
right thing to do. We don't try to keep cfq setting across elevator
switch. When we're switching from cfq, we're detaching iocg policy
too. The settings going away is perfectly fine. I actually think
it's a pretty bad idea to implement ad-hoc setting persistence in
kernel. Just making sure that userland is notified is far better
approach. Userland has all the facilities to deal with this type of
situations.
When switching from cfq to deadline, we lose the whole proportional io
control. It's way more confusing to have lingering settings which
don't do anything.
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 2/2] blk-throttle: Take blkcg->lock while traversing blkcg->policy_list
2011-10-20 21:29 ` Tejun Heo
@ 2011-10-21 12:10 ` Vivek Goyal
2011-10-25 14:13 ` Jens Axboe
0 siblings, 1 reply; 11+ messages in thread
From: Vivek Goyal @ 2011-10-21 12:10 UTC (permalink / raw)
To: Tejun Heo; +Cc: linux-kernel, jaxboe
On Thu, Oct 20, 2011 at 02:29:58PM -0700, Tejun Heo wrote:
> Hello,
>
> On Thu, Oct 20, 2011 at 05:20:21PM -0400, Vivek Goyal wrote:
> > The only problem with this approach is that it will cleanup per device
> > weight rules also at elevator_exit() time which is not same as device
> > removal and one might device to bring CFQ back on device and we will
> > need the rules again.
>
> I actually think removoing those rules on elevator detach would be the
> right thing to do. We don't try to keep cfq setting across elevator
> switch. When we're switching from cfq, we're detaching iocg policy
> too. The settings going away is perfectly fine. I actually think
> it's a pretty bad idea to implement ad-hoc setting persistence in
> kernel. Just making sure that userland is notified is far better
> approach. Userland has all the facilities to deal with this type of
> situations.
>
> When switching from cfq to deadline, we lose the whole proportional io
> control. It's way more confusing to have lingering settings which
> don't do anything.
I am not so sure about this. Suppose tomorrow another IO sheduler starts
taking into account the cgroup gloabl weight or cgroup per device weight
to do some kind of IO prioritization, then removing the rules upon
changing the IO schduler will not make sense.
IOW, rules are per cgroup per device and not per cgroup per IO scheduler
and more than one IO scheduler should be able to share the rules.
Thanks
Vivek
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/2] blk-throttle: Free up policy node associated with deleted rule
2011-10-20 21:08 [PATCH 1/2] blk-throttle: Free up policy node associated with deleted rule Vivek Goyal
2011-10-20 21:08 ` [PATCH 2/2] blk-throttle: Take blkcg->lock while traversing blkcg->policy_list Vivek Goyal
2011-10-20 21:09 ` [PATCH 1/2] blk-throttle: Free up policy node associated with deleted rule Tejun Heo
@ 2011-10-25 13:36 ` Vivek Goyal
2011-10-25 13:45 ` Jens Axboe
2 siblings, 1 reply; 11+ messages in thread
From: Vivek Goyal @ 2011-10-25 13:36 UTC (permalink / raw)
To: jaxboe, Jens Axboe; +Cc: tj, linux kernel mailing list
On Thu, Oct 20, 2011 at 05:08:25PM -0400, Vivek Goyal wrote:
> If a rule is being deleted, free up associated policy node. Otherwise
> that memory is leaked.
>
> Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
Hi Jens,
Do you see any issues with the two patches. Can you please consider these
for merging.
Thanks
Vivek
> ---
> block/blk-cgroup.c | 1 +
> 1 files changed, 1 insertions(+), 0 deletions(-)
>
> diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
> index b596e54..4ddf11f 100644
> --- a/block/blk-cgroup.c
> +++ b/block/blk-cgroup.c
> @@ -1085,6 +1085,7 @@ static int blkiocg_file_write(struct cgroup *cgrp, struct cftype *cft,
>
> if (blkio_delete_rule_command(newpn)) {
> blkio_policy_delete_node(pn);
> + kfree(pn);
> spin_unlock_irq(&blkcg->lock);
> goto update_io_group;
> }
> --
> 1.7.4.4
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/2] blk-throttle: Free up policy node associated with deleted rule
2011-10-25 13:36 ` Vivek Goyal
@ 2011-10-25 13:45 ` Jens Axboe
0 siblings, 0 replies; 11+ messages in thread
From: Jens Axboe @ 2011-10-25 13:45 UTC (permalink / raw)
To: Vivek Goyal; +Cc: tj@kernel.org, linux kernel mailing list
On 2011-10-25 15:36, Vivek Goyal wrote:
> On Thu, Oct 20, 2011 at 05:08:25PM -0400, Vivek Goyal wrote:
>> If a rule is being deleted, free up associated policy node. Otherwise
>> that memory is leaked.
>>
>> Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
>
> Hi Jens,
>
> Do you see any issues with the two patches. Can you please consider these
> for merging.
They are in, thanks.
--
Jens Axboe
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 2/2] blk-throttle: Take blkcg->lock while traversing blkcg->policy_list
2011-10-21 12:10 ` Vivek Goyal
@ 2011-10-25 14:13 ` Jens Axboe
2011-10-25 19:01 ` Vivek Goyal
0 siblings, 1 reply; 11+ messages in thread
From: Jens Axboe @ 2011-10-25 14:13 UTC (permalink / raw)
To: Vivek Goyal; +Cc: Tejun Heo, linux-kernel@vger.kernel.org
On 2011-10-21 14:10, Vivek Goyal wrote:
> On Thu, Oct 20, 2011 at 02:29:58PM -0700, Tejun Heo wrote:
>> Hello,
>>
>> On Thu, Oct 20, 2011 at 05:20:21PM -0400, Vivek Goyal wrote:
>>> The only problem with this approach is that it will cleanup per device
>>> weight rules also at elevator_exit() time which is not same as device
>>> removal and one might device to bring CFQ back on device and we will
>>> need the rules again.
>>
>> I actually think removoing those rules on elevator detach would be the
>> right thing to do. We don't try to keep cfq setting across elevator
>> switch. When we're switching from cfq, we're detaching iocg policy
>> too. The settings going away is perfectly fine. I actually think
>> it's a pretty bad idea to implement ad-hoc setting persistence in
>> kernel. Just making sure that userland is notified is far better
>> approach. Userland has all the facilities to deal with this type of
>> situations.
>>
>> When switching from cfq to deadline, we lose the whole proportional io
>> control. It's way more confusing to have lingering settings which
>> don't do anything.
>
> I am not so sure about this. Suppose tomorrow another IO sheduler starts
> taking into account the cgroup gloabl weight or cgroup per device weight
> to do some kind of IO prioritization, then removing the rules upon
> changing the IO schduler will not make sense.
>
> IOW, rules are per cgroup per device and not per cgroup per IO scheduler
> and more than one IO scheduler should be able to share the rules.
FWIW, I agree with Tejun here. A switch operation is a reset, start from
scratch. We don't preserve other per IO-scheduler settings on a switch,
preserving _some_ settings is just confusing.
--
Jens Axboe
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 2/2] blk-throttle: Take blkcg->lock while traversing blkcg->policy_list
2011-10-25 14:13 ` Jens Axboe
@ 2011-10-25 19:01 ` Vivek Goyal
0 siblings, 0 replies; 11+ messages in thread
From: Vivek Goyal @ 2011-10-25 19:01 UTC (permalink / raw)
To: Jens Axboe; +Cc: Tejun Heo, linux-kernel@vger.kernel.org
On Tue, Oct 25, 2011 at 04:13:11PM +0200, Jens Axboe wrote:
> On 2011-10-21 14:10, Vivek Goyal wrote:
> > On Thu, Oct 20, 2011 at 02:29:58PM -0700, Tejun Heo wrote:
> >> Hello,
> >>
> >> On Thu, Oct 20, 2011 at 05:20:21PM -0400, Vivek Goyal wrote:
> >>> The only problem with this approach is that it will cleanup per device
> >>> weight rules also at elevator_exit() time which is not same as device
> >>> removal and one might device to bring CFQ back on device and we will
> >>> need the rules again.
> >>
> >> I actually think removoing those rules on elevator detach would be the
> >> right thing to do. We don't try to keep cfq setting across elevator
> >> switch. When we're switching from cfq, we're detaching iocg policy
> >> too. The settings going away is perfectly fine. I actually think
> >> it's a pretty bad idea to implement ad-hoc setting persistence in
> >> kernel. Just making sure that userland is notified is far better
> >> approach. Userland has all the facilities to deal with this type of
> >> situations.
> >>
> >> When switching from cfq to deadline, we lose the whole proportional io
> >> control. It's way more confusing to have lingering settings which
> >> don't do anything.
> >
> > I am not so sure about this. Suppose tomorrow another IO sheduler starts
> > taking into account the cgroup gloabl weight or cgroup per device weight
> > to do some kind of IO prioritization, then removing the rules upon
> > changing the IO schduler will not make sense.
> >
> > IOW, rules are per cgroup per device and not per cgroup per IO scheduler
> > and more than one IO scheduler should be able to share the rules.
>
> FWIW, I agree with Tejun here. A switch operation is a reset, start from
> scratch. We don't preserve other per IO-scheduler settings on a switch,
> preserving _some_ settings is just confusing.
Ok. But this is more of a per queue setting (per cgroup, per device) and
not per IO scheduler one. That's a different thing that currently only CFQ
makes use of it.
If we start looking at them just as CFQ specific weigths, then it is a
different story. My thought process about these files was per cgroup per
device weights.
Thanks
Vivek
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2011-10-25 19:01 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-20 21:08 [PATCH 1/2] blk-throttle: Free up policy node associated with deleted rule Vivek Goyal
2011-10-20 21:08 ` [PATCH 2/2] blk-throttle: Take blkcg->lock while traversing blkcg->policy_list Vivek Goyal
2011-10-20 21:11 ` Tejun Heo
2011-10-20 21:20 ` Vivek Goyal
2011-10-20 21:29 ` Tejun Heo
2011-10-21 12:10 ` Vivek Goyal
2011-10-25 14:13 ` Jens Axboe
2011-10-25 19:01 ` Vivek Goyal
2011-10-20 21:09 ` [PATCH 1/2] blk-throttle: Free up policy node associated with deleted rule Tejun Heo
2011-10-25 13:36 ` Vivek Goyal
2011-10-25 13:45 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).