public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Liang, Kan" <kan.liang@linux.intel.com>
To: Ian Rogers <irogers@google.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Jiri Olsa <jolsa@kernel.org>, Namhyung Kim <namhyung@kernel.org>,
	Zhengjun Xing <zhengjun.xing@linux.intel.com>,
	linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
	Edward Baker <edward.baker@intel.com>,
	Dan Williams <dan.j.williams@intel.com>,
	perry.taylor@intel.com, caleb.biggers@intel.com,
	samantha.alt@intel.com, weilin.wang@intel.com
Subject: Re: [PATCH v2 8/9] perf metrics: Add has_optane literal
Date: Thu, 23 Mar 2023 16:31:21 -0400	[thread overview]
Message-ID: <44476adc-3797-504b-2b82-8ec670c691b6@linux.intel.com> (raw)
In-Reply-To: <20230323192028.135759-9-irogers@google.com>



On 2023-03-23 3:20 p.m., Ian Rogers wrote:
> Add literal so that if optane memory isn't installed we can record
> fewer events.  

I think we call it pmem (Persistent Memory) everywhere in the Linux
code. Maybe we should use #has_pmem instead?

Thanks,
Kan
> The file detection mechanism was suggested by Dan
> Williams <dan.j.williams@intel.com> in:
> https://lore.kernel.org/linux-perf-users/641bbe1eced26_1b98bb29440@dwillia2-xfh.jf.intel.com.notmuch/
> 
> Signed-off-by: Ian Rogers <irogers@google.com>
> ---
>  tools/perf/util/expr.c | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
> 
> diff --git a/tools/perf/util/expr.c b/tools/perf/util/expr.c
> index d46a1878bc9e..a43cdda0b044 100644
> --- a/tools/perf/util/expr.c
> +++ b/tools/perf/util/expr.c
> @@ -14,6 +14,7 @@
>  #include "util/hashmap.h"
>  #include "smt.h"
>  #include "tsc.h"
> +#include <api/fs/fs.h>
>  #include <linux/err.h>
>  #include <linux/kernel.h>
>  #include <linux/zalloc.h>
> @@ -400,6 +401,20 @@ double arch_get_tsc_freq(void)
>  }
>  #endif
>  
> +static double has_optane(void)
> +{
> +	static bool has_optane, cached;
> +	const char *sysfs = sysfs__mountpoint();
> +	char path[PATH_MAX];
> +
> +	if (!cached) {
> +		snprintf(path, sizeof(path), "%s/firmware/acpi/tables/NFIT", sysfs);
> +		has_optane = access(path, F_OK) == 0;
> +		cached = true;
> +	}
> +	return has_optane ? 1.0 : 0.0;
> +}
> +
>  double expr__get_literal(const char *literal, const struct expr_scanner_ctx *ctx)
>  {
>  	const struct cpu_topology *topology;
> @@ -449,6 +464,10 @@ double expr__get_literal(const char *literal, const struct expr_scanner_ctx *ctx
>  		result = perf_pmu__cpu_slots_per_cycle();
>  		goto out;
>  	}
> +	if (!strcmp("#has_optane", literal)) {
> +		result = has_optane();
> +		goto out;
> +	}
>  
>  	pr_err("Unrecognized literal '%s'", literal);
>  out:

  reply	other threads:[~2023-03-23 20:31 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-23 19:20 [PATCH v2 0/9] Update Intel events and make optane events dynamic Ian Rogers
2023-03-23 19:20 ` [PATCH v2 1/9] perf vendor events: Broadwell v27 events Ian Rogers
2023-03-23 19:20 ` [PATCH v2 2/9] perf vendor events: Broadwellde v9 events Ian Rogers
2023-03-23 19:20 ` [PATCH v2 3/9] perf vendor events: Broadwellx v20 events Ian Rogers
2023-03-23 19:20 ` [PATCH v2 4/9] perf vendor events: Haswell v33 events Ian Rogers
2023-03-23 19:20 ` [PATCH v2 5/9] perf vendor events: Haswellx v27 events Ian Rogers
2023-03-23 19:20 ` [PATCH v2 6/9] perf vendor events: Jaketown v23 events Ian Rogers
2023-03-23 19:20 ` [PATCH v2 7/9] perf vendor events: Sandybridge v19 events Ian Rogers
2023-03-23 19:20 ` [PATCH v2 8/9] perf metrics: Add has_optane literal Ian Rogers
2023-03-23 20:31   ` Liang, Kan [this message]
2023-03-23 20:43     ` Dan Williams
2023-03-24  7:15       ` Ian Rogers
2023-03-23 19:20 ` [PATCH v2 9/9] perf vendor events: Update metrics to detect optane memory at runtime Ian Rogers

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=44476adc-3797-504b-2b82-8ec670c691b6@linux.intel.com \
    --to=kan.liang@linux.intel.com \
    --cc=acme@kernel.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=caleb.biggers@intel.com \
    --cc=dan.j.williams@intel.com \
    --cc=edward.baker@intel.com \
    --cc=irogers@google.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=perry.taylor@intel.com \
    --cc=peterz@infradead.org \
    --cc=samantha.alt@intel.com \
    --cc=weilin.wang@intel.com \
    --cc=zhengjun.xing@linux.intel.com \
    /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