mbox series

[0/2] Support hugetlb charge moving at task migration

Message ID cover.1632843268.git.baolin.wang@linux.alibaba.com (mailing list archive)
Headers show
Series Support hugetlb charge moving at task migration | expand

Message

Baolin Wang Sept. 29, 2021, 10:19 a.m. UTC
Hi,

Now in the hugetlb cgroup, charges associated with a task aren't moved
to the new hugetlb cgroup at task migration, which is odd for hugetlb
cgroup usage. This patch set adds hugetlb cgroup charge moving when
migrate tasks among cgroups, which are based on the memcg charge moving.

Please help to review. Thanks.

Baolin Wang (2):
  hugetlb_cgroup: Add interfaces to move hugetlb charge at task
    migration
  hugetlb_cgroup: Add post_attach interface for tasks migration

 mm/hugetlb_cgroup.c | 230 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 230 insertions(+)

Comments

Michal Hocko Sept. 30, 2021, 10:46 a.m. UTC | #1
On Wed 29-09-21 18:19:26, Baolin Wang wrote:
> Hi,
> 
> Now in the hugetlb cgroup, charges associated with a task aren't moved
> to the new hugetlb cgroup at task migration, which is odd for hugetlb
> cgroup usage.

Could you elaborate some more about the usecase and/or problems you see
with the existing semantic?

> This patch set adds hugetlb cgroup charge moving when
> migrate tasks among cgroups, which are based on the memcg charge moving.

Memcg charge moving has shown some problems over time and hence this is
not part of cgroup v2 interface anymore. Even for cgroup v1 this has
been an opt-in. I do not see anything like that in this patch series.
Why should all existing workloads follow a different semantic during
task migration now?

> Please help to review. Thanks.
> 
> Baolin Wang (2):
>   hugetlb_cgroup: Add interfaces to move hugetlb charge at task
>     migration
>   hugetlb_cgroup: Add post_attach interface for tasks migration
> 
>  mm/hugetlb_cgroup.c | 230 ++++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 230 insertions(+)
> 
> -- 
> 1.8.3.1
Baolin Wang Oct. 7, 2021, 3:39 p.m. UTC | #2
Hi Michal,

(Sorry for late reply due to my holidays)
On 2021/9/30 18:46, Michal Hocko wrote:
> On Wed 29-09-21 18:19:26, Baolin Wang wrote:
>> Hi,
>>
>> Now in the hugetlb cgroup, charges associated with a task aren't moved
>> to the new hugetlb cgroup at task migration, which is odd for hugetlb
>> cgroup usage.
> 
> Could you elaborate some more about the usecase and/or problems you see
> with the existing semantic?

The problems is that, it did not check if the tasks can move to the new 
hugetlb cgroup if the new hugetlb cgroup has a limitation, and the 
hugetlb cgroup usage is incorrect when moving tasks among hugetlb cgroups.

> 
>> This patch set adds hugetlb cgroup charge moving when
>> migrate tasks among cgroups, which are based on the memcg charge moving.
> 
> Memcg charge moving has shown some problems over time and hence this is
> not part of cgroup v2 interface anymore. Even for cgroup v1 this has

Sorry, I missed this part, could you elaborate on the issues? I can have 
a close look about the problems of memcg charge moving.

> been an opt-in. I do not see anything like that in this patch series.
> Why should all existing workloads follow a different semantic during
> task migration now?

But I think it is reasonable for some cases moving the old charging to 
the new cgroup when task migration. Maybe I can add a new hugetlb cgroup 
file to control if need this or not?

Thanks for your comments.
Michal Hocko Oct. 8, 2021, 7:12 a.m. UTC | #3
On Thu 07-10-21 23:39:15, Baolin Wang wrote:
> Hi Michal,
> 
> (Sorry for late reply due to my holidays)
> On 2021/9/30 18:46, Michal Hocko wrote:
> > On Wed 29-09-21 18:19:26, Baolin Wang wrote:
> > > Hi,
> > > 
> > > Now in the hugetlb cgroup, charges associated with a task aren't moved
> > > to the new hugetlb cgroup at task migration, which is odd for hugetlb
> > > cgroup usage.
> > 
> > Could you elaborate some more about the usecase and/or problems you see
> > with the existing semantic?
> 
> The problems is that, it did not check if the tasks can move to the new
> hugetlb cgroup if the new hugetlb cgroup has a limitation, and the hugetlb
> cgroup usage is incorrect when moving tasks among hugetlb cgroups.

