lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 08 Apr 2014 16:09:03 +0900
From:	Namhyung Kim <namhyung@...il.com>
To:	Don Zickus <dzickus@...hat.com>
Cc:	acme@...stprotocols.net, LKML <linux-kernel@...r.kernel.org>,
	jolsa@...hat.com, jmario@...hat.com, fowles@...each.com,
	peterz@...radead.org, eranian@...gle.com, andi.kleen@...el.com,
	Arnaldo Carvalho de Melo <acme@...hat.com>,
	David Ahern <dsahern@...il.com>,
	Frederic Weisbecker <fweisbec@...il.com>,
	Mike Galbraith <efault@....de>,
	Paul Mackerras <paulus@...ba.org>,
	Richard Fowles <rfowles@...hat.com>
Subject: Re: [PATCH 04/15 V3] perf c2c: Dump raw records, decode data_src bits

On Mon, 24 Mar 2014 15:36:55 -0400, Don Zickus wrote:
> +	union perf_mem_data_src dsrc = { .val = val, };
> +	int printed = scnprintf(bf, size, PREFIX);
> +	size_t i;
> +	bool first_present = true;
> +
> +	for (i = 0; i < ARRAY_SIZE(decode_bits); i++) {
> +		int bitval;
> +
> +		switch (decode_bits[i].field) {
> +		case OP:  bitval = decode_bits[i].bit & dsrc.mem_op;    break;
> +		case LVL: bitval = decode_bits[i].bit & dsrc.mem_lvl;   break;
> +		case SNP: bitval = decode_bits[i].bit & dsrc.mem_snoop; break;
> +		case LCK: bitval = decode_bits[i].bit & dsrc.mem_lock;  break;
> +		case TLB: bitval = decode_bits[i].bit & dsrc.mem_dtlb;  break;
> +		default: bitval = 0;					break;
> +		}
> +
> +		if (!bitval)
> +			continue;
> +
> +		if (strlen(decode_bits[i].name) + !!i > size - printed - sizeof(SUFFIX)) {
> +			sprintf(bf + size - sizeof(SUFFIX) - sizeof(ELLIPSIS) + 1, ELLIPSIS);
> +			printed = size - sizeof(SUFFIX);
> +			break;
> +		}
> +
> +		printed += scnprintf(bf + printed, size - printed, "%s%s",
> +				     first_present ? "" : ",", decode_bits[i].name);
> +		first_present = false;
> +	}
> +
> +	printed += scnprintf(bf + printed, size - printed, SUFFIX);

It seems that adjusting bf and size as printed might make the code
somewhat simpler and readable - i.e.:

        ret = scnprintf(bf, size, "%s", ...);

        bf += ret;
        size -= ret;
        printed += ret;


> +	return printed;
>  }
>  
> -static int perf_c2c__process_load(struct perf_evsel *evsel,
> -				  struct perf_sample *sample,
> -				  struct addr_location *al)
> +static int perf_c2c__fprintf_header(FILE *fp)
>  {
> -	perf_sample__fprintf(sample, evsel, al, stdout);
> -	return 0;
> +	int printed = fprintf(fp, "%c %-16s  %6s  %6s  %4s  %18s  %18s  %18s  %6s  %-10s %-60s %s\n", 
> +			      'T',
> +			      "Status",
> +			      "Pid",
> +			      "Tid",
> +			      "CPU",
> +			      "Inst Adrs",
> +			      "Virt Data Adrs",
> +			      "Phys Data Adrs",
> +			      "Cycles",
> +			      "Source",
> +			      "  Decoded Source",
> +			      "ObJect:Symbol");

s/ObJect/Object/ ?

Thanks,
Namhyung


> +	return printed + fprintf(fp, "%-*.*s\n", printed, printed, graph_dotted_line);
> +}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