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

Improve posix-futex debugging #904

Closed

Conversation

skuenzer
Copy link
Member

Base target

  • Architecture(s): [all]
  • Platform(s): [all]
  • Application(s): [N/A]

Additional configuration

  • CONFIG_LIBPOSIX_FUTEX=y
  • CONFIG_LIBPOSIX_FUTEX_DEBUG=y

Description of changes

This PR adds a set of debug messages to better understand the futex state, like threads getting into blocked state or waking up because of timeouts.

@skuenzer skuenzer requested a review from a team as a code owner May 23, 2023 12:28
@skuenzer skuenzer added this to the v0.14.0 (Prometheus) milestone May 23, 2023
@razvand razvand requested review from csvancea and removed request for a team May 23, 2023 13:06
@razvand razvand added area/lib Internal Unikraft Microlibrary topic/posix Topics pertaining to POSIX standard lang/c Issues or PRs to do with C/C++ topic/testing Topics on testing labels May 23, 2023
@razvand razvand removed their request for review May 31, 2023 04:50
@razvand
Copy link
Contributor

razvand commented May 31, 2023

@skuenzer , could you please fix the checkpatch issues?

@razvand
Copy link
Contributor

razvand commented Jun 1, 2023

@skuenzer , could you please fix the checkpatch issues?

Apart from the checkpatch issues, everything works OK. After fixing the checkpatch issues and after @maniatro111 and @csvancea provide their reviews, I will do the final approval of the PR.

Copy link
Member

@csvancea csvancea left a comment

Choose a reason for hiding this comment

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

Apart from the checkpatch and that minor nitpick -- LGTM

Reviewed-by: Cosmin Vancea csvancea@gmail.com

Comment on lines +124 to +126
uk_pr_debug("FUTEX_WAIT: Wait %"__PRIsnsec" nsec for wake-up\n",
(__snsec) (*timeout));
uk_thread_block_until(current, (__snsec) (*timeout));
Copy link
Member

Choose a reason for hiding this comment

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

Minor: maybe turn the expression (__snsec) (*timeout) into a variable since it is used multiple times?

Copy link
Member Author

Choose a reason for hiding this comment

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

With this patch, it is only used a second time in the debug message that I add. However, normally this message is not compiled in, so I find adding a variable that stores the dereferenced value of timeout for a single occurrence unnecessary.

Copy link
Contributor

@flpostolache flpostolache left a comment

Choose a reason for hiding this comment

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

@skuenzer Looks good to me. One small preference. Either add a space before and after the equal sign or remove them from both sides so that the result will be Condition = 2147483664 instead of Condition =2147483664.

@skuenzer
Copy link
Member Author

skuenzer commented Jun 7, 2023

@skuenzer , could you please fix the checkpatch issues?

As far as I can see, these are our standard warnings for long strings. Our checkpatch clone does not yet support detecting that we are having a print command with uk_pr_* that is why it is warning.

@skuenzer
Copy link
Member Author

skuenzer commented Jun 7, 2023

@skuenzer Looks good to me. One small preference. Either add a space before and after the equal sign or remove them from both sides so that the result will be Condition = 2147483664 instead of Condition =2147483664.

Right, sorry, I did not notice it. For sure I am fixing this.

@skuenzer skuenzer force-pushed the skuenzer/fix/futex-debugging branch from c81af62 to 2a27cdb Compare June 7, 2023 12:38
Copy link
Contributor

@flpostolache flpostolache left a comment

Choose a reason for hiding this comment

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

Looks good now. All checkpatch issues are caused by uk_pr_* commands which are not ignored at the moment.

Reviewed-by: Florin Postolache florin.postolache.of@gmail.com

Introduces a configuration option to enable debug messages for
`lib/posix-futex`.

Signed-off-by: Simon Kuenzer <simon@unikraft.io>
Adds a set of debug messages to better understand the futex state, like
threads getting into blocked state or waking up because of timeouts.

Signed-off-by: Simon Kuenzer <simon@unikraft.io>
This commit removes a nesting if-statement to increase readability
of `futex_wait()`.

Signed-off-by: Simon Kuenzer <simon@unikraft.io>
@skuenzer skuenzer force-pushed the skuenzer/fix/futex-debugging branch from 2a27cdb to 9873c24 Compare July 4, 2023 23:32
@unikraft-bot
Copy link
Member

⚠️ Checkpatch passed with warnings

Beep boop! I ran Unikraft's checkpatch.pl support script on your pull request but it encountered warnings:

SHA commit checkpatch
a07c073 lib/posix-futex: Debug config option
5a3df80 lib/posix-futex: Increase debug output ⚠️
9873c24 lib/posix-futex: Improve `futex_wait()` ⚠️

Truncated logs starting from first warning 5a3df80:

WARNING:LONG_LINE_STRING: line over 80 characters
#39: FILE: lib/posix-futex/futex.c:106:
+		uk_pr_debug("FUTEX_WAIT: Condition =%"PRIu32" met (uaddr: %p)\n",

WARNING:LONG_LINE_STRING: line over 80 characters
#54: FILE: lib/posix-futex/futex.c:120:
+			uk_pr_debug("FUTEX_WAIT: Wait %"__PRIsnsec" nsec for wake-up\n",

WARNING:LONG_LINE_STRING: line over 80 characters
#82: FILE: lib/posix-futex/futex.c:155:
+		uk_pr_debug("FUTEX_WAIT: Condition =%"PRIu32" not met (uaddr: %p)\n",

total: 0 errors, 3 warnings, 63 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
      mechanically convert to the typical style using --fix or --fix-inplace.

/tmp/build/a53d4c5b/patches/0002-lib-posix-futex-Increase-debug-output.patch has style problems, please review.

NOTE: Ignored message types: ASSIGN_IN_IF FILE_PATH_CHANGES NEW_TYPEDEFS OBSOLETE

NOTE: If any of the errors are false positives, please report
      them to the maintainer, see CHECKPATCH in MAINTAINERS.

View complete logs | Learn more about Unikraft's coding style and contribution guidelines.

Copy link
Contributor

@razvand razvand left a comment

Choose a reason for hiding this comment

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

Approved-by: Razvan Deaconescu razvand@unikraft.io

unikraft-bot pushed a commit that referenced this pull request Aug 9, 2023
Adds a set of debug messages to better understand the futex state, like
threads getting into blocked state or waking up because of timeouts.

Signed-off-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Florin Postolache <florin.postolache.of@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #904
unikraft-bot pushed a commit that referenced this pull request Aug 9, 2023
This commit removes a nesting if-statement to increase readability
of `futex_wait()`.

Signed-off-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Florin Postolache <florin.postolache.of@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #904
@unikraft-bot unikraft-bot added the ci/merged Merged by CI label Aug 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/lib Internal Unikraft Microlibrary ci/merged Merged by CI lang/c Issues or PRs to do with C/C++ topic/posix Topics pertaining to POSIX standard topic/testing Topics on testing
Projects
Status: Done!
Development

Successfully merging this pull request may close these issues.

None yet

5 participants