From: "Ananyev, Konstantin" <konstantin.ananyev@intel.com>
To: "Andralojc, WojciechX" <wojciechx.andralojc@intel.com>,
"dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH v2] Patch introducing API to read/write Intel Architecture Model Specific Registers (MSR)...
Date: Wed, 20 Jan 2016 11:25:52 +0000 [thread overview]
Message-ID: <2601191342CEEE43887BDE71AB97725836AEC360@irsmsx105.ger.corp.intel.com> (raw)
In-Reply-To: <1453287399-65915-1-git-send-email-wojciechx.andralojc@intel.com>
Hi Wojciech,
Couple of nits, see below.
Konstantin
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Wojciech Andralojc
> Sent: Wednesday, January 20, 2016 10:57 AM
> To: dev@dpdk.org
> Subject: [dpdk-dev] [PATCH v2] Patch introducing API to read/write Intel Architecture Model Specific Registers (MSR)...
>
> Patch rework based on feedback, only x86 specific functions left under lib/librte_eal/common/include/arch/x86/.
>
> Signed-off-by: Wojciech Andralojc <wojciechx.andralojc@intel.com>
> ---
> lib/librte_eal/common/include/arch/x86/rte_msr.h | 158 +++++++++++++++++++++++
> 1 file changed, 158 insertions(+)
> create mode 100644 lib/librte_eal/common/include/arch/x86/rte_msr.h
>
> diff --git a/lib/librte_eal/common/include/arch/x86/rte_msr.h b/lib/librte_eal/common/include/arch/x86/rte_msr.h
> new file mode 100644
> index 0000000..9d16633
> --- /dev/null
> +++ b/lib/librte_eal/common/include/arch/x86/rte_msr.h
> +
> +#ifndef _RTE_MSR_X86_64_H_
> +#define _RTE_MSR_X86_64_H_
> +
> +#ifdef __cplusplus
> +extern "C" {
> +#endif
> +
> +#include <fcntl.h> //O_RDONLY
> +#include <unistd.h> //pread
Pls remove '//' comments here.
> +
> +#include <rte_debug.h>
> +#include <rte_log.h>
> +
> +#define CPU_MSR_PATH "/dev/cpu/%u/msr"
> +#define CPU_MSR_PATH_MAX_LEN 32
> +
> +/**
> + * This function should not be called directly.
> + * Function to open CPU's MSR file
> + */
> +static int
> +__msr_open_file(const unsigned lcore, int flags)
> +{
> + char fname[CPU_MSR_PATH_MAX_LEN] = {0};
Why not just use PATH_MAX here?
> + int fd = -1;
> +
> + snprintf(fname, sizeof(fname) - 1, CPU_MSR_PATH, lcore);
> +
> + fd = open(fname, flags);
> +
> + if (fd < 0)
> + RTE_LOG(ERR, PQOS, "Error opening file '%s'!\n", fname);
> +
> + return fd;
> +}
> +
> +/**
> + * Function to read CPU's MSR
> + *
> + * @param [in] lcore
> + * CPU logical core id
Hmm, are you aware that DPDK lcore id != CPU lcore id?
Might be better to use 'cpuid' name here?
Just to avoid confusion.
> + *
> + * @param [in] reg
> + * MSR reg to read
> + *
> + * @param [out] value
> + * Read value of MSR reg
> + *
> + * @return
> + * Operations status
> +*/
> +
> +static inline int
> +rte_msr_read(const unsigned lcore, const uint32_t reg, uint64_t *value)
I don't think there is a need to put rte_msr_read/rte_msr_write()
Definition into a header file and make them static inline.
Just normal external function definition seems sufficient here.
> +{
> + int fd = -1;
> + int ret = -1;
> +
> + RTE_VERIFY(value != NULL);
That's a a public API.
No need to coredump if one of the input parameters is invalid.
> + if (value == NULL)
> + return -1;
Might be better -EINVAL;
> +
> + fd = __msr_open_file(lcore, O_RDONLY);
> +
> + if (fd >= 0) {
> + ssize_t read_ret = 0;
> +
> + read_ret = pread(fd, value, sizeof(value[0]), (off_t)reg);
> +
> + if (read_ret != sizeof(value[0])) {
> + RTE_LOG(ERR, PQOS, "RDMSR failed for reg[0x%x] on lcore %u\n",
> + (unsigned)reg, lcore);
> + } else
> + ret = 0;
> +
> + close(fd);
> + }
> +
> + return ret;
> +}
next prev parent reply other threads:[~2016-01-20 11:25 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-17 12:12 [dpdk-dev] [PATCH] Patch introducing API to read/write Intel Architecture Model Specific Registers (MSR), rte_msr_read and rte_msr_write functions Wojciech Andralojc
[not found] ` <3FD2C4106EAA5C43838688C653B6E2AFDB8422@IRSMSX103.ger.corp.intel.com>
2016-01-06 17:33 ` Jerin Jacob
2016-01-20 10:56 ` [dpdk-dev] [PATCH v2] Patch introducing API to read/write Intel Architecture Model Specific Registers (MSR) Wojciech Andralojc
2016-01-20 11:25 ` Ananyev, Konstantin [this message]
2016-01-21 8:18 ` [dpdk-dev] [PATCH v3] " Wojciech Andralojc
2016-01-21 9:34 ` Thomas Monjalon
2016-01-21 10:38 ` Panu Matilainen
2016-01-21 10:51 ` Ananyev, Konstantin
2016-01-22 10:05 ` Panu Matilainen
2016-01-22 11:05 ` Ananyev, Konstantin
2016-01-22 11:37 ` Andralojc, WojciechX
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=2601191342CEEE43887BDE71AB97725836AEC360@irsmsx105.ger.corp.intel.com \
--to=konstantin.ananyev@intel.com \
--cc=dev@dpdk.org \
--cc=wojciechx.andralojc@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;
as well as URLs for NNTP newsgroup(s).