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

feat(kmod): reuse mempool #451

Closed
wants to merge 1 commit into from
Closed

feat(kmod): reuse mempool #451

wants to merge 1 commit into from

Conversation

veqcc
Copy link
Contributor

@veqcc veqcc commented Feb 28, 2025

Description

Implemented the feature for reusing mempools to avoid the shortage of memory.

Major changes are:

  • created memory_allocator.c to manage shared memory meta data.
  • added two tests:
    • test_case_new_shm_too_big
    • test_case_new_shm_too_many

Related links

Memory allocation design is based on TIER IV INTERNAL.

How was this PR tested?

  • Autoware (required)
  • bash scripts/e2e_test_1to1_with_ros2sub (required)
  • bash scripts/e2e_test_2to2 (required)
  • sample application

Notes for reviewers

Signed-off-by: veqcc <ryuta.kambe@tier4.jp>
mempool_128mb_pid[i] = 0;
return 0;
}
}
Copy link
Contributor

@Koichi98 Koichi98 Feb 28, 2025

Choose a reason for hiding this comment

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

現状のAutowareだとありえないケースだと思いますが、publisherがexitした後にsubscriberが生き残り続けた場合subscriberはまだ該当の仮想アドレス範囲を共有メモリにmapした状態で参照を続けています。その上で、新たに参加したpublisherがたまたまその仮想アドレス範囲をassignされてしまい、しかもsubscriberがそのpublisherのpublishするtopicをsubscribeしようとすると仮想アドレス範囲がかぶってmmapでエラーになってしまいます。

これを回避するにはfree_memoryを行うのを「該当プロセスがexitした」かつ「すべてのmapped_pids上のsubscriberプロセスがexitした」ことを確認の上で行う必要がありそうです。幸いこのmapped_pidsという配列がprocess_infoのstruct上に今はあるのでやろうと思えばできそうなんで、一応やっとくというのはどうでしょう?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

たしかにそうですね、やります。

@veqcc veqcc marked this pull request as draft February 28, 2025 09:49
@veqcc veqcc closed this Mar 5, 2025
@veqcc veqcc deleted the feat/reuse_mempool branch March 5, 2025 08:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants