aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2015-12-30 18:24:26 +0100
committerDmitry Vyukov <dvyukov@google.com>2015-12-30 18:24:26 +0100
commitddcd0929e3550ea0e376b0c73e50d617b40b9d50 (patch)
treee0f8657af79d06278ed3a7414cdb47800cf4eaf3
parent3ccc84556b76405e1012f5106aa9fae756937147 (diff)
prog: give more priority to generic socket syscalls
-rw-r--r--prog/prio.go15
-rw-r--r--sys/decl.go5
2 files changed, 20 insertions, 0 deletions
diff --git a/prog/prio.go b/prog/prio.go
index 35e296b83..61afedd60 100644
--- a/prog/prio.go
+++ b/prog/prio.go
@@ -130,6 +130,21 @@ func calcStaticPriorities() [][]float32 {
}
}
}
+
+ // Sockets essentially form another level of classification. And we want
+ // more priority for generic socket calls (e.g. recvmsg) against particular
+ // protocol socket calls (e.g. AF_ALG bind). But it is not expressable with
+ // the above uses thing, because we don't want more priority for different
+ // protocols (e.g. AF_ALF vs AF_BLUETOOTH).
+ for c0, w0 := range uses[fmt.Sprintf("res%v-%v", sys.ResFD, sys.FdSock)] {
+ for _, sk := range sys.SocketSubkinds() {
+ for c1, w1 := range uses[fmt.Sprintf("res%v-%v", sys.ResFD, sk)] {
+ prios[c0][c1] += w0 * w1
+ prios[c1][c0] += w0 * w1
+ }
+ }
+ }
+
// Self-priority (call wrt itself) is assigned to the maximum priority
// this call has wrt other calls. This way the priority is high, but not too high.
for c0, pp := range prios {
diff --git a/sys/decl.go b/sys/decl.go
index 8b01669e3..2e3d42218 100644
--- a/sys/decl.go
+++ b/sys/decl.go
@@ -137,6 +137,11 @@ func ResourceSubkinds(kind ResourceKind) []ResourceSubkind {
}
}
+func SocketSubkinds() []ResourceSubkind {
+ return []ResourceSubkind{FdAlg, FdAlgConn, FdNfcRaw, FdNfcLlcp, FdBtHci, FdBtSco,
+ FdBtL2cap, FdBtRfcomm, FdBtHidp, FdBtCmtp, FdBtBnep, FdUnix, FdSctp}
+}
+
const (
InvalidFD = ^uintptr(0)
BogusFD = uintptr(100000 - 1)