From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH 2/3] add support for dynamicly allocation of mmu pages. Date: Sun, 19 Aug 2007 11:19:31 +0300 Message-ID: <46C7FD13.5080704@qumranet.com> References: <1187466696.28221.36.camel@izike-desktop.qumranet.com> <1187467003.28221.42.camel@izike-desktop.qumranet.com> <1187467694.28221.52.camel@izike-desktop.qumranet.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org To: Izik Eidus Return-path: In-Reply-To: <1187467694.28221.52.camel-wV29XY6ncz+I84jL4+POOYeT0m0igiSA0E9HWUfgJXw@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: kvm-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org Errors-To: kvm-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org List-Id: kvm.vger.kernel.org Izik Eidus wrote: > simply make the slot memory allocation function to count how much it > allocate, and create blocks of mmu pages by this, > in addition it initiate the lists. > > +++ new_kvm_main.c 2007-08-19 06:21:45.000000000 +0300 > @@ -297,6 +297,8 @@ > Please use 'diff -p' (or simply 'git diff') so that patches have more context information. > kvm_io_bus_init(&kvm->pio_bus); > mutex_init(&kvm->lock); > INIT_LIST_HEAD(&kvm->active_mmu_pages); > + INIT_LIST_HEAD(&kvm->mmu_page_hash_blocks); > + kvm->n_mmu_page_hash_blocks = 0; > kvm_io_bus_init(&kvm->mmio_bus); > spin_lock(&kvm_lock); > list_add(&kvm->vm_list, &vm_list); > @@ -336,6 +338,10 @@ > kvm_free_physmem_slot(&kvm->memslots[i], NULL); > } > > +static void kvm_free_mmu_hash(struct kvm *kvm) > +{ > +} > + > static void free_pio_guest_pages(struct kvm_vcpu *vcpu) > { > int i; > @@ -382,6 +388,7 @@ > kvm_io_bus_destroy(&kvm->mmio_bus); > kvm_free_vcpus(kvm); > kvm_free_physmem(kvm); > + kvm_free_mmu_hash(kvm); > kfree(kvm); > } > > @@ -637,6 +644,7 @@ > struct kvm_memory_slot *memslot; > struct kvm_memory_slot old, new; > int memory_config_version; > + int total_mmu_page_hash_blocks; > > r = -EINVAL; > /* General sanity checks */ > @@ -740,6 +748,20 @@ > if (mem->slot >= kvm->nmemslots) > kvm->nmemslots = mem->slot + 1; > > + total_mmu_page_hash_blocks = (npages + kvm->n_mmu_page_hash_blocks * > + KVM_NUM_MMU_PAGES_BLOCK * KVM_MMU_PAGES_DIVIDER) / > + KVM_NUM_MMU_PAGES_BLOCK / KVM_MMU_PAGES_DIVIDER; > + > + for (; kvm->n_mmu_page_hash_blocks < total_mmu_page_hash_blocks; ++ kvm->n_mmu_page_hash_blocks) { > 80 column limit. > + struct kvm_mmu_hash_block *hash_block = vmalloc(sizeof(struct kvm_mmu_hash_block)); > + > + if (!hash_block) > + goto out_unlock; > + > + memset(hash_block, 0, sizeof(struct kvm_mmu_hash_block)); > + list_add(&hash_block->head, &kvm->mmu_page_hash_blocks); > + } > + > *memslot = new; > ++kvm->memory_config_version; > > This looks very coarse. Why not just resize the hash table? -- error compiling committee.c: too many arguments to function ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/