Could you be more specific please? What do you mean by cgroup usage is
incorrect? Ideally could you describe your usecase?
 
> > > This patch set adds hugetlb cgroup charge moving when
> > > migrate tasks among cgroups, which are based on the memcg charge moving.
> > 
> > Memcg charge moving has shown some problems over time and hence this is
> > not part of cgroup v2 interface anymore. Even for cgroup v1 this has
> 
> Sorry, I missed this part, could you elaborate on the issues? I can have a
> close look about the problems of memcg charge moving.

The operation is quite expensive. Synchronization with charging is not
trivial. I do not have the full list handy but you can search the
mm mailing list archives for more information.

> > been an opt-in. I do not see anything like that in this patch series.
> > Why should all existing workloads follow a different semantic during
> > task migration now?
> 
> But I think it is reasonable for some cases moving the old charging to the
> new cgroup when task migration. Maybe I can add a new hugetlb cgroup file to
> control if need this or not?

It would be good to describe those use cases and why they really need
this. Because as things stand now, the charge migration is not supported
in cgroup v2 for memory cgroup controller and there are no plans to add
the support so it would be quite unexpected that hugetlb controller
would behave differently. And cgroup v1 is considered legacy and new
features are ususally not added as there is a hope to move users to v2.
Baolin Wang Oct. 8, 2021, 9:17 a.m. UTC | #4
On 2021/10/8 15:12, Michal Hocko wrote:
> On Thu 07-10-21 23:39:15, Baolin Wang wrote:
>> Hi Michal,
>>
>> (Sorry for late reply due to my holidays)
>> On 2021/9/30 18:46, Michal Hocko wrote:
>>> On Wed 29-09-21 18:19:26, Baolin Wang wrote:
>>>> Hi,
>>>>
>>>> Now in the hugetlb cgroup, charges associated with a task aren't moved
>>>> to the new hugetlb cgroup at task migration, which is odd for hugetlb
>>>> cgroup usage.
>>>
>>> Could you elaborate some more about the usecase and/or problems you see
>>> with the existing semantic?
>>
>> The problems is that, it did not check if the tasks can move to the new
>> hugetlb cgroup if the new hugetlb cgroup has a limitation, and the hugetlb
>> cgroup usage is incorrect when moving tasks among hugetlb cgroups.
> 
> Could you be more specific please? What do you mean by cgroup usage is
> incorrect? Ideally could you describe your usecase?

Sorry for confusing, what I mean is, when tasks from one hugetlb cgroup 
are migrated to a new hugetlb cgroup, the new hugetlb cgroup's hugetlb 
page usage is not increased accordingly. The issue I found is just from 
my testing for the hugetlb cgroup, and I think this is not resonable if 
we've already set a hugetlb limitation for a cgroup, but we always 
ignore it when tasks migration among hugetlb cgroups.

>>>> This patch set adds hugetlb cgroup charge moving when
>>>> migrate tasks among cgroups, which are based on the memcg charge moving.
>>>
>>> Memcg charge moving has shown some problems over time and hence this is
>>> not part of cgroup v2 interface anymore. Even for cgroup v1 this has
>>
>> Sorry, I missed this part, could you elaborate on the issues? I can have a
>> close look about the problems of memcg charge moving.
> 
> The operation is quite expensive. Synchronization with charging is not
> trivial. I do not have the full list handy but you can search the
> mm mailing list archives for more information.

Sure, thanks.

> 
>>> been an opt-in. I do not see anything like that in this patch series.
>>> Why should all existing workloads follow a different semantic during
>>> task migration now?
>>
>> But I think it is reasonable for some cases moving the old charging to the
>> new cgroup when task migration. Maybe I can add a new hugetlb cgroup file to
>> control if need this or not?
> 
> It would be good to describe those use cases and why they really need
> this. Because as things stand now, the charge migration is not supported
> in cgroup v2 for memory cgroup controller and there are no plans to add
> the support so it would be quite unexpected that hugetlb controller
> would behave differently. And cgroup v1 is considered legacy and new
> features are ususally not added as there is a hope to move users to v2.

