----- Original Message -----
> From: "Zhouping Liu" <[email protected]>
> To: "LTP List" <[email protected]>
> Sent: Friday, 15 March, 2013 4:03:08 PM
> Subject: [LTP] [PATCH v2 3/7] numa_helper: added a new function is_numa()
> 
> Added a new function is_numa(), which is desinged to judge
> whether a system contains more than 1 available numa nodes
> or not, and lots of cases need it.
> 
> Signed-off-by: Zhouping Liu <[email protected]>
> ---
>  testcases/kernel/include/numa_helper.h |  1 +
>  testcases/kernel/lib/numa_helper.c     | 25
>  +++++++++++++++++++++++++
>  2 files changed, 26 insertions(+)
> 
> diff --git a/testcases/kernel/include/numa_helper.h
> b/testcases/kernel/include/numa_helper.h
> index 8e82d7b..251fd54 100644
> --- a/testcases/kernel/include/numa_helper.h
> +++ b/testcases/kernel/include/numa_helper.h
> @@ -34,5 +34,6 @@ unsigned long get_max_node(void);
>  int get_allowed_nodes_arr(int flag, int *num_nodes, int **nodes);
>  int get_allowed_nodes(int flag, int count, ...);
>  void nh_dump_nodes();
> +int is_numa(void (*cleanup_fn)(void));
>  
>  #endif
> diff --git a/testcases/kernel/lib/numa_helper.c
> b/testcases/kernel/lib/numa_helper.c
> index 4ab8e3c..f9a4c3a 100644
> --- a/testcases/kernel/lib/numa_helper.c
> +++ b/testcases/kernel/lib/numa_helper.c
> @@ -265,3 +265,28 @@ void nh_dump_nodes()
>       print_node_info(NH_CPUS);
>       print_node_info(NH_MEMS | NH_CPUS);
>  }
> +
> +/*
> + * is_numa - judge a system is NUMA system or not
> + * NOTE: the function is designed to try to find more than
> + *       1 available node, at least each node contains memory.
> + * WARN: Don't use this func in child, as it calls tst_brkm()
> + * RETURNS:
> + *     0 - it's not a NUMA system
> + *     1 - it's a NUMA system
> + */
> +int is_numa(void (*cleanup_fn)(void))
> +{
> +     int ret;
> +     int numa_nodes = 0;
> +     int *nodes = NULL;
> +
> +     ret = get_allowed_nodes_arr(NH_MEMS, &numa_nodes, &nodes);

If you don't need node ids, you can pass NULL:
        ret = get_allowed_nodes_arr(NH_MEMS, &numa_nodes, NULL);
Otherwise you should free 'nodes' variable.

> +     if (ret < 0)
> +             tst_brkm(TBROK | TERRNO, cleanup_fn, "get_allowed_nodes_arr");
> +
> +     if (numa_nodes > 1)
> +             return 1;
> +     else
> +             return 0;
> +}
> --
> 1.7.11.7
> 
> 
> ------------------------------------------------------------------------------
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics
> Download AppDynamics Lite for free today:
> http://p.sf.net/sfu/appdyn_d2d_mar
> _______________________________________________
> Ltp-list mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/ltp-list
> 

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to