-
Notifications
You must be signed in to change notification settings - Fork 920
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
[WIP] Adopt specific-engine open methods (new libsinsp
APIs)
#2164
[WIP] Adopt specific-engine open methods (new libsinsp
APIs)
#2164
Conversation
Signed-off-by: Andrea Terzolo <andrea.terzolo@polito.it>
Signed-off-by: Andrea Terzolo <andrea.terzolo@polito.it>
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Andreagit97 The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Signed-off-by: Andrea Terzolo <andrea.terzolo@polito.it>
Signed-off-by: Andrea Terzolo <andrea.terzolo@polito.it>
Signed-off-by: Andrea Terzolo <andrea.terzolo@polito.it>
the input plugin will be set during the inspector open phase Signed-off-by: Andrea Terzolo <andrea.terzolo@polito.it> Co-authored-by: Jason Dellaluce <jasondellaluce@gmail.com>
every engine has a dedicated open method Signed-off-by: Andrea Terzolo <andrea.terzolo@polito.it>
497588b
to
c74793c
Compare
OMG this is amazing 💯 . Thanks for all the hard work! This is a significant and much needed cleanup and also extends configurability. Few suggestions re (1) How to choose correct values? Would this for example for eBPF mean the
(2) How about writing down the "mathematical equations" for each driver in the yaml parameter explanation and even show how the default value is calculated? For driver-bpf for example:
Almost wonder if the parameter should just be the (3) For eBPF ring buffer for examples reading that ring size has to be a power of 2. How does this translate to kmod and current perf buffer in driver-bpf? Never seen any hard coded values not power of 2 AFAIK ... see (1) user input sanitization. https://www.kernel.org/doc/html/latest/bpf/ringbuf.html?highlight=ring+buffer (4) Lastly after clarifying (1) - (3), could we give 5 concrete recommendations in the yaml parameter definition? Maybe 1-2 for decrease and 3-4 good steps to increase the value? End users probably wouldn't want to become mathematicians. Maybe also include some notes on what effects of increasing or decreasing buffer sizes are? E.g. too large of a buffer on little server load could slow down the engine. A buffer too small can cause more kernel side event drops. We can iterate on such recommendations as we gather field experience, happy to help, because some of what I just mentioned may be based more on reputation and is not backed up by data and perf studies. [This feedback applies to other parameters in |
@@ -212,6 +212,10 @@ void falco_configuration::init(string conf_filename, const vector<string> &cmdli | |||
m_webserver_ssl_enabled = m_config->get_scalar<bool>("webserver.ssl_enabled", false); | |||
m_webserver_ssl_certificate = m_config->get_scalar<string>("webserver.ssl_certificate", "/etc/falco/falco.pem"); | |||
|
|||
// we put this value in the configuration file because in this way we can change the dimension | |||
// at every reload. | |||
m_single_buffer_dimension = m_config->get_scalar<uint64_t>("single_buffer_dimension", 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should or could we be doing more to ensure end user parameter input is not bogus? This would apply to any parameter and is not specific to this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For what concern the validity checks for sure we have to implement them in the final drivers since they are the end users of this info, we can put also something in Falco, BTW if we use the page number as a value there is not too much to check probably that it is greater than 0
and that it is a power of 2
, right?
Hey @incertum these are all good points: (1)(2) This was also my doubt, not sure what could be the best choice for the end user, specify the value in bytes or specify the number of pages (in this second case we need to provide the page size of the system in some way, maybe through a simple flag (3) yeah in both BPF probes we always need a power of 2, in the kmod I have to check, if I remember well we don't have this constraint here. (4) Absolutely agree with that, probably at the beginning they would be quite silly suggestions but as we gather more experience we can enrich them as you said! |
# - This number is expressed in bytes. | ||
# - This number must be a multiple of your system page size, otherwise the allocation will fail. | ||
# - If you leave `0`, every driver will set its internal default dimension. | ||
single_buffer_dimension: 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
single_buffer_dimension: 0 | |
syscall_buffer_size: 0 |
Since this option affects the syscall
data source only, I'd prefix it with syscall_
and move it close to other syscall_
options.
Also, I'd simplify the name and explain in the comment what that size means and how it affects the operations (eg. the driver will create a buffer per CPU, syscall_buffer_size
specifies the size in bytes of each buffer...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
completely agree with the new name!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we decide to have this param be just a multiple of page size need to adjust the _size
at the end and explain.
[nit] More additional explanations for end users less familiar with architecture. Something like:
Falco uses a shared buffer between kernel and userspace to serve events up to userspace for subsequent processing and rules matching. With the TBD_BUFFER_PARAM_NAME
you can increase or decrease the default buffer size for either driver (BPF, kmod, modern BPF) wrt the system call tracing functionality. In more detail, Falco uses one buffer for every online CPU, but you generically adjust the size once with this parameter. Increasing the buffer can help reducing kernel side syscall drops while decreasing the buffer can help speed up the entire engine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more thought that just occurred to me, maybe have default value be actual default value and not 0 to be consistent with other parameters? @Andreagit97 @leogr
But now I can see an issue for kmod vs eBPF default values, hmmm ... and we should always gracefully start up Falco with default value like it's the case right now.
Hey @Andreagit97 and @incertum Since the buffer size is not just a driver thing but also directly affects the performance of the userspace program, I would like the parameter to behave consistently regardless of the driver used. This would also simplify the user experience. However, I am not yet clear about the best way to achieve this.
Considering what I said above, specifying the value in bytes is probably not the best choice. Moreover, are there other alternatives?
If possible, I'd not introduce a special case for a particular type of driver. I'd directly or indirectly force the result of the math to be a power of 2 unless a compelling use case exists for the kmod that does not work with this constraint. IMO these are the kind of questions we need to ask ourselves before making such a decision.
👍 In general, I'd prefer to keep things as simple as possible. Although that may be opinionated, I'd also validate the value against hard-coded min and max to make the configuration less error-prone (if we don't want to enforce limits, we can just emit warnings). I guess we can calculate the min value in some way. For the max limit, we may choose a reasonably high value. We are already enforcing arbitrary limits in similar situations. For example 👇 falco/userspace/falco/configuration.cpp Lines 271 to 274 in 0828296
|
/milestone 0.33.0 |
@Andreagit97 @leogr @jasondellaluce @FedeDP Go with the multiples of page sizes as parameter? Agreed with it needing to be consistent across drivers @leogr and very simple. |
As said here falcosecurity/libs#540 (comment) i will continue the discussion here:
Yeah, I think this is the right way.
Not sure about that it, this could be too much restrictive i think that upper and lower bound + check the power of 2 could be enough, WDYT?
As said in the previous point we need at least these 2 checks:
And I think we need it in Falco as a consumer, but also in scap/sinsp since they are the final users of this size, so at least 2 levels
Yeah also agree on that it would be easier and clearer to manage them all in the same way! |
#ifdef HAS_MODERN_BPF | ||
("modern-bpf", "Use BPF modern probe to capture new events.", cxxopts::value(modern_bpf)->default_value("false")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to write here something about the fact that is experimental
Works and agreed on performing the checks twice. [nit] |
Close it in favor of #2201 |
What type of PR is this?
/kind cleanup
/kind feature
Any specific area of the project related to this PR?
/area build
/area engine
What this PR does / why we need it:
This PR is based on 👉 falcosecurity/libs#540.
It introduces 4 main novelties:
single_buffer_dimension
, this will be the dimension that a single buffer in our drivers will have. (BPF, kmod, modern BPF).FALCO_BPF_PROBE
env variable is now managed by the consumer (i.e Falco) and no more by the libraries. BTW the behavior is always the same so the final user won't notice any difference.modern_bpf
engine, right now you can only try it by usingFALCOSECURITY_LIBS_SOURCE_DIR
andDRIVER_SOURCE_DIR
options.Which issue(s) this PR fixes:
Special notes for your reviewer:
This PR is based on 👉 falcosecurity/libs#540, the [WIP] will be removed when the libs PR will be merged
Does this PR introduce a user-facing change?: