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

dpdk: rework hugepage hints to use per-numa information v2 #9898

Closed

Conversation

lukashino
Copy link
Contributor

Follow-up #9735

Previous integration of hugepage analysis only fetched data from /proc/meminfo. However, this proved to be often deceiving mainly for providing only global information and not taking into account different hugepage sizes (e.g. 1GB hugepages) and different NUMA nodes.

Describe changes:

https://redmine.openinfosecfoundation.org/issues/6419

Previous integration of hugepage analysis only fetched data
from /proc/meminfo. However this proved to be often
deceiving mainly for providing only global information and
not taking into account different hugepage sizes (e.g. 1GB
hugepages) and different NUMA nodes.

Ticket: OISF#6419
Copy link

codecov bot commented Nov 27, 2023

Codecov Report

Merging #9898 (45db6a9) into master (d005fff) will decrease coverage by 0.16%.
The diff coverage is 58.04%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9898      +/-   ##
==========================================
- Coverage   82.45%   82.30%   -0.16%     
==========================================
  Files         972      973       +1     
  Lines      273057   273213     +156     
==========================================
- Hits       225156   224859     -297     
- Misses      47901    48354     +453     
Flag Coverage Δ
fuzzcorpus 63.97% <0.00%> (-0.40%) ⬇️
suricata-verify 61.06% <58.04%> (-0.03%) ⬇️
unittests 62.88% <0.00%> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

@suricata-qa
Copy link

Information: QA ran without warnings.

Pipeline 16735

@victorjulien victorjulien added this to the 8.0 milestone Dec 1, 2023
Copy link
Member

@victorjulien victorjulien left a comment

Choose a reason for hiding this comment

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

cppcheck

src/util-hugepages.c:120:9: warning: %hd in format string (no. 1) requires 'short' but the argument type is 'unsigned short'. [invalidPrintfArgType_sint]
        snprintf(path, sizeof(path),
        ^
src/util-hugepages.c:129:13: warning: %hd in format string (no. 1) requires 'short *' but the argument type is 'unsigned short *'. [invalidScanfArgType_int]
        if (fscanf(f, "%hd", &hugepages[i].allocated) != 1) {
            ^
src/util-hugepages.c:137:9: warning: %hd in format string (no. 1) requires 'short' but the argument type is 'unsigned short'. [invalidPrintfArgType_sint]
        snprintf(path, sizeof(path),
        ^
src/util-hugepages.c:146:13: warning: %hd in format string (no. 1) requires 'short *' but the argument type is 'unsigned short *'. [invalidScanfArgType_int]
        if (fscanf(f, "%hd", &hugepages[i].free) != 1) {
            ^
src/util-hugepages.c:126:20: warning: Either the condition '!f' is redundant or there is possible null pointer dereference: f. [nullPointerRedundantCheck]
            fclose(f);
                   ^
src/util-hugepages.c:124:13: note: Assuming that condition '!f' is not redundant
        if (!f) {
            ^
src/util-hugepages.c:126:20: note: Null pointer dereference
            fclose(f);
                   ^
src/util-hugepages.c:143:20: warning: Either the condition '!f' is redundant or there is possible null pointer dereference: f. [nullPointerRedundantCheck]
            fclose(f);
                   ^
src/util-hugepages.c:141:13: note: Assuming that condition '!f' is not redundant
        if (!f) {
            ^
src/util-hugepages.c:143:20: note: Null pointer dereference
            fclose(f);
                   ^
src/util-hugepages.c:126:20: error: Null pointer dereference [nullPointer]
            fclose(f);
                   ^
src/util-hugepages.c:143:20: error: Null pointer dereference [nullPointer]
            fclose(f);
                   ^

scan-build about the same

In function 'SystemHugepagePerNodeGetHugepageInfoLinux',
    inlined from 'SystemHugepagePerNodeGetHugepageInfo' at util-hugepages.c:178:11,
    inlined from 'SystemHugepageSnapshotCreate' at util-hugepages.c:300:23:
util-hugepages.c:126:13: warning: argument 1 null where non-null expected [-Wnonnull]
  126 |             fclose(f);
      |             ^~~~~~~~~
In file included from suricata-common.h:64,
                 from suricata.h:67,
                 from util-hugepages.c:24:
/usr/include/stdio.h: In function 'SystemHugepageSnapshotCreate':
/usr/include/stdio.h:183:12: note: in a call to function 'fclose' declared 'nonnull'
  183 | extern int fclose (FILE *__stream) __nonnull ((1));
      |            ^~~~~~
In function 'SystemHugepagePerNodeGetHugepageInfoLinux',
    inlined from 'SystemHugepagePerNodeGetHugepageInfo' at util-hugepages.c:178:11,
    inlined from 'SystemHugepageSnapshotCreate' at util-hugepages.c:300:23:
util-hugepages.c:143:13: warning: argument 1 null where non-null expected [-Wnonnull]
  143 |             fclose(f);
      |             ^~~~~~~~~
/usr/include/stdio.h: In function 'SystemHugepageSnapshotCreate':
/usr/include/stdio.h:183:12: note: in a call to function 'fclose' declared 'nonnull'
  183 | extern int fclose (FILE *__stream) __nonnull ((1));
      |            ^~~~~~
util-hugepages.c:126:13: warning: Null pointer passed to 1st parameter expecting 'nonnull' [core.NonNullParamChecker]
            fclose(f);
            ^~~~~~~~~
util-hugepages.c:143:13: warning: Null pointer passed to 1st parameter expecting 'nonnull' [core.NonNullParamChecker]
            fclose(f);
            ^~~~~~~~~
2 warnings generated.

NodeInfo *nodes = SCCalloc(node_cnt, sizeof(*nodes));
if (nodes == NULL) {
FatalError("failed to allocate memory for NUMA node info");
return NULL;
Copy link
Member

Choose a reason for hiding this comment

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

unreachable due to FatalError

Copy link
Contributor Author

Choose a reason for hiding this comment

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

return statement removed

SCFree(s);
}

SystemHugepageSnapshot *SystemHugepageSnapshotCreate(void)
Copy link
Member

Choose a reason for hiding this comment

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

can you add a comment about the return values?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added

@lukashino
Copy link
Contributor Author

Continues in #10164

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants