Local APIC ID

2009-07-24 Thread Barret Rhoden
Hi - 

Is the Local APIC ID supposed to be 0?  In older versions of kvm (like
85), it was set by default to the same ID as returned by cpuid, but now
it's 0.  I'm running from a recent commit (181d9e8ef2bc42) of the
kvm-kmod repo, though I don't know when it was changed.

If it's supposed to be that way, then great, but if not, I figured I'd
ask.

Thanks,

Barret

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [Autotest] [KVM-AUTOTEST PATCH 12/17] KVM test: add simple timedrift test (mainly for Windows)

2009-07-24 Thread Lucas Meneghel Rodrigues
On Tue, Jul 21, 2009 at 12:29 PM, Michael Goldish wrote:
>
> - "Yolkfull Chow"  wrote:
>
>> On Mon, Jul 20, 2009 at 06:07:19PM +0300, Michael Goldish wrote:
>> > 1) Log into a guest.
>> > 2) Take a time reading from the guest and host.
>> > 3) Run load on the guest and host.
>> > 4) Take a second time reading.
>> > 5) Stop the load and rest for a while.
>> > 6) Take a third time reading.
>> > 7) If the drift immediately after load is higher than a user-
>> > specified value (in %), fail.
>> > If the drift after the rest period is higher than a user-specified
>> value,
>> > fail.
>> >
>> > Signed-off-by: Michael Goldish 
>> > ---
>> >  client/tests/kvm/kvm.py       |    1 +
>> >  client/tests/kvm/kvm_tests.py |  161
>> -
>> >  2 files changed, 160 insertions(+), 2 deletions(-)
>> >
>> > diff --git a/client/tests/kvm/kvm.py b/client/tests/kvm/kvm.py
>> > index b18b643..070e463 100644
>> > --- a/client/tests/kvm/kvm.py
>> > +++ b/client/tests/kvm/kvm.py
>> > @@ -55,6 +55,7 @@ class kvm(test.test):
>> >                  "kvm_install":  test_routine("kvm_install",
>> "run_kvm_install"),
>> >                  "linux_s3":     test_routine("kvm_tests",
>> "run_linux_s3"),
>> >                  "stress_boot":  test_routine("kvm_tests",
>> "run_stress_boot"),
>> > +                "timedrift":    test_routine("kvm_tests",
>> "run_timedrift"),
>> >                  }
>> >
>> >          # Make it possible to import modules from the test's
>> bindir
>> > diff --git a/client/tests/kvm/kvm_tests.py
>> b/client/tests/kvm/kvm_tests.py
>> > index 5991aed..ca0b8c0 100644
>> > --- a/client/tests/kvm/kvm_tests.py
>> > +++ b/client/tests/kvm/kvm_tests.py
>> > @@ -1,4 +1,4 @@
>> > -import time, os, logging
>> > +import time, os, logging, re, commands
>> >  from autotest_lib.client.common_lib import utils, error
>> >  import kvm_utils, kvm_subprocess, ppm_utils, scan_results
>> >
>> > @@ -529,7 +529,6 @@ def run_stress_boot(tests, params, env):
>> >      """
>> >      # boot the first vm
>> >      vm = kvm_utils.env_get_vm(env, params.get("main_vm"))
>> > -
>> >      if not vm:
>> >          raise error.TestError("VM object not found in
>> environment")
>> >      if not vm.is_alive():
>> > @@ -586,3 +585,161 @@ def run_stress_boot(tests, params, env):
>> >          for se in sessions:
>> >              se.close()
>> >          logging.info("Total number booted: %d" % (num -1))
>> > +
>> > +
>> > +def run_timedrift(test, params, env):
>> > +    """
>> > +    Time drift test (mainly for Windows guests):
>> > +
>> > +    1) Log into a guest.
>> > +    2) Take a time reading from the guest and host.
>> > +    3) Run load on the guest and host.
>> > +    4) Take a second time reading.
>> > +    5) Stop the load and rest for a while.
>> > +    6) Take a third time reading.
>> > +    7) If the drift immediately after load is higher than a user-
>> > +    specified value (in %), fail.
>> > +    If the drift after the rest period is higher than a
>> user-specified value,
>> > +    fail.
>> > +
>> > +   �...@param test: KVM test object.
>> > +   �...@param params: Dictionary with test parameters.
>> > +   �...@param env: Dictionary with the test environment.
>> > +    """
>> > +    vm = kvm_utils.env_get_vm(env, params.get("main_vm"))
>> > +    if not vm:
>> > +        raise error.TestError("VM object not found in
>> environment")
>> > +    if not vm.is_alive():
>> > +        raise error.TestError("VM seems to be dead; Test requires a
>> living VM")
>> > +
>> > +    logging.info("Waiting for guest to be up...")
>> > +
>> > +    session = kvm_utils.wait_for(vm.ssh_login, 240, 0, 2)
>> > +    if not session:
>> > +        raise error.TestFail("Could not log into guest")
>> > +
>> > +    logging.info("Logged in")
>> > +
>> > +    # Collect test parameters:
>> > +    # Command to run to get the current time
>> > +    time_command = params.get("time_command")
>> > +    # Filter which should match a string to be passed to
>> time.strptime()
>> > +    time_filter_re = params.get("time_filter_re")
>> > +    # Time format for time.strptime()
>> > +    time_format = params.get("time_format")
>> > +    guest_load_command = params.get("guest_load_command")
>> > +    guest_load_stop_command =
>> params.get("guest_load_stop_command")
>> > +    host_load_command = params.get("host_load_command")
>> > +    guest_load_instances = int(params.get("guest_load_instances",
>> "1"))
>> > +    host_load_instances = int(params.get("host_load_instances",
>> "0"))
>> > +    # CPU affinity mask for taskset
>> > +    cpu_mask = params.get("cpu_mask", "0xFF")
>> > +    load_duration = float(params.get("load_duration", "30"))
>> > +    rest_duration = float(params.get("rest_duration", "10"))
>> > +    drift_threshold = float(params.get("drift_threshold", "200"))
>> > +    drift_threshold_after_rest =
>> float(params.get("drift_threshold_after_rest",
>> > +                                                  "200"))
>> > +
>> > + 

[PATCH -tip -v13 02/11] x86: x86 instruction decoder build-time selftest

2009-07-24 Thread Masami Hiramatsu
Add a user-space selftest of x86 instruction decoder at kernel build time.
When CONFIG_X86_DECODER_SELFTEST=y, Kbuild builds a test harness of x86
instruction decoder and performs it after building vmlinux.
The test compares the results of objdump and x86 instruction decoder
code and check there are no differences.

Changes from v12:
 - Remove user_include.h.
 - Use $(OBJDUMP) instead of native objdump.
 - Use hostprogs-y and include insn.c and inat.c directly from test_gen_insn.c.

Signed-off-by: Masami Hiramatsu 
Signed-off-by: Jim Keniston 
Cc: Sam Ravnborg 
Cc: H. Peter Anvin 
Cc: Steven Rostedt 
Cc: Ananth N Mavinakayanahalli 
Cc: Srikar Dronamraju 
Cc: Ingo Molnar 
Cc: Frederic Weisbecker 
Cc: Andi Kleen 
Cc: Vegard Nossum 
Cc: Avi Kivity 
Cc: Przemysław Pawełczyk 
---

 arch/x86/Kconfig.debug|9 +++
 arch/x86/Makefile |3 +
 arch/x86/tools/Makefile   |   15 +
 arch/x86/tools/distill.awk|   42 +++
 arch/x86/tools/test_get_len.c |  113 +
 5 files changed, 182 insertions(+), 0 deletions(-)
 create mode 100644 arch/x86/tools/Makefile
 create mode 100644 arch/x86/tools/distill.awk
 create mode 100644 arch/x86/tools/test_get_len.c

diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
index d105f29..7d0b681 100644
--- a/arch/x86/Kconfig.debug
+++ b/arch/x86/Kconfig.debug
@@ -186,6 +186,15 @@ config X86_DS_SELFTEST
 config HAVE_MMIOTRACE_SUPPORT
def_bool y
 
+config X86_DECODER_SELFTEST
+ bool "x86 instruction decoder selftest"
+ depends on DEBUG_KERNEL
+   ---help---
+Perform x86 instruction decoder selftests at build time.
+This option is useful for checking the sanity of x86 instruction
+decoder code.
+If unsure, say "N".
+
 #
 # IO delay types:
 #
diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index 1b68659..5fe16bf 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -154,6 +154,9 @@ all: bzImage
 KBUILD_IMAGE := $(boot)/bzImage
 
 bzImage: vmlinux
+ifeq ($(CONFIG_X86_DECODER_SELFTEST),y)
+   $(Q)$(MAKE) $(build)=arch/x86/tools posttest
+endif
$(Q)$(MAKE) $(build)=$(boot) $(KBUILD_IMAGE)
$(Q)mkdir -p $(objtree)/arch/$(UTS_MACHINE)/boot
$(Q)ln -fsn ../../x86/boot/bzImage 
$(objtree)/arch/$(UTS_MACHINE)/boot/$@
diff --git a/arch/x86/tools/Makefile b/arch/x86/tools/Makefile
new file mode 100644
index 000..3dd626b
--- /dev/null
+++ b/arch/x86/tools/Makefile
@@ -0,0 +1,15 @@
+PHONY += posttest
+quiet_cmd_posttest = TEST$@
+  cmd_posttest = $(OBJDUMP) -d $(objtree)/vmlinux | awk -f 
$(srctree)/arch/x86/tools/distill.awk | $(obj)/test_get_len
+
+posttest: $(obj)/test_get_len vmlinux
+   $(call cmd,posttest)
+
+hostprogs-y:= test_get_len
+
+# -I needed for generated C source and C source which in the kernel tree.
+HOSTCFLAGS_test_get_len.o := -Wall -I$(objtree)/arch/x86/lib/ 
-I$(srctree)/arch/x86/include/ -I$(srctree)/arch/x86/lib/
+
+# Dependancies are also needed.
+$(obj)/test_get_len.o: $(srctree)/arch/x86/lib/insn.c 
$(srctree)/arch/x86/lib/inat.c $(srctree)/arch/x86/include/asm/inat_types.h 
$(srctree)/arch/x86/include/asm/inat.h $(srctree)/arch/x86/include/asm/insn.h 
$(objtree)/arch/x86/lib/inat-tables.c
+
diff --git a/arch/x86/tools/distill.awk b/arch/x86/tools/distill.awk
new file mode 100644
index 000..d433619
--- /dev/null
+++ b/arch/x86/tools/distill.awk
@@ -0,0 +1,42 @@
+#!/bin/awk -f
+# Usage: objdump -d a.out | awk -f distill.awk | ./test_get_len
+# Distills the disassembly as follows:
+# - Removes all lines except the disassembled instructions.
+# - For instructions that exceed 1 line (7 bytes), crams all the hex bytes
+# into a single line.
+# - Remove bad(or prefix only) instructions
+
+BEGIN {
+   prev_addr = ""
+   prev_hex = ""
+   prev_mnemonic = ""
+   bad_expr = 
"(\\(bad\\)|^rex|^.byte|^rep(z|nz)$|^lock$|^es$|^cs$|^ss$|^ds$|^fs$|^gs$|^data(16|32)$|^addr(16|32|64))"
+   fwait_expr = "^9b "
+   fwait_str="9b\tfwait"
+}
+
+/^ *[0-9a-f]+:/ {
+   if (split($0, field, "\t") < 3) {
+   # This is a continuation of the same insn.
+   prev_hex = prev_hex field[2]
+   } else {
+   # Skip bad instructions
+   if (match(prev_mnemonic, bad_expr))
+   prev_addr = ""
+   # Split fwait from other f* instructions
+   if (match(prev_hex, fwait_expr) && prev_mnemonic != "fwait") {
+   printf "%s\t%s\n", prev_addr, fwait_str
+   sub(fwait_expr, "", prev_hex)
+   }
+   if (prev_addr != "")
+   printf "%s\t%s\t%s\n", prev_addr, prev_hex, 
prev_mnemonic
+   prev_addr = field[1]
+   prev_hex = field[2]
+   prev_mnemonic = field[3]
+   }
+}
+
+END {
+   if (prev_addr != "")
+   printf "%s\t%s\t%s\n", prev_addr, prev_hex, prev_mnemonic
+}
diff -

[PATCH -tip -v13 01/11] x86: instruction decoder API

2009-07-24 Thread Masami Hiramatsu
Add x86 instruction decoder to arch-specific libraries. This decoder
can decode x86 instructions used in kernel into prefix, opcode, modrm,
sib, displacement and immediates. This can also show the length of
instructions.

This version introduces instruction attributes for decoding instructions.
The instruction attribute tables are generated from the opcode map file
(x86-opcode-map.txt) by the generator script(gen-insn-attr-x86.awk).

Currently, the opcode maps are based on opcode maps in Intel(R) 64 and
IA-32 Architectures Software Developers Manual Vol.2: Appendix.A,
and consist of below two types of opcode tables.

1-byte/2-bytes/3-bytes opcodes, which has 256 elements, are
written as below;

 Table: table-name
 Referrer: escaped-name
 opcode: mnemonic|GrpXXX [operand1[,operand2...]] [(extra1)[,(extra2)...] [| 
2nd-mnemonic ...]
  (or)
 opcode: escape # escaped-name
 EndTable

Group opcodes, which has 8 elements, are written as below;

 GrpTable: GrpXXX
 reg:  mnemonic [operand1[,operand2...]] [(extra1)[,(extra2)...] [| 
2nd-mnemonic ...]
 EndTable

These opcode maps include a few SSE and FP opcodes (for setup), because
those opcodes are used in the kernel.

Changes from v12:
 - Use arch/x86/tools dir instead of arch/x86/scripts.
 - Remove all EXPORT_SYMBOL_GPL() and linux/module.h.
 - Replace all types defined in linux/types.h.
 - Use inline functions instead of macros.
 - Add VIA's RNG/ACE instructions.

Signed-off-by: Masami Hiramatsu 
Signed-off-by: Jim Keniston 
Acked-by: H. Peter Anvin 
Cc: Sam Ravnborg 
Cc: Steven Rostedt 
Cc: Ananth N Mavinakayanahalli 
Cc: Srikar Dronamraju 
Cc: Ingo Molnar 
Cc: Frederic Weisbecker 
Cc: Andi Kleen 
Cc: Vegard Nossum 
Cc: Avi Kivity 
Cc: Przemysław Pawełczyk 
---

 arch/x86/include/asm/inat.h  |  188 +
 arch/x86/include/asm/inat_types.h|   29 +
 arch/x86/include/asm/insn.h  |  143 +++
 arch/x86/lib/Makefile|   13 +
 arch/x86/lib/inat.c  |   78 
 arch/x86/lib/insn.c  |  464 ++
 arch/x86/lib/x86-opcode-map.txt  |  719 ++
 arch/x86/tools/gen-insn-attr-x86.awk |  314 +++
 8 files changed, 1948 insertions(+), 0 deletions(-)
 create mode 100644 arch/x86/include/asm/inat.h
 create mode 100644 arch/x86/include/asm/inat_types.h
 create mode 100644 arch/x86/include/asm/insn.h
 create mode 100644 arch/x86/lib/inat.c
 create mode 100644 arch/x86/lib/insn.c
 create mode 100644 arch/x86/lib/x86-opcode-map.txt
 create mode 100644 arch/x86/tools/gen-insn-attr-x86.awk

diff --git a/arch/x86/include/asm/inat.h b/arch/x86/include/asm/inat.h
new file mode 100644
index 000..2866fdd
--- /dev/null
+++ b/arch/x86/include/asm/inat.h
@@ -0,0 +1,188 @@
+#ifndef _ASM_X86_INAT_H
+#define _ASM_X86_INAT_H
+/*
+ * x86 instruction attributes
+ *
+ * Written by Masami Hiramatsu 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+#include 
+
+/*
+ * Internal bits. Don't use bitmasks directly, because these bits are
+ * unstable. You should use checking functions.
+ */
+
+#define INAT_OPCODE_TABLE_SIZE 256
+#define INAT_GROUP_TABLE_SIZE 8
+
+/* Legacy instruction prefixes */
+#define INAT_PFX_OPNDSZ1   /* 0x66 */ /* LPFX1 */
+#define INAT_PFX_REPNE 2   /* 0xF2 */ /* LPFX2 */
+#define INAT_PFX_REPE  3   /* 0xF3 */ /* LPFX3 */
+#define INAT_PFX_LOCK  4   /* 0xF0 */
+#define INAT_PFX_CS5   /* 0x2E */
+#define INAT_PFX_DS6   /* 0x3E */
+#define INAT_PFX_ES7   /* 0x26 */
+#define INAT_PFX_FS8   /* 0x64 */
+#define INAT_PFX_GS9   /* 0x65 */
+#define INAT_PFX_SS10  /* 0x36 */
+#define INAT_PFX_ADDRSZ11  /* 0x67 */
+
+#define INAT_LPREFIX_MAX   3
+
+/* Immediate size */
+#define INAT_IMM_BYTE  1
+#define INAT_IMM_WORD  2
+#define INAT_IMM_DWORD 3
+#define INAT_IMM_QWORD 4
+#define INAT_IMM_PTR   5
+#define INAT_IMM_VWORD32   6
+#define INAT_IMM_VWORD 7
+
+/* Legacy prefix */
+#define INAT_PFX_OFFS  0
+#define INAT_PFX_BITS  4
+#define INAT_PFX_MAX((1 << INAT_PFX_BITS) - 1)
+#define INAT_PFX_MASK  (INAT_PFX_MAX << INAT_PFX_OFFS)
+/* Escape opcodes */
+#define INAT_ESC_OFFS  (INAT_PFX_OFFS + INAT_PFX_BITS)
+#define INAT_ESC_BITS  2
+#def

[PATCH -tip -v13 11/11] tracing: Add kprobes event profiling interface

2009-07-24 Thread Masami Hiramatsu
Add profiling interaces for each kprobes event. This interface provides
how many times each probe hit or missed.

Changes from v12:
 - Reformat profile data.

Signed-off-by: Masami Hiramatsu 
Cc: Ananth N Mavinakayanahalli 
Cc: Christoph Hellwig 
Cc: Steven Rostedt 
Cc: Ingo Molnar 
Cc: Frederic Weisbecker 
Cc: Tom Zanussi 
Cc: Li Zefan 
---

 Documentation/trace/kprobetrace.txt |8 +++
 kernel/trace/trace_kprobe.c |   43 +++
 2 files changed, 51 insertions(+), 0 deletions(-)

diff --git a/Documentation/trace/kprobetrace.txt 
b/Documentation/trace/kprobetrace.txt
index 437ad49..9c6be05 100644
--- a/Documentation/trace/kprobetrace.txt
+++ b/Documentation/trace/kprobetrace.txt
@@ -69,6 +69,14 @@ filter:
  names and field names for describing filters.
 
 
+Event Profiling
+---
+ You can check the total number of probe hits and probe miss-hits via
+/sys/kernel/debug/tracing/kprobe_profile.
+ The first column is event name, the second is the number of probe hits,
+the third is the number of probe miss-hits.
+
+
 Usage examples
 --
 To add a probe as a new event, write a new definition to kprobe_events
diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
index 9f9f161..aedf25a 100644
--- a/kernel/trace/trace_kprobe.c
+++ b/kernel/trace/trace_kprobe.c
@@ -178,6 +178,7 @@ struct trace_probe {
struct kprobe   kp;
struct kretproberp;
};
+   unsigned long   nhit;
const char  *symbol;/* symbol name */
struct ftrace_event_callcall;
unsigned intnr_args;
@@ -766,6 +767,37 @@ static const struct file_operations kprobe_events_ops = {
.write  = probes_write,
 };
 
+/* Probes profiling interfaces */
+static int probes_profile_seq_show(struct seq_file *m, void *v)
+{
+   struct trace_probe *tp = v;
+
+   seq_printf(m, "  %-44s %15lu %15lu\n", tp->call.name, tp->nhit,
+  probe_is_return(tp) ? tp->rp.kp.nmissed : tp->kp.nmissed);
+
+   return 0;
+}
+
+static const struct seq_operations profile_seq_op = {
+   .start  = probes_seq_start,
+   .next   = probes_seq_next,
+   .stop   = probes_seq_stop,
+   .show   = probes_profile_seq_show
+};
+
+static int profile_open(struct inode *inode, struct file *file)
+{
+   return seq_open(file, &profile_seq_op);
+}
+
+static const struct file_operations kprobe_profile_ops = {
+   .owner  = THIS_MODULE,
+   .open   = profile_open,
+   .read   = seq_read,
+   .llseek = seq_lseek,
+   .release= seq_release,
+};
+
 /* Kprobe handler */
 static __kprobes int kprobe_trace_func(struct kprobe *kp, struct pt_regs *regs)
 {
@@ -776,6 +808,8 @@ static __kprobes int kprobe_trace_func(struct kprobe *kp, 
struct pt_regs *regs)
unsigned long irq_flags;
struct ftrace_event_call *call = &tp->call;
 
+   tp->nhit++;
+
local_save_flags(irq_flags);
pc = preempt_count();
 
@@ -1152,9 +1186,18 @@ static __init int init_kprobe_trace(void)
entry = debugfs_create_file("kprobe_events", 0644, d_tracer,
NULL, &kprobe_events_ops);
 
+   /* Event list interface */
if (!entry)
pr_warning("Could not create debugfs "
   "'kprobe_events' entry\n");
+
+   /* Profile interface */
+   entry = debugfs_create_file("kprobe_profile", 0444, d_tracer,
+   NULL, &kprobe_profile_ops);
+
+   if (!entry)
+   pr_warning("Could not create debugfs "
+  "'kprobe_profile' entry\n");
return 0;
 }
 fs_initcall(init_kprobe_trace);


-- 
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America), Inc.
Software Solutions Division

e-mail: mhira...@redhat.com
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH -tip -v13 00/11] tracing: kprobe-based event tracer and x86 instruction decoder

2009-07-24 Thread Masami Hiramatsu
Hi,

Here are the patches of kprobe-based event tracer for x86, version 13,
which allows you to probe various kernel events through ftrace interface.
The tracer supports per-probe filtering which allows you to set filters
on each probe and shows formats of each probe. I think this is more
generic integration with ftrace, especially event-tracer.

This version includes below fixes.
 - Update x86 instruction decoder accroding to Sam Ravnborg's advice.
   (PATCH 1/11, 2/11, 3/11, 4/11)
 - Add VIA's RNG/ACE instructions. (PATCH 1/11)
 - Check O_TRUNC instead of !O_APPEND for cleanup. (PATCH 8/11)
 - Reformat profile data. (PATCH 11/11)

This patchset also includes x86(-64) instruction decoder which
supports non-SSE/FP opcodes and includes x86 opcode map. The decoder
is used for finding the instruction boundaries when inserting new
kprobes. I think it will be possible to share this opcode map
with KVM's decoder.
The decoder is tested when building kernel, the test compares the 
results of objdump and the decoder right after building vmlinux.
You can enable that test by CONFIG_X86_DECODER_SELFTEST=y.

This series can be applied on the latest linux-2.6.31-rc3-tip.

This supports only x86(-32/-64) (but porting it on other arch
just needs kprobes/kretprobes and register and stack access APIs).


Enhancement ideas will be added after merging:
- Make a stress test of kprobes on this tracer.
  (see http://sources.redhat.com/ml/systemtap/2009-q2/msg01055.html)
- Easy probe setting wrapper which analyzes dwarf..
- .init function tracing support.
- Support primitive types(long, ulong, int, uint, etc) for args.


Kprobe-based Event Tracer
=

Overview

This tracer is similar to the events tracer which is based on Tracepoint
infrastructure. Instead of Tracepoint, this tracer is based on kprobes(kprobe
and kretprobe). It probes anywhere where kprobes can probe(this means, all
functions body except for __kprobes functions).

Unlike the function tracer, this tracer can probe instructions inside of
kernel functions. It allows you to check which instruction has been executed.

Unlike the Tracepoint based events tracer, this tracer can add new probe points
on the fly.

Similar to the events tracer, this tracer doesn't need to be activated via
current_tracer, instead of that, just set probe points via
/sys/kernel/debug/tracing/kprobe_events. And you can set filters on each
probe events via /sys/kernel/debug/tracing/events/kprobes//filter.


Synopsis of kprobe_events
-
  p[:EVENT] SYMBOL[+offs|-offs]|MEMADDR [FETCHARGS] : Set a probe
  r[:EVENT] SYMBOL[+0] [FETCHARGS]  : Set a return probe

 EVENT  : Event name. If omitted, the event name is generated
  based on SYMBOL+offs or MEMADDR.
 SYMBOL[+offs|-offs]: Symbol+offset where the probe is inserted.
 MEMADDR: Address where the probe is inserted.

 FETCHARGS  : Arguments. Each probe can have up to 128 args.
  %REG  : Fetch register REG
  sN: Fetch Nth entry of stack (N >= 0)
  @ADDR : Fetch memory at ADDR (ADDR should be in kernel)
  @SYM[+|-offs] : Fetch memory at SYM +|- offs (SYM should be a data symbol)
  aN: Fetch function argument. (N >= 0)(*)
  rv: Fetch return value.(**)
  ra: Fetch return address.(**)
  +|-offs(FETCHARG) : fetch memory at FETCHARG +|- offs address.(***)

  (*) aN may not correct on asmlinkaged functions and at the middle of
  function body.
  (**) only for return probe.
  (***) this is useful for fetching a field of data structures.


Per-Probe Event Filtering
-
 Per-probe event filtering feature allows you to set different filter on each
probe and gives you what arguments will be shown in trace buffer. If an event
name is specified right after 'p:' or 'r:' in kprobe_events, the tracer adds
an event under tracing/events/kprobes/, at the directory you can see
'id', 'enabled', 'format' and 'filter'.

enabled:
  You can enable/disable the probe by writing 1 or 0 on it.

format:
  It shows the format of this probe event. It also shows aliases of arguments
 which you specified to kprobe_events.

filter:
  You can write filtering rules of this event. And you can use both of aliase
 names and field names for describing filters.


Event Profiling
---
 You can check the total number of probe hits and probe miss-hits via
/sys/kernel/debug/tracing/kprobe_profile.
 The first column is event name, the second is the number of probe hits,
the third is the number of probe miss-hits.


Usage examples
--
To add a probe as a new event, write a new definition to kprobe_events
as below.

  echo p:myprobe do_sys_open a0 a1 a2 a3 > 
/sys/kernel/debug/tracing/kprobe_events

 This sets a kprobe on the top of do_sys_open() function with recording
1st to 4th arguments as "myprobe" event.

  echo r:myretprobe do_sys_open rv ra >> /sys/kernel/debug/tracing/kprobe_events

[PATCH -tip -v13 10/11] tracing: Generate names for each kprobe event automatically

2009-07-24 Thread Masami Hiramatsu
Generate names for each kprobe event based on the probe point,
and remove generic k*probe event types because there is no user
of those types.

Signed-off-by: Masami Hiramatsu 
Cc: Ananth N Mavinakayanahalli 
Cc: Christoph Hellwig 
Cc: Steven Rostedt 
Cc: Ingo Molnar 
Cc: Frederic Weisbecker 
Cc: Tom Zanussi 
---

 Documentation/trace/kprobetrace.txt |3 +-
 kernel/trace/trace_event_types.h|   18 --
 kernel/trace/trace_kprobe.c |   64 ++-
 3 files changed, 35 insertions(+), 50 deletions(-)

diff --git a/Documentation/trace/kprobetrace.txt 
b/Documentation/trace/kprobetrace.txt
index b29a54b..437ad49 100644
--- a/Documentation/trace/kprobetrace.txt
+++ b/Documentation/trace/kprobetrace.txt
@@ -28,7 +28,8 @@ Synopsis of kprobe_events
   p[:EVENT] SYMBOL[+offs|-offs]|MEMADDR [FETCHARGS]: Set a probe
   r[:EVENT] SYMBOL[+0] [FETCHARGS] : Set a return probe
 
- EVENT : Event name.
+ EVENT : Event name. If omitted, the event name is generated
+ based on SYMBOL+offs or MEMADDR.
  SYMBOL[+offs|-offs]   : Symbol+offset where the probe is inserted.
  MEMADDR   : Address where the probe is inserted.
 
diff --git a/kernel/trace/trace_event_types.h b/kernel/trace/trace_event_types.h
index 186b598..e74f090 100644
--- a/kernel/trace/trace_event_types.h
+++ b/kernel/trace/trace_event_types.h
@@ -175,22 +175,4 @@ TRACE_EVENT_FORMAT(kmem_free, TRACE_KMEM_FREE, 
kmemtrace_free_entry, ignore,
TP_RAW_FMT("type:%u call_site:%lx ptr:%p")
 );
 
-TRACE_EVENT_FORMAT(kprobe, TRACE_KPROBE, kprobe_trace_entry, ignore,
-   TRACE_STRUCT(
-   TRACE_FIELD(unsigned long, ip, ip)
-   TRACE_FIELD(int, nargs, nargs)
-   TRACE_FIELD_ZERO(unsigned long, args)
-   ),
-   TP_RAW_FMT("%08lx: args:0x%lx ...")
-);
-
-TRACE_EVENT_FORMAT(kretprobe, TRACE_KRETPROBE, kretprobe_trace_entry, ignore,
-   TRACE_STRUCT(
-   TRACE_FIELD(unsigned long, func, func)
-   TRACE_FIELD(unsigned long, ret_ip, ret_ip)
-   TRACE_FIELD(int, nargs, nargs)
-   TRACE_FIELD_ZERO(unsigned long, args)
-   ),
-   TP_RAW_FMT("%08lx <- %08lx: args:0x%lx ...")
-);
 #undef TRACE_SYSTEM
diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
index e78c4ea..9f9f161 100644
--- a/kernel/trace/trace_kprobe.c
+++ b/kernel/trace/trace_kprobe.c
@@ -34,6 +34,7 @@
 
 #define MAX_TRACE_ARGS 128
 #define MAX_ARGSTR_LEN 63
+#define MAX_EVENT_NAME_LEN 64
 
 /* currently, trace_kprobe only supports X86. */
 
@@ -272,11 +273,11 @@ static struct trace_probe *alloc_trace_probe(const char 
*symbol,
if (!tp->symbol)
goto error;
}
-   if (event) {
-   tp->call.name = kstrdup(event, GFP_KERNEL);
-   if (!tp->call.name)
-   goto error;
-   }
+   if (!event)
+   goto error;
+   tp->call.name = kstrdup(event, GFP_KERNEL);
+   if (!tp->call.name)
+   goto error;
 
INIT_LIST_HEAD(&tp->list);
return tp;
@@ -306,7 +307,7 @@ static struct trace_probe *find_probe_event(const char 
*event)
struct trace_probe *tp;
 
list_for_each_entry(tp, &probe_list, list)
-   if (tp->call.name && !strcmp(tp->call.name, event))
+   if (!strcmp(tp->call.name, event))
return tp;
return NULL;
 }
@@ -322,8 +323,7 @@ static void __unregister_trace_probe(struct trace_probe *tp)
 /* Unregister a trace_probe and probe_event: call with locking probe_lock */
 static void unregister_trace_probe(struct trace_probe *tp)
 {
-   if (tp->call.name)
-   unregister_probe_event(tp);
+   unregister_probe_event(tp);
__unregister_trace_probe(tp);
list_del(&tp->list);
 }
@@ -352,18 +352,16 @@ static int register_trace_probe(struct trace_probe *tp)
goto end;
}
/* register as an event */
-   if (tp->call.name) {
-   old_tp = find_probe_event(tp->call.name);
-   if (old_tp) {
-   /* delete old event */
-   unregister_trace_probe(old_tp);
-   free_trace_probe(old_tp);
-   }
-   ret = register_probe_event(tp);
-   if (ret) {
-   pr_warning("Faild to register probe event(%d)\n", ret);
-   __unregister_trace_probe(tp);
-   }
+   old_tp = find_probe_event(tp->call.name);
+   if (old_tp) {
+   /* delete old event */
+   unregister_trace_probe(old_tp);
+   free_trace_probe(old_tp);
+   }
+   ret = register_probe_event(tp);
+   if (ret) {
+   pr_warning("Faild to register probe event(%d)\n", ret);
+   __unregister_trace_probe(tp);
}
li

[PATCH -tip -v13 08/11] tracing: add kprobe-based event tracer

2009-07-24 Thread Masami Hiramatsu
Add kprobes-based event tracer on ftrace.

This tracer is similar to the events tracer which is based on Tracepoint
infrastructure. Instead of Tracepoint, this tracer is based on kprobes
(kprobe and kretprobe). It probes anywhere where kprobes can probe(this
 means, all functions body except for __kprobes functions).

Similar to the events tracer, this tracer doesn't need to be activated via
current_tracer, instead of that, just set probe points via
/sys/kernel/debug/tracing/kprobe_events. And you can set filters on each
probe events via /sys/kernel/debug/tracing/events/kprobes//filter.

This tracer supports following probe arguments for each probe.

  %REG  : Fetch register REG
  sN: Fetch Nth entry of stack (N >= 0)
  @ADDR : Fetch memory at ADDR (ADDR should be in kernel)
  @SYM[+|-offs] : Fetch memory at SYM +|- offs (SYM should be a data symbol)
  aN: Fetch function argument. (N >= 0)
  rv: Fetch return value.
  ra: Fetch return address.
  +|-offs(FETCHARG) : fetch memory at FETCHARG +|- offs address.

See Documentation/trace/kprobetrace.txt for details.

Changes from v12:
 - Check O_TRUNC for cleanup events, instead of !O_APPEND.

Signed-off-by: Masami Hiramatsu 
Acked-by: Ananth N Mavinakayanahalli 
Cc: Christoph Hellwig 
Cc: Steven Rostedt 
Cc: Ingo Molnar 
Cc: Frederic Weisbecker 
Cc: Tom Zanussi 
Cc: Li Zefan 
---

 Documentation/trace/kprobetrace.txt |  138 
 kernel/trace/Kconfig|   12 
 kernel/trace/Makefile   |1 
 kernel/trace/trace.h|   29 +
 kernel/trace/trace_event_types.h|   18 +
 kernel/trace/trace_kprobe.c | 1193 +++
 6 files changed, 1391 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/trace/kprobetrace.txt
 create mode 100644 kernel/trace/trace_kprobe.c

diff --git a/Documentation/trace/kprobetrace.txt 
b/Documentation/trace/kprobetrace.txt
new file mode 100644
index 000..9ad907c
--- /dev/null
+++ b/Documentation/trace/kprobetrace.txt
@@ -0,0 +1,138 @@
+ Kprobe-based Event Tracer
+ =
+
+ Documentation is written by Masami Hiramatsu
+
+
+Overview
+
+This tracer is similar to the events tracer which is based on Tracepoint
+infrastructure. Instead of Tracepoint, this tracer is based on kprobes(kprobe
+and kretprobe). It probes anywhere where kprobes can probe(this means, all
+functions body except for __kprobes functions).
+
+Unlike the function tracer, this tracer can probe instructions inside of
+kernel functions. It allows you to check which instruction has been executed.
+
+Unlike the Tracepoint based events tracer, this tracer can add and remove
+probe points on the fly.
+
+Similar to the events tracer, this tracer doesn't need to be activated via
+current_tracer, instead of that, just set probe points via
+/sys/kernel/debug/tracing/kprobe_events. And you can set filters on each
+probe events via /sys/kernel/debug/tracing/events/kprobes//filter.
+
+
+Synopsis of kprobe_events
+-
+  p[:EVENT] SYMBOL[+offs|-offs]|MEMADDR [FETCHARGS]: Set a probe
+  r[:EVENT] SYMBOL[+0] [FETCHARGS] : Set a return probe
+
+ EVENT : Event name.
+ SYMBOL[+offs|-offs]   : Symbol+offset where the probe is inserted.
+ MEMADDR   : Address where the probe is inserted.
+
+ FETCHARGS : Arguments.
+  %REG : Fetch register REG
+  sN   : Fetch Nth entry of stack (N >= 0)
+  @ADDR: Fetch memory at ADDR (ADDR should be in kernel)
+  @SYM[+|-offs]: Fetch memory at SYM +|- offs (SYM should be a data 
symbol)
+  aN   : Fetch function argument. (N >= 0)(*)
+  rv   : Fetch return value.(**)
+  ra   : Fetch return address.(**)
+  +|-offs(FETCHARG) : fetch memory at FETCHARG +|- offs address.(***)
+
+  (*) aN may not correct on asmlinkaged functions and at the middle of
+  function body.
+  (**) only for return probe.
+  (***) this is useful for fetching a field of data structures.
+
+
+Per-Probe Event Filtering
+-
+ Per-probe event filtering feature allows you to set different filter on each
+probe and gives you what arguments will be shown in trace buffer. If an event
+name is specified right after 'p:' or 'r:' in kprobe_events, the tracer adds
+an event under tracing/events/kprobes/, at the directory you can see
+'id', 'enabled', 'format' and 'filter'.
+
+enabled:
+  You can enable/disable the probe by writing 1 or 0 on it.
+
+format:
+  It shows the format of this probe event. It also shows aliases of arguments
+ which you specified to kprobe_events.
+
+filter:
+  You can write filtering rules of this event. And you can use both of aliase
+ names and field names for describing filters.
+
+
+Usage examples
+--
+To add a probe as a new event, write a new definition to kprobe_events
+as below.
+
+  echo p:myprobe do_sys_open a0 a1 a2 a3 > 
/sys/kernel/debug/t

[PATCH -tip -v13 09/11] tracing: Kprobe-tracer supports more than 6 arguments

2009-07-24 Thread Masami Hiramatsu
Support up to 128 arguments for each kprobes event.

Signed-off-by: Masami Hiramatsu 
Cc: Ananth N Mavinakayanahalli 
Cc: Christoph Hellwig 
Cc: Steven Rostedt 
Cc: Ingo Molnar 
Cc: Frederic Weisbecker 
Cc: Tom Zanussi 
---

 Documentation/trace/kprobetrace.txt |2 +-
 kernel/trace/trace_kprobe.c |   21 +
 2 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/Documentation/trace/kprobetrace.txt 
b/Documentation/trace/kprobetrace.txt
index 9ad907c..b29a54b 100644
--- a/Documentation/trace/kprobetrace.txt
+++ b/Documentation/trace/kprobetrace.txt
@@ -32,7 +32,7 @@ Synopsis of kprobe_events
  SYMBOL[+offs|-offs]   : Symbol+offset where the probe is inserted.
  MEMADDR   : Address where the probe is inserted.
 
- FETCHARGS : Arguments.
+ FETCHARGS : Arguments. Each probe can have up to 128 args.
   %REG : Fetch register REG
   sN   : Fetch Nth entry of stack (N >= 0)
   @ADDR: Fetch memory at ADDR (ADDR should be in kernel)
diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
index 39491f0..e78c4ea 100644
--- a/kernel/trace/trace_kprobe.c
+++ b/kernel/trace/trace_kprobe.c
@@ -32,7 +32,7 @@
 #include "trace.h"
 #include "trace_output.h"
 
-#define TRACE_KPROBE_ARGS 6
+#define MAX_TRACE_ARGS 128
 #define MAX_ARGSTR_LEN 63
 
 /* currently, trace_kprobe only supports X86. */
@@ -178,11 +178,15 @@ struct trace_probe {
struct kretproberp;
};
const char  *symbol;/* symbol name */
-   unsigned intnr_args;
-   struct fetch_func   args[TRACE_KPROBE_ARGS];
struct ftrace_event_callcall;
+   unsigned intnr_args;
+   struct fetch_func   args[];
 };
 
+#define SIZEOF_TRACE_PROBE(n)  \
+   (offsetof(struct trace_probe, args) +   \
+   (sizeof(struct fetch_func) * (n)))
+
 static int kprobe_trace_func(struct kprobe *kp, struct pt_regs *regs);
 static int kretprobe_trace_func(struct kretprobe_instance *ri,
struct pt_regs *regs);
@@ -255,11 +259,11 @@ static DEFINE_MUTEX(probe_lock);
 static LIST_HEAD(probe_list);
 
 static struct trace_probe *alloc_trace_probe(const char *symbol,
-const char *event)
+const char *event, int nargs)
 {
struct trace_probe *tp;
 
-   tp = kzalloc(sizeof(struct trace_probe), GFP_KERNEL);
+   tp = kzalloc(SIZEOF_TRACE_PROBE(nargs), GFP_KERNEL);
if (!tp)
return ERR_PTR(-ENOMEM);
 
@@ -559,9 +563,10 @@ static int create_trace_probe(int argc, char **argv)
if (offset && is_return)
return -EINVAL;
}
+   argc -= 2; argv += 2;
 
/* setup a probe */
-   tp = alloc_trace_probe(symbol, event);
+   tp = alloc_trace_probe(symbol, event, argc);
if (IS_ERR(tp))
return PTR_ERR(tp);
 
@@ -580,8 +585,8 @@ static int create_trace_probe(int argc, char **argv)
kp->addr = addr;
 
/* parse arguments */
-   argc -= 2; argv += 2; ret = 0;
-   for (i = 0; i < argc && i < TRACE_KPROBE_ARGS; i++) {
+   ret = 0;
+   for (i = 0; i < argc && i < MAX_TRACE_ARGS; i++) {
if (strlen(argv[i]) > MAX_ARGSTR_LEN) {
pr_info("Argument%d(%s) is too long.\n", i, argv[i]);
ret = -ENOSPC;


-- 
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America), Inc.
Software Solutions Division

e-mail: mhira...@redhat.com
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH -tip -v13 05/11] x86: add pt_regs register and stack access APIs

2009-07-24 Thread Masami Hiramatsu
Add following APIs for accessing registers and stack entries from pt_regs.
These APIs are required by kprobes-based event tracer on ftrace.
Some other debugging tools might be able to use it too.

- regs_query_register_offset(const char *name)
   Query the offset of "name" register.

- regs_query_register_name(unsigned int offset)
   Query the name of register by its offset.

- regs_get_register(struct pt_regs *regs, unsigned int offset)
   Get the value of a register by its offset.

- regs_within_kernel_stack(struct pt_regs *regs, unsigned long addr)
   Check the address is in the kernel stack.

- regs_get_kernel_stack_nth(struct pt_regs *reg, unsigned int nth)
   Get Nth entry of the kernel stack. (N >= 0)

- regs_get_argument_nth(struct pt_regs *reg, unsigned int nth)
   Get Nth argument at function call. (N >= 0)


Signed-off-by: Masami Hiramatsu 
Reviewed-by: Frederic Weisbecker 
Cc: Andi Kleen 
Cc: Christoph Hellwig 
Cc: Steven Rostedt 
Cc: Ananth N Mavinakayanahalli 
Cc: Ingo Molnar 
Cc: Frederic Weisbecker 
Cc: Roland McGrath 
Cc: Srikar Dronamraju 
Cc: linux-a...@vger.kernel.org
---

 arch/x86/include/asm/ptrace.h |   62 +++
 arch/x86/kernel/ptrace.c  |  112 +
 2 files changed, 174 insertions(+), 0 deletions(-)

diff --git a/arch/x86/include/asm/ptrace.h b/arch/x86/include/asm/ptrace.h
index 0f0d908..a3d49dd 100644
--- a/arch/x86/include/asm/ptrace.h
+++ b/arch/x86/include/asm/ptrace.h
@@ -7,6 +7,7 @@
 
 #ifdef __KERNEL__
 #include 
+#include 
 #endif
 
 #ifndef __ASSEMBLY__
@@ -216,6 +217,67 @@ static inline unsigned long user_stack_pointer(struct 
pt_regs *regs)
return regs->sp;
 }
 
+/* Query offset/name of register from its name/offset */
+extern int regs_query_register_offset(const char *name);
+extern const char *regs_query_register_name(unsigned int offset);
+#define MAX_REG_OFFSET (offsetof(struct pt_regs, ss))
+
+/**
+ * regs_get_register() - get register value from its offset
+ * @regs:  pt_regs from which register value is gotten.
+ * @offset:offset number of the register.
+ *
+ * regs_get_register returns the value of a register whose offset from @regs
+ * is @offset. The @offset is the offset of the register in struct pt_regs.
+ * If @offset is bigger than MAX_REG_OFFSET, this returns 0.
+ */
+static inline unsigned long regs_get_register(struct pt_regs *regs,
+ unsigned int offset)
+{
+   if (unlikely(offset > MAX_REG_OFFSET))
+   return 0;
+   return *(unsigned long *)((unsigned long)regs + offset);
+}
+
+/**
+ * regs_within_kernel_stack() - check the address in the stack
+ * @regs:  pt_regs which contains kernel stack pointer.
+ * @addr:  address which is checked.
+ *
+ * regs_within_kenel_stack() checks @addr is within the kernel stack page(s).
+ * If @addr is within the kernel stack, it returns true. If not, returns false.
+ */
+static inline int regs_within_kernel_stack(struct pt_regs *regs,
+  unsigned long addr)
+{
+   return ((addr & ~(THREAD_SIZE - 1))  ==
+   (kernel_stack_pointer(regs) & ~(THREAD_SIZE - 1)));
+}
+
+/**
+ * regs_get_kernel_stack_nth() - get Nth entry of the stack
+ * @regs:  pt_regs which contains kernel stack pointer.
+ * @n: stack entry number.
+ *
+ * regs_get_kernel_stack_nth() returns @n th entry of the kernel stack which
+ * is specifined by @regs. If the @n th entry is NOT in the kernel stack,
+ * this returns 0.
+ */
+static inline unsigned long regs_get_kernel_stack_nth(struct pt_regs *regs,
+ unsigned int n)
+{
+   unsigned long *addr = (unsigned long *)kernel_stack_pointer(regs);
+   addr += n;
+   if (regs_within_kernel_stack(regs, (unsigned long)addr))
+   return *addr;
+   else
+   return 0;
+}
+
+/* Get Nth argument at function call */
+extern unsigned long regs_get_argument_nth(struct pt_regs *regs,
+  unsigned int n);
+
 /*
  * These are defined as per linux/ptrace.h, which see.
  */
diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
index cabdabc..32729ec 100644
--- a/arch/x86/kernel/ptrace.c
+++ b/arch/x86/kernel/ptrace.c
@@ -49,6 +49,118 @@ enum x86_regset {
REGSET_IOPERM32,
 };
 
+struct pt_regs_offset {
+   const char *name;
+   int offset;
+};
+
+#define REG_OFFSET_NAME(r) {.name = #r, .offset = offsetof(struct pt_regs, r)}
+#define REG_OFFSET_END {.name = NULL, .offset = 0}
+
+static const struct pt_regs_offset regoffset_table[] = {
+#ifdef CONFIG_X86_64
+   REG_OFFSET_NAME(r15),
+   REG_OFFSET_NAME(r14),
+   REG_OFFSET_NAME(r13),
+   REG_OFFSET_NAME(r12),
+   REG_OFFSET_NAME(r11),
+   REG_OFFSET_NAME(r10),
+   REG_OFFSET_NAME(r9),
+   REG_OFFSET_NAME(r8),
+#endif
+   REG_OFFSET_NAME(bx),
+   REG_OFFSET_NAME(cx),
+ 

[PATCH -tip -v13 06/11] tracing: ftrace dynamic ftrace_event_call support

2009-07-24 Thread Masami Hiramatsu
Add dynamic ftrace_event_call support to ftrace. Trace engines can adds new
ftrace_event_call to ftrace on the fly. Each operator functions of the call
takes a ftrace_event_call data structure as an argument, because these
functions may be shared among several ftrace_event_calls.

Signed-off-by: Masami Hiramatsu 
Acked-by: Frederic Weisbecker 
Cc: Steven Rostedt 
Cc: Ingo Molnar 
Cc: Tom Zanussi 
---

 include/linux/ftrace_event.h |   13 +---
 include/trace/ftrace.h   |   22 ++---
 kernel/trace/trace_events.c  |   72 --
 kernel/trace/trace_export.c  |   27 
 4 files changed, 86 insertions(+), 48 deletions(-)

diff --git a/include/linux/ftrace_event.h b/include/linux/ftrace_event.h
index 5c093ff..f7733b6 100644
--- a/include/linux/ftrace_event.h
+++ b/include/linux/ftrace_event.h
@@ -108,12 +108,13 @@ struct ftrace_event_call {
struct dentry   *dir;
struct trace_event  *event;
int enabled;
-   int (*regfunc)(void);
-   void(*unregfunc)(void);
+   int (*regfunc)(struct ftrace_event_call *);
+   void(*unregfunc)(struct ftrace_event_call *);
int id;
-   int (*raw_init)(void);
-   int (*show_format)(struct trace_seq *s);
-   int (*define_fields)(void);
+   int (*raw_init)(struct ftrace_event_call *);
+   int (*show_format)(struct ftrace_event_call *,
+  struct trace_seq *);
+   int (*define_fields)(struct ftrace_event_call *);
struct list_headfields;
int filter_active;
void*filter;
@@ -138,6 +139,8 @@ extern int filter_current_check_discard(struct 
ftrace_event_call *call,
 
 extern int trace_define_field(struct ftrace_event_call *call, char *type,
  char *name, int offset, int size, int is_signed);
+extern int trace_add_event_call(struct ftrace_event_call *call);
+extern void trace_remove_event_call(struct ftrace_event_call *call);
 
 #define is_signed_type(type)   (((type)(-1)) < 0)
 
diff --git a/include/trace/ftrace.h b/include/trace/ftrace.h
index 1867553..d696580 100644
--- a/include/trace/ftrace.h
+++ b/include/trace/ftrace.h
@@ -147,7 +147,8 @@
 #undef TRACE_EVENT
 #define TRACE_EVENT(call, proto, args, tstruct, func, print)   \
 static int \
-ftrace_format_##call(struct trace_seq *s)  \
+ftrace_format_##call(struct ftrace_event_call *event_call, \
+struct trace_seq *s)   \
 {  \
struct ftrace_raw_##call field __attribute__((unused)); \
int ret = 0;\
@@ -289,10 +290,9 @@ ftrace_raw_output_##call(struct trace_iterator *iter, int 
flags)   \
 #undef TRACE_EVENT
 #define TRACE_EVENT(call, proto, args, tstruct, func, print)   \
 int\
-ftrace_define_fields_##call(void)  \
+ftrace_define_fields_##call(struct ftrace_event_call *event_call)  \
 {  \
struct ftrace_raw_##call field; \
-   struct ftrace_event_call *event_call = &event_##call;   \
int ret;\
\
__common_field(int, type, 1);   \
@@ -355,7 +355,7 @@ static inline int ftrace_get_offsets_##call(
\
  * event_trace_printk(_RET_IP_, ": " );
  * }
  *
- * static int ftrace_reg_event_(void)
+ * static int ftrace_reg_event_(struct ftrace_event_call *unused)
  * {
  * int ret;
  *
@@ -366,7 +366,7 @@ static inline int ftrace_get_offsets_##call(
\
  * return ret;
  * }
  *
- * static void ftrace_unreg_event_(void)
+ * static void ftrace_unreg_event_(struct ftrace_event_call *unused)
  * {
  * unregister_trace_(ftrace_event_);
  * }
@@ -399,7 +399,7 @@ static inline int ftrace_get_offsets_##call(
\
  * trace_current_buffer_unlock_commit(event, irq_flags, pc);
  * }
  *
- * static int ftrace_raw_reg_event_(void)
+ * static int ftrace_raw_reg_event_(struct ftrace_event_call *unused)
  * {
  * int ret;
  *
@@ -410,7 +410,7 @@ static inline int ftrace_get_offsets_##call(
\
  * return re

[PATCH -tip -v13 07/11] tracing: Introduce TRACE_FIELD_ZERO() macro

2009-07-24 Thread Masami Hiramatsu
Use TRACE_FIELD_ZERO(type, item) instead of TRACE_FIELD_ZERO_CHAR(item).
This also includes a fix of TRACE_ZERO_CHAR() macro.

Signed-off-by: Masami Hiramatsu 
Cc: Steven Rostedt 
Cc: Ingo Molnar 
Cc: Tom Zanussi 
Cc: Frederic Weisbecker 
---

 kernel/trace/trace_event_types.h |4 ++--
 kernel/trace/trace_export.c  |   16 
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/kernel/trace/trace_event_types.h b/kernel/trace/trace_event_types.h
index 6db005e..e74f090 100644
--- a/kernel/trace/trace_event_types.h
+++ b/kernel/trace/trace_event_types.h
@@ -109,7 +109,7 @@ TRACE_EVENT_FORMAT(bprint, TRACE_BPRINT, bprint_entry, 
ignore,
TRACE_STRUCT(
TRACE_FIELD(unsigned long, ip, ip)
TRACE_FIELD(char *, fmt, fmt)
-   TRACE_FIELD_ZERO_CHAR(buf)
+   TRACE_FIELD_ZERO(char, buf)
),
TP_RAW_FMT("%08lx (%d) fmt:%p %s")
 );
@@ -117,7 +117,7 @@ TRACE_EVENT_FORMAT(bprint, TRACE_BPRINT, bprint_entry, 
ignore,
 TRACE_EVENT_FORMAT(print, TRACE_PRINT, print_entry, ignore,
TRACE_STRUCT(
TRACE_FIELD(unsigned long, ip, ip)
-   TRACE_FIELD_ZERO_CHAR(buf)
+   TRACE_FIELD_ZERO(char, buf)
),
TP_RAW_FMT("%08lx (%d) fmt:%p %s")
 );
diff --git a/kernel/trace/trace_export.c b/kernel/trace/trace_export.c
index 7cee79d..23125b5 100644
--- a/kernel/trace/trace_export.c
+++ b/kernel/trace/trace_export.c
@@ -42,9 +42,9 @@ extern void __bad_type_size(void);
if (!ret)   \
return 0;
 
-#undef TRACE_FIELD_ZERO_CHAR
-#define TRACE_FIELD_ZERO_CHAR(item)\
-   ret = trace_seq_printf(s, "\tfield:char " #item ";\t"   \
+#undef TRACE_FIELD_ZERO
+#define TRACE_FIELD_ZERO(type, item)   \
+   ret = trace_seq_printf(s, "\tfield:" #type " " #item ";\t"  \
   "offset:%u;\tsize:0;\n", \
   (unsigned int)offsetof(typeof(field), item)); \
if (!ret)   \
@@ -90,9 +90,6 @@ ftrace_format_##call(struct ftrace_event_call *dummy, struct 
trace_seq *s)\
 
 #include "trace_event_types.h"
 
-#undef TRACE_ZERO_CHAR
-#define TRACE_ZERO_CHAR(arg)
-
 #undef TRACE_FIELD
 #define TRACE_FIELD(type, item, assign)\
entry->item = assign;
@@ -105,6 +102,9 @@ ftrace_format_##call(struct ftrace_event_call *dummy, 
struct trace_seq *s)\
 #define TRACE_FIELD_SIGN(type, item, assign, is_signed)\
TRACE_FIELD(type, item, assign)
 
+#undef TRACE_FIELD_ZERO
+#define TRACE_FIELD_ZERO(type, item)
+
 #undef TP_CMD
 #define TP_CMD(cmd...) cmd
 
@@ -176,8 +176,8 @@ __attribute__((section("_ftrace_events"))) event_##call = { 
\
if (ret)\
return ret;
 
-#undef TRACE_FIELD_ZERO_CHAR
-#define TRACE_FIELD_ZERO_CHAR(item)
+#undef TRACE_FIELD_ZERO
+#define TRACE_FIELD_ZERO(type, item)
 
 #undef TRACE_EVENT_FORMAT
 #define TRACE_EVENT_FORMAT(call, proto, args, fmt, tstruct, tpfmt) \


-- 
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America), Inc.
Software Solutions Division

e-mail: mhira...@redhat.com
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH -tip -v13 04/11] kprobes: cleanup fix_riprel() using insn decoder on x86

2009-07-24 Thread Masami Hiramatsu
Cleanup fix_riprel() in arch/x86/kernel/kprobes.c by using x86 instruction
decoder.

Signed-off-by: Masami Hiramatsu 
Cc: Ananth N Mavinakayanahalli 
Cc: Jim Keniston 
Cc: Ingo Molnar 
---

 arch/x86/kernel/kprobes.c |  128 -
 1 files changed, 23 insertions(+), 105 deletions(-)

diff --git a/arch/x86/kernel/kprobes.c b/arch/x86/kernel/kprobes.c
index 80d493f..98f48d0 100644
--- a/arch/x86/kernel/kprobes.c
+++ b/arch/x86/kernel/kprobes.c
@@ -109,50 +109,6 @@ static const u32 twobyte_is_boostable[256 / 32] = {
/*  --- */
/*  0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f  */
 };
-static const u32 onebyte_has_modrm[256 / 32] = {
-   /*  0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f  */
-   /*  --- */
-   W(0x00, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0) | /* 00 */
-   W(0x10, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0) , /* 10 */
-   W(0x20, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0) | /* 20 */
-   W(0x30, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0) , /* 30 */
-   W(0x40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) | /* 40 */
-   W(0x50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) , /* 50 */
-   W(0x60, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0) | /* 60 */
-   W(0x70, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) , /* 70 */
-   W(0x80, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) | /* 80 */
-   W(0x90, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) , /* 90 */
-   W(0xa0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) | /* a0 */
-   W(0xb0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) , /* b0 */
-   W(0xc0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0) | /* c0 */
-   W(0xd0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1) , /* d0 */
-   W(0xe0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) | /* e0 */
-   W(0xf0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1)   /* f0 */
-   /*  --- */
-   /*  0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f  */
-};
-static const u32 twobyte_has_modrm[256 / 32] = {
-   /*  0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f  */
-   /*  --- */
-   W(0x00, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1) | /* 0f */
-   W(0x10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0) , /* 1f */
-   W(0x20, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1) | /* 2f */
-   W(0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) , /* 3f */
-   W(0x40, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) | /* 4f */
-   W(0x50, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) , /* 5f */
-   W(0x60, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) | /* 6f */
-   W(0x70, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1) , /* 7f */
-   W(0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) | /* 8f */
-   W(0x90, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) , /* 9f */
-   W(0xa0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1) | /* af */
-   W(0xb0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1) , /* bf */
-   W(0xc0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0) | /* cf */
-   W(0xd0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) , /* df */
-   W(0xe0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) | /* ef */
-   W(0xf0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0)   /* ff */
-   /*  --- */
-   /*  0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f  */
-};
 #undef W
 
 struct kretprobe_blackpoint kretprobe_blacklist[] = {
@@ -345,68 +301,30 @@ static int __kprobes is_IF_modifier(kprobe_opcode_t *insn)
 static void __kprobes fix_riprel(struct kprobe *p)
 {
 #ifdef CONFIG_X86_64
-   u8 *insn = p->ainsn.insn;
-   s64 disp;
-   int need_modrm;
-
-   /* Skip legacy instruction prefixes.  */
-   while (1) {
-   switch (*insn) {
-   case 0x66:
-   case 0x67:
-   case 0x2e:
-   case 0x3e:
-   case 0x26:
-   case 0x64:
-   case 0x65:
-   case 0x36:
-   case 0xf0:
-   case 0xf3:
-   case 0xf2:
-   ++insn;
-   continue;
-   }
-   break;
-   }
+   struct insn insn;
+   kernel_insn_init(&insn, p->ainsn.insn);
 
-   /* Skip REX instruction prefix.  */
-   if (is_REX_prefix(insn))
-   ++insn;
-
-   if (*insn == 0x0f) {
-   /* Two-byte opcode.  */
-   ++insn;
-   need_modrm = test_bit(*insn,
- (unsi

[PATCH -tip -v13 03/11] kprobes: checks probe address is instruction boudary on x86

2009-07-24 Thread Masami Hiramatsu
Ensure safeness of inserting kprobes by checking whether the specified
address is at the first byte of a instruction on x86.
This is done by decoding probed function from its head to the probe point.

Signed-off-by: Masami Hiramatsu 
Acked-by: Ananth N Mavinakayanahalli 
Cc: Jim Keniston 
Cc: Ingo Molnar 
---

 arch/x86/kernel/kprobes.c |   69 +
 1 files changed, 69 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kernel/kprobes.c b/arch/x86/kernel/kprobes.c
index b5b1848..80d493f 100644
--- a/arch/x86/kernel/kprobes.c
+++ b/arch/x86/kernel/kprobes.c
@@ -48,6 +48,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -55,6 +56,7 @@
 #include 
 #include 
 #include 
+#include 
 
 void jprobe_return_end(void);
 
@@ -245,6 +247,71 @@ retry:
}
 }
 
+/* Recover the probed instruction at addr for further analysis. */
+static int recover_probed_instruction(kprobe_opcode_t *buf, unsigned long addr)
+{
+   struct kprobe *kp;
+   kp = get_kprobe((void *)addr);
+   if (!kp)
+   return -EINVAL;
+
+   /*
+*  Basically, kp->ainsn.insn has an original instruction.
+*  However, RIP-relative instruction can not do single-stepping
+*  at different place, fix_riprel() tweaks the displacement of
+*  that instruction. In that case, we can't recover the instruction
+*  from the kp->ainsn.insn.
+*
+*  On the other hand, kp->opcode has a copy of the first byte of
+*  the probed instruction, which is overwritten by int3. And
+*  the instruction at kp->addr is not modified by kprobes except
+*  for the first byte, we can recover the original instruction
+*  from it and kp->opcode.
+*/
+   memcpy(buf, kp->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
+   buf[0] = kp->opcode;
+   return 0;
+}
+
+/* Dummy buffers for kallsyms_lookup */
+static char __dummy_buf[KSYM_NAME_LEN];
+
+/* Check if paddr is at an instruction boundary */
+static int __kprobes can_probe(unsigned long paddr)
+{
+   int ret;
+   unsigned long addr, offset = 0;
+   struct insn insn;
+   kprobe_opcode_t buf[MAX_INSN_SIZE];
+
+   if (!kallsyms_lookup(paddr, NULL, &offset, NULL, __dummy_buf))
+   return 0;
+
+   /* Decode instructions */
+   addr = paddr - offset;
+   while (addr < paddr) {
+   kernel_insn_init(&insn, (void *)addr);
+   insn_get_opcode(&insn);
+
+   /* Check if the instruction has been modified. */
+   if (insn.opcode.bytes[0] == BREAKPOINT_INSTRUCTION) {
+   ret = recover_probed_instruction(buf, addr);
+   if (ret)
+   /*
+* Another debugging subsystem might insert
+* this breakpoint. In that case, we can't
+* recover it.
+*/
+   return 0;
+   kernel_insn_init(&insn, buf);
+   }
+   insn_get_length(&insn);
+   addr += insn.length;
+   }
+
+   return (addr == paddr);
+}
+
 /*
  * Returns non-zero if opcode modifies the interrupt flag.
  */
@@ -360,6 +427,8 @@ static void __kprobes arch_copy_kprobe(struct kprobe *p)
 
 int __kprobes arch_prepare_kprobe(struct kprobe *p)
 {
+   if (!can_probe((unsigned long)p->addr))
+   return -EILSEQ;
/* insn: must be on special executable page on x86. */
p->ainsn.insn = get_insn_slot();
if (!p->ainsn.insn)


-- 
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America), Inc.
Software Solutions Division

e-mail: mhira...@redhat.com
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [Autotest] [KVM-AUTOTEST PATCH 11/17] KVM test: kvm_tests.cfg.sample: convert PPM files to PNG by default

2009-07-24 Thread Lucas Meneghel Rodrigues
On Mon, Jul 20, 2009 at 12:07 PM, Michael Goldish wrote:
> By default, always remove PPM files, and keep PNG files only for failed tests.
> This shouldn't do much harm, because while PPMs can be incorporated directly
> into step files, PNGs can be converted back to PPMs easily, and take less disk
> space.
> (PNG is a lossless compression format.)
>
> The 'keep_ppm_files' and 'keep_ppm_files_on_error' settings are commented out
> so the user can easily enable them if desired.

Applied.

> Signed-off-by: Michael Goldish 
> ---
>  client/tests/kvm/kvm_tests.cfg.sample |    5 +++--
>  1 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/client/tests/kvm/kvm_tests.cfg.sample 
> b/client/tests/kvm/kvm_tests.cfg.sample
> index 02112b7..1288952 100644
> --- a/client/tests/kvm/kvm_tests.cfg.sample
> +++ b/client/tests/kvm/kvm_tests.cfg.sample
> @@ -8,8 +8,9 @@ main_vm = vm1
>
>  # Some preprocessor/postprocessor params
>  start_vm = yes
> -keep_ppm_files = no
> -keep_ppm_files_on_error = yes
> +convert_ppm_files_to_png_on_error = yes
> +#keep_ppm_files = yes
> +#keep_ppm_files_on_error = yes
>  kill_vm = no
>  kill_vm_gracefully = yes
>
> --
> 1.5.4.1
>
> ___
> Autotest mailing list
> autot...@test.kernel.org
> http://test.kernel.org/cgi-bin/mailman/listinfo/autotest
>



-- 
Lucas Meneghel
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [Autotest] [KVM-AUTOTEST PATCH 10/17] KVM test: optionally convert PPM files to PNG format after test

2009-07-24 Thread Lucas Meneghel Rodrigues
On Mon, Jul 20, 2009 at 12:07 PM, Michael Goldish wrote:
> This is intended to save disk space.  Requires ImageMagick (uses mogrify).
>
> To enable:
> convert_ppm_files_to_png = yes
>
> To enable only for failed tests:
> convert_ppm_files_to_png_on_error = yes
>
> Reminder: by default PPM files are removed after the test (and after the
> conversion, if requested).  To keep them specify:
> keep_ppm_files = yes
>
> To keep them only for failed tests:
> keep_ppm_files_on_error = yes
>
> A reasonable choice would be to keep PNG files for failed tests, and never
> keep PPM files.  To do this specify
> convert_ppm_files_to_png_on_error = yes
> without specifying 'keep_ppm_files = yes' or 'keep_ppm_files_on_error = yes'
> (or explicitly set to 'no', if it was set to 'yes' on a higher level in the
> config hierarchy).
>
> This patch also makes small cosmetic changes to the 'keep_ppm_files' feature.

Applied.

> Signed-off-by: Michael Goldish 
> ---
>  client/tests/kvm/kvm_preprocessing.py |   16 
>  1 files changed, 12 insertions(+), 4 deletions(-)
>
> diff --git a/client/tests/kvm/kvm_preprocessing.py 
> b/client/tests/kvm/kvm_preprocessing.py
> index 7b97f00..71f7a6b 100644
> --- a/client/tests/kvm/kvm_preprocessing.py
> +++ b/client/tests/kvm/kvm_preprocessing.py
> @@ -264,11 +264,19 @@ def postprocess(test, params, env):
>     """
>     process(test, params, env, postprocess_image, postprocess_vm)
>
> -    # See if we should get rid of all PPM files
> -    if not params.get("keep_ppm_files") == "yes":
> -        # Remove them all
> +    # Should we convert PPM files to PNG format?
> +    if params.get("convert_ppm_files_to_png") == "yes":
> +        logging.debug("'convert_ppm_files_to_png' specified; converting PPM"
> +                      " files to PNG format...")
> +        mogrify_cmd = ("mogrify -format png %s" %
> +                       os.path.join(test.debugdir, "*.ppm"))
> +        kvm_subprocess.run_fg(mogrify_cmd, logging.debug, "(mogrify) ",
> +                              timeout=30.0)
> +
> +    # Should we keep the PPM files?
> +    if params.get("keep_ppm_files") != "yes":
>         logging.debug("'keep_ppm_files' not specified; removing all PPM files"
> -                      " from results dir...")
> +                      " from debug dir...")
>         rm_cmd = "rm -vf %s" % os.path.join(test.debugdir, "*.ppm")
>         kvm_subprocess.run_fg(rm_cmd, logging.debug, "(rm) ", timeout=5.0)
>
> --
> 1.5.4.1
>
> ___
> Autotest mailing list
> autot...@test.kernel.org
> http://test.kernel.org/cgi-bin/mailman/listinfo/autotest
>



