Comments (10)
The problem analyzing is not enough. The warning
WARNING: at net/core/stream.c:201 sk_stream_kill_queues+0x12b/0x160()
is produced by
WARN_ON(sk->sk_forward_alloc)
So which exactly callback called by skb->destructor
decrements the counter? Which callback is registered for skb->destructor
when we process the skb in ss_tcp_process_data()?
Also why __kfree_skb() called anyway for the skb doesn't decrement the counter properly?
Please explain all the points.
from tempesta.
sk->sk_forward_alloc
isn't decremented. It's incremented. Different callbacks may do that, such as sk_stream_rfree()
or sock_rfree()
. They may be assigned to skb->destructor
by sk_stream_set_owner_r()
or sk_set_owner_r()
. From the accounting point of view it doesn't really matter as they do the same kind of a job. What does matter is a general principle of what happens and how that happens. According to it, we need to adjust accounting when we remove an skb from the socket's receive queue as that skb had been accounted for at the time it had been put there. We get a warning (not an error) if we don't do that. The system takes care of that by setting up an approproate skb destructor. In the regular course of things that happens when an skb is deleted as the data that it held has been consumed by an application.
Similar thing happens on the egress path.
The sk->sk_forward_alloc
counter is for socket's own accounting. It has nothing to do with skb accounting. An skb is freed by calling __kfree_skb()
when it's no longer needed. An skb destructor is called when the skb is freed, and the destructor makes all final touches that are required.
from tempesta.
The unclear thing is that __kfree_skb() calls skb->destructor() in skb_release_head_state() called by skb_release_all(). So why do we need to call skb->destructor() explicitly via skb_orphan() as in the patch?
from tempesta.
In the comment to the path it's said that in the regualar course of action socket accounting data is adjusted when an SKB is freed. As explained above, that happens as stream data is consumed by an application, and the data is no longer needed to hang around in the kernel.
That's not what happens in Tempesta though. In the Synchronous Sockets architecture we "consume" the stream data inside Tempesta by taking SKBs out of the receive queue of one socket and putting them into the send queue of another, totally different socket. __kfree_skb()
is never called for the receive socket in this case, and so the destructor is not called as well. These SKBs are then "re-owned" by the egress socket while not being correctly "un-owned" from the ingress socket. That's where orphaning comes in, and that's why we need to call it. Otherwise we see a warning for broken accounting in the ingress socket.
from tempesta.
Ok, thanks. It seems we reassign destructor callback when pass the skb to other socket, this is normally done by skb_set_owner_{r,w}(). I'll investigate the issue more as part of overall Synchronous Sockets architecture review.
from tempesta.
This issue is somewhat connected with #56. If some SKBs are not released or released incorrectly, then socket accounting may break.
from tempesta.
It turned out that the kernel was giving accounting warnings on a socket that didn't belong to Tempesta. Issue #96 was discovered while researching this accounting problem. This problem is not reproduced after #96 was fixed.
from tempesta.
Recent Tempesta execution traces show that this issue is still pending, and this time it is happening with Tempesta sockets, which is proven by extra specific printouts added to the Linux kernel code.
This issue is actually caused by irregular freeing of SKBs that make up HTTP messages processed by Tempesta. Socket accounting is managed by calls to skb->destructor()
when SKBs are freed. When an SKB is not released as it should be, that keeps bytes occoupied by that SKB accounted for by the socket, which, in turn, causes these kernel warnings when the socket is released.
This issue will be solved as soon as all SKBs are released properly, which is the essense of issue #56.
from tempesta.
Warning WARNING: at net/core/stream.c:201 sk_stream_kill_queues
for current master isn't 100% reproducable due to earlier crashes on skb freeing. I see the warnings in 30-50% of runs.
from tempesta.
This issue no longer comes up as SKBs are freed correctly now (see #56).
from tempesta.
Related Issues (20)
- Server failover configuration saving error. HOT 3
- Memory leak on test run HOT 1
- Rework the work queue from MPMC to MPSC
- Migrate to Ubuntu 24 LTS
- Headers processing optimization
- Move tls encryption from kernel code to Tempesta FW source code and adjuct TCP window, when we push skb to socket write queue for HTTP1 tls also HOT 2
- Zero 'sent bytes' in access log for non-empty responses HOT 1
- Integrate `checkpatch.pl` to our build/commit pipeline HOT 2
- Crash on malformed server response.
- Edge Side Application Callbacks
- Memory leak found in ping flood
- Kernel BUG in hpack. HOT 1
- Make socket callbacks `sk_fill_write_queue` and `sk_write_xmit` reentable or close connection in case of -ENOMEM HOT 2
- No `POST` processing and subsequent crash HOT 6
- New Let's Encrypt certificate with SHA384 parsing error HOT 2
- BUG at /root/tempesta/tls/x509_crt.c:874 HOT 1
- Hang with use-after-free in tfw_tls_conn_send+0x66 HOT 4
- Installer unable to operate with github
- `SETTINGS_NO_RFC7540_PRIORITIES` and RFC 9218 streams prioritization
- BUG at /root/tempesta/fw/cache.c:2027
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tempesta.