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

Mekhanik evgenii/1411 rework allocation streams #2164

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

EvgeniiMekhanik
Copy link
Contributor

No description provided.

In previous commit we decide to allocate 2 pages
after http2 connection and use free space after
http2 connection structure for stream schedulers.
But for negotiable (which can be http1 or http2)
we use http2 connection structure also. So for
such connections (if it is http1 connection) we
allocate 2 pages for stream schedulers which
are not used in fact. Now allocation strategy
was changed: we allocate 2 pages for http2
context, which now is a pointer in http2 connection,
so we don't allocate extra memory for http1 negotiable
connection.
@EvgeniiMekhanik EvgeniiMekhanik force-pushed the MekhanikEvgenii/1411-rework-allocation-streams branch from ca429e9 to 3fac4e8 Compare July 10, 2024 15:31

conn->h2 = tfw_h2_context_alloc();
if (!conn->h2)
return -ENOMEM;
Copy link
Contributor

Choose a reason for hiding this comment

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

I would like to ask you to print T_ERR in case of ENOMEM as well. And really minor thing, maybe move TfwH2Conn *conn = (TfwH2Conn*)tls->sk->sk_user_data into if (TFW_FSM_TYPE(sk_proto) == TFW_FSM_H2)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes fixed

fw/http2.c Outdated Show resolved Hide resolved
{
struct page *pg;

pg = alloc_pages(GFP_ATOMIC, TFW_H2_PAGE_ORDER);
Copy link
Contributor

Choose a reason for hiding this comment

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

We decide for better memory locality to preallocate 8 pages

But you allocating 4 pages, is commit message correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes fixed. We decide to allocate 2 pages.

{
TfwStream *stream = (TfwStream *)base;

while ((char *)stream <= (char *)next_block - sizeof(TfwStream)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems here is memory corruption because of <=, in case when quantity is a multiple of size, the store will be filled without hole in the end that need for storing pointer to next block.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why if stream == next - sizeof(TfwStream) we have one place for struct stream. I am not right?

According to our ivsetigation typical streams count
opened by browser is about 15 - 25. We decide for
better memory locality to preallocate 2 pages
(8192 bytes, this is enough for 29 streams) and use
it as a streams memory. If is memory is exceeded we
allocate new 2 pages and use as a streams memory again.
We use 8 bytes at the end of the memory which is used
for streams as a pointer to the new page block.
@EvgeniiMekhanik EvgeniiMekhanik force-pushed the MekhanikEvgenii/1411-rework-allocation-streams branch from ecc12dd to 80e7ec3 Compare July 17, 2024 10:10
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