Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correction of tracing from child process and new EAL params support #2505

Merged
merged 4 commits into from Oct 25, 2017

Conversation

jiriproX
Copy link
Contributor

Correction of tracing from child process

  • There was read 16kb from pipe but only less then 1kb was traced.
    Rest of trace data was lost.
    Added support for two EAL parameters:
    LogLevel - optional EAL paramenter which enable debug traces from rte libs
    If parameter is not used default trace level = 7 (INFO) is used
    LogLevel "8" - (DEBUG) can be set to collectd.conf into dpdkstat
    EAL section
    RteDriverLibPath - optional EAL parameter which enable loading of shared
    pmd driver libs. Param value can be full path to single
    pmd diriver lib or directory where pmd driver libs are
    located. E.g.: "/usr/lib/dpdk-pmd/librte_pmd_i40e.so"
    or "/usr/lib/dpdk-pmd"

Signed-off-by: Jiri Prokes jirix.x.prokes@intel.com

- There was read 16kb from pipe but only less then 1kb was traced.
  Rest of trace data was lost.
Added support for two EAL parameters:
  LogLevel - optional EAL paramenter which enable debug traces from rte libs
             If parameter is not used default trace level = 7 (INFO) is used
             LogLevel "8" - (DEBUG) can be set to collectd.conf into dpdkstat
             EAL section
  RteDriverLibPath - optional EAL parameter which enable loading of shared
                     pmd driver libs. Param value can be full path to single
                     pmd diriver lib or directory where pmd driver libs are
                     located. E.g.: "/usr/lib/dpdk-pmd/librte_pmd_i40e.so"
                                 or "/usr/lib/dpdk-pmd"

Signed-off-by: Jiri Prokes <jirix.x.prokes@intel.com>
Signed-off-by: Jiri Prokes <jirix.x.prokes@intel.com>
Copy link
Contributor

@maryamtahhan maryamtahhan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make sure to also update collectd.conf.in and collectd.conf.pod

@octo octo added the Feature label Oct 24, 2017
Copy link
Member

@octo octo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @jiriproX,

thank you very much for your pull request! I've left some review comments inline.

Best regards,
—octo

src/utils_dpdk.c Outdated
#define DPDK_EAL_ARGC 5
#define DPDK_MAX_BUFFER_SIZE (4096 * 4)
#define DPDK_EAL_ARGC 10
// Complete trace should fit into 1024 chars
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this comment: the trace should fit into 1024 bytes, that's why we set DPDK_MAX_BUFFER_SIZE to 896?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated comment.

@@ -493,6 +504,15 @@ static int dpdk_helper_eal_init(dpdk_helper_ctx_t *phc) {
argp[argc++] = "--proc-type";
argp[argc++] = "secondary";

if (strcasecmp(phc->eal_config.log_level, "") != 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit, at your option: You don't need the case-insensitive variant when comparing with an empty string. Here and below.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. Nevertheless I just reused what was used for --socket-mem. I would let it there.

@@ -697,6 +717,8 @@ static void dpdk_helper_check_pipe(dpdk_helper_ctx_t *phc) {
.fd = phc->pipes[0], .events = POLLIN,
};
int data_avail = poll(&fds, 1, 0);
DEBUG("%s:dpdk_helper_check_pipe: poll data_avail=%d", phc->shm_name,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally this should have a "dpdk_common:" prefix like the other debug messages.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so. It is consistent with traces which were already present there.

src/utils_dpdk.h Outdated
@@ -51,6 +51,8 @@ struct dpdk_eal_config_s {
char memory_channels[DATA_MAX_NAME_LEN];
char socket_memory[DATA_MAX_NAME_LEN];
char file_prefix[DATA_MAX_NAME_LEN];
char log_level[DATA_MAX_NAME_LEN];
char rte_driver_lib_path[DATA_MAX_NAME_LEN];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd use PATH_MAX as the size of this buffer – the define is better suited for this purpose.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

src/utils_dpdk.c Outdated
if (nbytes <= 0)
break;
sstrncpy(out, buf, nbytes);
buf[nbytes] = '\n';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why \n? Did you intend to nil-terminate the string? In that case use buf[nbytes] = 0; instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is just defined char. sstrncpy ignore char at that position anyway. Nevertheless you are right '\0' will be better here.

src/utils_dpdk.c Outdated
if (nbytes <= 0)
break;
sstrncpy(out, buf, nbytes);
buf[nbytes] = '\n';
sstrncpy(out, buf, (nbytes + 1));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use sizeof(out) as the third parameter (after making sure that buf is nil-terminated, see above).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sstrncpy does not check nil in string, so it will copy complete buffer. In our case only real data are copied.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sstrncpy() expects a nil-terminated string as second argument and copies it into the memory pointed to by the first argument. It will, however, not copy more than the third argument.

While your variant also works, it is uncommon and therefore confusing. Please use sizeof(out) instead of nbytes + 1.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've changed that as you requested. Nevertheless if I understood documentation right then it is less efficient than original one. It always write complete buffer even if read nbytes is only few chars. Rest of buffer is filled with zeros.

Signed-off-by: Jiri Prokes <jirix.x.prokes@intel.com>
Copy link
Member

@octo octo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @jiriproX,

thank you very much for your update! Once the ssstrncpy() call is fixed this is good to go.

Best regards,
—octo

src/utils_dpdk.c Outdated
if (nbytes <= 0)
break;
sstrncpy(out, buf, nbytes);
buf[nbytes] = '\n';
sstrncpy(out, buf, (nbytes + 1));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sstrncpy() expects a nil-terminated string as second argument and copies it into the memory pointed to by the first argument. It will, however, not copy more than the third argument.

While your variant also works, it is uncommon and therefore confusing. Please use sizeof(out) instead of nbytes + 1.

Signed-off-by: Jiri Prokes <jirix.x.prokes@intel.com>
Copy link
Member

@octo octo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @jiriproX!

@octo octo added the Automerge Labels PRs to be merged by a bot once approved label Oct 25, 2017
@collectd-bot collectd-bot merged commit b7a8e04 into collectd:master Oct 25, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Automerge Labels PRs to be merged by a bot once approved Feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants