WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] introduce size_param()

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] introduce size_param()
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Mon, 31 Aug 2009 03:00:20 -0700
Delivery-date: Mon, 31 Aug 2009 03:00:48 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1251709613 -3600
# Node ID 709a42e8514688b5c955fef4472de7553e6d7544
# Parent  f974a04432fc289cde79ca009df8ae92e8e7ceeb
introduce size_param()

With there being several instances of custom_param() where the handler
is just invoking parse_size_and_unit(), it seems to make sense to
introduce a simplifying abstraction.

Also fix serial_txbufsz not having been guaranteed to be a power of
two.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxxxx>
---
 xen/arch/ia64/xen/domain.c |    6 +-----
 xen/arch/x86/e820.c        |    5 ++---
 xen/common/kernel.c        |   15 +++++++++++++++
 xen/drivers/char/console.c |    6 ++----
 xen/drivers/char/serial.c  |   17 +++++++++--------
 xen/include/xen/init.h     |   13 ++++++++++++-
 6 files changed, 41 insertions(+), 21 deletions(-)

diff -r f974a04432fc -r 709a42e85146 xen/arch/ia64/xen/domain.c
--- a/xen/arch/ia64/xen/domain.c        Mon Aug 31 09:54:25 2009 +0100
+++ b/xen/arch/ia64/xen/domain.c        Mon Aug 31 10:06:53 2009 +0100
@@ -2387,11 +2387,7 @@ arch_do_vcpu_op(int cmd, struct vcpu *v,
        return rc;
 }
 
-static void __init parse_dom0_mem(char *s)
-{
-       dom0_size = parse_size_and_unit(s, NULL);
-}
-custom_param("dom0_mem", parse_dom0_mem);
+size_param("dom0_mem", dom0_size);
 
 /*
  * Helper function for the optimization stuff handling the identity mapping
diff -r f974a04432fc -r 709a42e85146 xen/arch/x86/e820.c
--- a/xen/arch/x86/e820.c       Mon Aug 31 09:54:25 2009 +0100
+++ b/xen/arch/x86/e820.c       Mon Aug 31 10:06:53 2009 +0100
@@ -11,9 +11,8 @@
 #include <asm/msr.h>
 
 /* opt_mem: Limit of physical RAM. Any RAM beyond this point is ignored. */
-unsigned long long opt_mem;
-static void parse_mem(char *s) { opt_mem = parse_size_and_unit(s, NULL); }
-custom_param("mem", parse_mem);
+static unsigned long long __initdata opt_mem;
+size_param("mem", opt_mem);
 
 /* opt_nomtrr_check: Don't clip ram to highest cacheable MTRR. */
 static int __initdata e820_mtrr_clip = -1;
diff -r f974a04432fc -r 709a42e85146 xen/common/kernel.c
--- a/xen/common/kernel.c       Mon Aug 31 09:54:25 2009 +0100
+++ b/xen/common/kernel.c       Mon Aug 31 10:06:53 2009 +0100
@@ -92,6 +92,21 @@ void cmdline_parse(char *cmdline)
                     bool_assert = !bool_assert;
                 *(int *)param->var = bool_assert;
                 break;
+            case OPT_SIZE: {
+                uint64_t sz = parse_size_and_unit(optval, NULL);
+                switch ( param->len )
+                {
+                case sizeof(uint32_t):
+                    *(uint32_t *)param->var = sz;
+                    break;
+                case sizeof(uint64_t):
+                    *(uint64_t *)param->var = sz;
+                    break;
+                default:
+                    BUG();
+                }
+                break;
+            }
             case OPT_CUSTOM:
                 ((void (*)(const char *))param->var)(optval);
                 break;
