From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcelo Tosatti Subject: Re: [PATCH] kvm/qemu: use statfs to determine size of huge pages Date: Fri, 20 Feb 2009 21:18:42 -0300 Message-ID: <20090221001842.GA8300@amt.cnet> References: <1235057376-22481-1-git-send-email-joerg.roedel@amd.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Avi Kivity , kvm@vger.kernel.org To: Joerg Roedel Return-path: Received: from mx2.redhat.com ([66.187.237.31]:60807 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751754AbZBUATX (ORCPT ); Fri, 20 Feb 2009 19:19:23 -0500 Content-Disposition: inline In-Reply-To: <1235057376-22481-1-git-send-email-joerg.roedel@amd.com> Sender: kvm-owner@vger.kernel.org List-ID: Hi Joerg, On Thu, Feb 19, 2009 at 04:29:36PM +0100, Joerg Roedel wrote: > The current method of finding out the size of huge pages does not work > reliable anymore. Current Linux supports more than one huge page size > but /proc/meminfo only show one of the supported sizes. > To find out the real page size used can be found by calling statfs. This > patch changes kvm/qemu to use statfs instead of parsing /proc/meminfo. > > Signed-off-by: Joerg Roedel > + if (fs.f_type != HUGETLBFS_MAGIC) { > + fprintf(stderr, "Path not on HugeTLBFS: %s\n", path); > + return 0; > } Would be nicer to use standard page size (sysconf) in case its not a hugetlbfs mount, instead of failing. Useful for testing with shmem. > - size = strstr(buf, needle); > - if (!size) > - return 0; > - size += strlen(needle); > - hugepagesize = strtol(size, NULL, 0); > - return hugepagesize; > + return fs.f_bsize; > } > > static void *alloc_mem_area(size_t memory, unsigned long *len, const char *path) > @@ -4762,7 +4760,7 @@ static void *alloc_mem_area(size_t memory, unsigned long *len, const char *path) > if (asprintf(&filename, "%s/kvm.XXXXXX", path) == -1) > return NULL; > > - hpagesize = gethugepagesize() * 1024; > + hpagesize = gethugepagesize(path); > if (!hpagesize) > return NULL; Out of curiosity, your immediate reason for this patch is use of gbpages?