* [PATCH] xen: make sysfs files behave as their names suggest
@ 2009-01-29 0:50 Jeremy Fitzhardinge
2009-01-29 2:35 ` Simon Horman
2009-01-29 12:20 ` Ingo Molnar
0 siblings, 2 replies; 5+ messages in thread
From: Jeremy Fitzhardinge @ 2009-01-29 0:50 UTC (permalink / raw)
To: Ingo Molnar
Cc: Linux Kernel Mailing List, Stable Kernel,
dan.magenheimer@oracle.com
1: make "target_kb" only accept and produce a memory size in kilobytes.
2: add a second "target" file which produces output in bytes, and will accept
memparse input (scaled bytes)
This fixes the rather irritating problem that writing the same value
read back into target_kb would end up shrinking the domain by a factor
of 1024, with generally bad results.
Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
---
drivers/xen/balloon.c | 33 ++++++++++++++++++++++++++++++++-
1 file changed, 32 insertions(+), 1 deletion(-)
===================================================================
--- a/drivers/xen/balloon.c
+++ b/drivers/xen/balloon.c
@@ -586,7 +586,7 @@
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
- target_bytes = memparse(buf, &endchar);
+ target_bytes = simple_strtoull(buf, &endchar, 0) * 1024;
balloon_set_new_target(target_bytes >> PAGE_SHIFT);
@@ -596,8 +596,39 @@
static SYSDEV_ATTR(target_kb, S_IRUGO | S_IWUSR,
show_target_kb, store_target_kb);
+
+static ssize_t show_target(struct sys_device *dev, struct sysdev_attribute *attr,
+ char *buf)
+{
+ return sprintf(buf, "%llu\n",
+ (u64)balloon_stats.target_pages << PAGE_SHIFT);
+}
+
+static ssize_t store_target(struct sys_device *dev,
+ struct sysdev_attribute *attr,
+ const char *buf,
+ size_t count)
+{
+ char *endchar;
+ unsigned long long target_bytes;
+
+ if (!capable(CAP_SYS_ADMIN))
+ return -EPERM;
+
+ target_bytes = memparse(buf, &endchar);
+
+ balloon_set_new_target(target_bytes >> PAGE_SHIFT);
+
+ return count;
+}
+
+static SYSDEV_ATTR(target, S_IRUGO | S_IWUSR,
+ show_target, store_target);
+
+
static struct sysdev_attribute *balloon_attrs[] = {
&attr_target_kb,
+ &attr_target,
};
static struct attribute *balloon_info_attrs[] = {
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] xen: make sysfs files behave as their names suggest
2009-01-29 0:50 [PATCH] xen: make sysfs files behave as their names suggest Jeremy Fitzhardinge
@ 2009-01-29 2:35 ` Simon Horman
2009-01-29 4:31 ` Jeremy Fitzhardinge
2009-01-29 12:20 ` Ingo Molnar
1 sibling, 1 reply; 5+ messages in thread
From: Simon Horman @ 2009-01-29 2:35 UTC (permalink / raw)
To: Jeremy Fitzhardinge
Cc: Ingo Molnar, Linux Kernel Mailing List, Stable Kernel,
dan.magenheimer@oracle.com
On Wed, Jan 28, 2009 at 04:50:20PM -0800, Jeremy Fitzhardinge wrote:
> 1: make "target_kb" only accept and produce a memory size in kilobytes.
> 2: add a second "target" file which produces output in bytes, and will accept
> memparse input (scaled bytes)
>
> This fixes the rather irritating problem that writing the same value
> read back into target_kb would end up shrinking the domain by a factor
> of 1024, with generally bad results.
Are there any compatibility issues that we should care about
related to this change?
--
Simon Horman
VA Linux Systems Japan K.K., Sydney, Australia Satellite Office
H: www.vergenet.net/~horms/ W: www.valinux.co.jp/en
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] xen: make sysfs files behave as their names suggest
2009-01-29 2:35 ` Simon Horman
@ 2009-01-29 4:31 ` Jeremy Fitzhardinge
2009-01-29 6:44 ` Simon Horman
0 siblings, 1 reply; 5+ messages in thread
From: Jeremy Fitzhardinge @ 2009-01-29 4:31 UTC (permalink / raw)
To: Simon Horman
Cc: Ingo Molnar, Linux Kernel Mailing List, Stable Kernel,
dan.magenheimer@oracle.com
Simon Horman wrote:
> On Wed, Jan 28, 2009 at 04:50:20PM -0800, Jeremy Fitzhardinge wrote:
>
>> 1: make "target_kb" only accept and produce a memory size in kilobytes.
>> 2: add a second "target" file which produces output in bytes, and will accept
>> memparse input (scaled bytes)
>>
>> This fixes the rather irritating problem that writing the same value
>> read back into target_kb would end up shrinking the domain by a factor
>> of 1024, with generally bad results.
>>
>
> Are there any compatibility issues that we should care about
> related to this change?
>
Well, in theory, but not in practice I think.
It changes the behaviour of target_kb from accepting bytes into
kilobytes, and it no longer parses a k/m/g suffix. The old behaviour
was a definite bug, given the name of the file, so I consider this to be
pure bugfix. The kernel introducing this interface has only been out
for a week or two, so I don't think there's much chance anyone has
started relying on the buggy behaviour.
J
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] xen: make sysfs files behave as their names suggest
2009-01-29 4:31 ` Jeremy Fitzhardinge
@ 2009-01-29 6:44 ` Simon Horman
0 siblings, 0 replies; 5+ messages in thread
From: Simon Horman @ 2009-01-29 6:44 UTC (permalink / raw)
To: Jeremy Fitzhardinge
Cc: Ingo Molnar, Linux Kernel Mailing List, Stable Kernel,
dan.magenheimer@oracle.com
On Wed, Jan 28, 2009 at 08:31:25PM -0800, Jeremy Fitzhardinge wrote:
> Simon Horman wrote:
>> On Wed, Jan 28, 2009 at 04:50:20PM -0800, Jeremy Fitzhardinge wrote:
>>
>>> 1: make "target_kb" only accept and produce a memory size in kilobytes.
>>> 2: add a second "target" file which produces output in bytes, and will accept
>>> memparse input (scaled bytes)
>>>
>>> This fixes the rather irritating problem that writing the same value
>>> read back into target_kb would end up shrinking the domain by a factor
>>> of 1024, with generally bad results.
>>>
>>
>> Are there any compatibility issues that we should care about
>> related to this change?
>>
>
> Well, in theory, but not in practice I think.
>
> It changes the behaviour of target_kb from accepting bytes into
> kilobytes, and it no longer parses a k/m/g suffix. The old behaviour
> was a definite bug, given the name of the file, so I consider this to be
> pure bugfix. The kernel introducing this interface has only been out
> for a week or two, so I don't think there's much chance anyone has
> started relying on the buggy behaviour.
Thanks for the clarification. I have no objections.
--
Simon Horman
VA Linux Systems Japan K.K., Sydney, Australia Satellite Office
H: www.vergenet.net/~horms/ W: www.valinux.co.jp/en
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] xen: make sysfs files behave as their names suggest
2009-01-29 0:50 [PATCH] xen: make sysfs files behave as their names suggest Jeremy Fitzhardinge
2009-01-29 2:35 ` Simon Horman
@ 2009-01-29 12:20 ` Ingo Molnar
1 sibling, 0 replies; 5+ messages in thread
From: Ingo Molnar @ 2009-01-29 12:20 UTC (permalink / raw)
To: Jeremy Fitzhardinge
Cc: Linux Kernel Mailing List, Stable Kernel,
dan.magenheimer@oracle.com, H. Peter Anvin
* Jeremy Fitzhardinge <jeremy@goop.org> wrote:
> 1: make "target_kb" only accept and produce a memory size in kilobytes.
> 2: add a second "target" file which produces output in bytes, and will accept
> memparse input (scaled bytes)
>
> This fixes the rather irritating problem that writing the same value
> read back into target_kb would end up shrinking the domain by a factor
> of 1024, with generally bad results.
>
> Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
> ---
> drivers/xen/balloon.c | 33 ++++++++++++++++++++++++++++++++-
> 1 file changed, 32 insertions(+), 1 deletion(-)
applied to tip/x86/urgent, thanks Jeremy!
Ingo
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-01-29 12:21 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-29 0:50 [PATCH] xen: make sysfs files behave as their names suggest Jeremy Fitzhardinge
2009-01-29 2:35 ` Simon Horman
2009-01-29 4:31 ` Jeremy Fitzhardinge
2009-01-29 6:44 ` Simon Horman
2009-01-29 12:20 ` Ingo Molnar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox