public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Caspar Zhang <caspar@casparzhang.com>
To: Wanlong Gao <gaowanlong@cn.fujitsu.com>
Cc: ltp-list@lists.sourceforge.net
Subject: Re: [LTP] [PATCH v2 1/5] A library used to mount hugetlbfs automatically
Date: Wed, 28 Dec 2011 14:55:04 +0800	[thread overview]
Message-ID: <4EFABD48.7030005@casparzhang.com> (raw)
In-Reply-To: <1325052154-13957-1-git-send-email-gaowanlong@cn.fujitsu.com>

On 12/28/2011 02:02 PM, Wanlong Gao wrote:
> This library includes a set of functions used to mount hugetlbfs automatically when doing the hugemmap tests.
> 
> Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
> ---
>  testcases/kernel/mem/hugetlb/hugemmap/Makefile |    6 ++-
>  testcases/kernel/mem/hugetlb/hugemmap/libmnt.c |   58 ++++++++++++++++++++++++
>  2 files changed, 63 insertions(+), 1 deletions(-)
>  create mode 100644 testcases/kernel/mem/hugetlb/hugemmap/libmnt.c
> 
> diff --git a/testcases/kernel/mem/hugetlb/hugemmap/Makefile b/testcases/kernel/mem/hugetlb/hugemmap/Makefile
> index a1ba46e..e6ba4fe 100644
> --- a/testcases/kernel/mem/hugetlb/hugemmap/Makefile
> +++ b/testcases/kernel/mem/hugetlb/hugemmap/Makefile
> @@ -23,5 +23,9 @@
>  top_srcdir              ?= ../../../../..
>  
>  include $(top_srcdir)/include/mk/testcases.mk
> -include $(abs_srcdir)/../Makefile.inc
> +
> +MAKE_TARGETS	:= $(filter-out libmnt,$(patsubst $(abs_srcdir)/%.c,%,$(wildcard $(abs_srcdir)/*.c)))
> +
> +$(MAKE_TARGETS): %: %.o libmnt.o
> +
>  include $(top_srcdir)/include/mk/generic_leaf_target.mk
> diff --git a/testcases/kernel/mem/hugetlb/hugemmap/libmnt.c b/testcases/kernel/mem/hugetlb/hugemmap/libmnt.c
> new file mode 100644
> index 0000000..36e2700
> --- /dev/null
> +++ b/testcases/kernel/mem/hugetlb/hugemmap/libmnt.c
> @@ -0,0 +1,58 @@
> +/*
> + *
> + *   Copyright (c) Fujitsu Corp., 2011
> + *
> + *   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 <stdio.h>
> +#include <stdlib.h>
> +#include <sys/mount.h>
> +#include <errno.h>
> +
> +#include "test.h"
> +#include "libmnt.h"
> +
> +void hugepage_alloc(int num)
> +{
> +	FILE *file = fopen("/proc/sys/vm/nr_hugepages", "w+");
> +	if (file == NULL) {
> +		tst_brkm(TBROK|TERRNO, NULL,
> +			 "fopen failed on /proc/sys/vm/nr_hugepages");
> +	}
> +
> +	if (fprintf(file, "%d", num) < 0) {
> +		tst_brkm(TBROK|TERRNO, NULL,
> +			 "fprintf failed on /proc/sys/vm/nr_hugepages");
> +	}
> +
> +	fclose(file);
> +}

Besides the questions I mentions in previous mail, you may also want to
use new functions I committed to mem/lib just now:

    void set_sys_tune(char *sys_file, long tune, int check);
    long get_sys_tune(char *sys_file);

Thanks,
Caspar

> +
> +void mount_hugetlbfs(char *mount_point)
> +{
> +	if (mount("none", mount_point, "hugetlbfs", 0, NULL) < 0) {
> +		tst_brkm(TBROK|TERRNO, NULL,
> +			 "mount failed on %s", mount_point);
> +	}
> +}
> +
> +void umount_hugetlbfs(char *mount_point)
> +{
> +	if (umount(mount_point)) {
> +		tst_brkm(TBROK|TERRNO, NULL,
> +			 "umount faild on %s", mount_point);
> +	}
> +}


------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create 
new or port existing apps to sell to consumers worldwide. Explore the 
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

  reply	other threads:[~2011-12-28  7:01 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1322044169-30851-1-git-send-email-gaowanlong@cn.fujitsu.com>
     [not found] ` <1322044169-30851-2-git-send-email-gaowanlong@cn.fujitsu.com>
2011-12-28  5:21   ` [LTP] [PATCH 1/5] A library used to mount hugetlbfs automatically Caspar Zhang
2011-12-28  6:02     ` [LTP] [PATCH v2 " Wanlong Gao
2011-12-28  6:55       ` Caspar Zhang [this message]
     [not found] ` <1322044169-30851-3-git-send-email-gaowanlong@cn.fujitsu.com>
2011-12-28  5:22   ` [LTP] [PATCH 2/5] hugemmap01.c : automatically mount hugetlbfs Caspar Zhang
2011-12-28  6:23     ` Wanlong Gao
2011-12-28  6:43       ` Caspar Zhang
2011-12-28  6:40 ` [LTP] [PATCH 7/5] hugemmap: change hard-coded page alloc size to a macro Wanlong Gao
     [not found] ` <4EF308EF.9010604@cn.fujitsu.com>
     [not found]   ` <4EF9169B.2000106@cn.fujitsu.com>
2012-01-20 14:40     ` [LTP] [PATCH 0/5] Automatically mount hugetlbfs for hugemmap tests Cyril Hrubis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4EFABD48.7030005@casparzhang.com \
    --to=caspar@casparzhang.com \
    --cc=gaowanlong@cn.fujitsu.com \
    --cc=ltp-list@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox