Takashi,
The patch was applied to CVS. Unfortunately, I do not have a Cell-based machine,
thus I could not test the patch. Let me know if it works for you.
Thanks for your contributions.
On Wed, Sep 26, 2007 at 07:21:20PM +0900, Takashi02 Yamamoto wrote:
> Hi.
>
> I'm working at Sony.
> I'm porting perfmon2 to Sony Cell platform.
>
> This patch is initial Cell support for pfmon command.
> It mainly adds the base files to use Cell PMU.
>
> Please type 'make ARCH=cell' to build pfmon for Cell.
>
> Signed-off-by: Takashi Yamamoto <Takashi02_Yamamoto at hq.scei.sony.co.jp>
> ---
> pfmon/Makefile | 5 +
> pfmon/pfmon.c | 3
> pfmon/pfmon.h | 4 +
> pfmon/pfmon_cell.c | 168
> ++++++++++++++++++++++++++++++++++++++++++++++++
> pfmon/pfmon_cell.h | 61 +++++++++++++++++
> pfmon/pfmon_support.h | 1
> pfmon/pfmon_util_cell.c | 127 ++++++++++++++++++++++++++++++++++++
> 7 files changed, 369 insertions(+)
>
> --- a/pfmon/Makefile
> +++ b/pfmon/Makefile
> @@ -103,6 +103,11 @@ SRCS += pfmon_util_mips64.c pfmon_mips64
> CFLAGS += -DCONFIG_PFMON_MIPS64
> endif
>
> +ifeq ($(ARCH),cell)
> +SRCS += pfmon_cell.c pfmon_util_cell.c
> +CFLAGS += -DCONFIG_PFMON_CELL
> +endif
> +
> DIRS=smpl_mod
> SMPL_MOD_LIB=smpl_mod/libsmplfmt.a
> TARGET=pfmon
> --- a/pfmon/pfmon.c
> +++ b/pfmon/pfmon.c
> @@ -57,6 +57,9 @@ static pfmon_support_t *pfmon_cpus[]={
> &pfmon_mips64_ice9a,
> &pfmon_mips64_ice9b,
> #endif
> +#ifdef CONFIG_PFMON_CELL
> + &pfmon_cell,
> +#endif
> NULL
> };
>
> --- a/pfmon/pfmon.h
> +++ b/pfmon/pfmon.h
> @@ -55,6 +55,10 @@
> #include "pfmon_mips64.h"
> #endif
>
> +#ifdef __powerpc__
> +#include "pfmon_cell.h"
> +#endif
> +
> typedef pfarg_pmd_t pfmon_pmd_t;
> typedef pfarg_pmc_t pfmon_pmc_t;
> typedef pfarg_setdesc_t pfmon_setdesc_t;
> --- /dev/null
> +++ b/pfmon/pfmon_cell.c
> @@ -0,0 +1,168 @@
> +/*
> + * Cell Broadband Engine PMU support for pfmon.
> + *
> + * This file is part of pfmon, a sample tool to measure performance
> + * of applications for Linux.
> + *
> + * Copyright (C) 2007 Sony Computer Entertainment Inc.
> + * Copyright 2007 Sony Corporation.
> + *
> + * 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; version 2 of the License.
> + *
> + * 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 <ctype.h>
> +#include <pfmlib_cell.h>
> +#include "pfmon.h"
> +
> +static pfmon_cell_options_t pfmon_cell_opt;
> +
> +typedef struct {
> + int dummy;
> + pfmon_cell_args_t args;
> +} pfmon_cell_param_t;
> +
> +static int pfmon_cell_prepare_registers(pfmon_event_set_t *set)
> +{
> + DPRINT(("set:%p\n", set));
> + return 0;
> +}
> +
> +static int pfmon_cell_install_pmc_registers(pfmon_sdesc_t *sdesc,
> + pfmon_event_set_t *set)
> +{
> + DPRINT(("set:%p sdesc:%p\n", set, sdesc));
> + return 0;
> +}
> +
> +static int pfmon_cell_install_pmd_registers(pfmon_sdesc_t *sdesc,
> + pfmon_event_set_t *set)
> +{
> + DPRINT(("set:%p sdesc:%p\n", set, sdesc));
> + return 0;
> +}
> +
> +static void pfmon_cell_usage(void)
> +{
> + DPRINT(("\n"));
> +}
> +
> +static struct option cmd_cell_options[] = {
> + {0, 0, 0, 0},
> +};
> +
> +static int pfmon_cell_initialize(void)
> +{
> + int r;
> +
> + r = pfmon_register_options(cmd_cell_options,
> + sizeof(cmd_cell_options));
> + if (r)
> + return r;
> +
> + /* connect pfmon model specific options */
> + options.model_options = &pfmon_cell_opt;
> +
> + return 0;
> +}
> +
> +static int pfmon_cell_parse_options(int code, char *optarg)
> +{
> + DPRINT(("\n"));
> + return 0;
> +}
> +
> +static int pfmon_cell_create_set(pfmon_event_set_t *set)
> +{
> + pfmlib_cell_input_param_t *p;
> +
> + if (set->mod_inp)
> + return 0;
> +
> + p = malloc(sizeof(pfmlib_cell_input_param_t));
> + if (p == NULL)
> + fatal_error("cannot allocate memory for PMU specific "
> + "options\n");
> +
> + memset(p, 0, sizeof(pfmlib_cell_input_param_t));
> +
> + set->mod_inp = p;
> + set->mod_args = NULL;
> +
> + return 0;
> +}
> +
> +static int pfmon_cell_setup(pfmon_event_set_t *set)
> +{
> + pfmlib_cell_input_param_t *p;
> + int i;
> +
> + DPRINT(("%s set:%p\n", __FUNCTION__, set));
> +
> + p = set->mod_inp;
> + p->triggers = 0;
> + for (i = 0; i < PMU_CELL_NUM_COUNTERS; i++) {
> + p->pfp_cell_counters[i].pmX_control_num = 0;
> + p->pfp_cell_counters[i].spe_subunit = 0;
> + p->pfp_cell_counters[i].polarity = 1;
> + p->pfp_cell_counters[i].input_control = 0;
> + p->pfp_cell_counters[i].cnt_mask = 0;
> + p->pfp_cell_counters[i].flags = 0;
> + }
> +
> + return 0;
> +}
> +
> +static int pfmon_cell_print_header(FILE *fp)
> +{
> + DPRINT(("\n"));
> + return 0;
> +}
> +
> +static int pfmon_cell_setup_ctx_flags(pfmon_ctx_t *ctx)
> +{
> + DPRINT(("\n"));
> + return 0;
> +}
> +
> +static void pfmon_cell_verify_cmdline(int argc, char **argv)
> +{
> + if (options.code_trigger_start ||
> + options.code_trigger_stop ||
> + options.data_trigger_start ||
> + options.data_trigger_stop ||
> + options.opt_code_trigger_repeat ||
> + options.opt_code_trigger_follow ||
> + options.opt_data_trigger_repeat ||
> + options.opt_data_trigger_follow ||
> + options.opt_data_trigger_ro ||
> + options.opt_data_trigger_wo)
> + fatal_error("trigger options are not implemented\n");
> +}
> +
> +pfmon_support_t pfmon_cell = {
> + .name = "Cell/B.E PMU",
> + .pmu_type = PFMLIB_CELL_PMU,
> + .pfmon_initialize = pfmon_cell_initialize,
> + .pfmon_usage = pfmon_cell_usage,
> + .pfmon_parse_options = pfmon_cell_parse_options,
> + .pfmon_create_set = pfmon_cell_create_set,
> + .pfmon_setup = pfmon_cell_setup,
> + .pfmon_prepare_registers = pfmon_cell_prepare_registers,
> + .pfmon_install_pmc_registers = pfmon_cell_install_pmc_registers,
> + .pfmon_install_pmd_registers = pfmon_cell_install_pmd_registers,
> + .pfmon_print_header = pfmon_cell_print_header,
> + .pfmon_setup_ctx_flags = pfmon_cell_setup_ctx_flags,
> + .pfmon_verify_cmdline = pfmon_cell_verify_cmdline,
> +};
> --- /dev/null
> +++ b/pfmon/pfmon_cell.h
> @@ -0,0 +1,61 @@
> +/*
> + * Cell Broadband Engine PMU support for pfmon.
> + *
> + * This file is part of pfmon, a sample tool to measure performance
> + * of applications for Linux.
> + *
> + * Copyright (C) 2007 Sony Computer Entertainment Inc.
> + * Copyright 2007 Sony Corporation.
> + *
> + * 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; version 2 of the License.
> + *
> + * 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
> + */
> +
> +#ifndef __PFMON_CELL_H__
> +#define __PFMON_CELL_H__ 1
> +
> +static __inline__ unsigned int bit_weight(unsigned long x)
> +{
> + unsigned int cnt = 0;
> +
> + for (; x; x >>= 1)
> + if (x & 0x1)
> + cnt++;
> + return cnt;
> +}
> +
> +static inline unsigned long find_last_bit_set(unsigned long x)
> +{
> + unsigned int bit, last_bit = ~0;
> +
> + for (bit = 0; x; bit++, x >>= 1)
> + if (x & 0x1)
> + last_bit = bit;
> +
> + return last_bit;
> +}
> +
> +typedef struct {
> + int dummy;
> +} pfmon_cache_info_t;
> +
> +typedef struct {
> + int dummy;
> +} pfmon_cell_options_t;
> +
> +typedef struct {
> + int dummy;
> +} pfmon_cell_args_t;
> +
> +#endif /* __PFMON_CELL_H__ */
> --- a/pfmon/pfmon_support.h
> +++ b/pfmon/pfmon_support.h
> @@ -42,6 +42,7 @@ extern pfmon_support_t pfmon_mips64_20kc
> extern pfmon_support_t pfmon_mips64_25kf;
> extern pfmon_support_t pfmon_mips64_ice9a;
> extern pfmon_support_t pfmon_mips64_ice9b;
> +extern pfmon_support_t pfmon_cell;
>
> #endif /* __PFMON_SUPPORT_H__ */
>
> --- /dev/null
> +++ b/pfmon/pfmon_util_cell.c
> @@ -0,0 +1,127 @@
> +/*
> + * Cell Broadband Engine PMU support for pfmon.
> + *
> + * This file is part of pfmon, a sample tool to measure performance
> + * of applications for Linux.
> + *
> + * Copyright (C) 2007 Sony Computer Entertainment Inc.
> + * Copyright 2007 Sony Corporation.
> + *
> + * 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; version 2 of the License.
> + *
> + * 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 <sys/types.h>
> +#include <stdio.h>
> +#include <errno.h>
> +#include <unistd.h>
> +#include <syscall.h>
> +
> +#include "pfmon.h"
> +
> +int pfmon_set_code_breakpoint(pid_t pid, pfmon_trigger_t *brk)
> +{
> + DPRINT(("\n"));
> + return -1;
> +}
> +
> +int pfmon_clear_code_breakpoint(pid_t pid, pfmon_trigger_t *brk)
> +{
> + DPRINT(("\n"));
> + return -1;
> +}
> +
> +int pfmon_set_data_breakpoint(pid_t pid, pfmon_trigger_t *brk)
> +{
> + DPRINT(("\n"));
> + return -1;
> +}
> +
> +int pfmon_clear_data_breakpoint(pid_t pid, pfmon_trigger_t *brk)
> +{
> + DPRINT(("\n"));
> + return -1;
> +}
> +
> +int pfmon_resume_after_code_breakpoint(pid_t pid, pfmon_trigger_t *brk)
> +{
> + DPRINT(("\n"));
> + return -1;
> +}
> +
> +int pfmon_resume_after_data_breakpoint(pid_t pid, pfmon_trigger_t *brk)
> +{
> + DPRINT(("\n"));
> + return -1;
> +}
> +
> +void pfmon_arch_initialize(void)
> +{
> + DPRINT(("\n"));
> + options.opt_support_gen = 0;
> + options.libpfm_generic = 0;
> + options.nibrs = 0;
> + options.ndbrs = 0;
> +}
> +
> +int pfmon_enable_all_breakpoints(pid_t pid)
> +{
> + DPRINT(("\n"));
> + return -1;
> +}
> +
> +int pfmon_disable_all_breakpoints(pid_t pid)
> +{
> + DPRINT(("\n"));
> + return -1;
> +}
> +
> +int pfmon_validate_code_trigger_address(unsigned long addr)
> +{
> + DPRINT(("\n"));
> + return -1;
> +}
> +
> +int pfmon_validate_data_trigger_address(unsigned long addr)
> +{
> + DPRINT(("\n"));
> + return -1;
> +}
> +
> +void pfmon_segv_handler_info(struct siginfo *si, void *sc)
> +{
> + DPRINT(("\n"));
> +}
> +
> +int pfmon_get_breakpoint_addr(pid_t pid, unsigned long *addr, int
> *is_data)
> +{
> + DPRINT(("\n"));
> + return -1;
> +}
> +
> +int pfmon_get_return_pointer(pid_t pid, unsigned long *rp)
> +{
> + DPRINT(("\n"));
> + return -1;
> +}
> +
> +void pfmon_print_simple_cpuinfo(FILE *fp, const char *msg)
> +{
> + fprintf(fp, "%sCell Broadband Engine. \n", msg);
> +}
> +
> +void pfmon_print_cpuinfo(FILE * fp)
> +{
> + fprintf(fp, "# CPU name: Cell Broadband Engine. \n");
> +}
> _______________________________________________
> perfmon mailing list
> [email protected]
> http://www.hpl.hp.com/hosted/linux/mail-archives/perfmon/
--
-Stephane
_______________________________________________
perfmon mailing list
[email protected]
http://www.hpl.hp.com/hosted/linux/mail-archives/perfmon/