OK, understood. Seems you have a strong opinion that it is unnecessary 
to introduce this feature for cgroup v1 now, then I will drop this patch 
set. Thanks for your input.
Michal Hocko Oct. 8, 2021, 11:55 a.m. UTC | #5
On Fri 08-10-21 17:17:12, Baolin Wang wrote:
> 
> 
> On 2021/10/8 15:12, Michal Hocko wrote:
> > On Thu 07-10-21 23:39:15, Baolin Wang wrote:
> > > Hi Michal,
> > > 
> > > (Sorry for late reply due to my holidays)
> > > On 2021/9/30 18:46, Michal Hocko wrote:
> > > > On Wed 29-09-21 18:19:26, Baolin Wang wrote:
> > > > > Hi,
> > > > > 
> > > > > Now in the hugetlb cgroup, charges associated with a task aren't moved
> > > > > to the new hugetlb cgroup at task migration, which is odd for hugetlb
> > > > > cgroup usage.
> > > > 
> > > > Could you elaborate some more about the usecase and/or problems you see
> > > > with the existing semantic?
> > > 
> > > The problems is that, it did not check if the tasks can move to the new
> > > hugetlb cgroup if the new hugetlb cgroup has a limitation, and the hugetlb
> > > cgroup usage is incorrect when moving tasks among hugetlb cgroups.
> > 
> > Could you be more specific please? What do you mean by cgroup usage is
> > incorrect? Ideally could you describe your usecase?
> 
> Sorry for confusing, what I mean is, when tasks from one hugetlb cgroup are
> migrated to a new hugetlb cgroup, the new hugetlb cgroup's hugetlb page
> usage is not increased accordingly.

Which is a perferctly reasonable behavior as the memory has been
consumed from the original cgroup and it will be freed there as well.
Migrating to a new cgroup doesn't imply all the resources to be migrated
as well.

> The issue I found is just from my
> testing for the hugetlb cgroup, and I think this is not resonable if we've
> already set a hugetlb limitation for a cgroup, but we always ignore it when
> tasks migration among hugetlb cgroups.

I would like to learn more about why you consider this unreasonable.
This will likely depend on the reason why you want/need to migrate task.
If you want to move a task to completely new resource domain (read a
completely different cgroup subtree) then I can imagine you want to
leave all the resources but this will have problems with other resource
controllers - e.g. memory cgroup v2 which doesn't allow charge migration
either.
Baolin Wang Oct. 9, 2021, 2:24 p.m. UTC | #6
On 2021/10/8 19:55, Michal Hocko wrote:
> On Fri 08-10-21 17:17:12, Baolin Wang wrote:
>>
>>
>> On 2021/10/8 15:12, Michal Hocko wrote:
>>> On Thu 07-10-21 23:39:15, Baolin Wang wrote:
>>>> Hi Michal,
>>>>
>>>> (Sorry for late reply due to my holidays)
>>>> On 2021/9/30 18:46, Michal Hocko wrote:
>>>>> On Wed 29-09-21 18:19:26, Baolin Wang wrote:
>>>>>> Hi,
>>>>>>
>>>>>> Now in the hugetlb cgroup, charges associated with a task aren't moved
>>>>>> to the new hugetlb cgroup at task migration, which is odd for hugetlb
>>>>>> cgroup usage.
>>>>>
>>>>> Could you elaborate some more about the usecase and/or problems you see
>>>>> with the existing semantic?
>>>>
>>>> The problems is that, it did not check if the tasks can move to the new
>>>> hugetlb cgroup if the new hugetlb cgroup has a limitation, and the hugetlb
>>>> cgroup usage is incorrect when moving tasks among hugetlb cgroups.
>>>
>>> Could you be more specific please? What do you mean by cgroup usage is
>>> incorrect? Ideally could you describe your usecase?
>>
>> Sorry for confusing, what I mean is, when tasks from one hugetlb cgroup are
>> migrated to a new hugetlb cgroup, the new hugetlb cgroup's hugetlb page
>> usage is not increased accordingly.
> 
> Which is a perferctly reasonable behavior as the memory has been
> consumed from the original cgroup and it will be freed there as well.
> Migrating to a new cgroup doesn't imply all the resources to be migrated
> as well.

OK.

>> The issue I found is just from my
>> testing for the hugetlb cgroup, and I think this is not resonable if we've
>> already set a hugetlb limitation for a cgroup, but we always ignore it when
>> tasks migration among hugetlb cgroups.
> 
> I would like to learn more about why you consider this unreasonable.
> This will likely depend on the reason why you want/need to migrate task.
> If you want to move a task to completely new resource domain (read a

Yes.

> completely different cgroup subtree) then I can imagine you want to
> leave all the resources but this will have problems with other resource
> controllers - e.g. memory cgroup v2 which doesn't allow charge migration
> either.

OK. I see. Thanks.