diff mbox

Resend: patch: qemu + hugetlbfs..

Message ID 497A34EA.3050703@redhat.com (mailing list archive)
State Accepted, archived
Headers show

Commit Message

john cooper Jan. 23, 2009, 9:21 p.m. UTC
Avi Kivity wrote:
> john cooper wrote:
>> This trivial patch never did manage to find its way
>> in.  Marcelo called it to my attention earlier in
>> the week.  I've tweaked it to apply to kvm-83 and
>> the resulting patch is attached.  I've left the
>> prior e-mail discussion below for reference.
>>
>
> Sorry for missing this (copying me helps).  Please resubmit with a 
> signoff.Also, please protect with #ifdef MAP_POPULATE to ease merging 
> into upstream eventually.
Updated patch attached.

-john


Signed-off-by: john cooper <john.cooper@redhat.com>

Comments

Avi Kivity Feb. 5, 2009, 3:42 p.m. UTC | #1
john cooper wrote:
> Avi Kivity wrote:
>> john cooper wrote:
>>> This trivial patch never did manage to find its way
>>> in.  Marcelo called it to my attention earlier in
>>> the week.  I've tweaked it to apply to kvm-83 and
>>> the resulting patch is attached.  I've left the
>>> prior e-mail discussion below for reference.
>>>
>>
>> Sorry for missing this (copying me helps).  Please resubmit with a 
>> signoff.Also, please protect with #ifdef MAP_POPULATE to ease merging 
>> into upstream eventually.
> Updated patch attached.
>

Sorry, still rejects horribly.  What did you generate this against?

The kernel/ part seems unrelated.
Marcelo Tosatti Feb. 5, 2009, 4:12 p.m. UTC | #2
On Thu, Feb 05, 2009 at 05:42:34PM +0200, Avi Kivity wrote:
> john cooper wrote:
>> Avi Kivity wrote:
>>> john cooper wrote:
>>>> This trivial patch never did manage to find its way
>>>> in.  Marcelo called it to my attention earlier in
>>>> the week.  I've tweaked it to apply to kvm-83 and
>>>> the resulting patch is attached.  I've left the
>>>> prior e-mail discussion below for reference.
>>>>
>>>
>>> Sorry for missing this (copying me helps).  Please resubmit with a  
>>> signoff.Also, please protect with #ifdef MAP_POPULATE to ease merging 
>>> into upstream eventually.
>> Updated patch attached.
>>
>
> Sorry, still rejects horribly.  What did you generate this against?
>
> The kernel/ part seems unrelated.

This was merged through the kvm-devel branch (unless you dropped it).

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Avi Kivity Feb. 5, 2009, 4:15 p.m. UTC | #3
Marcelo Tosatti wrote:
>>
>> Sorry, still rejects horribly.  What did you generate this against?
>>
>> The kernel/ part seems unrelated.
>>     
>
> This was merged through the kvm-devel branch (unless you dropped it).
>   

Right, so that's why it rejected.

I even saw it in the log when I tried to find why it rejected... and 
ignored it.
diff mbox

Patch

=================================================================
--- a/qemu/vl.c
+++ b/qemu/vl.c
@@ -237,6 +237,9 @@  int semihosting_enabled = 0;
 int time_drift_fix = 0;
 unsigned int kvm_shadow_memory = 0;
 const char *mem_path = NULL;
+#ifdef MAP_POPULATE
+int mem_prealloc = 1;	/* force preallocation of physical target memory */
+#endif
 int hpagesize = 0;
 const char *cpu_vendor_string;
 #ifdef TARGET_ARM
@@ -4116,7 +4119,12 @@  static void help(int exitcode)
 #endif
            "-tdf            inject timer interrupts that got lost\n"
            "-kvm-shadow-memory megs set the amount of shadow pages to be allocated\n"
-           "-mem-path       set the path to hugetlbfs/tmpfs mounted directory, also enables allocation of guest memory with huge pages\n"
+           "-mem-path       set the path to hugetlbfs/tmpfs mounted directory, also\n"
+           "                enables allocation of guest memory with huge pages\n"
+#ifdef MAP_POPULATE
+           "-mem-prealloc   toggles preallocation of -mem-path backed physical memory\n"
+           "                at startup.  Default is enabled.\n"
+#endif
 	   "-option-rom rom load a file, rom, into the option ROM space\n"
 #ifdef TARGET_SPARC
            "-prom-env variable=value  set OpenBIOS nvram variables\n"
@@ -4246,6 +4254,9 @@  enum {
     QEMU_OPTION_tdf,
     QEMU_OPTION_kvm_shadow_memory,
     QEMU_OPTION_mempath,
+#ifdef MAP_POPULATE
+    QEMU_OPTION_mem_prealloc,
+#endif
 };
 
 typedef struct QEMUOption {
@@ -4381,6 +4392,9 @@  static const QEMUOption qemu_options[] =
     { "icount", HAS_ARG, QEMU_OPTION_icount },
     { "incoming", HAS_ARG, QEMU_OPTION_incoming },
     { "mem-path", HAS_ARG, QEMU_OPTION_mempath },
+#ifdef MAP_POPULATE
+    { "mem-prealloc", 0, QEMU_OPTION_mem_prealloc },
+#endif
     { NULL },
 };
 
@@ -4663,6 +4677,9 @@  void *alloc_mem_area(size_t memory, unsi
     char *filename;
     void *area;
     int fd;
+#ifdef MAP_POPULATE
+    int flags;
+#endif
 
     if (asprintf(&filename, "%s/kvm.XXXXXX", path) == -1)
 	return NULL;
@@ -4690,13 +4707,21 @@  void *alloc_mem_area(size_t memory, unsi
      */
     ftruncate(fd, memory);
 
+#ifdef MAP_POPULATE
+    /* NB: MAP_POPULATE won't exhaustively alloc all phys pages in the case
+     * MAP_PRIVATE is requested.  For mem_prealloc we mmap as MAP_SHARED
+     * to sidestep this quirk.
+     */
+    flags = mem_prealloc ? MAP_POPULATE|MAP_SHARED : MAP_PRIVATE;
+    area = mmap(0, memory, PROT_READ|PROT_WRITE, flags, fd, 0);
+#else
     area = mmap(0, memory, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0);
+#endif
     if (area == MAP_FAILED) {
-	perror("mmap");
+	perror("alloc_mem_area: can't mmap hugetlbfs pages");
 	close(fd);
-	return NULL;
+	return (NULL);
     }
-
     *len = memory;
     return area;
 }
@@ -5377,6 +5402,11 @@  int main(int argc, char **argv, char **e
             case QEMU_OPTION_mempath:
 		mem_path = optarg;
 		break;
+#ifdef MAP_POPULATE
+            case QEMU_OPTION_mem_prealloc:
+		mem_prealloc = !mem_prealloc;
+		break;
+#endif
             case QEMU_OPTION_name:
                 qemu_name = optarg;
                 break;
=================================================================
--- a/kernel/x86/Kbuild
+++ b/kernel/x86/Kbuild
@@ -9,8 +9,8 @@  kvm-objs := kvm_main.o x86.o mmu.o x86_e
 ifeq ($(EXT_CONFIG_KVM_TRACE),y)
 kvm-objs += kvm_trace.o
 endif
-ifeq ($(CONFIG_DMAR),y)
-kvm-objs += vtd.o
+ifeq ($(CONFIG_IOMMU_API),y)
+kvm-objs += iommu.o
 endif
 kvm-intel-objs := vmx.o vmx-debug.o ../external-module-compat.o
 kvm-amd-objs := svm.o ../external-module-compat.o