-- 
Lucas Meneghel
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [Autotest] [KVM-AUTOTEST PATCH 08/17] kvm_guest_wizard: allow keeping screendump history for debugging purposes

2009-07-24 Thread Lucas Meneghel Rodrigues
On Mon, Jul 20, 2009 at 12:07 PM, Michael Goldish wrote:
> Add two new step file test parameters:
> - keep_screendump_history: if equals 'yes', screendump history is saved in
>  test.debugdir/barrier_history in JPG format.  Each screendump taken by the
>  test is saved if it differs from the previous screendump.  By default, when
>  a barrier succeeds all history is removed, so eventually the remaining files
>  are only those of the (last) failed barrier, if any.
> - keep_all_history: if equals 'yes', screendump history is not removed upon
>  barrier success.  The test leaves behind all the collected screendump 
> history.

Applied.

> Signed-off-by: Michael Goldish 
> ---
>  client/tests/kvm/kvm_guest_wizard.py |   38 -
>  1 files changed, 32 insertions(+), 6 deletions(-)
>
> diff --git a/client/tests/kvm/kvm_guest_wizard.py 
> b/client/tests/kvm/kvm_guest_wizard.py
> index eb0e2d5..73b830e 100644
> --- a/client/tests/kvm/kvm_guest_wizard.py
> +++ b/client/tests/kvm/kvm_guest_wizard.py
> @@ -1,6 +1,6 @@
>  import os, time, md5, re, shutil, logging
>  from autotest_lib.client.common_lib import utils, error
> -import kvm_utils, ppm_utils
> +import kvm_utils, ppm_utils, kvm_subprocess
>
>  """
>  Utilities to perform automatic guest installation using step files.
> @@ -53,6 +53,11 @@ def barrier_2(vm, words, params, debug_dir, 
> data_scrdump_filename,
>     else:
>         stuck_detection_history = 2
>
> +    keep_screendump_history = params.get("keep_screendump_history") == "yes"
> +    if keep_screendump_history:
> +        keep_all_history = params.get("keep_all_history") == "yes"
> +        history_dir = os.path.join(debug_dir, "barrier_history")
> +
>     end_time = time.time() + timeout
>     end_time_stuck = time.time() + fail_if_stuck_for
>     start_time = time.time()
> @@ -91,21 +96,42 @@ def barrier_2(vm, words, params, debug_dir, 
> data_scrdump_filename,
>         # Read image file
>         (w, h, data) = ppm_utils.image_read_from_ppm_file(scrdump_filename)
>
> +        # Compute md5sum of whole image
> +        whole_image_md5sum = ppm_utils.image_md5sum(w, h, data)
> +
> +        # Write screendump to history_dir (as JPG) if requested
> +        # and if the screendump differs from the previous one
> +        if (keep_screendump_history and
> +            whole_image_md5sum not in prev_whole_image_md5sums[:1]):
> +            try:
> +                os.makedirs(history_dir)
> +            except:
> +                pass
> +            history_scrdump_filename = os.path.join(history_dir,
> +                    "scrdump-step_%s-%s.jpg" % (current_step_num,
> +                                                
> time.strftime("%Y%m%d-%H%M%S")))
> +            kvm_subprocess.run_fg("convert -quality 30 %s %s" %
> +                                  (scrdump_filename, 
> history_scrdump_filename),
> +                                  logging.debug, "(convert) ", timeout=30)
> +
>         # Compare md5sum of barrier region with the expected md5sum
>         calced_md5sum = ppm_utils.get_region_md5sum(w, h, data, x1, y1, dx, 
> dy,
>                                                     cropped_scrdump_filename)
>         if calced_md5sum == md5sum:
> +            # Success -- remove screendump history unless requested not to
> +            if keep_screendump_history and not keep_all_history:
> +                kvm_subprocess.run_fg("rm -rvf %s" % history_dir,
> +                                      logging.debug, "(rm) ", timeout=30)
> +            # Report success
>             return True
>
> -        # Compute md5sum of whole image in order to compare it with
> -        # previous ones
> -        whole_image_md5sum = ppm_utils.image_md5sum(w, h, data)
> +        # Insert image md5sum into queue of last seen images:
>         # If md5sum is already in queue...
>         if whole_image_md5sum in prev_whole_image_md5sums:
>             # Remove md5sum from queue
>             prev_whole_image_md5sums.remove(whole_image_md5sum)
>         else:
> -            # Extend 'stuck' timeout
> +            # Otherwise extend 'stuck' timeout
>             end_time_stuck = time.time() + fail_if_stuck_for
>         # Insert md5sum at beginning of queue
>         prev_whole_image_md5sums.insert(0, whole_image_md5sum)
> @@ -129,7 +155,7 @@ def barrier_2(vm, words, params, debug_dir, 
> data_scrdump_filename,
>         if data_scrdump_filename and os.path.exists(data_scrdump_filename):
>             # Read expected screendump image
>             (ew, eh, edata) = \
> -            ppm_utils.image_read_from_ppm_file(data_scrdump_filename)
> +                    ppm_utils.image_read_from_ppm_file(data_scrdump_filename)
>             # Write it in debug_dir
>             ppm_utils.image_write_to_ppm_file(expected_scrdump_filename,
>                                               ew, eh, edata)
> --
> 1.5.4.1
>
> ___
> Autotest mailing list
> autot

Re: [Autotest] [KVM-AUTOTEST PATCH 07/17] kvm_guest_wizard: pass 'params' directly to barrier_2()

2009-07-24 Thread Lucas Meneghel Rodrigues
On Mon, Jul 20, 2009 at 12:07 PM, Michael Goldish wrote:
> Currently parameters for barrier_2() are extracted from 'params' in the main
> run_steps() test routine, and then passed to barrier_2().
> Instead, let barrier_2() extract parameters from 'params' as it sees fit.
> This will make adding new parameters slightly easier and cleaner.

Applied.

> Signed-off-by: Michael Goldish 
> ---
>  client/tests/kvm/kvm_guest_wizard.py |   37 -
>  1 files changed, 18 insertions(+), 19 deletions(-)
>
> diff --git a/client/tests/kvm/kvm_guest_wizard.py 
> b/client/tests/kvm/kvm_guest_wizard.py
> index 143e61e..eb0e2d5 100644
> --- a/client/tests/kvm/kvm_guest_wizard.py
> +++ b/client/tests/kvm/kvm_guest_wizard.py
> @@ -17,8 +17,8 @@ def handle_var(vm, params, varname):
>     return True
>
>
> -def barrier_2(vm, words, fail_if_stuck_for, stuck_detection_history,
> -              debug_dir, data_scrdump_filename, current_step_num):
> +def barrier_2(vm, words, params, debug_dir, data_scrdump_filename,
> +              current_step_num):
>     if len(words) < 7:
>         logging.error("Bad barrier_2 command line")
>         return False
> @@ -41,6 +41,18 @@ def barrier_2(vm, words, fail_if_stuck_for, 
> stuck_detection_history,
>                                                  
> "cropped_scrdump_expected.ppm")
>     comparison_filename = os.path.join(debug_dir, "comparison.ppm")
>
> +    fail_if_stuck_for = params.get("fail_if_stuck_for")
> +    if fail_if_stuck_for:
> +        fail_if_stuck_for = float(fail_if_stuck_for)
> +    else:
> +        fail_if_stuck_for = 1e308
> +
> +    stuck_detection_history = params.get("stuck_detection_history")
> +    if stuck_detection_history:
> +        stuck_detection_history = int(stuck_detection_history)
> +    else:
> +        stuck_detection_history = 2
> +
>     end_time = time.time() + timeout
>     end_time_stuck = time.time() + fail_if_stuck_for
>     start_time = time.time()
> @@ -151,18 +163,6 @@ def run_steps(test, params, env):
>     if not os.path.exists(steps_filename):
>         raise error.TestError("Steps file not found: %s" % steps_filename)
>
> -    fail_if_stuck_for = params.get("fail_if_stuck_for")
> -    if fail_if_stuck_for:
> -        fail_if_stuck_for = float(fail_if_stuck_for)
> -    else:
> -        fail_if_stuck_for = 1e308
> -
> -    stuck_detection_history = params.get("stuck_detection_history")
> -    if stuck_detection_history:
> -        stuck_detection_history = int(stuck_detection_history)
> -    else:
> -        stuck_detection_history = 2
> -
>     sf = open(steps_filename, "r")
>     lines = sf.readlines()
>     sf.close()
> @@ -201,13 +201,12 @@ def run_steps(test, params, env):
>                 logging.error("Variable not defined: %s" % words[1])
>         elif words[0] == "barrier_2":
>             if current_screendump:
> -                scrdump_filename = (
> -                os.path.join(ppm_utils.get_data_dir(steps_filename),
> -                             current_screendump))
> +                scrdump_filename = os.path.join(
> +                    ppm_utils.get_data_dir(steps_filename),
> +                    current_screendump)
>             else:
>                 scrdump_filename = None
> -            if not barrier_2(vm, words, fail_if_stuck_for,
> -                             stuck_detection_history, test.debugdir,
> +            if not barrier_2(vm, words, params, test.debugdir,
>                              scrdump_filename, current_step_num):
>                 skip_current_step = True
>         else:
> --
> 1.5.4.1
>
> ___
> Autotest mailing list
> autot...@test.kernel.org
> http://test.kernel.org/cgi-bin/mailman/listinfo/autotest
>



-- 
Lucas Meneghel
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [Autotest] [KVM-AUTOTEST PATCH 06/17] kvm_guest_wizard: rename output_dir to debug_dir in barrier_2()

2009-07-24 Thread Lucas Meneghel Rodrigues
On Mon, Jul 20, 2009 at 12:07 PM, Michael Goldish wrote:
> The name 'debug_dir' makes it clearer that it corresponds to test.debugdir.

Applied.

> Signed-off-by: Michael Goldish 
> ---
>  client/tests/kvm/kvm_guest_wizard.py |   20 ++--
>  1 files changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/client/tests/kvm/kvm_guest_wizard.py 
> b/client/tests/kvm/kvm_guest_wizard.py
> index 2dd9be5..143e61e 100644
> --- a/client/tests/kvm/kvm_guest_wizard.py
> +++ b/client/tests/kvm/kvm_guest_wizard.py
> @@ -18,7 +18,7 @@ def handle_var(vm, params, varname):
>
>
>  def barrier_2(vm, words, fail_if_stuck_for, stuck_detection_history,
> -              output_dir, data_scrdump_filename, current_step_num):
> +              debug_dir, data_scrdump_filename, current_step_num):
>     if len(words) < 7:
>         logging.error("Bad barrier_2 command line")
>         return False
> @@ -34,12 +34,12 @@ def barrier_2(vm, words, fail_if_stuck_for, 
> stuck_detection_history,
>     if sleep_duration < 1.0: sleep_duration = 1.0
>     if sleep_duration > 10.0: sleep_duration = 10.0
>
> -    scrdump_filename = os.path.join(output_dir, "scrdump.ppm")
> -    cropped_scrdump_filename = os.path.join(output_dir, 
> "cropped_scrdump.ppm")
> -    expected_scrdump_filename = os.path.join(output_dir, 
> "scrdump_expected.ppm")
> -    expected_cropped_scrdump_filename = os.path.join(output_dir,
> +    scrdump_filename = os.path.join(debug_dir, "scrdump.ppm")
> +    cropped_scrdump_filename = os.path.join(debug_dir, "cropped_scrdump.ppm")
> +    expected_scrdump_filename = os.path.join(debug_dir, 
> "scrdump_expected.ppm")
> +    expected_cropped_scrdump_filename = os.path.join(debug_dir,
>                                                  
> "cropped_scrdump_expected.ppm")
> -    comparison_filename = os.path.join(output_dir, "comparison.ppm")
> +    comparison_filename = os.path.join(debug_dir, "comparison.ppm")
>
>     end_time = time.time() + timeout
>     end_time_stuck = time.time() + fail_if_stuck_for
> @@ -99,7 +99,7 @@ def barrier_2(vm, words, fail_if_stuck_for, 
> stuck_detection_history,
>         prev_whole_image_md5sums.insert(0, whole_image_md5sum)
>         # Limit queue length to stuck_detection_history
>         prev_whole_image_md5sums = \
> -        prev_whole_image_md5sums[:stuck_detection_history]
> +                prev_whole_image_md5sums[:stuck_detection_history]
>
>         # Sleep for a while
>         time.sleep(sleep_duration)
> @@ -113,12 +113,12 @@ def barrier_2(vm, words, fail_if_stuck_for, 
> stuck_detection_history,
>         logging.info(message)
>         return False
>     else:
> -        # Collect information and put it in output_dir
> +        # Collect information and put it in debug_dir
>         if data_scrdump_filename and os.path.exists(data_scrdump_filename):
>             # Read expected screendump image
>             (ew, eh, edata) = \
>             ppm_utils.image_read_from_ppm_file(data_scrdump_filename)
> -            # Write it in output_dir
> +            # Write it in debug_dir
>             ppm_utils.image_write_to_ppm_file(expected_scrdump_filename,
>                                               ew, eh, edata)
>             # Write the cropped version as well
> @@ -131,7 +131,7 @@ def barrier_2(vm, words, fail_if_stuck_for, 
> stuck_detection_history,
>                 ppm_utils.image_write_to_ppm_file(comparison_filename, w, h,
>                                                   data)
>         # Print error messages and fail the test
> -        long_message = message + "\n(see analysis at %s)" % output_dir
> +        long_message = message + "\n(see analysis at %s)" % debug_dir
>         logging.error(long_message)
>         raise error.TestFail, message
>
> --
> 1.5.4.1
>
> ___
> Autotest mailing list
> autot...@test.kernel.org
> http://test.kernel.org/cgi-bin/mailman/listinfo/autotest
>



-- 
Lucas Meneghel
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2] use coalesce memory regions functions from upstream

2009-07-24 Thread Glauber Costa
Delete ours, they do the same thing.

Signed-off-by: Glauber Costa 
---
 kvm-all.c  |2 +-
 qemu-kvm.c |   45 -
 2 files changed, 1 insertions(+), 46 deletions(-)

diff --git a/kvm-all.c b/kvm-all.c
index 157b968..e798496 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -344,6 +344,7 @@ int kvm_physical_sync_dirty_bitmap(target_phys_addr_t 
start_addr,
 
 return ret;
 }
+#endif
 
 int kvm_coalesce_mmio_region(target_phys_addr_t start, ram_addr_t size)
 {
@@ -383,7 +384,6 @@ int kvm_uncoalesce_mmio_region(target_phys_addr_t start, 
ram_addr_t size)
 return ret;
 }
 
-#endif
 int kvm_check_extension(KVMState *s, unsigned int extension)
 {
 int ret;
diff --git a/qemu-kvm.c b/qemu-kvm.c
index c1454fd..23bd61a 100644
--- a/qemu-kvm.c
+++ b/qemu-kvm.c
@@ -1175,51 +1175,6 @@ int kvm_init_coalesced_mmio(kvm_context_t kvm)
return r;
 }
 
-int kvm_coalesce_mmio_region(target_phys_addr_t addr, ram_addr_t size)
-{
-#ifdef KVM_CAP_COALESCED_MMIO
-   struct kvm_coalesced_mmio_zone zone;
-   int r;
-
-   if (kvm_state->coalesced_mmio) {
-
-   zone.addr = addr;
-   zone.size = size;
-
-   r = kvm_vm_ioctl(kvm_state, KVM_REGISTER_COALESCED_MMIO, &zone);
-   if (r < 0) {
-   perror("kvm_register_coalesced_mmio_zone");
-   return r;
-   }
-   return 0;
-   }
-#endif
-   return -ENOSYS;
-}
-
-int kvm_uncoalesce_mmio_region(target_phys_addr_t addr, ram_addr_t size)
-{
-#ifdef KVM_CAP_COALESCED_MMIO
-   struct kvm_coalesced_mmio_zone zone;
-   int r;
-
-   if (kvm_state->coalesced_mmio) {
-
-   zone.addr = addr;
-   zone.size = size;
-
-   r = kvm_vm_ioctl(kvm_state, KVM_UNREGISTER_COALESCED_MMIO, 
&zone);
-   if (r < 0) {
-   perror("kvm_unregister_coalesced_mmio_zone");
-   return r;
-   }
-   DPRINTF("Unregistered coalesced mmio region for %llx (%lx)\n", 
addr, size);
-   return 0;
-   }
-#endif
-   return -ENOSYS;
-}
-
 #ifdef KVM_CAP_DEVICE_ASSIGNMENT
 int kvm_assign_pci_device(kvm_context_t kvm,
  struct kvm_assigned_pci_dev *assigned_dev)
-- 
1.6.2.2

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/2] Use coalescing region from upstream

2009-07-24 Thread Glauber Costa
Marcelo,

these two patches move the control of coalescing regions to upstream code.
Note the first one won't apply in your tip. I'm assuming you have already
applied the ones who remove some pit/irqchip related variables in kvm_context

thanks!


--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/2] use coalesced_mmio field from qemu upstream

2009-07-24 Thread Glauber Costa
remove it from kvm_context too. Besides it all,
helps catching any missing conversion

Signed-off-by: Glauber Costa 
---
 qemu-kvm.c |   14 ++
 qemu-kvm.h |2 --
 2 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/qemu-kvm.c b/qemu-kvm.c
index b9164ee..c1454fd 100644
--- a/qemu-kvm.c
+++ b/qemu-kvm.c
@@ -1026,9 +1026,9 @@ again:
post_kvm_run(kvm, env);
 
 #if defined(KVM_CAP_COALESCED_MMIO)
-   if (kvm->coalesced_mmio) {
+   if (kvm_state->coalesced_mmio) {
struct kvm_coalesced_mmio_ring *ring = (void *)run +
-   kvm->coalesced_mmio * PAGE_SIZE;
+   kvm_state->coalesced_mmio * 
PAGE_SIZE;
while (ring->first != ring->last) {
kvm_mmio_write(kvm->opaque,
 ring->coalesced_mmio[ring->first].phys_addr,
@@ -1164,11 +1164,11 @@ int kvm_inject_nmi(kvm_vcpu_context_t vcpu)
 int kvm_init_coalesced_mmio(kvm_context_t kvm)
 {
int r = 0;
-   kvm->coalesced_mmio = 0;
+   kvm_state->coalesced_mmio = 0;
 #ifdef KVM_CAP_COALESCED_MMIO
r = kvm_ioctl(kvm_state, KVM_CHECK_EXTENSION, KVM_CAP_COALESCED_MMIO);
if (r > 0) {
-   kvm->coalesced_mmio = r;
+   kvm_state->coalesced_mmio = r;
return 0;
}
 #endif
@@ -1178,11 +1178,10 @@ int kvm_init_coalesced_mmio(kvm_context_t kvm)
 int kvm_coalesce_mmio_region(target_phys_addr_t addr, ram_addr_t size)
 {
 #ifdef KVM_CAP_COALESCED_MMIO
-   kvm_context_t kvm = kvm_context;
struct kvm_coalesced_mmio_zone zone;
int r;
 
-   if (kvm->coalesced_mmio) {
+   if (kvm_state->coalesced_mmio) {
 
zone.addr = addr;
zone.size = size;
@@ -1201,11 +1200,10 @@ int kvm_coalesce_mmio_region(target_phys_addr_t addr, 
ram_addr_t size)
 int kvm_uncoalesce_mmio_region(target_phys_addr_t addr, ram_addr_t size)
 {
 #ifdef KVM_CAP_COALESCED_MMIO
-   kvm_context_t kvm = kvm_context;
struct kvm_coalesced_mmio_zone zone;
int r;
 
-   if (kvm->coalesced_mmio) {
+   if (kvm_state->coalesced_mmio) {
 
zone.addr = addr;
zone.size = size;
diff --git a/qemu-kvm.h b/qemu-kvm.h
index 1e5d89a..0de546f 100644
--- a/qemu-kvm.h
+++ b/qemu-kvm.h
@@ -61,8 +61,6 @@ struct kvm_context {
int irqchip_inject_ioctl;
/// in-kernel pit status
int pit_in_kernel;
-   /// in-kernel coalesced mmio
-   int coalesced_mmio;
 #ifdef KVM_CAP_IRQ_ROUTING
struct kvm_irq_routing *irq_routes;
int nr_allocated_irq_routes;
-- 
1.6.2.2

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [AUTOTEST] print login command and change some timeout values

2009-07-24 Thread Lucas Meneghel Rodrigues
On Fri, 2009-07-24 at 12:03 -0400, Michael Goldish wrote:
> - "sudhir kumar"  wrote:
> 
> > On Fri, Jul 24, 2009 at 5:54 PM, Michael Goldish
> > wrote:
> > >
> > > - "sudhir kumar"  wrote:
> > >
> > >> This patch does two small things.
> > >> 1. Prints the guest login command to debug messages.
> > >
> > > Why do we want to do that?
> > I do not see any harm in that. We are logging "trying to login". If
> > sometimes login fail we can check by manually typing the same command
> > and see what went wrong. That print statement has helped me in past
> > quite a number of times.
> 
> OK, no problem. What do you think about printing the login command and
> the "trying to login" message on the same line, like:
> Trying to login: ssh r...@localhost 5000
> or
> Trying to login with command: ssh r...@localhost 5000
> or
> Trying to login (ssh r...@localhost 5000)
> or something like that.

I like the idea. Combining the two strings will save up some space and
help to debug things.

If noone objects, I am going to commit a slightly modified version of
Sudhir's patch with your suggestion, Michael.

> If you don't like any of these options, the patch is OK as it is.
> I just thought it would be a good idea to keep the output short,
> because "Trying to login" is displayed repeatedly during boot so
> it can produce a lot of (not so interesting) output.
> 
> > >> 2. Changes the guest login timeout to 240 seconds. I see the
> > timeout
> > >> for
> > >> *.wait_for() functions in boot test is 240 seconds, while in reboot
> > is
> > >> 120
> > >> seconds which causes the test to fail. We might have missed it by
> > >> mistake.
> > >> 240 seconds is a reasonable timeout duration. This patch fixes
> > that.
> > >
> > > Using the same timeout value everywhere makes sense, but it
> > surprises me
> > > that tests are failing because 120 isn't enough. It sounds like the
> > host
> > > has to be heavily loaded for the boot to take longer than 2 minutes.
> > But
> > > if it happened to you then let's increase the timeout.
> > 
> > Yes please,
> > the test failed very near to the sshd daemon was about to run. So
> > that
> > shows 120 seconds is not sufficient. The host was not at all loaded
> > and is a pretty high end machine.
> > Thanks.
> 
> OK, I agree. I guess I run fast guests most of the time, and some guests
> can take much longer to boot.
> 
> > >> Signed-off-by: Sudhir Kumar 
> > >>
> > >> Index: autotest/client/tests/kvm/kvm_utils.py
> > >>
> > ===
> > >> --- autotest.orig/client/tests/kvm/kvm_utils.py
> > >> +++ autotest/client/tests/kvm/kvm_utils.py
> > >> @@ -637,6 +637,7 @@ def remote_login(command, password, prom
> > >>  password_prompt_count = 0
> > >>
> > >>  logging.debug("Trying to login...")
> > >> +logging.debug("Guest login Command: %s" % command)
> > >>
> > >>  while True:
> > >>  (match, text) = sub.read_until_last_line_matches(
> > >> Index: autotest/client/tests/kvm/kvm_tests.py
> > >>
> > ===
> > >> --- autotest.orig/client/tests/kvm/kvm_tests.py
> > >> +++ autotest/client/tests/kvm/kvm_tests.py
> > >> @@ -48,7 +48,7 @@ def run_boot(test, params, env):
> > >>
> > >>  logging.info("Guest is down; waiting for it to go up
> > >> again...")
> > >>
> > >> -session = kvm_utils.wait_for(vm.ssh_login, 120, 0, 2)
> > >> +session = kvm_utils.wait_for(vm.ssh_login, 240, 0, 2)
> > >>  if not session:
> > >>  raise error.TestFail("Could not log into guest after
> > >> reboot")
> > >>
> > >> @@ -88,7 +88,7 @@ def run_shutdown(test, params, env):
> > >>
> > >>  logging.info("Shutdown command sent; waiting for guest to go
> > >> down...")
> > >>
> > >> -if not kvm_utils.wait_for(vm.is_dead, 120, 0, 1):
> > >> +if not kvm_utils.wait_for(vm.is_dead, 240, 0, 1):
> > >>  raise error.TestFail("Guest refuses to go down")
> > >>
> > >>  logging.info("Guest is down")
> > >> @@ -445,7 +445,7 @@ def run_yum_update(test, params, env):
> > >>
> > >>  logging.info("Logging into guest...")
> > >>
> > >> -session = kvm_utils.wait_for(vm.ssh_login, 120, 0, 2)
> > >> +session = kvm_utils.wait_for(vm.ssh_login, 240, 0, 2)
> > >>  if not session:
> > >>  message = "Could not log into guest"
> > >>  logging.error(message)
> > >>
> > >>
> > >>
> > >> --
> > >> Sudhir Kumar
> > >
> > 
> > 
> > 
> > -- 
> > Sudhir Kumar

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] remove useless wrappers around functions

2009-07-24 Thread Glauber Costa
Some more cleanup from the libkvm era. Functions that starts with
kvm_qemu_yyy just to wrap a kvm_yyy. I'm removing it, and changing
the name of one of them to match upstream.

Signed-off-by: Glauber Costa 
---
 qemu-kvm-ia64.c |2 +-
 qemu-kvm-x86.c  |2 +-
 qemu-kvm.c  |   12 +---
 qemu-kvm.h  |5 +
 4 files changed, 4 insertions(+), 17 deletions(-)

diff --git a/qemu-kvm-ia64.c b/qemu-kvm-ia64.c
index b8a2587..062fbd4 100644
--- a/qemu-kvm-ia64.c
+++ b/qemu-kvm-ia64.c
@@ -25,7 +25,7 @@ void kvm_arch_save_regs(CPUState *env)
 {
 }
 
-int kvm_arch_qemu_init_env(CPUState *cenv)
+int kvm_arch_init_vcpu(CPUState *cenv)
 {
 return 0;
 }
diff --git a/qemu-kvm-x86.c b/qemu-kvm-x86.c
index 0a42455..2af9e3f 100644
--- a/qemu-kvm-x86.c
+++ b/qemu-kvm-x86.c
@@ -1257,7 +1257,7 @@ static void kvm_trim_features(uint32_t *features, 
uint32_t supported)
 }
 }
 
-int kvm_arch_qemu_init_env(CPUState *cenv)
+int kvm_arch_init_vcpu(CPUState *cenv)
 {
 struct kvm_cpuid_entry2 cpuid_ent[100];
 #ifdef KVM_CPUID_SIGNATURE
diff --git a/qemu-kvm.c b/qemu-kvm.c
index fdf71a8..b9164ee 100644
--- a/qemu-kvm.c
+++ b/qemu-kvm.c
@@ -1890,7 +1890,7 @@ static int kvm_main_loop_cpu(CPUState *env)
 
 pthread_mutex_lock(&qemu_mutex);
 
-kvm_qemu_init_env(env);
+kvm_arch_init_vcpu(env);
 #ifdef TARGET_I386
 kvm_tpr_vcpu_start(env);
 #endif
@@ -2336,16 +2336,6 @@ int kvm_setup_guest_memory(void *area, unsigned long 
size)
 return ret;
 }
 
-int kvm_qemu_check_extension(int ext)
-{
-return kvm_check_extension(kvm_state, ext);
-}
-
-int kvm_qemu_init_env(CPUState *cenv)
-{
-return kvm_arch_qemu_init_env(cenv);
-}
-
 #ifdef KVM_CAP_SET_GUEST_DEBUG
 
 struct kvm_set_guest_debug_data {
diff --git a/qemu-kvm.h b/qemu-kvm.h
index 5eb1ee5..1e5d89a 100644
--- a/qemu-kvm.h
+++ b/qemu-kvm.h
@@ -938,7 +938,6 @@ struct kvm_pit_state { };
 
 
 int kvm_main_loop(void);
-int kvm_qemu_init(void);
 int kvm_init_ap(void);
 int kvm_vcpu_inited(CPUState *env);
 void kvm_load_registers(CPUState *env);
@@ -952,8 +951,6 @@ int kvm_remove_breakpoint(CPUState *current_env, 
target_ulong addr,
   target_ulong len, int type);
 void kvm_remove_all_breakpoints(CPUState *current_env);
 int kvm_update_guest_debug(CPUState *env, unsigned long reinject_trap);
-int kvm_qemu_init_env(CPUState *env);
-int kvm_qemu_check_extension(int ext);
 void kvm_apic_init(CPUState *env);
 /* called from vcpu initialization */
 void qemu_kvm_load_lapic(CPUState *env);
@@ -992,7 +989,7 @@ void kvm_arch_save_regs(CPUState *env);
 void kvm_arch_load_regs(CPUState *env);
 void kvm_arch_load_mpstate(CPUState *env);
 void kvm_arch_save_mpstate(CPUState *env);
-int kvm_arch_qemu_init_env(CPUState *cenv);
+int kvm_arch_init_vcpu(CPUState *cenv);
 void kvm_arch_pre_kvm_run(void *opaque, CPUState *env);
 void kvm_arch_post_kvm_run(void *opaque, CPUState *env);
 int kvm_arch_has_work(CPUState *env);
-- 
1.6.2.2

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] use kvm_has_sync_mmu from upstream.

2009-07-24 Thread Glauber Costa
they have it, and it does the same as we do.

Signed-off-by: Glauber Costa 
---
 kvm-all.c  |3 +++
 qemu-kvm.c |9 -
 2 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/kvm-all.c b/kvm-all.c
index b4b5a35..157b968 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -848,6 +848,8 @@ int kvm_vcpu_ioctl(CPUState *env, int type, ...)
 return ret;
 }
 
+#endif
+
 int kvm_has_sync_mmu(void)
 {
 #ifdef KVM_CAP_SYNC_MMU
@@ -859,6 +861,7 @@ int kvm_has_sync_mmu(void)
 #endif
 }
 
+#ifdef KVM_UPSTREAM
 void kvm_setup_guest_memory(void *start, size_t size)
 {
 if (!kvm_has_sync_mmu()) {
diff --git a/qemu-kvm.c b/qemu-kvm.c
index bca256c..fdf71a8 100644
--- a/qemu-kvm.c
+++ b/qemu-kvm.c
@@ -1152,15 +1152,6 @@ int kvm_pit_in_kernel(kvm_context_t kvm)
return kvm->pit_in_kernel;
 }
 
-int kvm_has_sync_mmu(void)
-{
-int r = 0;
-#ifdef KVM_CAP_SYNC_MMU
-r = kvm_ioctl(kvm_state, KVM_CHECK_EXTENSION, KVM_CAP_SYNC_MMU);
-#endif
-return r;
-}
-
 int kvm_inject_nmi(kvm_vcpu_context_t vcpu)
 {
 #ifdef KVM_CAP_USER_NMI
-- 
1.6.2.2

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [AUTOTEST] print login command and change some timeout values

2009-07-24 Thread Michael Goldish

- "sudhir kumar"  wrote:

> On Fri, Jul 24, 2009 at 5:54 PM, Michael Goldish
> wrote:
> >
> > - "sudhir kumar"  wrote:
> >
> >> This patch does two small things.
> >> 1. Prints the guest login command to debug messages.
> >
> > Why do we want to do that?
> I do not see any harm in that. We are logging "trying to login". If
> sometimes login fail we can check by manually typing the same command
> and see what went wrong. That print statement has helped me in past
> quite a number of times.

OK, no problem. What do you think about printing the login command and
the "trying to login" message on the same line, like:
Trying to login: ssh r...@localhost 5000
or
Trying to login with command: ssh r...@localhost 5000
or
Trying to login (ssh r...@localhost 5000)
or something like that.

If you don't like any of these options, the patch is OK as it is.
I just thought it would be a good idea to keep the output short,
because "Trying to login" is displayed repeatedly during boot so
it can produce a lot of (not so interesting) output.

> >> 2. Changes the guest login timeout to 240 seconds. I see the
> timeout
> >> for
> >> *.wait_for() functions in boot test is 240 seconds, while in reboot
> is
> >> 120
> >> seconds which causes the test to fail. We might have missed it by
> >> mistake.
> >> 240 seconds is a reasonable timeout duration. This patch fixes
> that.
> >
> > Using the same timeout value everywhere makes sense, but it
> surprises me
> > that tests are failing because 120 isn't enough. It sounds like the
> host
> > has to be heavily loaded for the boot to take longer than 2 minutes.
> But
> > if it happened to you then let's increase the timeout.
> 
> Yes please,
> the test failed very near to the sshd daemon was about to run. So
> that
> shows 120 seconds is not sufficient. The host was not at all loaded
> and is a pretty high end machine.
> Thanks.

OK, I agree. I guess I run fast guests most of the time, and some guests
can take much longer to boot.

> >> Signed-off-by: Sudhir Kumar 
> >>
> >> Index: autotest/client/tests/kvm/kvm_utils.py
> >>
> ===
> >> --- autotest.orig/client/tests/kvm/kvm_utils.py
> >> +++ autotest/client/tests/kvm/kvm_utils.py
> >> @@ -637,6 +637,7 @@ def remote_login(command, password, prom
> >>      password_prompt_count = 0
> >>
> >>      logging.debug("Trying to login...")
> >> +    logging.debug("Guest login Command: %s" % command)
> >>
> >>      while True:
> >>          (match, text) = sub.read_until_last_line_matches(
> >> Index: autotest/client/tests/kvm/kvm_tests.py
> >>
> ===
> >> --- autotest.orig/client/tests/kvm/kvm_tests.py
> >> +++ autotest/client/tests/kvm/kvm_tests.py
> >> @@ -48,7 +48,7 @@ def run_boot(test, params, env):
> >>
> >>          logging.info("Guest is down; waiting for it to go up
> >> again...")
> >>
> >> -        session = kvm_utils.wait_for(vm.ssh_login, 120, 0, 2)
> >> +        session = kvm_utils.wait_for(vm.ssh_login, 240, 0, 2)
> >>          if not session:
> >>              raise error.TestFail("Could not log into guest after
> >> reboot")
> >>
> >> @@ -88,7 +88,7 @@ def run_shutdown(test, params, env):
> >>
> >>      logging.info("Shutdown command sent; waiting for guest to go
> >> down...")
> >>
> >> -    if not kvm_utils.wait_for(vm.is_dead, 120, 0, 1):
> >> +    if not kvm_utils.wait_for(vm.is_dead, 240, 0, 1):
> >>          raise error.TestFail("Guest refuses to go down")
> >>
> >>      logging.info("Guest is down")
> >> @@ -445,7 +445,7 @@ def run_yum_update(test, params, env):
> >>
> >>      logging.info("Logging into guest...")
> >>
> >> -    session = kvm_utils.wait_for(vm.ssh_login, 120, 0, 2)
> >> +    session = kvm_utils.wait_for(vm.ssh_login, 240, 0, 2)
> >>      if not session:
> >>          message = "Could not log into guest"
> >>          logging.error(message)
> >>
> >>
> >>
> >> --
> >> Sudhir Kumar
> >
> 
> 
> 
> -- 
> Sudhir Kumar
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [AUTOTEST] print login command and change some timeout values

2009-07-24 Thread sudhir kumar
On Fri, Jul 24, 2009 at 5:54 PM, Michael Goldish wrote:
>
> - "sudhir kumar"  wrote:
>
>> This patch does two small things.
>> 1. Prints the guest login command to debug messages.
>
> Why do we want to do that?
I do not see any harm in that. We are logging "trying to login". If
sometimes login fail we can check by manually typing the same command
and see what went wrong. That print statement has helped me in past
quite a number of times.
>
>> 2. Changes the guest login timeout to 240 seconds. I see the timeout
>> for
>> *.wait_for() functions in boot test is 240 seconds, while in reboot is
>> 120
>> seconds which causes the test to fail. We might have missed it by
>> mistake.
>> 240 seconds is a reasonable timeout duration. This patch fixes that.
>
> Using the same timeout value everywhere makes sense, but it surprises me
> that tests are failing because 120 isn't enough. It sounds like the host
> has to be heavily loaded for the boot to take longer than 2 minutes. But
> if it happened to you then let's increase the timeout.

Yes please,
the test failed very near to the sshd daemon was about to run. So that
shows 120 seconds is not sufficient. The host was not at all loaded
and is a pretty high end machine.
Thanks.

>> Signed-off-by: Sudhir Kumar 
>>
>> Index: autotest/client/tests/kvm/kvm_utils.py
>> ===
>> --- autotest.orig/client/tests/kvm/kvm_utils.py
>> +++ autotest/client/tests/kvm/kvm_utils.py
>> @@ -637,6 +637,7 @@ def remote_login(command, password, prom
>>      password_prompt_count = 0
>>
>>      logging.debug("Trying to login...")
>> +    logging.debug("Guest login Command: %s" % command)
>>
>>      while True:
>>          (match, text) = sub.read_until_last_line_matches(
>> Index: autotest/client/tests/kvm/kvm_tests.py
>> ===
>> --- autotest.orig/client/tests/kvm/kvm_tests.py
>> +++ autotest/client/tests/kvm/kvm_tests.py
>> @@ -48,7 +48,7 @@ def run_boot(test, params, env):
>>
>>          logging.info("Guest is down; waiting for it to go up
>> again...")
>>
>> -        session = kvm_utils.wait_for(vm.ssh_login, 120, 0, 2)
>> +        session = kvm_utils.wait_for(vm.ssh_login, 240, 0, 2)
>>          if not session:
>>              raise error.TestFail("Could not log into guest after
>> reboot")
>>
>> @@ -88,7 +88,7 @@ def run_shutdown(test, params, env):
>>
>>      logging.info("Shutdown command sent; waiting for guest to go
>> down...")
>>
>> -    if not kvm_utils.wait_for(vm.is_dead, 120, 0, 1):
>> +    if not kvm_utils.wait_for(vm.is_dead, 240, 0, 1):
>>          raise error.TestFail("Guest refuses to go down")
>>
>>      logging.info("Guest is down")
>> @@ -445,7 +445,7 @@ def run_yum_update(test, params, env):
>>
>>      logging.info("Logging into guest...")
>>
>> -    session = kvm_utils.wait_for(vm.ssh_login, 120, 0, 2)
>> +    session = kvm_utils.wait_for(vm.ssh_login, 240, 0, 2)
>>      if not session:
>>          message = "Could not log into guest"
>>          logging.error(message)
>>
>>
>>
>> --
>> Sudhir Kumar
>



-- 
Sudhir Kumar
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[KVM-AUTOTEST PATCH] KVM test: kvm_subprocess: fix a problem that arises with Python 2.6

2009-07-24 Thread Michael Goldish
After launching the server the client waits for it to finish initializing.
This is done by waiting for a line of output from the server's STDOUT.
Currently, the client assumes that the first line of output coming from the
server indicates that it's done initializing.  With Python 2.4 this used to be
true, but Python 2.6 prints deprecation warnings for certain standard modules
as soon as they are imported.  This makes the client think the server is ready
when in fact it isn't.

This patch fixes the problem by waiting for a certain unique output line from
the server instead of just waiting for the first line.

Signed-off-by: Michael Goldish 
---
 client/tests/kvm/kvm_subprocess.py |5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/client/tests/kvm/kvm_subprocess.py 
b/client/tests/kvm/kvm_subprocess.py
index 413bdaa..c15e779 100644
--- a/client/tests/kvm/kvm_subprocess.py
+++ b/client/tests/kvm/kvm_subprocess.py
@@ -212,7 +212,8 @@ class kvm_spawn:
 sub.stdin.write("%s\n" % ",".join(self.readers))
 sub.stdin.write("%s\n" % command)
 # Wait for the server to complete its initialization
-sub.stdout.readline()
+while not "Server %s ready" % self.id in sub.stdout.readline():
+pass
 
 # Open the reading pipes
 self.reader_fds = {}
@@ -1081,7 +1082,7 @@ def _server_main():
 file.close()
 
 # Print something to stdout so the client can start working
-print "hello"
+print "Server %s ready" % id
 sys.stdout.flush()
 
 # Initialize buffers
-- 
1.5.4.1

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[ kvm-Bugs-2826486 ] Clock speed in FreeBSD

2009-07-24 Thread SourceForge.net
Bugs item #2826486, was opened at 2009-07-24 02:16
Message generated for change (Comment added) made by eswierk
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=893831&aid=2826486&group_id=180599

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: POLYMORF34 (polymorf34)
Assigned to: Nobody/Anonymous (nobody)
Summary: Clock speed in FreeBSD

Initial Comment:
I use KVM 88 and KVM 85 on Gentoo GNU/Linux 2.6.29, running on Intel Core2 CPU 
6320 and Intel Xeon CPU E5405, both in 64 bits mode.
All gests running on FreeBSD 7.1-p5 in 64 bits with -smp 1. The first machine 
host only one gest.

The "sleep" command on FreeBSD does not work has expected. All sleep time are 
multiplied by 3

Example :

 freebsdmachine ~ # time sleep 1
real0m3.148s
user0m0.000s
sys 0m0.002s

freebsdmachine ~ # time sleep 10
real0m31.429s
user0m0.009s
sys 0m0.002s

With the "-no-kvm" flag, the "sleep" command works has expected.

--

Comment By: Ed Swierk (eswierk)
Date: 2009-07-24 07:01

Message:
Seems like there's a bug in one of the emulated timers. I worked around it
with the Fedora 11 version of kvm by using the -no-kvm-irqchip flag. 


--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=893831&aid=2826486&group_id=180599
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCHv2 2/2] virtio: fix memory leak on device removal

2009-07-24 Thread Rusty Russell
On Thu, 23 Jul 2009 09:27:37 pm Michael S. Tsirkin wrote:
> Make vp_free_vectors do the reverse of vq_request_vectors.
> 
> Signed-off-by: Michael S. Tsirkin 

Thanks, applied!

Rusty.
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCHv2 1/2] virtio: fix double free_irq on device removal

2009-07-24 Thread Rusty Russell
On Thu, 23 Jul 2009 09:27:31 pm Michael S. Tsirkin wrote:
> msix_user_vectors counted both per-vq and shared/config vectors.
> This causes BUG_ON when device is removed, as
> free_vectors tries to free per-vq vectors.

OK, I looked at this patch, then looked at this code (after it was applied).

I'm still very confused.

Looking at the call site for vp_find_vq:

for (i = 0; i < nvqs; ++i) {
if (!callbacks[i])
vector = per_vq_vector = VIRTIO_MSI_NO_VECTOR;
else if (vp_dev->msix_used_vectors < vp_dev->msix_vectors)
per_vq_vector = vector = allocated_vectors++;
else {
vector = VP_MSIX_VQ_VECTOR;
per_vq_vector = VIRTIO_MSI_NO_VECTOR;
}

Now, I can't find where msix_used_vectors is set, only once where it's
incremented.  It seems completely redundant and confusing now?  And
this "< vp_dev->msix_vectors" test is wrong?

AFAICT there are three cases:
1) We don't have MSI, so we use a normal interrupt for all vqs (old style).
This request_irq is done in  vp_request_vectors.
2) We get some, but not enough for one per queue.  We then use 2: one for
   changes, and one for all vqs.  Requested in vp_request_vectors.
3) We get enough.  Use one for changes, one per vq.  Each vq
   requests in vp_find_vq.

I suggest you be explicit, and don't do any request in vp_find_vq().  Do the
per-vq request (case 3) in the find_vqs() loop, so vp_find_vq doesn't need
to know anything except to do the iowrite16 if vector != VIRTIO_MSI_NO_VECTOR.

Maybe an explicit "bool per_vq_vectors" would make it clearer, too.

Note: this is partially my fault for not reviewing this code when it went in.
I know Anthony is disclaiming virtio_pci :)

Thanks,
Rusty.
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [AUTOTEST] print login command and change some timeout values

2009-07-24 Thread Michael Goldish

- "sudhir kumar"  wrote:

> This patch does two small things.
> 1. Prints the guest login command to debug messages.

Why do we want to do that?

> 2. Changes the guest login timeout to 240 seconds. I see the timeout
> for
> *.wait_for() functions in boot test is 240 seconds, while in reboot is
> 120
> seconds which causes the test to fail. We might have missed it by
> mistake.
> 240 seconds is a reasonable timeout duration. This patch fixes that.

Using the same timeout value everywhere makes sense, but it surprises me
that tests are failing because 120 isn't enough. It sounds like the host
has to be heavily loaded for the boot to take longer than 2 minutes. But
if it happened to you then let's increase the timeout.

> Signed-off-by: Sudhir Kumar 
> 
> Index: autotest/client/tests/kvm/kvm_utils.py
> ===
> --- autotest.orig/client/tests/kvm/kvm_utils.py
> +++ autotest/client/tests/kvm/kvm_utils.py
> @@ -637,6 +637,7 @@ def remote_login(command, password, prom
>  password_prompt_count = 0
> 
>  logging.debug("Trying to login...")
> +logging.debug("Guest login Command: %s" % command)
> 
>  while True:
>  (match, text) = sub.read_until_last_line_matches(
> Index: autotest/client/tests/kvm/kvm_tests.py
> ===
> --- autotest.orig/client/tests/kvm/kvm_tests.py
> +++ autotest/client/tests/kvm/kvm_tests.py
> @@ -48,7 +48,7 @@ def run_boot(test, params, env):
> 
>  logging.info("Guest is down; waiting for it to go up
> again...")
> 
> -session = kvm_utils.wait_for(vm.ssh_login, 120, 0, 2)
> +session = kvm_utils.wait_for(vm.ssh_login, 240, 0, 2)
>  if not session:
>  raise error.TestFail("Could not log into guest after
> reboot")
> 
> @@ -88,7 +88,7 @@ def run_shutdown(test, params, env):
> 
>  logging.info("Shutdown command sent; waiting for guest to go
> down...")
> 
> -if not kvm_utils.wait_for(vm.is_dead, 120, 0, 1):
> +if not kvm_utils.wait_for(vm.is_dead, 240, 0, 1):
>  raise error.TestFail("Guest refuses to go down")
> 
>  logging.info("Guest is down")
> @@ -445,7 +445,7 @@ def run_yum_update(test, params, env):
> 
>  logging.info("Logging into guest...")
> 
> -session = kvm_utils.wait_for(vm.ssh_login, 120, 0, 2)
> +session = kvm_utils.wait_for(vm.ssh_login, 240, 0, 2)
>  if not session:
>  message = "Could not log into guest"
>  logging.error(message)
> 
> 
> 
> -- 
> Sudhir Kumar
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Host latency peaks due to kvm-intel

2009-07-24 Thread Gregory Haskins
Jan Kiszka wrote:
> Gregory Haskins wrote:
>   
>> Jan Kiszka wrote:
>> 
>>> Hi,
>>>
>>> did anyone recently tried current KVM for Intel over some real-time
>>> Linux? I'm seeing more than 500 us latency peaks on the host,
>>> specifically during VM startup. This applies to both 2.6.29.6-rt23 and
>>> Xenomai/I-pipe. For -rt, I both tried the included (patched) KVM modules
>>> as well as kvm.git head with some additionally required -rt fixes.
>>> Xenomai ran over a 2.6.30 kernel with my own KVM-enabler patch.
>>>
>>> Early instrumentation actually points to the guest exit itself: I added
>>> markers right before and after the assembly part of vmx_vcpu_run, and
>>> further instrumentation reports that the next host APIC tick should go
>>> off right inside guest mode. But KVM leaves the switching part 500 us
>>> too late in that case - as if guest exit on external IRQs was disabled.
>>>
>>> Will debug this further, but I'm also curious to hear other user
>>> experiences.
>>>
>>> Jan
>>>
>>>   
>>>   
>> Hi Jan,
>>   Did you try to run with latency-tracer enabled?  If not, this may
>> pinpoint the source for you.
>> 
>
> I did, see above.
>   

Ah, sorry.  It wasn't clear what "instrumenation" was or if you felt it
was definitively pinpointed.  :P

Regards,
-Greg




signature.asc
Description: OpenPGP digital signature


Re: Timeout of network interface with OpenBSD 4.5 VM

2009-07-24 Thread Chris Dukes
http://zeniv.linux.org.uk/~pakrat/obsd45

3 configs, 3 kernels.
All work on a Core2 Duo T7300 running 2.6.27-7-generic (From ubuntu intrepid)
crammed onto a laptop that's mostly running hardy.
The OpenBSD virtual machines have 256M allocated, e1000 NIC, and vde backing
it.


-- 
Chris Dukes
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Timeout of network interface with OpenBSD 4.5 VM

2009-07-24 Thread Chris Dukes
On Fri, Jul 24, 2009 at 06:08:51AM -0300, Daniel Bareiro wrote:
> Hi Chris.
> 
> I was trying with the configuration suggested by Nick, but in this case
> I get a panic [1]. Reading a post of Dmitiry Zotikov [2], it would seem
> that the one is a problem with Qemu.
> 
> Thanks for your reply.

Well, I was recently able to get 32 bit OpenBSD 4.5 running under
kvm-88 by taking the stock GENERIC config and only disabling the mpbios
device.

I'll try to drop the kernel and the config file somewhere
later this morning to see if it's just a fluke for
KVM-88 on 2.6.27 on a core2duo.
> 
> Regards,
> Daniel
> 
> [1] http://thread.gmane.org/gmane.os.openbsd.misc/160465/focus=161149
> [2] http://thread.gmane.org/gmane.os.openbsd.misc/160945
> -- 
> Fingerprint: BFB3 08D6 B4D1 31B2 72B9  29CE 6696 BF1B 14E6 1D37
> Powered by Debian GNU/Linux Squeeze - Linux user #188.598



-- 
Chris Dukes
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [AUTOTEST] print login command and change some timeout values

2009-07-24 Thread sudhir kumar
Ah!
As reported earlier the patch might be wrapped up. So sending as an
attachment too.

On Fri, Jul 24, 2009 at 4:58 PM, sudhir kumar wrote:
> This patch does two small things.
> 1. Prints the guest login command to debug messages.
> 2. Changes the guest login timeout to 240 seconds. I see the timeout for
> *.wait_for() functions in boot test is 240 seconds, while in reboot is 120
> seconds which causes the test to fail. We might have missed it by mistake.
> 240 seconds is a reasonable timeout duration. This patch fixes that.
>
> Signed-off-by: Sudhir Kumar 
>
> Index: autotest/client/tests/kvm/kvm_utils.py
> ===
> --- autotest.orig/client/tests/kvm/kvm_utils.py
> +++ autotest/client/tests/kvm/kvm_utils.py
> @@ -637,6 +637,7 @@ def remote_login(command, password, prom
>     password_prompt_count = 0
>
>     logging.debug("Trying to login...")
> +    logging.debug("Guest login Command: %s" % command)
>
>     while True:
>         (match, text) = sub.read_until_last_line_matches(
> Index: autotest/client/tests/kvm/kvm_tests.py
> ===
> --- autotest.orig/client/tests/kvm/kvm_tests.py
> +++ autotest/client/tests/kvm/kvm_tests.py
> @@ -48,7 +48,7 @@ def run_boot(test, params, env):
>
>         logging.info("Guest is down; waiting for it to go up again...")
>
> -        session = kvm_utils.wait_for(vm.ssh_login, 120, 0, 2)
> +        session = kvm_utils.wait_for(vm.ssh_login, 240, 0, 2)
>         if not session:
>             raise error.TestFail("Could not log into guest after reboot")
>
> @@ -88,7 +88,7 @@ def run_shutdown(test, params, env):
>
>     logging.info("Shutdown command sent; waiting for guest to go down...")
>
> -    if not kvm_utils.wait_for(vm.is_dead, 120, 0, 1):
> +    if not kvm_utils.wait_for(vm.is_dead, 240, 0, 1):
>         raise error.TestFail("Guest refuses to go down")
>
>     logging.info("Guest is down")
> @@ -445,7 +445,7 @@ def run_yum_update(test, params, env):
>
>     logging.info("Logging into guest...")
>
> -    session = kvm_utils.wait_for(vm.ssh_login, 120, 0, 2)
> +    session = kvm_utils.wait_for(vm.ssh_login, 240, 0, 2)
>     if not session:
>         message = "Could not log into guest"
>         logging.error(message)
>
>
>
> --
> Sudhir Kumar
>



-- 
Sudhir Kumar
This patch does two small things.
1. Prints the guest login command to debug messages.
2. Changes the guest login timeout to 240 seconds. I see the timeout for
*.wait_for() functions in boot test is 240 seconds, while in reboot is 120
seconds which causes the test to fail. We might have missed it by mistake.
240 seconds is a reasonable timeout duration. This patch fixes that.

Signed-off-by: Sudhir Kumar 

Index: autotest/client/tests/kvm/kvm_utils.py
===
--- autotest.orig/client/tests/kvm/kvm_utils.py
+++ autotest/client/tests/kvm/kvm_utils.py
@@ -637,6 +637,7 @@ def remote_login(command, password, prom
 password_prompt_count = 0

 logging.debug("Trying to login...")
+logging.debug("Guest login Command: %s" % command)

 while True:
 (match, text) = sub.read_until_last_line_matches(
Index: autotest/client/tests/kvm/kvm_tests.py
===
--- autotest.orig/client/tests/kvm/kvm_tests.py
+++ autotest/client/tests/kvm/kvm_tests.py
@@ -48,7 +48,7 @@ def run_boot(test, params, env):

 logging.info("Guest is down; waiting for it to go up again...")

-session = kvm_utils.wait_for(vm.ssh_login, 120, 0, 2)
+session = kvm_utils.wait_for(vm.ssh_login, 240, 0, 2)
 if not session:
 raise error.TestFail("Could not log into guest after reboot")

@@ -88,7 +88,7 @@ def run_shutdown(test, params, env):

 logging.info("Shutdown command sent; waiting for guest to go down...")

-if not kvm_utils.wait_for(vm.is_dead, 120, 0, 1):
+if not kvm_utils.wait_for(vm.is_dead, 240, 0, 1):
 raise error.TestFail("Guest refuses to go down")

 logging.info("Guest is down")
@@ -445,7 +445,7 @@ def run_yum_update(test, params, env):

 logging.info("Logging into guest...")

-session = kvm_utils.wait_for(vm.ssh_login, 120, 0, 2)
+session = kvm_utils.wait_for(vm.ssh_login, 240, 0, 2)
 if not session:
 message = "Could not log into guest"
 logging.error(message)



[AUTOTEST] print login command and change some timeout values

2009-07-24 Thread sudhir kumar
This patch does two small things.
1. Prints the guest login command to debug messages.
2. Changes the guest login timeout to 240 seconds. I see the timeout for
*.wait_for() functions in boot test is 240 seconds, while in reboot is 120
seconds which causes the test to fail. We might have missed it by mistake.
240 seconds is a reasonable timeout duration. This patch fixes that.

Signed-off-by: Sudhir Kumar 

Index: autotest/client/tests/kvm/kvm_utils.py
===
--- autotest.orig/client/tests/kvm/kvm_utils.py
+++ autotest/client/tests/kvm/kvm_utils.py
@@ -637,6 +637,7 @@ def remote_login(command, password, prom
 password_prompt_count = 0

 logging.debug("Trying to login...")
+logging.debug("Guest login Command: %s" % command)

 while True:
 (match, text) = sub.read_until_last_line_matches(
Index: autotest/client/tests/kvm/kvm_tests.py
===
--- autotest.orig/client/tests/kvm/kvm_tests.py
+++ autotest/client/tests/kvm/kvm_tests.py
@@ -48,7 +48,7 @@ def run_boot(test, params, env):

 logging.info("Guest is down; waiting for it to go up again...")

-session = kvm_utils.wait_for(vm.ssh_login, 120, 0, 2)
+session = kvm_utils.wait_for(vm.ssh_login, 240, 0, 2)
 if not session:
 raise error.TestFail("Could not log into guest after reboot")

@@ -88,7 +88,7 @@ def run_shutdown(test, params, env):

 logging.info("Shutdown command sent; waiting for guest to go down...")

-if not kvm_utils.wait_for(vm.is_dead, 120, 0, 1):
+if not kvm_utils.wait_for(vm.is_dead, 240, 0, 1):
 raise error.TestFail("Guest refuses to go down")

 logging.info("Guest is down")
@@ -445,7 +445,7 @@ def run_yum_update(test, params, env):

 logging.info("Logging into guest...")

-session = kvm_utils.wait_for(vm.ssh_login, 120, 0, 2)
+session = kvm_utils.wait_for(vm.ssh_login, 240, 0, 2)
 if not session:
 message = "Could not log into guest"
 logging.error(message)



-- 
Sudhir Kumar
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Host latency peaks due to kvm-intel

2009-07-24 Thread Jan Kiszka
Gregory Haskins wrote:
> Jan Kiszka wrote:
>> Hi,
>>
>> did anyone recently tried current KVM for Intel over some real-time
>> Linux? I'm seeing more than 500 us latency peaks on the host,
>> specifically during VM startup. This applies to both 2.6.29.6-rt23 and
>> Xenomai/I-pipe. For -rt, I both tried the included (patched) KVM modules
>> as well as kvm.git head with some additionally required -rt fixes.
>> Xenomai ran over a 2.6.30 kernel with my own KVM-enabler patch.
>>
>> Early instrumentation actually points to the guest exit itself: I added
>> markers right before and after the assembly part of vmx_vcpu_run, and
>> further instrumentation reports that the next host APIC tick should go
>> off right inside guest mode. But KVM leaves the switching part 500 us
>> too late in that case - as if guest exit on external IRQs was disabled.
>>
>> Will debug this further, but I'm also curious to hear other user
>> experiences.
>>
>> Jan
>>
>>   
> Hi Jan,
>   Did you try to run with latency-tracer enabled?  If not, this may
> pinpoint the source for you.

I did, see above.

It finally turned out that I got burned once again by wbinvd: My test
CPUs (and likely also some of my customer) are too "old" to support
SECONDARY_VM_EXEC_CONTROL, which includes trapping guest's wbinvd
invocations. Too bad.

I vaguely recall that someone promised to add a feature reporting
facility for all those nice things, modern VM-extensions may or may not
support (something like or even an extension of /proc/cpuinfo). What is
the state of this plan? Would be specifically interesting for Intel CPUs
as there seem to be many of them out there with restrictions for special
use cases - like real-time.

Jan (who is now patching his guest to avoid wbinvd where possible)

-- 
Siemens AG, Corporate Technology, CT SE 2
Corporate Competence Center Embedded Linux
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[ kvm-Bugs-2826486 ] Clock speed in FreeBSD

2009-07-24 Thread SourceForge.net
Bugs item #2826486, was opened at 2009-07-24 11:16
Message generated for change (Tracker Item Submitted) made by polymorf34
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=893831&aid=2826486&group_id=180599

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: POLYMORF34 (polymorf34)
Assigned to: Nobody/Anonymous (nobody)
Summary: Clock speed in FreeBSD

Initial Comment:
I use KVM 88 and KVM 85 on Gentoo GNU/Linux 2.6.29, running on Intel Core2 CPU 
6320 and Intel Xeon CPU E5405, both in 64 bits mode.
All gests running on FreeBSD 7.1-p5 in 64 bits with -smp 1. The first machine 
host only one gest.

The "sleep" command on FreeBSD does not work has expected. All sleep time are 
multiplied by 3

Example :

 freebsdmachine ~ # time sleep 1
real0m3.148s
user0m0.000s
sys 0m0.002s

freebsdmachine ~ # time sleep 10
real0m31.429s
user0m0.009s
sys 0m0.002s

With the "-no-kvm" flag, the "sleep" command works has expected.

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=893831&aid=2826486&group_id=180599
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Timeout of network interface with OpenBSD 4.5 VM

2009-07-24 Thread Daniel Bareiro
Hi Chris.

On Monday, 20 July 2009 11:51:14 -0400,
Chris Dukes wrote:

> Per a posting to openbsd misc mailing list on the 15th by Nick Osborn
 
> > All good advice, but in the meantime a kernel without acpimadt,
> > ioapic, and mpbios drivers will do the job. It appears they must be
> > completely removed rather than just disabled.
 
> And he goes on to post a minimal kernel config that achieves that
> goal.

I was trying with the configuration suggested by Nick, but in this case
I get a panic [1]. Reading a post of Dmitiry Zotikov [2], it would seem
that the one is a problem with Qemu.

Thanks for your reply.

Regards,
Daniel

[1] http://thread.gmane.org/gmane.os.openbsd.misc/160465/focus=161149
[2] http://thread.gmane.org/gmane.os.openbsd.misc/160945
-- 
Fingerprint: BFB3 08D6 B4D1 31B2 72B9  29CE 6696 BF1B 14E6 1D37
Powered by Debian GNU/Linux Squeeze - Linux user #188.598


signature.asc
Description: Digital signature


Re: [PATCH] KVM: VMX: Fix locking order in handle_invalid_guest_state

2009-07-24 Thread Jan Kiszka
Marcelo Tosatti wrote:
> On Wed, Jul 22, 2009 at 11:53:26PM +0200, Jan Kiszka wrote:
>> Release and re-acquire preemption and IRQ lock in the same order as
>> vcpu_enter_guest does.
> 
> This should happen in vcpu_enter_guest, before it decides to disable
> preemption/irqs (so you consolidate the control there).

Maybe, maybe not. handle_invalid_guest_state is an alternative way of
"executing" guest code, and it currently shares the setup and tear-down
with vmx_vcpu_run. If it has to share parts that actually require
preemption and IRQ lock, then moving makes not much sense. Can anyone
comment on what the requirements for handle_invalid_guest_state are?

I would suggest to merge this fix first and then decide about and
potentially merge a refactoring patch.

Jan

> 
> Maybe add a new member to x86_ops?
> 
>> Signed-off-by: Jan Kiszka 
>> ---
>>
>>  arch/x86/kvm/vmx.c |4 ++--
>>  1 files changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
>> index d75c271..4f914c3 100644
>> --- a/arch/x86/kvm/vmx.c
>> +++ b/arch/x86/kvm/vmx.c
>> @@ -3324,8 +3324,8 @@ static void handle_invalid_guest_state(struct kvm_vcpu 
>> *vcpu,
>>  struct vcpu_vmx *vmx = to_vmx(vcpu);
>>  enum emulation_result err = EMULATE_DONE;
>>  
>> -preempt_enable();
>>  local_irq_enable();
>> +preempt_enable();
>>  
>>  while (!guest_state_valid(vcpu)) {
>>  err = emulate_instruction(vcpu, kvm_run, 0, 0, 0);
>> @@ -3344,8 +3344,8 @@ static void handle_invalid_guest_state(struct kvm_vcpu 
>> *vcpu,
>>  schedule();
>>  }
>>  
>> -local_irq_disable();
>>  preempt_disable();
>> +local_irq_disable();
>>  
>>  vmx->invalid_state_emulation_result = err;
>>  }
>>
> 
> 




signature.asc
Description: OpenPGP digital signature