From: Waiman Long <longman@redhat.com>
To: Tom Hromatka <tom.hromatka@oracle.com>, Tejun Heo <tj@kernel.org>,
Li Zefan <lizefan@huawei.com>,
Johannes Weiner <hannes@cmpxchg.org>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>
Cc: cgroups@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-doc@vger.kernel.org, kernel-team@fb.com, pjt@google.com,
luto@amacapital.net, Mike Galbraith <efault@gmx.de>,
torvalds@linux-foundation.org, Roman Gushchin <guro@fb.com>,
Juri Lelli <juri.lelli@redhat.com>,
Patrick Bellasi <patrick.bellasi@arm.com>
Subject: Re: [PATCH v13 03/11] cpuset: Simply allocation and freeing of cpumasks
Date: Mon, 15 Oct 2018 14:43:22 -0400 [thread overview]
Message-ID: <b5ec84fe-e9ed-7b82-7183-cb84f485dfc7@redhat.com> (raw)
In-Reply-To: <fe132a9a-472d-22db-43ef-42c00b68c8dd@oracle.com>
On 10/15/2018 02:35 PM, Tom Hromatka wrote:
>
>
> On 10/12/2018 11:55 AM, Waiman Long wrote:
>> The previous commit introduces a new subparts_cpus mask into the cpuset
>> data structure and a new tmpmasks structure. Managing the allocation
>> and freeing of those cpumasks is becoming more complex.
>>
>> So a number of helper functions are added to simplify and streamline
>> the management of those cpumasks. To make it simple, all the cpumasks
>> are now pre-cleared on allocation.
>>
>> Signed-off-by: Waiman Long <longman@redhat.com>
>> ---
>> kernel/cgroup/cpuset.c | 104
>> +++++++++++++++++++++++++++++++++----------------
>> 1 file changed, 71 insertions(+), 33 deletions(-)
>>
>> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
>> index 29a2bdc..9ac5f94 100644
>> --- a/kernel/cgroup/cpuset.c
>> +++ b/kernel/cgroup/cpuset.c
>> @@ -456,6 +456,57 @@ static int is_cpuset_subset(const struct cpuset
>> *p, const struct cpuset *q)
>> }
>> /**
>> + * alloc_cpumasks - allocate three cpumasks for cpuset
>> + * @cs: the cpuset that have cpumasks to be allocated.
>> + * @tmp: the tmpmasks structure pointer
>> + * Return: 0 if successful, -ENOMEM otherwise.
>> + *
>> + * Only one of the two input arguments should be non-NULL.
>> + */
>> +static inline int alloc_cpumasks(struct cpuset *cs, struct tmpmasks
>> *tmp)
>> +{
>> + cpumask_var_t *pmask1, *pmask2, *pmask3;
>> +
>> + if (cs) {
>> + pmask1 = &cs->cpus_allowed;
>> + pmask2 = &cs->effective_cpus;
>> + pmask3 = &cs->subparts_cpus;
>> + } else {
>> + pmask1 = &tmp->new_cpus;
>> + pmask2 = &tmp->addmask;
>> + pmask3 = &tmp->delmask;
>> + }
>> +
>> + if (!zalloc_cpumask_var(pmask1, GFP_KERNEL))
>> + return -ENOMEM;
>> +
>> + if (!zalloc_cpumask_var(pmask2, GFP_KERNEL))
>> + goto free_one;
>> +
>> + if (!zalloc_cpumask_var(pmask3, GFP_KERNEL))
>> + goto free_two;
>> +
>> + return 0;
>> +
>> +free_two:
>> + free_cpumask_var(*pmask2);
>> +free_one:
>> + free_cpumask_var(*pmask1);
>> + return -ENOMEM;
>> +}
>> +
>> +/**
>> + * free_cpumasks - free cpumasks in a tmpmasks structure
>> + * @tmp: the tmpmasks structure pointer
>> + */
>> +static inline void free_cpumasks(struct tmpmasks *tmp)
>> +{
>> + free_cpumask_var(tmp->new_cpus);
>> + free_cpumask_var(tmp->addmask);
>> + free_cpumask_var(tmp->delmask);
>> +}
>> +
>
> I hesitate to bring this up, but since you're respinning this
> patch for a different bug...
>
> Would it make sense to have free_cpumasks() have a similar
> API and behavior to alloc_cpumasks()? I could see this potentially
> causing bugs/confusion in future patches.
>
> Thanks.
>
> Tom
>
>
Thanks for the comment. Yes I will make the change.
-Longman
next prev parent reply other threads:[~2018-10-15 18:43 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-12 17:55 [PATCH v13 00/11] cpuset: Enable cpuset controller in default hierarchy Waiman Long
2018-10-12 17:55 ` [PATCH v13 01/11] " Waiman Long
2018-10-15 18:31 ` Tom Hromatka
2018-10-15 18:41 ` Waiman Long
2018-10-15 19:10 ` Tom Hromatka
2018-10-12 17:55 ` [PATCH v13 02/11] cpuset: Define data structures to support scheduling partition Waiman Long
2018-10-12 17:55 ` [PATCH v13 03/11] cpuset: Simply allocation and freeing of cpumasks Waiman Long
2018-10-15 18:35 ` Tom Hromatka
2018-10-15 18:43 ` Waiman Long [this message]
2018-10-12 17:55 ` [PATCH v13 04/11] cpuset: Add new v2 cpuset.sched.partition flag Waiman Long
2018-10-13 14:10 ` kbuild test robot
2018-10-12 17:55 ` [PATCH v13 05/11] cpuset: Add an error state to cpuset.sched.partition Waiman Long
2018-10-12 17:55 ` [PATCH v13 06/11] cpuset: Track cpusets that use parent's effective_cpus Waiman Long
2018-10-12 17:55 ` [PATCH v13 07/11] cpuset: Make CPU hotplug work with partition Waiman Long
2018-10-12 17:55 ` [PATCH v13 08/11] cpuset: Make generate_sched_domains() " Waiman Long
2018-10-12 17:55 ` [PATCH v13 09/11] cpuset: Expose cpus.effective and mems.effective on cgroup v2 root Waiman Long
2018-10-12 17:55 ` [PATCH v13 10/11] cpuset: Add documentation about the new "cpuset.sched.partition" flag Waiman Long
2018-10-12 17:55 ` [PATCH v13 11/11] cpuset: Expose cpuset.cpus.subpartitions with cgroup_debug Waiman Long
2018-10-15 16:35 ` [PATCH v13 00/11] cpuset: Enable cpuset controller in default hierarchy Tejun Heo
2018-10-15 17:04 ` Waiman Long
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=b5ec84fe-e9ed-7b82-7183-cb84f485dfc7@redhat.com \
--to=longman@redhat.com \
--cc=cgroups@vger.kernel.org \
--cc=efault@gmx.de \
--cc=guro@fb.com \
--cc=hannes@cmpxchg.org \
--cc=juri.lelli@redhat.com \
--cc=kernel-team@fb.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lizefan@huawei.com \
--cc=luto@amacapital.net \
--cc=mingo@redhat.com \
--cc=patrick.bellasi@arm.com \
--cc=peterz@infradead.org \
--cc=pjt@google.com \
--cc=tj@kernel.org \
--cc=tom.hromatka@oracle.com \
--cc=torvalds@linux-foundation.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;
as well as URLs for NNTP newsgroup(s).