Refactor schemas and virresctrl to support optional <cache> element
in <cachetune>.
Later, the monitor entry will be introduced and to be placed
under <cachetune>. Either cache entry or monitor entry is
an optional element of <cachetune>.
An cachetune has no <cache> element is taking the default resource
allocating policy defined in '/sys/fs/resctrl/schemata'.
Signed-off-by: Wang Huaqiang <huaqiang.wang@intel.com>
---
docs/formatdomain.html.in | 4 ++--
docs/schemas/domaincommon.rng | 4 ++--
src/util/virresctrl.c | 28 ++++++++++++++++++++++++++++
3 files changed, 32 insertions(+), 4 deletions(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 8189959..b1651e3 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -943,8 +943,8 @@
<dl>
<dt><code>cache</code></dt>
<dd>
- This element controls the allocation of CPU cache and has the
- following attributes:
+ This optional element controls the allocation of CPU cache and has
+ the following attributes:
<dl>
<dt><code>level</code></dt>
<dd>
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 099a949..5c533d6 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -956,7 +956,7 @@
<attribute name="vcpus">
<ref name='cpuset'/>
</attribute>
- <oneOrMore>
+ <zeroOrMore>
<element name="cache">
<attribute name="id">
<ref name='unsignedInt'/>
@@ -980,7 +980,7 @@
</attribute>
</optional>
</element>
- </oneOrMore>
+ </zeroOrMore>
</element>
</zeroOrMore>
<zeroOrMore>
diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c
index 5d811a2..91bd341 100644
--- a/src/util/virresctrl.c
+++ b/src/util/virresctrl.c
@@ -234,6 +234,11 @@ virResctrlInfoMonFree(virResctrlInfoMonPtr mon)
* in case there is no allocation for that particular cache allocation (level,
* cache, ...) or memory allocation for particular node).
*
+ * Allocation corresponding to root directory, /sys/fs/sysctrl/, defines the
+ * default resource allocating policy, which is created immediately after
+ * mounting, and owns all the tasks and cpus in the system. Cache or memory
+ * bandwidth resource will be shared for tasks in this allocation.
+ *
* =====Cache allocation technology (CAT)=====
*
* Since one allocation can be made for caches on different levels, the first
@@ -2215,6 +2220,15 @@ virResctrlAllocDeterminePath(virResctrlAllocPtr alloc,
return -1;
}
+ /* If the allocation is empty, then the path will be SYSFS_RESCTRL_PATH */
+ if (virResctrlAllocIsEmpty(alloc)) {
+ if (!alloc->path &&
+ VIR_STRDUP(alloc->path, SYSFS_RESCTRL_PATH) < 0)
+ return -1;
+
+ return 0;
+ }
+
if (!alloc->path &&
virAsprintf(&alloc->path, "%s/%s-%s",
SYSFS_RESCTRL_PATH, machinename, alloc->id) < 0)
@@ -2248,6 +2262,11 @@ virResctrlAllocCreate(virResctrlInfoPtr resctrl,
if (virResctrlAllocDeterminePath(alloc, machinename) < 0)
return -1;
+ /* If the allocation is empty, then do not create directory in underlying
+ * resctrl file system */
+ if (virResctrlAllocIsEmpty(alloc))
+ return 0;
+
if (virFileExists(alloc->path)) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Path '%s' for resctrl allocation exists"),
@@ -2302,6 +2321,11 @@ virResctrlAllocAddPID(virResctrlAllocPtr alloc,
char *pidstr = NULL;
int ret = 0;
+ /* If the allocation is empty, then it is impossible to add a PID to
+ * allocation due to lacking of its 'tasks' file. Just return */
+ if (virResctrlAllocIsEmpty(alloc))
+ return 0;
+
if (!alloc->path) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Cannot add pid to non-existing resctrl allocation"));
@@ -2334,6 +2358,10 @@ virResctrlAllocRemove(virResctrlAllocPtr alloc)
{
int ret = 0;
+ /* No directory have ever been created. Just return */
+ if (virResctrlAllocIsEmpty(alloc))
+ return 0;
+
if (!alloc->path)
return 0;
--
2.7.4
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
On 10/22/18 4:01 AM, Wang Huaqiang wrote:
> Refactor schemas and virresctrl to support optional <cache> element
> in <cachetune>.
>
> Later, the monitor entry will be introduced and to be placed
> under <cachetune>. Either cache entry or monitor entry is
> an optional element of <cachetune>.
>
> An cachetune has no <cache> element is taking the default resource
> allocating policy defined in '/sys/fs/resctrl/schemata'.
>
> Signed-off-by: Wang Huaqiang <huaqiang.wang@intel.com>
> ---
> docs/formatdomain.html.in | 4 ++--
> docs/schemas/domaincommon.rng | 4 ++--
> src/util/virresctrl.c | 28 ++++++++++++++++++++++++++++
> 3 files changed, 32 insertions(+), 4 deletions(-)
>
[...]
> + /* If the allocation is empty, then the path will be SYSFS_RESCTRL_PATH */
> + if (virResctrlAllocIsEmpty(alloc)) {
> + if (!alloc->path &&
> + VIR_STRDUP(alloc->path, SYSFS_RESCTRL_PATH) < 0)
> + return -1;
> +
> + return 0;
> + }
> +
Because of ...
> if (!alloc->path &&
> virAsprintf(&alloc->path, "%s/%s-%s",
> SYSFS_RESCTRL_PATH, machinename, alloc->id) < 0)
[...]
> @@ -2334,6 +2358,10 @@ virResctrlAllocRemove(virResctrlAllocPtr alloc)
> {
> int ret = 0;
>
> + /* No directory have ever been created. Just return */
> + if (virResctrlAllocIsEmpty(alloc))
> + return 0;
... the change to virResctrlAllocDeterminePath to fill in alloc->path
when virResctrlAllocIsEmpty to be a default path, this should be:
if (STREQ_NULLABLE(alloc->path, SYSFS_RESCTRL_PATH))
return 0;
or moved after the next check and the _NULLABLE removed.
Whether the AllocIsEmpty is true or not shouldn't be the bearing on
whether the directory created because of that
> +
> if (!alloc->path)
> return 0;
>
>
I can adjust for you, let me know; otherwise, things are fine for the
Reviewed-by: John Ferlan <jferlan@redhat.com>
John
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
On 2018年11月05日 23:01, John Ferlan wrote:
>
> On 10/22/18 4:01 AM, Wang Huaqiang wrote:
>> Refactor schemas and virresctrl to support optional <cache> element
>> in <cachetune>.
>>
>> Later, the monitor entry will be introduced and to be placed
>> under <cachetune>. Either cache entry or monitor entry is
>> an optional element of <cachetune>.
>>
>> An cachetune has no <cache> element is taking the default resource
>> allocating policy defined in '/sys/fs/resctrl/schemata'.
>>
>> Signed-off-by: Wang Huaqiang <huaqiang.wang@intel.com>
>> ---
>> docs/formatdomain.html.in | 4 ++--
>> docs/schemas/domaincommon.rng | 4 ++--
>> src/util/virresctrl.c | 28 ++++++++++++++++++++++++++++
>> 3 files changed, 32 insertions(+), 4 deletions(-)
>>
> [...]
>
>> + /* If the allocation is empty, then the path will be SYSFS_RESCTRL_PATH */
>> + if (virResctrlAllocIsEmpty(alloc)) {
>> + if (!alloc->path &&
>> + VIR_STRDUP(alloc->path, SYSFS_RESCTRL_PATH) < 0)
>> + return -1;
>> +
>> + return 0;
>> + }
>> +
> Because of ...
>
>> if (!alloc->path &&
>> virAsprintf(&alloc->path, "%s/%s-%s",
>> SYSFS_RESCTRL_PATH, machinename, alloc->id) < 0)
> [...]
>
>> @@ -2334,6 +2358,10 @@ virResctrlAllocRemove(virResctrlAllocPtr alloc)
>> {
>> int ret = 0;
>>
>> + /* No directory have ever been created. Just return */
>> + if (virResctrlAllocIsEmpty(alloc))
>> + return 0;
> ... the change to virResctrlAllocDeterminePath to fill in alloc->path
> when virResctrlAllocIsEmpty to be a default path, this should be:
>
> if (STREQ_NULLABLE(alloc->path, SYSFS_RESCTRL_PATH))
> return 0;
>
> or moved after the next check and the _NULLABLE removed.
>
> Whether the AllocIsEmpty is true or not shouldn't be the bearing on
> whether the directory created because of that
Agree with the changes.
"No need to create a directory that has already been created by system."
(SYSFS_RESCTRL_PATH is the created directory).
>> +
>> if (!alloc->path)
>> return 0;
>>
>>
> I can adjust for you, let me know; otherwise, things are fine for the
>
> Reviewed-by: John Ferlan <jferlan@redhat.com>
>
> John
Thanks for the review.
Huaqiang
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
On 2018年11月06日 16:18, Huaqiang,Wang wrote:
>
>
> On 2018年11月05日 23:01, John Ferlan wrote:
>>
>> On 10/22/18 4:01 AM, Wang Huaqiang wrote:
>>> Refactor schemas and virresctrl to support optional <cache> element
>>> in <cachetune>.
>>>
>>> Later, the monitor entry will be introduced and to be placed
>>> under <cachetune>. Either cache entry or monitor entry is
>>> an optional element of <cachetune>.
>>>
>>> An cachetune has no <cache> element is taking the default resource
>>> allocating policy defined in '/sys/fs/resctrl/schemata'.
>>>
>>> Signed-off-by: Wang Huaqiang <huaqiang.wang@intel.com>
>>> ---
>>> docs/formatdomain.html.in | 4 ++--
>>> docs/schemas/domaincommon.rng | 4 ++--
>>> src/util/virresctrl.c | 28 ++++++++++++++++++++++++++++
>>> 3 files changed, 32 insertions(+), 4 deletions(-)
>>>
>> [...]
>>
>>> + /* If the allocation is empty, then the path will be
>>> SYSFS_RESCTRL_PATH */
>>> + if (virResctrlAllocIsEmpty(alloc)) {
>>> + if (!alloc->path &&
>>> + VIR_STRDUP(alloc->path, SYSFS_RESCTRL_PATH) < 0)
>>> + return -1;
>>> +
>>> + return 0;
>>> + }
>>> +
>> Because of ...
>>
>>> if (!alloc->path &&
>>> virAsprintf(&alloc->path, "%s/%s-%s",
>>> SYSFS_RESCTRL_PATH, machinename, alloc->id) < 0)
>> [...]
>>
>>> @@ -2334,6 +2358,10 @@ virResctrlAllocRemove(virResctrlAllocPtr alloc)
>>> {
>>> int ret = 0;
>>> + /* No directory have ever been created. Just return */
>>> + if (virResctrlAllocIsEmpty(alloc))
>>> + return 0;
>> ... the change to virResctrlAllocDeterminePath to fill in alloc->path
>> when virResctrlAllocIsEmpty to be a default path, this should be:
>>
>> if (STREQ_NULLABLE(alloc->path, SYSFS_RESCTRL_PATH))
>> return 0;
>>
>> or moved after the next check and the _NULLABLE removed.
>>
>> Whether the AllocIsEmpty is true or not shouldn't be the bearing on
>> whether the directory created because of that
>
> Agree with the changes.
> "No need to create a directory that has already been created by system."
> (SYSFS_RESCTRL_PATH is the created directory).
Should be "no need to destroy a system created directory, the
SYSFS_RESCTRL_PATH.
Directory SYSFS_RESCTRL_PATH is governed by system."
It might also be reasonable to make similar changes for
virResctrlAllocCreate,
because no need to create an already created directory, Right? And
*alloc->path must
be properly assigned, by virResctrlAllocDeterminePath, before a call of
virResctrlAllocCreate.
>
>>> +
>>> if (!alloc->path)
>>> return 0;
>>>
>> I can adjust for you, let me know; otherwise, things are fine for the
>>
>> Reviewed-by: John Ferlan <jferlan@redhat.com>
>>
>> John
>
> Thanks for the review.
> Huaqiang
>
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
On 11/6/18 3:30 AM, Huaqiang,Wang wrote:
>
>
> On 2018年11月06日 16:18, Huaqiang,Wang wrote:
>>
>>
>> On 2018年11月05日 23:01, John Ferlan wrote:
>>>
>>> On 10/22/18 4:01 AM, Wang Huaqiang wrote:
>>>> Refactor schemas and virresctrl to support optional <cache> element
>>>> in <cachetune>.
>>>>
>>>> Later, the monitor entry will be introduced and to be placed
>>>> under <cachetune>. Either cache entry or monitor entry is
>>>> an optional element of <cachetune>.
>>>>
>>>> An cachetune has no <cache> element is taking the default resource
>>>> allocating policy defined in '/sys/fs/resctrl/schemata'.
>>>>
>>>> Signed-off-by: Wang Huaqiang <huaqiang.wang@intel.com>
>>>> ---
>>>> docs/formatdomain.html.in | 4 ++--
>>>> docs/schemas/domaincommon.rng | 4 ++--
>>>> src/util/virresctrl.c | 28 ++++++++++++++++++++++++++++
>>>> 3 files changed, 32 insertions(+), 4 deletions(-)
>>>>
>>> [...]
>>>
>>>> + /* If the allocation is empty, then the path will be
>>>> SYSFS_RESCTRL_PATH */
>>>> + if (virResctrlAllocIsEmpty(alloc)) {
>>>> + if (!alloc->path &&
>>>> + VIR_STRDUP(alloc->path, SYSFS_RESCTRL_PATH) < 0)
>>>> + return -1;
>>>> +
>>>> + return 0;
>>>> + }
>>>> +
>>> Because of ...
>>>
>>>> if (!alloc->path &&
>>>> virAsprintf(&alloc->path, "%s/%s-%s",
>>>> SYSFS_RESCTRL_PATH, machinename, alloc->id) < 0)
>>> [...]
>>>
>>>> @@ -2334,6 +2358,10 @@ virResctrlAllocRemove(virResctrlAllocPtr alloc)
>>>> {
>>>> int ret = 0;
>>>> + /* No directory have ever been created. Just return */
>>>> + if (virResctrlAllocIsEmpty(alloc))
>>>> + return 0;
>>> ... the change to virResctrlAllocDeterminePath to fill in alloc->path
>>> when virResctrlAllocIsEmpty to be a default path, this should be:
>>>
>>> if (STREQ_NULLABLE(alloc->path, SYSFS_RESCTRL_PATH))
>>> return 0;
>>>
>>> or moved after the next check and the _NULLABLE removed.
>>>
>>> Whether the AllocIsEmpty is true or not shouldn't be the bearing on
>>> whether the directory created because of that
>>
>> Agree with the changes.
>> "No need to create a directory that has already been created by system."
>> (SYSFS_RESCTRL_PATH is the created directory).
>
> Should be "no need to destroy a system created directory, the
> SYSFS_RESCTRL_PATH.
> Directory SYSFS_RESCTRL_PATH is governed by system."
>
I'll add the comment:
+ /* Do not destroy if path is the system/default path for the
allocation */
> It might also be reasonable to make similar changes for
> virResctrlAllocCreate,
> because no need to create an already created directory, Right? And
> *alloc->path must
> be properly assigned, by virResctrlAllocDeterminePath, before a call of
> virResctrlAllocCreate.
>
True - I'll adjust the check there too to be:
+ /* If using the system/default path for the allocation, then we're
done */
+ if (STREQ(alloc->path, SYSFS_RESCTRL_PATH))
+ return 0;
+
Tks -
John
>>
>>>> +
>>>> if (!alloc->path)
>>>> return 0;
>>>>
>>> I can adjust for you, let me know; otherwise, things are fine for the
>>>
>>> Reviewed-by: John Ferlan <jferlan@redhat.com>
>>>
>>> John
>>
>> Thanks for the review.
>> Huaqiang
>>
>
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
© 2016 - 2026 Red Hat, Inc.