Comments (5)
Something else to think about: support of histograms for each key. Imagine we want to save this log2 histogram per-PID, per-comm, per-device-name, or some combination?
from bcc.
Could something like this be added in the meantime? ... I assume a final implementation will need bpf_log() functions anyway...
# git diff src/cc/export/helpers.h
diff --git a/src/cc/export/helpers.h b/src/cc/export/helpers.h
index 4571166..f0aaf9f 100644
--- a/src/cc/export/helpers.h
+++ b/src/cc/export/helpers.h
@@ -185,6 +185,28 @@ static inline void bpf_store_dword(void *skb, u64 off, u64 val) {
#define MASK(_n) ((_n) < 64 ? (1ull << (_n)) - 1 : ((u64)-1LL))
#define MASK128(_n) ((_n) < 128 ? ((unsigned __int128)1 << (_n)) - 1 : ((unsigned __int128)-1))
+static unsigned int bpf_log2(unsigned int v)
+{
+ unsigned int r;
+ unsigned int shift;
+
+ r = (v > 0xFFFF) << 4; v >>= r;
+ shift = (v > 0xFF) << 3; v >>= shift; r |= shift;
+ shift = (v > 0xF) << 2; v >>= shift; r |= shift;
+ shift = (v > 0x3) << 1; v >>= shift; r |= shift;
+ r |= (v >> 1);
+ return r;
+}
+
+static unsigned int bpf_log2l(unsigned long v)
+{
+ unsigned int hi = v >> 32;
+ if (hi)
+ return bpf_log2(hi) + 32 + 1;
+ else
+ return bpf_log2(v) + 1;
+}
+
struct bpf_context;
static inline __attribute__((always_inline))
from bcc.
Sure, if you send that I will be happy to merge it. Otherwise I'm planning
to start churning through these issues after the meetup today.
On Mon, Sep 21, 2015 at 3:34 PM, Brendan Gregg [email protected]
wrote:
Could something like this be added in the meantime? ... I assume a final
implementation will need bpf_log() functions anyway...git diff src/cc/export/helpers.h
diff --git a/src/cc/export/helpers.h b/src/cc/export/helpers.h
index 4571166..f0aaf9f 100644
--- a/src/cc/export/helpers.h
+++ b/src/cc/export/helpers.h
@@ -185,6 +185,28 @@ static inline void bpf_store_dword(void *skb, u64 off, u64 val) {
#define MASK(_n) ((_n) < 64 ? (1ull << (_n)) - 1 : ((u64)-1LL))
#define MASK128(_n) ((_n) < 128 ? ((unsigned __int128)1 << (_n)) - 1 : ((unsigned __int128)-1))+static unsigned int bpf_log2(unsigned int v)
+{
unsigned int r;
unsigned int shift;
r = (v > 0xFFFF) << 4; v >>= r;
shift = (v > 0xFF) << 3; v >>= shift; r |= shift;
shift = (v > 0xF) << 2; v >>= shift; r |= shift;
shift = (v > 0x3) << 1; v >>= shift; r |= shift;
r |= (v >> 1);
return r;
+}
+
+static unsigned int bpf_log2l(unsigned long v)
+{unsigned int hi = v >> 32;
if (hi)
return bpf_log2(hi) + 32 + 1;
else
return bpf_log2(v) + 1;
+}
+
struct bpf_context;static inline attribute((always_inline))
—
Reply to this email directly or view it on GitHub
#144 (comment).
from bcc.
I have some (maybe) improvements, and am looking for feedback.
The table could be defined by BPF_HISTOGRAM(name)
or BPF_HISTOGRAM(name, key_type)
. Default key_type is int. Leaf type is forced to be u64.
In the first scenario, a new table method is introduced, which just increments the slot based on integer argument. The underlying table type is an array.
BPF_HISTOGRAM(dist);
dist.increment(bpf_log2l(delta));
In the second scenario, the key type is definable, in this case it is a tuple of the bucket and the slot. The underlying table type is a hash.
typedef struct {
int cpu;
u32 slot;
} key_t;
BPF_HISTOGRAM(dist, key_t);
dist.increment((key_t){bpf_get_smp_processor_id(), bpf_log2l(delta)});
from bcc.
Seems reasonable.
Just to expand on the biolatency example. Right now that's a global log2 histogram. Possible enhancements to that tool:
-P
to print a latency histogram for each issuing PID-I
to print separate latency histograms for each I/O type: read, write-D
to print a latency histogram per-disk device
Doing multiple breakdowns -- eg, combining -P and -I, to get a breakdown per PID and per I/O type -- are less important given filter capabilities. Eg, imagine a workflow:
# ./biolatency -P # show latency by-PID
# ./biolatency -p 181 -I # given PID 181 has high latency, show PID 181 only by I/O type
# ./biolatency -rp 181 -D # show PID 181 read latency by-device
So I'm accomplishing breakdowns of breakdowns, but by using filters. Being able to have multiple keys would be useful too. I'm just showing how important it might be (at least for this example).
from bcc.
Related Issues (20)
- bcc-tools: trace.py syscall trace not working for proccess in container(lxc) HOT 1
- question: `LLVM ERROR: ` error with no indication
- [question]: Run ebpf demo failed.
- zfsslower wrongly tries to attach to non-existant zpl_read (regression of #1248)
- memleak: the symbol of the function that calls `new` disappeared HOT 2
- some regex escape sequences broke after fixing SyntaxWarning HOT 1
- Just ran into this issue while building / testing on Debian 8 amd64.
- can't deny access to a specific file
- can't deny access to a specific file
- no matching member function for call to 'replace'
- fatal error: clang/Basic/FileManager.h: No such file or directory
- ImportError: cannot import name 'BPF' from 'bcc' (unknown location)
- python-bcc works only if clang-libs Installed, fails with only clang16-libs Installed
- libbpf javagc fails when no PID is provided
- bpflist doesn't show attached probes
- Build fail from source HOT 4
- Fail building from source HOT 1
- attach_raw_socket function does not work well on Qualcomm modem HOT 1
- Build bcc from source code failed HOT 1
- Unable to obtain the complete function call stack of `__memset_avx2_erms`.
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 bcc.