hyungjun choi karol lewandowski samsung electronics · 2014. 6. 19. · 6 kdbus low-level, native...
TRANSCRIPT
![Page 1: Hyungjun Choi Karol Lewandowski Samsung Electronics · 2014. 6. 19. · 6 kdbus Low-level, native kernel D-Bus transport All communication between processes take place over special](https://reader036.vdocuments.net/reader036/viewer/2022082018/602c89d46711a327b8323d85/html5/thumbnails/1.jpg)
kdbus in Tizen 3.0
Hyungjun ChoiKarol Lewandowski
Samsung Electronics
![Page 2: Hyungjun Choi Karol Lewandowski Samsung Electronics · 2014. 6. 19. · 6 kdbus Low-level, native kernel D-Bus transport All communication between processes take place over special](https://reader036.vdocuments.net/reader036/viewer/2022082018/602c89d46711a327b8323d85/html5/thumbnails/2.jpg)
Agenda
![Page 3: Hyungjun Choi Karol Lewandowski Samsung Electronics · 2014. 6. 19. · 6 kdbus Low-level, native kernel D-Bus transport All communication between processes take place over special](https://reader036.vdocuments.net/reader036/viewer/2022082018/602c89d46711a327b8323d85/html5/thumbnails/3.jpg)
3
Agenda
● D-Bus vs kdbus● Motivation and project goals● First attempts● kdbus in Tizen 3.0● Challenges
![Page 4: Hyungjun Choi Karol Lewandowski Samsung Electronics · 2014. 6. 19. · 6 kdbus Low-level, native kernel D-Bus transport All communication between processes take place over special](https://reader036.vdocuments.net/reader036/viewer/2022082018/602c89d46711a327b8323d85/html5/thumbnails/4.jpg)
D-Bus vs kdbus
![Page 5: Hyungjun Choi Karol Lewandowski Samsung Electronics · 2014. 6. 19. · 6 kdbus Low-level, native kernel D-Bus transport All communication between processes take place over special](https://reader036.vdocuments.net/reader036/viewer/2022082018/602c89d46711a327b8323d85/html5/thumbnails/5.jpg)
5
D-Bus
● Message bus system● Method Call Transaction● Signals● Broadcasting● Policy● Activation● ...
App1
libdbus-1
App2
glib
dbus-daemon
1 - Call App2 method
2 – Consult policy
3 – Deliver App1 request
![Page 6: Hyungjun Choi Karol Lewandowski Samsung Electronics · 2014. 6. 19. · 6 kdbus Low-level, native kernel D-Bus transport All communication between processes take place over special](https://reader036.vdocuments.net/reader036/viewer/2022082018/602c89d46711a327b8323d85/html5/thumbnails/6.jpg)
6
kdbus
● Low-level, native kernel D-Bus transport● All communication between processes take
place over special character device nodesin /dev/kdbus.
● Receiver buffers● Single copy to destination(s)
● memfds● File descriptor for memory regions● Zero Copy!● At 512K zero copy is faster than single copy
![Page 7: Hyungjun Choi Karol Lewandowski Samsung Electronics · 2014. 6. 19. · 6 kdbus Low-level, native kernel D-Bus transport All communication between processes take place over special](https://reader036.vdocuments.net/reader036/viewer/2022082018/602c89d46711a327b8323d85/html5/thumbnails/7.jpg)
7
D-Bus vs kdbus
Method Call Transaction (Remote procedure call and reply)
D-Bus(It’s inefficient)
kdbus(It’s efficient)
10 copies 2 of fewer copies
4 complete validations 2 validations
4 context switches 2 context switches
Suitable only for control,not payload
Suitable for large data (GiB),zero-copy, optionally reusable
... ...
![Page 8: Hyungjun Choi Karol Lewandowski Samsung Electronics · 2014. 6. 19. · 6 kdbus Low-level, native kernel D-Bus transport All communication between processes take place over special](https://reader036.vdocuments.net/reader036/viewer/2022082018/602c89d46711a327b8323d85/html5/thumbnails/8.jpg)
Motivation and project goals
![Page 9: Hyungjun Choi Karol Lewandowski Samsung Electronics · 2014. 6. 19. · 6 kdbus Low-level, native kernel D-Bus transport All communication between processes take place over special](https://reader036.vdocuments.net/reader036/viewer/2022082018/602c89d46711a327b8323d85/html5/thumbnails/9.jpg)
9
Motivation and project goals
● Motivation● More efficient, always available IPC mechanism● kdbus may solve our issues with sharing large amounts of
data (tested w/ prototypes)
● Project goals● Transparency
(No need to modify D-Bus based codes)● Compatible with native D-Bus● Improve IPC performance of a Tizen product
![Page 10: Hyungjun Choi Karol Lewandowski Samsung Electronics · 2014. 6. 19. · 6 kdbus Low-level, native kernel D-Bus transport All communication between processes take place over special](https://reader036.vdocuments.net/reader036/viewer/2022082018/602c89d46711a327b8323d85/html5/thumbnails/10.jpg)
10
kdbus performance test results
Method call using libdbus
msg_size default [s] kdbus [s] diff [s] diff [%]
4 B 0.371 0.268 0.103 27.763
8 B 0.355 0.266 0.089 25.070
4 KB 0.438 0.310 0.128 29.224
8 KB 0.546 0.351 0.195 35.714
16 KB 0.707 0.447 0.260 36.775
64 KB 1.937 0.977 0.960 49.561
512 KB 16.88 9.816 7.064 41.848
1024 KB 37.239 22.384 14.855 39.891
The measurement was made by performing one thousand of calls and computing a sum of duration of every call.
4 B 8 B 4 kB 8 kB 16 kB 64 kB 512 kB 1024 kB
Method call using libdbus - test (perf_tuning branch)
Message s ize
Dif
fere
nce
[%
]
![Page 11: Hyungjun Choi Karol Lewandowski Samsung Electronics · 2014. 6. 19. · 6 kdbus Low-level, native kernel D-Bus transport All communication between processes take place over special](https://reader036.vdocuments.net/reader036/viewer/2022082018/602c89d46711a327b8323d85/html5/thumbnails/11.jpg)
First attempts
![Page 12: Hyungjun Choi Karol Lewandowski Samsung Electronics · 2014. 6. 19. · 6 kdbus Low-level, native kernel D-Bus transport All communication between processes take place over special](https://reader036.vdocuments.net/reader036/viewer/2022082018/602c89d46711a327b8323d85/html5/thumbnails/12.jpg)
12
Legacy D-Bus in Tizen
![Page 13: Hyungjun Choi Karol Lewandowski Samsung Electronics · 2014. 6. 19. · 6 kdbus Low-level, native kernel D-Bus transport All communication between processes take place over special](https://reader036.vdocuments.net/reader036/viewer/2022082018/602c89d46711a327b8323d85/html5/thumbnails/13.jpg)
13
kdbus-enabled dbus-daemon
![Page 14: Hyungjun Choi Karol Lewandowski Samsung Electronics · 2014. 6. 19. · 6 kdbus Low-level, native kernel D-Bus transport All communication between processes take place over special](https://reader036.vdocuments.net/reader036/viewer/2022082018/602c89d46711a327b8323d85/html5/thumbnails/14.jpg)
14
Legacy architecture
![Page 15: Hyungjun Choi Karol Lewandowski Samsung Electronics · 2014. 6. 19. · 6 kdbus Low-level, native kernel D-Bus transport All communication between processes take place over special](https://reader036.vdocuments.net/reader036/viewer/2022082018/602c89d46711a327b8323d85/html5/thumbnails/15.jpg)
15
D-Bus libraries in Tizen
● Tizen provides limited number of D-Bus binding libraries● Most of these build on libdbus-1 foundation● Currently only libdbus-1 and glib2 need to be ported to kdbus
![Page 16: Hyungjun Choi Karol Lewandowski Samsung Electronics · 2014. 6. 19. · 6 kdbus Low-level, native kernel D-Bus transport All communication between processes take place over special](https://reader036.vdocuments.net/reader036/viewer/2022082018/602c89d46711a327b8323d85/html5/thumbnails/16.jpg)
kdbus in Tizen 3.0
![Page 17: Hyungjun Choi Karol Lewandowski Samsung Electronics · 2014. 6. 19. · 6 kdbus Low-level, native kernel D-Bus transport All communication between processes take place over special](https://reader036.vdocuments.net/reader036/viewer/2022082018/602c89d46711a327b8323d85/html5/thumbnails/17.jpg)
17
Tizen 3.0 architecture with kdbus
![Page 18: Hyungjun Choi Karol Lewandowski Samsung Electronics · 2014. 6. 19. · 6 kdbus Low-level, native kernel D-Bus transport All communication between processes take place over special](https://reader036.vdocuments.net/reader036/viewer/2022082018/602c89d46711a327b8323d85/html5/thumbnails/18.jpg)
18
Tizen 3.0 architecture with kdbus
![Page 19: Hyungjun Choi Karol Lewandowski Samsung Electronics · 2014. 6. 19. · 6 kdbus Low-level, native kernel D-Bus transport All communication between processes take place over special](https://reader036.vdocuments.net/reader036/viewer/2022082018/602c89d46711a327b8323d85/html5/thumbnails/19.jpg)
19
systemd
● systemd >= v209 handles kdbus natively:● Creates and manages both system and user buses● Transparently handles transition from legacy dbus to kdbus
(service generators, service masking) at boot time
● Additionally provides:● sd-bus (libsystemd) library supporting both AF_UNIX and kdbus transports● bus-proxyd – compatibility AF_UNIX socket for legacy clients● bus-driverd – “org.freedesktop.DBus” support (but see following slides)
![Page 20: Hyungjun Choi Karol Lewandowski Samsung Electronics · 2014. 6. 19. · 6 kdbus Low-level, native kernel D-Bus transport All communication between processes take place over special](https://reader036.vdocuments.net/reader036/viewer/2022082018/602c89d46711a327b8323d85/html5/thumbnails/20.jpg)
20
Native glib (gio) kdbus port
● All major features present:● Exchanging messages, broadcasting, signals, name reg., etc.● Makes use of kdbus-specific functionalities (memfd, bloom filters)
● No changes in glib's API● Development closely follows upstream● Progress tracked on bugzilla.gnome.org● glib RM agreed to include it in next dev. version of glib
![Page 21: Hyungjun Choi Karol Lewandowski Samsung Electronics · 2014. 6. 19. · 6 kdbus Low-level, native kernel D-Bus transport All communication between processes take place over special](https://reader036.vdocuments.net/reader036/viewer/2022082018/602c89d46711a327b8323d85/html5/thumbnails/21.jpg)
21
Native libdbus-1 port
● Originally designed to work with kdbus-enabled dbus-daemon● Currently under active redesign & development
● Not up to date with current day kdbus● Uses “dbus-1” serialization on bus instead of GVariant
● Requires a lot of work to become in shape for upstreaming
![Page 22: Hyungjun Choi Karol Lewandowski Samsung Electronics · 2014. 6. 19. · 6 kdbus Low-level, native kernel D-Bus transport All communication between processes take place over special](https://reader036.vdocuments.net/reader036/viewer/2022082018/602c89d46711a327b8323d85/html5/thumbnails/22.jpg)
22
Security policy
● Simplified policy architecture● New Tizen services tend to perform policy checks by themselves
(via policykit, cynara, etc.)● Dropping dbus-daemon allows us to kill overly complicated DBus policies● Per-destination policy checks fit perfectly in kdbus model● Existing Smack policies can be reused
● Requires simple extensions to Linux LSM and kdbus
![Page 23: Hyungjun Choi Karol Lewandowski Samsung Electronics · 2014. 6. 19. · 6 kdbus Low-level, native kernel D-Bus transport All communication between processes take place over special](https://reader036.vdocuments.net/reader036/viewer/2022082018/602c89d46711a327b8323d85/html5/thumbnails/23.jpg)
23
kdbus-lsm security hooks
● New set LSM hooks● security_kdbus_send()● security_kdbus_recv()● security_kdbus_talk()● security_kdbus_name_acquire()● security_kdbus_name_list()● …
● Preliminary SMACK implementation suggested● Ongoing discussion with kdbus, SMACK, SELinux communities
![Page 24: Hyungjun Choi Karol Lewandowski Samsung Electronics · 2014. 6. 19. · 6 kdbus Low-level, native kernel D-Bus transport All communication between processes take place over special](https://reader036.vdocuments.net/reader036/viewer/2022082018/602c89d46711a327b8323d85/html5/thumbnails/24.jpg)
24
kdbus to Tizen 3.0 (summary of changes)
● Introducing kdbus requires:● Upgrading systemd >= 209 (most likely - v212)● Introducing kdbus kernel module● Patching glib (gio) for native kdbus port● Patching libdbus-1 for native kdbus port● Patching kernel(s) and kdbus for kdbus-lsm security hooks
● kdbus support to be enabled at build time● Patches available on kdbus-integration branches
![Page 25: Hyungjun Choi Karol Lewandowski Samsung Electronics · 2014. 6. 19. · 6 kdbus Low-level, native kernel D-Bus transport All communication between processes take place over special](https://reader036.vdocuments.net/reader036/viewer/2022082018/602c89d46711a327b8323d85/html5/thumbnails/25.jpg)
Challenges
![Page 26: Hyungjun Choi Karol Lewandowski Samsung Electronics · 2014. 6. 19. · 6 kdbus Low-level, native kernel D-Bus transport All communication between processes take place over special](https://reader036.vdocuments.net/reader036/viewer/2022082018/602c89d46711a327b8323d85/html5/thumbnails/26.jpg)
26
kdbus, systemd evolving rapidly
● No API/ABI guarantees● Major features still under active development:
● memfd moving to out of kdbus to generic kernel facility● bus-driverd dropped from systemd > 212
● Integration with Linux kernel might drastically change landscape
![Page 27: Hyungjun Choi Karol Lewandowski Samsung Electronics · 2014. 6. 19. · 6 kdbus Low-level, native kernel D-Bus transport All communication between processes take place over special](https://reader036.vdocuments.net/reader036/viewer/2022082018/602c89d46711a327b8323d85/html5/thumbnails/27.jpg)
27
Future work
● Tizen is going to use systemd-based kdbus stack only● kdbus-enabled dbus-daemon future is uncertain
● Native libdbus-1 kdbus port still requires a lot of work● kdbus-lsm patches:
● Long way to integration● kdbus' ability to “own a name” doesn't map well to SMACK model
● No known good methods for comprehensive system-wide testing
![Page 28: Hyungjun Choi Karol Lewandowski Samsung Electronics · 2014. 6. 19. · 6 kdbus Low-level, native kernel D-Bus transport All communication between processes take place over special](https://reader036.vdocuments.net/reader036/viewer/2022082018/602c89d46711a327b8323d85/html5/thumbnails/28.jpg)
28
Beyond Tizen
● systemd >= 213 will drop bus-driverd● org.freedesktop.DBus will no longer be available on kdbus (while retaining
it on legacy socket)● Lack of org.freedesktop.DBus makes kdbus to not cover all D-Bus spec
requirements● Upstream proposed changes to existing libraries
● Introduce user and machine bus types where kdbus might be available● Calling org.freedesktop.DBus would be explicitly disallowed on these buses
● The above changes make kdbus opt-in, not a transparent replacement for D-Bus
![Page 29: Hyungjun Choi Karol Lewandowski Samsung Electronics · 2014. 6. 19. · 6 kdbus Low-level, native kernel D-Bus transport All communication between processes take place over special](https://reader036.vdocuments.net/reader036/viewer/2022082018/602c89d46711a327b8323d85/html5/thumbnails/29.jpg)
Thank you!
![Page 30: Hyungjun Choi Karol Lewandowski Samsung Electronics · 2014. 6. 19. · 6 kdbus Low-level, native kernel D-Bus transport All communication between processes take place over special](https://reader036.vdocuments.net/reader036/viewer/2022082018/602c89d46711a327b8323d85/html5/thumbnails/30.jpg)
References
![Page 31: Hyungjun Choi Karol Lewandowski Samsung Electronics · 2014. 6. 19. · 6 kdbus Low-level, native kernel D-Bus transport All communication between processes take place over special](https://reader036.vdocuments.net/reader036/viewer/2022082018/602c89d46711a327b8323d85/html5/thumbnails/31.jpg)
31
References
● glib kdbus port● https://bugzilla.gnome.org/show_bug.cgi?id=721861
● Original kdbus-enabled dbus-daemon and libdbus-1● git://review.tizen.org/platform/upstream/dbus kdbus-dev
● libdbuspolicy-1 library● git://review.tizen.org/platform/upstream/dbus libdbuspolicy-dev
● kdbus-lsm patches● git://github.com/lmctl/linux kdbus-lsm-dev● git://github.com/lmctl/kdbus kdbus-lsm-dev
![Page 32: Hyungjun Choi Karol Lewandowski Samsung Electronics · 2014. 6. 19. · 6 kdbus Low-level, native kernel D-Bus transport All communication between processes take place over special](https://reader036.vdocuments.net/reader036/viewer/2022082018/602c89d46711a327b8323d85/html5/thumbnails/32.jpg)
32
References
● Rationale behind dropping bus-driverd● http://permalink.gmane.org/gmane.comp.sysutils.systemd.devel/18514
● https://bugzilla.gnome.org/show_bug.cgi?id=721861#c24
● D-Bus vs kdbus comparision● http://mindlinux.wordpress.com/2014/02/01/anatomy-of-kdbus-lennart-poettering/
● Tizen● http://en.wikipedia.org/wiki/Tizen● https://developer.tizen.org/
![Page 33: Hyungjun Choi Karol Lewandowski Samsung Electronics · 2014. 6. 19. · 6 kdbus Low-level, native kernel D-Bus transport All communication between processes take place over special](https://reader036.vdocuments.net/reader036/viewer/2022082018/602c89d46711a327b8323d85/html5/thumbnails/33.jpg)