diff -r f974a04432fc -r 709a42e85146 xen/drivers/char/console.c
--- a/xen/drivers/char/console.c        Mon Aug 31 09:54:25 2009 +0100
+++ b/xen/drivers/char/console.c        Mon Aug 31 10:06:53 2009 +0100
@@ -59,10 +59,8 @@ boolean_param("console_timestamps", opt_
 boolean_param("console_timestamps", opt_console_timestamps);
 
 /* conring_size: allows a large console ring than default (16kB). */
-static uint32_t opt_conring_size;
-static void parse_conring_size(char *s)
-{ opt_conring_size = parse_size_and_unit(s, NULL); }
-custom_param("conring_size", parse_conring_size);
+static uint32_t __initdata opt_conring_size;
+size_param("conring_size", opt_conring_size);
 
 #define _CONRING_SIZE 16384
 #define CONRING_IDX_MASK(i) ((i)&(conring_size-1))
diff -r f974a04432fc -r 709a42e85146 xen/drivers/char/serial.c
--- a/xen/drivers/char/serial.c Mon Aug 31 09:54:25 2009 +0100
+++ b/xen/drivers/char/serial.c Mon Aug 31 10:06:53 2009 +0100
@@ -19,11 +19,7 @@
 /* #define SERIAL_NEVER_DROP_CHARS 1 */
 
 unsigned int serial_txbufsz = 16384;
-static void __init parse_serial_tx_buffer(const char *s)
-{
-    serial_txbufsz = max((unsigned int)parse_size_and_unit(s, NULL), 512u);
-}
-custom_param("serial_tx_buffer", parse_serial_tx_buffer);
+size_param("serial_tx_buffer", serial_txbufsz);
 
 #define mask_serial_rxbuf_idx(_i) ((_i)&(serial_rxbufsz-1))
 #define mask_serial_txbuf_idx(_i) ((_i)&(serial_txbufsz-1))
@@ -493,9 +489,14 @@ void serial_async_transmit(struct serial
 void serial_async_transmit(struct serial_port *port)
 {
     BUG_ON(!port->driver->tx_empty);
-    if ( port->txbuf == NULL )
-        port->txbuf = alloc_xenheap_pages(
-            get_order_from_bytes(serial_txbufsz), 0);
+    if ( port->txbuf != NULL )
+        return;
+    if ( serial_txbufsz < 512 )
+        serial_txbufsz = 512;
+    while ( serial_txbufsz & (serial_txbufsz - 1) )
+        serial_txbufsz &= serial_txbufsz - 1;
+    port->txbuf = alloc_xenheap_pages(
+        get_order_from_bytes(serial_txbufsz), 0);
 }
 
 /*
diff -r f974a04432fc -r 709a42e85146 xen/include/xen/init.h
--- a/xen/include/xen/init.h    Mon Aug 31 09:54:25 2009 +0100
+++ b/xen/include/xen/init.h    Mon Aug 31 10:06:53 2009 +0100
@@ -78,7 +78,14 @@ extern initcall_t __initcall_start, __in
  */
 struct kernel_param {
     const char *name;
-    enum { OPT_STR, OPT_UINT, OPT_BOOL, OPT_INVBOOL, OPT_CUSTOM } type;
+    enum {
+        OPT_STR,
+        OPT_UINT,
+        OPT_BOOL,
+        OPT_INVBOOL,
+        OPT_SIZE,
+        OPT_CUSTOM
+    } type;
     void *var;
     unsigned int len;
 };
@@ -101,6 +108,10 @@ extern struct kernel_param __setup_start
     static char __setup_str_##_var[] __initdata = _name; \
     static struct kernel_param __setup_##_var __attribute_used__ \
         __initsetup = { __setup_str_##_var, OPT_UINT, &_var, sizeof(_var) }
+#define size_param(_name, _var) \
+    static char __setup_str_##_var[] __initdata = _name; \
+    static struct kernel_param __setup_##_var __attribute_used__ \
+        __initsetup = { __setup_str_##_var, OPT_SIZE, &_var, sizeof(_var) }
 #define string_param(_name, _var) \
     static char __setup_str_##_var[] __initdata = _name; \
     static struct kernel_param __setup_##_var __attribute_used__ \

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] introduce size_param(), Xen patchbot-unstable <=