It s Seafair weekend in Seattle. As always, the centerpiece is the H1 Unlimitedhydroplane races on Lake Washington.
In my social circle, I m nearly the only person I know who grew up in area. None of the newcomers I know had heard of hydroplane racing before moving to Seattle. Even after I explain it to them i.e., boats with 3,000+ horse power airplane engines that fly just above the water at more than 320kph (200mph) leaving 10m+ (30ft) wakes behind them! most people seem more puzzled than interested.
I grew up near the shore of Lake Washington and could see (and hear!) the races from my house. I don t follow hydroplane racing throughout the year but I do enjoy watching the races at Seafair. Here s my attempt to explain and make the case for the races to new Seattleites.
Before Microsoft, Amazon, Starbucks, etc., there were basically three major Seattle industries: (1) logging and lumber based industries like paper manufacturing; (2) maritime industries like fishing, shipbuilding, shipping, and the navy; (3) aerospace (i.e., Boeing). Vintage hydroplane racing represented the Seattle trifecta: Wooden boats with airplane engines!
The wooden U-60 Miss Thriftway circa 1955 (Thriftway is a Washinton-based supermarket that nobody outside has heard of) below is a picture of old-Seattle awesomeness. Modern hydroplanes are now made of fiberglass but two out of three isn t bad.
Although the boats are racing this year in events in Indiana, San Diego, and Detroit in addition to the two races in Washington, hydroplane racing retains deep ties to the region. Most of the drivers are from the Seattle area. Many or most of the teams and boats are based in Washington throughout the year. Many of the sponsors are unknown outside of the state. This parochialness itself cultivates a certain kind of appeal among locals.
In addition to old-Seattle/new-Seattle cultural divide, there s a class divide that I think is also worth challenging. Although the demographics of hydro-racing fans is surprisingly broad, it can seem like Formula One or NASCAR on the water. It seems safe to suggest that many of the demographic groups moving to Seattle for jobs in the tech industry are not big into motorsports. Although I m no follower of motorsports in general, I ve written before cultivated disinterest in professional sports, and it remains something that I believe is worth taking on.
It s not all great. In particular, the close relationship between Seafair and the military makes me very uneasy. That said, even with the military-heavy airshow, I enjoy the way that Seafair weekend provides a little pocket of old-Seattle that remains effectively unchanged from when I was a kid. I d encourage others to enjoy it as well!
this week, besides other activities, I again managed to NMU a few packages
as part of the GCC
5 transition. & again I could build on patches submitted by various
HP engineers & other helpful souls.
#757525 hardinfo: "hardinfo: FTBFS with clang instead of gcc" patch to build with -std=gnu89, upload to DELAYED/5
#758723 nagios-plugins-rabbitmq: "should depend on libjson-perl" add missing dependency, upload to DELAYED/5
#777766 src:adun.app: "adun.app: ftbfs with GCC-5" send updated patch to BTS
#777837 src:ebview: "ebview: ftbfs with GCC-5" add patch from paulownia@Safe-mail.net, upload to DELAYED/5
#777882 src:gnokii: "gnokii: ftbfs with GCC-5" build with -fgnu89-inline, upload to DELAYED/5
#777907 src:hunt: "hunt: ftbfs with GCC-5" apply patch from Nicholas Luedtke, upload to DELAYED/5
#777920 src:isdnutils: "isdnutils: ftbfs with GCC-5" add patch to build with -fgnu89-inline; upload to DELAYED/5
#778019 src:multimon: "multimon: ftbfs with GCC-5" build with -fgnu89-inline; upload to DELAYED/5
#778068 src:pork: "pork: ftbfs with GCC-5" build with -fgnu89-inline, QA upload
#778098 src:quarry: "quarry: ftbfs with GCC-5" build with -std=gnu89, upload to DELAYED/5, then rescheduled to 0-day with maintainer's permission
#778099 src:ratbox-services: "ratbox-services: ftbfs with GCC-5" build with -fgnu89-inline, upload to DELAYED/5, later cancelled because package is about to be removed (#793408)
#778109 src:s51dude: "s51dude: ftbfs with GCC-5" build with -fgnu89-inline, upload to DELAYED/5
#778116 src:shell-fm: "shell-fm: ftbfs with GCC-5" apply patch from Brett Johnson, upload to DELAYED/5
#778119 src:simulavr: "simulavr: ftbfs with GCC-5" apply patch from Brett Johnson, QA upload
#778120 src:sipsak: "sipsak: ftbfs with GCC-5" apply patch from Brett Johnson, upload to DELAYED/5
#778122 src:skyeye: "skyeye: ftbfs with GCC-5" build with -fgnu89-inline, QA upload
#778140 src:tcpcopy: "tcpcopy: ftbfs with GCC-5" add patch backported from upstream git, upload to DELAYED/5
#778145 src:thewidgetfactory: "thewidgetfactory: ftbfs with GCC-5" add missing #include, upload to DELAYED/5
#778164 src:vtun: "vtun: ftbfs with GCC-5" add patch from Tim Potter, upload to DELAYED/5
#790464 flow-tools: "Please drop conditional build-depend on libmysqlclient15-dev" drop obsolete dependency, NMU
#793336 src:libdevel-profile-perl: "libdevel-profile-perl: FTBFS with perl 5.22 in experimental (MakeMaker changes)" finish and upload package modernized by XTaran (pkg-perl)
#793580 libb-hooks-parser-perl: "libb-hooks-parser-perl: B::Hooks::Parser::Install::Files missing" investigate and forward upstream, upload new upstream release later (pkg-perl)
The recent AWS introduction of the Elastic File System gives you an automatic grow-and-shrink capability as an NFS mount, an exciting option that takes away the previous overhead in creating shared block file systems for EC2 instances.
However it should be noted that the same auto-management of capacity is not true in the EC2 instance s Elastic Block Store (EBS) block storage disks; sizing (and resizing) is left to the customer. With current 2015 EBS, one cannot simply increase the size of an EBS Volume as the storage becomes full; (as at June 2015) an EBS volume, once created, has fixed size. For many applications, that lack of resize function on its local EBS disks is not a problem; many server instances come into existence for a brief period, process some data and then get Terminated, so long term managment is not needed.
However for a long term data store on an instance (instead of S3, which I would recommend looking closely at from a durability and pricing fit), and where I want to harness the capacity to grow (or shrink) disk for my data, then I will need to leverage some slightly more advanced disk management. And just to make life interesting, I wish to do all this while the data is live and in-use, if possible.
Enter: Logical Volume Management, or LVM. It s been around for a long, long time: LVM 2 made a debut around 2002-2003 (2.00.09 was Mar 2004) and LVM 1 was many years before that so it s pretty mature now. It s a powerful layer that sits between your raw storage block devices (as seen by the operating system), and the partitions and file systems you would normally put on them.
In this post, I ll walk through the process of getting set up with LVM on Debian in the AWS EC2 environment, and how you d do some basic maintenance to add and remove (where possible) storage with minimal interruption.
Getting Started
First a little prep work for a new Debian instance with LVM.
As I d like to give the instance its own ability to manage its storage, I ll want to provision an IAM Role for EC2 Instances for this host. In the AWS console, visit IAM, Roles, and I ll create a new Role I ll name EC2-MyServer (or similar), and at this point I ll skip giving it any actual privileges (later we ll update this). As at this date, we can only associate an instance role/profile at instance launch time.
Now I launch a base image Debian EC2 instance launched with this IAM Role/Profile; the root file system is an EBS Volume. I am going to put data that I ll be managing on a separate disk from the root file system.
First, I need to get the LVM utilities installed. It s a simple package to install: the lvm2 package. From my EC2 instance I need to get root privileges (sudo -i) and run:
apt update && apt install lvm2
After a few moments, the package is installed. I ll choose a location that I want my data to live in, such as /opt/. I want a separate disk for this task for a number of reasons:
Root EBS volumes cannot currently be encrypted using Amazon s Encrypted EBS Volumes at this point in time. If I want to also use AWS encryption option, it ll have to be on a non-root disk. Note that instance-size restrictions also exist for EBS Encrypted Volumes.
It s possibly not worth make a snapshot of the Operating System at the same time as the user content data I am saving. The OS install (except the /etc/ folder) can almost entirely be recreated from a fresh install. so why snapshot that as well (unless that s your strategy for preserving /etc, /home, etc).
The type of EBS volume that you require may be different for different data: today (Apr 2015) there is a choice of Magnetic, General Purpose 2 (GP2) SSD, and Provisioned IO/s (PIOPS) SSD, each with different costs; and depending on our volume, we may want to select one for our root volume (operating system), and something else for our data storage.
I may want to use EBS snapshots to clone the disk to another host, without the base OS bundled in with the data I am cloning.
I will create this extra volume in the AWS console and present it to this host. I ll start by using a web browser (we ll use CLI later) with the EC2 console.
The first piece of information we need to know is where my EC2 instance is running. Specifically, the AWS Region and Availability Zone (AZ). EBS Volumes only exist within the one designated AZ. If I accidentally make the volume(s) in the wrong AZ, then I won t be able to connect them to my instance. It s not a huge issue, as I would just delete the volume and try again.
I navigate to the Instances panel of the EC2 Console, and find my instance in the list:
A (redacted) list of instance from the EC2 console.
Here I can see I have located an instance and it s running in US-East-1A: that s AZ A in Region US-East-1. I can also grab this with a wget from my running Debian instance by asking the MetaData server:
The returned text is simply: us-east-1a .
Time to navigate to Elastic Block Store , choose Volumes and click Create :
Creating a volume in AWS EC2: ensure the AZ is the same as your instance
You ll see I selected that I wanted AWS to encrypt this and as noted above, at this time that doesn t include the t2 family. However, you have an option of using encryption with LVM where the customer looks after the encryption key see LUKS.
What s nice is that I can do both have AWS Encrypted Volumes, and then use encryption on top of this, but I have to manage my own keys with LUKS, and should I lose them, then I can keep all the cyphertext!
I deselected this for my example (with a t2.micro), and continue; I could see the new volume in the list as creating , and then shortly afterwards as available . Time to attach it: select the disk, and either right-click and choose Attach , or from the menu at the top of the list, chose Actions -> Attach (both do the same thing).
Attaching a volume to an instance: you ll be prompted for the compatible instances in the same AZ.
At this point in time your EC2 instance will now notice a new disk; you can confirm this with dmesg tail , and you ll see something like:
[1994151.231815] xvdg: unknown partition table
(Note the time-stamp in square brackets will be different).
Previously at this juncture you would format the entire disk with your favourite file system, mount it in the desired location, and be done. But we re adding in LVM here between this raw device, and the filesystem we are yet to make .
Marking the block device for LVM
Our first operation with LVM is to put a marker on the volume to indicate it s being use for LVM so that when we scan the block device, we know what it s for. It s a really simple command:
pvcreate /dev/xvdg
The device name above (/dev/xvdg) should correspond to the one we saw from the dmesg output above. The output of the above is rather straight forward:
Physical volume "/dev/xvdg" successfully created
Checking our EBS Volume
We can check on the EBS volume which LVM sees as a Physical Volume using the pvs command.
Here we see the entire disk is currently unused.
Creating our First Volume Group
Next step, we need to make an initial LVM Volume Group which will use our Physical volume (xvdg). The Volume Group will then contain one (or more) Logical Volumes that we ll format and use. Again, a simple command to create a volume group by giving it its first physical device that it will use:
# vgcreate OptVG /dev/xvdg
Volume group "OptVG" successfully created
And likewise we can check our set of Volume Groups with vgs :
The Attribute flags here indicate this is writable, resizable, and allocating extents in normal mode. Lets proceed to make our (first) Logical Volume in this Volume Group:
# lvcreate -n OptLV -L 4.9G OptVG
Rounding up size to full physical extent 4.90 GiB
Logical volume "OptLV" created
You ll note that I have created our Logical Volume as almost the same size as the entire Volume Group (which is currently one disk) but I left some space unused: the reason for this comes down to keeping some space available for any jobs that LVM may want to use on the disk and this will be used later when we want to move data between raw disk devices.
If I wanted to use LVM for Snapshots, then I d want to leave more space free (unallocated) again.
We can check on our Logical Volume:
The attribytes indicating that the Logical Volume is writeable, is allocating its data to the disk in inherit mode (ie, as the Volume Group is doing), and that it is active. At this stage you may also discover we have a device /dev/OptVG/OptLV, and this is what we re going to format and mount. But before we do, we should review what file system we ll use.
Filesystems
Popular Linux file systems
Name
Shrink
Grow
Journal
Max File Sz
Max Vol Sz
btrfs
Y
Y
N
16 EB
16 EB
ext3
Y off-line
Y
Y
2 TB
32 TB
ext4
Y off-line
Y
Y
16 TB
1 EB
xfs
N
Y
Y
8 EB
8 EB
zfs*
N
Y
Y
16 EB
256 ZB
For more details see Wikipedia comparison. Note that ZFS requires 3rd party kernel module of FUSE layer, so I ll discount that here. BTRFS only went stable with Linux kernel 3.10, so with Debian Jessie that s a possibility; but for tried and trusted, I ll use ext4.
The selection of ext4 also means that I ll only be able to shrink this file system off-line (unmounted).
I ll make the filesystem:
# mkfs.ext4 /dev/OptVG/OptLV
mke2fs 1.42.12 (29-Aug-2014)
Creating filesystem with 1285120 4k blocks and 321280 inodes
Filesystem UUID: 4f831d17-2b80-495f-8113-580bd74389dd
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
And now mount this volume and check it out:
# mount /dev/OptVG/OptLV /opt/
# df -HT /opt
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/OptVG-OptLV ext4 5.1G 11M 4.8G 1% /opt
Lastly, we want this to be mounted next time we reboot, so edit /etc/fstab and add the line:
/dev/OptVG/OptLV /opt ext4 noatime,nodiratime 0 0
With this in place, we can now start using this disk. I selected here not to update the filesystem every time I access a file or folder updates get logged as normal but access time is just ignored.
Time to expand
After some time, our 5 GB /opt/ disk is rather full, and we need to make it bigger, but we wish to do so without any downtime. Amazon EBS doesn t support resizing volumes, so our strategy is to add a new larger volume, and remove the older one that no longer suits us; LVM and ext4 s online resize ability will allow us to do this transparently.
For this example, we ll decide that we want a 10 GB volume. It can be a different type of EBS volume to our original we re going to online-migrate all our data from one to the other.
As when we created the original 5 GB EBS volume above, create a new one in the same AZ and attach it to the host (perhaps a /dev/xvdh this time). We can check the new volume is visible with dmesg again:
[1999786.341602] xvdh: unknown partition table
And now we initalise this as a Physical volume for LVM:
# pvcreate /dev/xvdh
Physical volume "/dev/xvdh" successfully created
And then add this disk to our existing OptVG Volume Group:
# vgextend OptVG /dev/xvdh
Volume group "OptVG" successfully extended
We can now review our Volume group with vgs, and see our physical volumes with pvs:
There are now 2 Physical Volumes we have a 4.9 GB filesystem taking up space, so 10.09 GB of unallocated space in the VG.
Now its time to stop using the /dev/xvgd volume for any new requests:
# pvchange -x n /dev/xvdg
Physical volume "/dev/xvdg" changed
1 physical volume changed / 0 physical volumes not changed
At this time, our existing data is on the old disk, and our new data is on the new one. Its now that I d recommend running GNU screen (or similar) so you can detach from this shell session and reconnect, as the process of migrating the existing data can take some time (hours for large volumes):
During the move, checking the Monitoring tab in the AWS EC2 Console for the two volumes should show one with a large data Read metric, and one with a large data Write metric clearly data should be flowing off the old disk, and on to the new.
A note on disk throughput
The above move was a pretty small, and empty volume. Larger disks will take longer, naturally, so getting some speed out of the process maybe key. There s a few things we can do to tweak this:
EBS Optimised: a launch-time option that reserves network throughput from certain instance types back to the EBS service within the AZ. Depending on the size of the instance this is 500 MB/sec up to 4GB/sec. Note that for the c4 family of instances, EBS Optimised is on by default.
Size of GP2 disk: the larger the disk, the longer it can sustain high IO throughput but read this for details.
Size and speed of PIOPs disk: if consistent high IO is required, then moving to Provisioned IO disk may be useful. Looking at the (2 weeks) history of Cloudwatch logs for the old volume will give me some idea of the duty cycle of the disk IO.
Back to the move
Upon completion I can see that the disk in use is the new disk and not the old one, using pvs again:
So all 5 GB is now unused (compare to above, where only 96 MB was PFree). With that disk not containing data, I can tell LVM to remove the disk from the Volume Group:
# vgreduce OptVG /dev/xvdg
Removed "/dev/xvdg" from volume group "OptVG"
Then I cleanly wipe the labels from the volume:
# pvremove /dev/xvdg
Labels on physical volume "/dev/xvdg" successfully wiped
If I really want to clean the disk, I could choose to use shred(1) on the disk to overwrite with random data. This can take a lng time
Now the disk is completely unused and disassociated from the VG, I can return to the AWS EC2 Console, and detach the disk:
Detach an EBS volume from an EC2 instance
Wait for a few seconds, and the disk is then shown as available ; I then chose to delete the disk in the EC2 console (and stop paying for it).
Back to the Logical Volume it s still 4.9 GB, so I add 4.5 GB to it:
# lvresize -L +4.5G /dev/OptVG/OptLV
Size of logical volume OptVG/OptLV changed from 4.90 GiB (1255 extents) to 9.40 GiB (2407 extents).
Logical volume OptLV successfully resized
We now have 0.6GB free space on the physical volume (pvs confirms this).
Finally, its time to expand out ext4 file system:
# resize2fs /dev/OptVG/OptLV
resize2fs 1.42.12 (29-Aug-2014)
Filesystem at /dev/OptVG/OptLV is mounted on /opt; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 1
The filesystem on /dev/OptVG/OptLV is now 2464768 (4k) blocks long.
And with df we can now see:
# df -HT /opt/
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/OptVG-OptLV ext4 9.9G 12M 9.4G 1% /opt
Automating this
The IAM Role I made at the beginning of this post is now going to be useful. I ll start by adding an IAM Policy to the Role to permit me to List Volumes, Create Volumes, Attach Volumes and Detach Volumes to my instance-id. Lets start with creating a volume, with a policy like this:
This policy puts some restrictions on the volumes that this instance can create: only within the given Availability Zone (matching our instance), only GP2 SSD (no PIOPs volumes), and size no more than 250 GB. I ll add another policy to permit this instance role to tag volumes in this AZ that don t yet have a tag called InstanceId:
Now that I can create (and then tag) volumes, this becomes a simple procedure as to what else I can do to this volume. Deleting and creating snapshots of this volume are two obvious options, and the corresponding policy:
Of course it would be lovely if I could use a variable inside the policy condition instead of the literal string of the instance ID, but that s not currently possible.
Clearly some of the more important actions I want to take are to attach and detach a volume to my instance:
Now with this in place, we can start to fire up the AWS CLI we spoke of. We ll let the CLI inherit its credentials form the IAM Instance Role and the polices we just defined.
and at this stage, the above manipulation of the raw block device with LVM can begin. Likewise you can then use the CLI to detach and destroy any unwanted volumes if you are migrating off old block devices.
I've recently found myself explaining polkit (formerly PolicyKit) to one of
Collabora's clients, and thought that
blogging about the same topic might be useful for
other people who are confused by it;
so, here is why udisks2 and polkit are the way they are.
As always, opinions in this blog are my own, not Collabora's.
Privileged actions
Broadly, there are two ways a process can do something: it can do it
directly (i.e. ask the kernel directly), or it can use inter-process
communication to ask a service to do that operation on its behalf.
If it does it directly, the components that say whether it can succeed
are the Linux kernel's normal permissions checks
(DAC),
and if configured, AppArmor, SELinux or a similar
MAC layer.
All very simple so far.
Unfortunately, the kernel's relatively coarse-grained checks are not sufficient
to express the sorts of policies that exist on a desktop/laptop/mobile
system. My favourite example for this sort of thing is mounting filesystems.
If I plug in a USB stick with a FAT filesystem, it's reasonable to expect
my chosen user interface to either mount it automatically, or
let me press a button to mount it. Similarly, to avoid data loss, I
should be able to unmount it when I'm finished with it.
However, mounting and unmounting a USB stick is fundamentally the same
system call as mounting and unmounting any other filesystem - and if
ordinary users can do arbitrary mount system calls, they can cause all
sorts of chaos, for instance by mounting a filesystem that contains setuid
executables (privilege escalation), or umounting a critical OS filesystem
like /usr (denial of service). Something needs to arbitrate: you can mount
filesystems, but only under certain conditions .
The kernel developer motto for this sort of thing is mechanism, not policy :
they are very keen to avoid encoding particular environments' policies
(the sort of thing you could think of as business rules ) in the kernel,
because that makes it non-generic and hard to maintain. As a result,
direct mount/unmount actions are only allowed by privileged processes,
and it's up to user-space processes to arrange for a privileged process
to make the desired mount syscall.
Here are some other privileged actions which laptop/desktop users can
reasonably expect to just work , with or without requiring a sysadmin-like
(root-equivalent) user:
reconfiguring networking (privileged because, in the general case, it's an
availability and potentially integrity issue)
installing, upgrading or removing packages (privileged because, in the
general case, it can result in arbitrary root code execution)
suspending or shutting down the system (privileged because you wouldn't
want random people doing this on your server, but should normally be
allowed on e.g. laptops for people with physical access, because they could
just disconnect the power anyway)
In environments that use a MAC framework like AppArmor, actions that
would normally be allowed can become privileged: for instance, in a
framework for sandboxed applications, most apps shouldn't be allowed to
record audio. This prevents carrying out these actions directly,
again resulting in the only way to achieve them being to ask a service
to carry out the action.
Ask a system service to do it
On to the next design, then: I can submit a request to a privileged process,
which does some checks to make sure I'm not trying to break the system
(or alternatively, that I have enough sysadmin rights that I'm allowed
to break the system if I want to), and then does the privileged
action for me.
You might think I'm about to start discussing D-Bus and daemons, but
actually, a prominent earlier implementation of this was mount(8), which
is normally setuid root:
% ls -l /bin/mount
-rwsr-xr-x 1 root root 40000 May 22 11:37 /bin/mount
If you look at it from an odd angle, this is inter-process communication
across a privilege boundary: I run the setuid executable, creating a
process. Because the executable has the setuid bit set, the kernel makes
the process highly privileged: its effective uid is root, and it has
all the necessary capabilities to mount filesystems. I submit the request
by passing it in the command-line arguments. mount does some checks -
specifically, it looks in /etc/fstab to see whether the filesystem I'm
trying to mount has the user or users flag - then carries out the
mount system call.
There are a few obvious problems with this:
When machines had
a static set of hardware devices
(and a sysadmin who knew how to configure them), it might have
made sense to list them all in /etc/fstab; but this is not a useful
solution if you can plug in any number of USB drives, or if you are
a non-expert user with Linux on your laptop. The decision
ought to be based on general attributes of devices, such as is removable? ,
and on the role of the machine.
One fact that a reasonable security policy might include is users who
are logged in remotely should have less control over physically present
devices than those who are physically present - but that sort of thing
can't be checked by mount(8) without specifically teaching the
mount binary about it.
Ask a system service to do it, via D-Bus or other IPC
To avoid the issues of setuid, we could use inter-process communication in
the traditional sense: run a privileged daemon (on boot or on-demand),
make it listen for requests, and use the IPC channel as our privilege boundary.
udisks2 is one such privileged daemon, which uses D-Bus as its IPC channel.
D-Bus is a commonly-used inter-process system; one of its
intended/designed uses is to let user processes and system services
communicate, especially this sort of communication between a privileged
daemon and its less-privileged clients.
People sometimes criticize D-Bus as not doing anything you couldn't do yourself
with some AF_UNIX sockets. Well, no, of course it doesn't - the important
bit of the reference implementation and the various interoperable
reimplementations consists of a daemon and some AF_UNIX sockets, and the
rest is
a simple matter of programming.
However, it's sufficient for most uses in its problem space, and is usually better than inventing your
own.
The advantage of D-Bus over doing your own thing is precisely that you
are not doing your own thing: good IPC design is hard, and D-Bus makes
some structural decisions so that fewer application
authors have to think about them. For instance, it has a central hub daemon
(the dbus-daemon, or message bus ) so that n communicating applications
don't need O(n ) sockets; it uses the dbus-daemon to provide a
total message ordering
so you don't have to think about message reordering; it has a distributed
naming model (which can also be used as a distributed mutex) so you don't
have to design that; it has a serialization format and a type system so you
don't have to design one of those; it has a framework for activating"
run-on-demand daemons so they don't have to use resources initially,
implemented using a setuid helper and/or systemd; and so on.
If you have religious objections to D-Bus, you can mentally replace
D-Bus with AF_UNIX or something and most of this article will
still be true.
Is this OK?
In either case - exec'ing a privileged helper, or submitting a request to a
privileged daemon via IPC - the privileged process has two questions that
it needs to answer before it does its work:
what am I being asked to do?
should I do it?
It needs to make some sort of decision on the latter based on the
information available to it. However, before we even get there, there is
another layer:
did the request get there at all?
In the setuid model, there is a simple security check that you can
apply: you can make /bin/mount only executable by a particular group,
or only executable by certain AppArmor profiles, or similar. That works
up to a point, but cannot distinguish between physically-present and
not-physically-present users, or other facts that might be interesting
to your local security policy.
Similarly, in the IPC model, you can make certain communication channels
impossible, for instance by using dbus-daemon's ability to decide which
messages to deliver, or AF_UNIX sockets' filesystem permissions,
or a MAC framework like AppArmor.
Both of these are quite coarse-grained checks which don't really
understand the finer details of what is going on. If the answer to
"is this safe? is something of the form maybe, it depends on... ,
then they can't do the right thing: they must either let it through
and let the domain-specific privileged process do the check, or deny it
and lose potentially useful functionality.
For instance, in an AppArmor environment, some applications have absolutely no
legitimate reason to talk to udisks2, so the AppArmor policy can just
block it altogether. However, once again, this is a coarse-grained
check: the kernel has mechanism, not policy, and it doesn't know what
the service does or why. If the application does need to be able to talk
to the service at all, then finer-grained access control
(obeying some, but not all, requests) has to be the service's job.
dbus-daemon does have the ability to match messages in a relatively
fine-grained way, based on the object path, interface and member in
the message, as well as the routing information that it uses itself
(i.e. the source and destination). However, it is not clear that this
makes a great deal of sense conceptually: these are facts about the
mechanics of the IPC, not facts about the domain-specific request
(because the mechanics of the IPC are all that dbus-daemon understands).
For instance, taking the udisks2 example again, dbus-daemon can't
distinguish between an attempt to adjust mount options for a USB stick
(probably fine) and an attempt to adjust mount options for /usr (not good).
To have a domain-specific security policy, we need a domain-specific
component, for instance udisks2, to get involved. Unlike dbus-daemon,
udisks2 knows that not all disks are equal, knows which
categories make sense to distinguish, and can identify which categories
a particular disk is in. So udisks2 can make a more informed decision.
So, a naive approach might be to write a function in udisks2 that looks
something like this pseudocode:
may_i_mount_this_disk (user, disk, mount options) boolean
if (user is root user is root-equivalent)
return true;
if (disk is not removable)
return false;
if (mount options are scary)
return false;
if (user is in manipulate non-local disks group)
return true;
if (user is not logged-in locally)
return false;
# https://en.wikipedia.org/wiki/Multiseat_configuration
if (user is not logged-in on the same seat where the disk is
plugged in)
return false;
return true;
Delegating the security policy to something central
The pseudocode security policy outlined above is reasonably
complicated already, and doesn't necessarily cover everything that you
might want to consider.
Meanwhile, not every system is the same. A general-purpose Linux
distribution like Debian might run on server/mainframe systems with only
remote users, personal laptops/desktops with one root-equivalent user,
locked-down corporate laptops/desktops, mobile devices and so on; these
systems should not necessarily all have the same security policy.
Another interesting factor is that for some privileged operations, you
might want to carry out interactive authorization: ask the requesting user
to confirm that the action (which might have come from a background
process) should take place (like Windows'
UAC),
or to prove that the person currently at the keyboard is the same as
the person who logged in by giving their password
(like sudo).
We could in principle write code for all of this in udisks2, and in
NetworkManager, and in systemd, ... - but that clearly doesn't scale,
particularly if you want the security policy to be configurable.
Enter polkit
(formerly PolicyKit), a system service for applying security policies
to actions.
The way polkit works is that the application does its domain-specific
analysis of the request - in the case of udisks2, whether the device to
be mounted is removable, whether the mount options are reasonable, etc. -
and converts it into an action. The action gives polkit a way to
distinguish between things that are conceptually different, without
needing to know the specifics. For instance, udisks2 currently divides
up filesystem-mounting into org.freedesktop.udisks2.filesystem-mount,
org.freedesktop.udisks2.filesystem-mount-fstab,
org.freedesktop.udisks2.filesystem-mount-system and
org.freedesktop.udisks2.filesystem-mount-other-seat.
The application also finds the identity of the user making the request.
Next, the application sends the action, the identity of the requesting
user, and any other interesting facts to polkit. As currently implemented,
polkit is a D-Bus service, so this is an IPC request via D-Bus.
polkit consults its database of policies in order to choose one of several
results:
yes, allow it
no, do not allow it
ask the user to either authenticate as themselves or as a privileged
(sysadmin) user to allow it, or cancel authentication to not allow it
ask the user to authenticate the first time, but if they do, remember
that for a while and don't ask again
So how does polkit decide this? The first thing is that it reads the
machine-readable description of the actions, in /usr/share/polkit-1/actions,
which specifies a default policy. Next, it evaluates a local security policy
to see what that says. In the current version of polkit, the local security
policy is configured by writing JavaScript in /etc/polkit-1/rules.d
(local policy) and /usr/share/polkit-1/rules.d (OS-vendor defaults).
In older versions such as the one currently shipped in Debian unstable,
there was a plugin architecture; but in practice
nobody wrote plugins for it, and instead everyone used the
example local authority shipped with polkit, which was configured
via files in /etc/polkit-1/localauthority and
/etc/polkit-1/localauthority.d.
These policies can take into account useful facts like:
what is the action we're talking about?
is the user logged-in locally? are they active, i.e. they are not just on a
non-current virtual console?
is the user in particular groups?
For instance, gnome-control-center on Debian installs this snippet:
which is reasonably close to being pseudocode for active local users in the
sudo group may set the system locale, keyboard layout, hostname and time,
without needing to authenticate . A system administrator could of course
override that by dropping a higher-priority policy for some or all of these
actions into /etc/polkit-1/rules.d.
Summary
Kernel-based permission checks are not sufficiently fine-grained to be able
to express some quite reasonable security policies
Fine-grained access control needs domain-specific understanding
The kernel doesn't have that information (and neither does dbus-daemon)
The privileged service that does the domain-specific thing can provide the
domain-specific understanding to turn the request into an action
polkit evaluates a configurable policy to determine whether privileged
services should carry out requested actions
I recently acquired a Lenovo Yoga 2 13. While, at the time, the Yoga 3 was available, I decided to go for Yoga 2 13. The Yoga 3 comes with the newer Core M Broadwell family, which, in my opinion, doesn't really bring any astounding benefits.
The Yoga 2 13 comes in mulitple variants worldwide. Infact these hardware variations have different effets when run under Linux.
My varaint of Yoga 2 13 is:
CPU: Intel(R) Core(TM) i7-4510U CPU @ 2.00GHz
RAM: 8 GiB - Occupying 2 slots
Memory Controller Information
Supported Interleave: One-way Interleave
Current Interleave: One-way Interleave
Maximum Memory Module Size: 8192 MB
Maximum Total Memory Size: 16384 MB
Handle 0x0006, DMI type 6, 12 bytes
Handle 0x0007, DMI type 6, 12 bytes
The usual PCI devices:
rrs@learner:~$ lspci
00:00.0 Host bridge: Intel Corporation Haswell-ULT DRAM Controller (rev 0b)
00:02.0 VGA compatible controller: Intel Corporation Haswell-ULT Integrated Graphics Controller (rev 0b)
00:03.0 Audio device: Intel Corporation Haswell-ULT HD Audio Controller (rev 0b)
00:14.0 USB controller: Intel Corporation 8 Series USB xHCI HC (rev 04)
00:16.0 Communication controller: Intel Corporation 8 Series HECI #0 (rev 04)
00:1b.0 Audio device: Intel Corporation 8 Series HD Audio Controller (rev 04)
00:1c.0 PCI bridge: Intel Corporation 8 Series PCI Express Root Port 4 (rev e4)
00:1d.0 USB controller: Intel Corporation 8 Series USB EHCI #1 (rev 04)
00:1f.0 ISA bridge: Intel Corporation 8 Series LPC Controller (rev 04)
00:1f.2 SATA controller: Intel Corporation 8 Series SATA Controller 1 [AHCI mode] (rev 04)
00:1f.3 SMBus: Intel Corporation 8 Series SMBus Controller (rev 04)
01:00.0 Network controller: Realtek Semiconductor Co., Ltd. RTL8723BE PCIe Wireless Network Adapter
17:37
And the storage devices
Device Model: WDC WD5000M22K-24Z1LT0-SSHD-16GB
Device Model: KINGSTON SM2280S3120G
Storage
The drive runs into serious performance problems when its SSHD's NCQ (mis)feature is under use in Linux <= 4.0.
[28974.232550] ata2.00: configured for UDMA/133
[28974.232565] ahci 0000:00:1f.2: port does not support device sleep
[28983.680955] ata1.00: exception Emask 0x10 SAct 0x7fffffff SErr 0x400100 action 0x6 frozen
[28983.681000] ata1.00: irq_stat 0x08000000, interface fatal error
[28983.681027] ata1: SError: UnrecovData Handshk
[28983.681052] ata1.00: failed command: WRITE FPDMA QUEUED
[28983.681082] ata1.00: cmd 61/40:00:b8:84:88/05:00:0a:00:00/40 tag 0 ncq 688128 out
res 40/00:3c:78:a9:88/00:00:0a:00:00/40 Emask 0x10 (ATA bus error)
[28983.681152] ata1.00: status: DRDY
[28983.681171] ata1.00: failed command: WRITE FPDMA QUEUED
[28983.681202] ata1.00: cmd 61/40:08:f8:89:88/05:00:0a:00:00/40 tag 1 ncq 688128 out
res 40/00:3c:78:a9:88/00:00:0a:00:00/40 Emask 0x10 (ATA bus error)
[28983.681271] ata1.00: status: DRDY
[28983.681289] ata1.00: failed command: WRITE FPDMA QUEUED
[28983.681316] ata1.00: cmd 61/40:10:38:8f:88/05:00:0a:00:00/40 tag 2 ncq 688128 out
res 40/00:3c:78:a9:88/00:00:0a:00:00/40 Emask 0x10 (ATA bus error)
[28983.681387] ata1.00: status: DRDY
[28983.681407] ata1.00: failed command: WRITE FPDMA QUEUED
[28983.681435] ata1.00: cmd 61/40:18:78:94:88/05:00:0a:00:00/40 tag 3 ncq 688128 out
res 40/00:3c:78:a9:88/00:00:0a:00:00/40 Emask 0x10 (ATA bus error)
[28983.697642] ata1.00: status: DRDY
[28983.697643] ata1.00: failed command: WRITE FPDMA QUEUED
[28983.697646] ata1.00: cmd 61/40:c8:38:65:88/05:00:0a:00:00/40 tag 25 ncq 688128 out
res 40/00:3c:78:a9:88/00:00:0a:00:00/40 Emask 0x10 (ATA bus error)
[28983.697647] ata1.00: status: DRDY
[28983.697648] ata1.00: failed command: WRITE FPDMA QUEUED
[28983.697651] ata1.00: cmd 61/40:d0:78:6a:88/05:00:0a:00:00/40 tag 26 ncq 688128 out
res 40/00:3c:78:a9:88/00:00:0a:00:00/40 Emask 0x10 (ATA bus error)
[28983.697651] ata1.00: status: DRDY
[28983.697652] ata1.00: failed command: WRITE FPDMA QUEUED
[28983.697656] ata1.00: cmd 61/40:d8:b8:6f:88/05:00:0a:00:00/40 tag 27 ncq 688128 out
res 40/00:3c:78:a9:88/00:00:0a:00:00/40 Emask 0x10 (ATA bus error)
[28983.697657] ata1.00: status: DRDY
[28983.697658] ata1.00: failed command: WRITE FPDMA QUEUED
[28983.697661] ata1.00: cmd 61/40:e0:f8:74:88/05:00:0a:00:00/40 tag 28 ncq 688128 out
res 40/00:3c:78:a9:88/00:00:0a:00:00/40 Emask 0x10 (ATA bus error)
[28983.697662] ata1.00: status: DRDY
[28983.697663] ata1.00: failed command: WRITE FPDMA QUEUED
[28983.697666] ata1.00: cmd 61/40:e8:38:7a:88/05:00:0a:00:00/40 tag 29 ncq 688128 out
res 40/00:3c:78:a9:88/00:00:0a:00:00/40 Emask 0x10 (ATA bus error)
[28983.697667] ata1.00: status: DRDY
[28983.697668] ata1.00: failed command: WRITE FPDMA QUEUED
[28983.697672] ata1.00: cmd 61/40:f0:78:7f:88/05:00:0a:00:00/40 tag 30 ncq 688128 out
res 40/00:3c:78:a9:88/00:00:0a:00:00/40 Emask 0x10 (ATA bus error)
[28983.697672] ata1.00: status: DRDY
[28983.697676] ata1: hard resetting link
[28984.017356] ata1: SATA link up 6.0 Gbps (SStatus 133 SControl 300)
[28984.022612] ata1.00: configured for UDMA/133
[28984.022740] ata1: EH complete
[28991.611732] Suspending console(s) (use no_console_suspend to debug)
[28992.183822] sd 1:0:0:0: [sdb] Synchronizing SCSI cache
[28992.186569] sd 1:0:0:0: [sdb] Stopping disk
[28992.186604] sd 0:0:0:0: [sda] Synchronizing SCSI cache
[28992.189594] sd 0:0:0:0: [sda] Stopping disk
[28992.967426] PM: suspend of devices complete after 1351.349 msecs
[28992.999461] PM: late suspend of devices complete after 31.990 msecs
[28993.000058] ehci-pci 0000:00:1d.0: System wakeup enabled by ACPI
[28993.000306] xhci_hcd 0000:00:14.0: System wakeup enabled by ACPI
[28993.016463] PM: noirq suspend of devices complete after 16.978 msecs
[28993.017024] ACPI: Preparing to enter system sleep state S3
[28993.017349] PM: Saving platform NVS memory
[28993.017357] Disabling non-boot CPUs ...
[28993.017389] intel_pstate CPU 1 exiting
[28993.018727] kvm: disabling virtualization on CPU1
[28993.019320] smpboot: CPU 1 is now offline
[28993.019646] intel_pstate CPU 2 exiting
In the interim, to overcome this problem, we can force the device to run in degraded mode. I'm not sure if it is really the degraded mode, or the device was falsely advertised as a 6 GiB capable device. Time will tell, but for now, force it to run in 3 GiB mode, and so far, I haven't run into the above mentioned probems. To force 3 GiB speed, apply the following.
And then verify it... As you can see below, I've forced it for ata1 because I want my SSD drive to run at full-speed. I've done enough I/O, which earlier resulted in the kernel spitting the SATA errors. With this workaround, the kernel does not spit any error messages.
[ 1.273365] libata version 3.00 loaded.
[ 1.287290] ahci 0000:00:1f.2: AHCI 0001.0300 32 slots 4 ports 6 Gbps 0x3 impl SATA mode
[ 1.288238] ata1: FORCE: PHY spd limit set to 3.0Gbps
[ 1.288240] ata1: SATA max UDMA/133 abar m2048@0xb051b000 port 0xb051b100 irq 41
[ 1.288242] ata2: SATA max UDMA/133 abar m2048@0xb051b000 port 0xb051b180 irq 41
[ 1.288244] ata3: DUMMY
[ 1.288245] ata4: DUMMY
[ 1.606971] ata1: SATA link up 3.0 Gbps (SStatus 123 SControl 320)
[ 1.607906] ata1.00: ATA-9: WDC WD5000M22K-24Z1LT0-SSHD-16GB, 02.01A03, max UDMA/133
[ 1.607910] ata1.00: 976773168 sectors, multi 0: LBA48 NCQ (depth 31/32), AA
[ 1.608856] ata1.00: configured for UDMA/133
[ 1.609106] scsi 0:0:0:0: Direct-Access ATA WDC WD5000M22K-2 1A03 PQ: 0 ANSI: 5
[ 1.927167] ata2: SATA link up 6.0 Gbps (SStatus 133 SControl 300)
[ 1.928980] ata2.00: ATA-8: KINGSTON SM2280S3120G, S8FM06.A, max UDMA/133
[ 1.928983] ata2.00: 234441648 sectors, multi 16: LBA48 NCQ (depth 31/32), AA
[ 1.929616] ata2.00: configured for UDMA/133
And the throughput you get out of your WD SATA SSHD drive, with capability set to 3.0 GiB is:
rrs@learner:/media/SSHD/tmp$ while true; do dd if=/dev/zero of=foo.img bs=1M count=20000; sync; rm -rf foo.img; sync; done
20000+0 records in
20000+0 records out
20971520000 bytes (21 GB) copied, 202.014 s, 104 MB/s
20000+0 records in
20000+0 records out
20971520000 bytes (21 GB) copied, 206.111 s, 102 MB/s
Hannes Reinecke has submitted patches for NCQ enhancements, for Linux 4.1, which I hope will resolve these problems. Another option is to disable NCQ for the drive, or else blacklist the make/model in driver/ata/libata-core.c
By the time I finished this blog entry draft, I had tests to conclude that this did not look like an NCQ problem. Because in degraded mode too, it runs with NCQ enabled (check above).
Another interesting feature of this drive is support for TRIM / DISCARD. This drive's FTL accepts the TRIM command. Ofcourse, you need to ensure that you have discard enabled in all the layers. In my case, SATA + Device Mapper (Crypt and LVM) + File System (ext4)
Display
The overall display of this device is amazing. It is large enough to give you vibrant look. At 1920x1080 resolution, things look good. The display support was available out-of-the-box.
There were some suspend / resume hangs that occured with kernels < 4.x, during suspend / resume. The issue was root caused and fixed for Linux 4.0.
You may still notice the following kernel messages, though not problematic to me so far.
[28977.518114] PM: thaw of devices complete after 3607.979 msecs
[28977.590389] i915 0000:00:02.0: BAR 6: [??? 0x00000000 flags 0x2] has bogus alignment
[28977.590582] i915 0000:00:02.0: BAR 6: [??? 0x00000000 flags 0x2] has bogus alignment
[28977.591095] i915 0000:00:02.0: BAR 6: [??? 0x00000000 flags 0x2] has bogus alignment
[28977.591185] i915 0000:00:02.0: BAR 6: [??? 0x00000000 flags 0x2] has bogus alignment
[28977.591368] acpi device:30: Cannot transition to power state D3cold for parent in (unknown)
[28977.591911] pci_bus 0000:01: Allocating resources
[28977.591933] i915 0000:00:02.0: BAR 6: [??? 0x00000000 flags 0x2] has bogus alignment
[28977.592093] i915 0000:00:02.0: BAR 6: [??? 0x00000000 flags 0x2] has bogus alignment
[28977.592401] i915 0000:00:02.0: BAR 6: [??? 0x00000000 flags 0x2] has bogus alignment
You may need to disable the Intel Management Engine Interface (mei.ko), incase you run into suspend/resume problems.
rrs@learner:/media/SSHD/tmp$ cat /etc/modprobe.d/intel-mei-blacklist.conf
blacklist mei
blacklist mei-me
17:01
You may also run into the following Kernel Oops during suspend/resume. Below, you see 2 interation of sleep because it first hibernates and then sleeps (s2both).
[ 180.470206] Syncing filesystems ... done.
[ 180.473337] Freezing user space processes ... (elapsed 0.001 seconds) done.
[ 180.475210] PM: Marking nosave pages: [mem 0x00000000-0x00000fff]
[ 180.475213] PM: Marking nosave pages: [mem 0x0006f000-0x0006ffff]
[ 180.475215] PM: Marking nosave pages: [mem 0x00088000-0x000fffff]
[ 180.475220] PM: Marking nosave pages: [mem 0x97360000-0x97b5ffff]
[ 180.475274] PM: Marking nosave pages: [mem 0x9c36f000-0x9cffefff]
[ 180.475356] PM: Marking nosave pages: [mem 0x9d000000-0xffffffff]
[ 180.476877] PM: Basic memory bitmaps created
[ 180.477003] PM: Preallocating image memory... done (allocated 380227 pages)
[ 180.851800] PM: Allocated 1520908 kbytes in 0.37 seconds (4110.56 MB/s)
[ 180.851802] Freezing remaining freezable tasks ... (elapsed 0.001 seconds) done.
[ 180.853355] Suspending console(s) (use no_console_suspend to debug)
[ 180.853520] wlan0: deauthenticating from c4:6e:1f:d0:67:26 by local choice (Reason: 3=DEAUTH_LEAVING)
[ 180.864159] cfg80211: Calling CRDA to update world regulatory domain
[ 181.172222] PM: freeze of devices complete after 319.294 msecs
[ 181.196080] ------------[ cut here ]------------
[ 181.196124] WARNING: CPU: 3 PID: 3707 at drivers/gpu/drm/i915/intel_display.c:7904 hsw_enable_pc8+0x659/0x7c0 [i915]()
[ 181.196125] SPLL enabled
[ 181.196159] Modules linked in: rfcomm ctr ccm bnep pci_stub vboxpci(O) vboxnetadp(O) vboxnetflt(O) vboxdrv(O) bridge stp llc xt_conntrack iptable_filter ipt_MASQUERADE nf_nat_masquerade_ipv4 iptable_nat nf_conntrack_ipv4 nf_defrag_ipv4 nf_nat_ipv4 nf_nat nf_conntrack xt_CHECKSUM xt_tcpudp iptable_mangle ip_tables x_tables nls_utf8 nls_cp437 vfat fat rtsx_usb_ms memstick snd_hda_codec_hdmi joydev mousedev hid_sensor_rotation hid_sensor_incl_3d hid_sensor_als hid_sensor_accel_3d hid_sensor_magn_3d hid_sensor_gyro_3d hid_sensor_trigger industrialio_triggered_buffer kfifo_buf industrialio hid_sensor_iio_common iTCO_wdt iTCO_vendor_support hid_multitouch x86_pkg_temp_thermal intel_powerclamp coretemp intel_rapl iosf_mbi kvm_intel kvm btusb hid_sensor_hub bluetooth uvcvideo videobuf2_vmalloc videobuf2_memops
[ 181.196203] videobuf2_core v4l2_common videodev media pcspkr evdev mac_hid arc4 psmouse serio_raw efivars i2c_i801 rtl8723be btcoexist rtl8723_common rtl_pci rtlwifi mac80211 snd_soc_rt5640 cfg80211 snd_soc_rl6231 snd_hda_codec_realtek i915 snd_soc_core snd_hda_codec_generic ideapad_laptop ac snd_compress dw_dmac sparse_keymap drm_kms_helper rfkill battery dw_dmac_core snd_hda_intel snd_pcm_dmaengine snd_soc_sst_acpi snd_hda_controller video 8250_dw regmap_i2c snd_hda_codec drm snd_hwdep snd_pcm spi_pxa2xx_platform i2c_designware_platform soc_button_array snd_timer i2c_designware_core snd i2c_algo_bit soundcore shpchp lpc_ich button processor fuse ipv6 autofs4 ext4 crc16 jbd2 mbcache btrfs xor raid6_pq algif_skcipher af_alg dm_crypt dm_mod sg usbhid sd_mod rtsx_usb_sdmmc rtsx_usb crct10dif_pclmul
[ 181.196220] crc32_pclmul crc32c_intel ghash_clmulni_intel aesni_intel aes_x86_64 lrw gf128mul glue_helper ablk_helper cryptd ahci libahci libata xhci_pci ehci_pci xhci_hcd ehci_hcd scsi_mod usbcore usb_common thermal fan thermal_sys hwmon i2c_hid hid i2c_core sdhci_acpi sdhci mmc_core gpio_lynxpoint
[ 181.196224] CPU: 3 PID: 3707 Comm: kworker/u16:7 Tainted: G O 4.0.4+ #14
[ 181.196225] Hardware name: LENOVO 20344/INVALID, BIOS 96CN29WW(V1.15) 10/16/2014
[ 181.196230] Workqueue: events_unbound async_run_entry_fn
[ 181.196233] 0000000000000000 ffffffffa0706f68 ffffffff81522198 ffff880064debc88
[ 181.196235] ffffffff8106c5b1 ffff880251460000 ffff880250f83b68 ffff880250f83b78
[ 181.196237] ffff880250f83800 0000000000000001 ffffffff8106c62a ffffffffa071407c
[ 181.196238] Call Trace:
[ 181.196248] [<ffffffff81522198>] ? dump_stack+0x40/0x50
[ 181.196251] [<ffffffff8106c5b1>] ? warn_slowpath_common+0x81/0xb0
[ 181.196254] [<ffffffff8106c62a>] ? warn_slowpath_fmt+0x4a/0x50
[ 181.196278] [<ffffffffa06ae349>] ? hsw_enable_pc8+0x659/0x7c0 [i915]
[ 181.196289] [<ffffffffa0643ee0>] ? intel_suspend_complete+0xe0/0x6e0 [i915]
[ 181.196300] [<ffffffffa0644501>] ? i915_drm_suspend_late+0x21/0x90 [i915]
[ 181.196311] [<ffffffffa0644690>] ? i915_pm_poweroff_late+0x40/0x40 [i915]
[ 181.196318] [<ffffffff813fa7ba>] ? dpm_run_callback+0x4a/0x100
[ 181.196321] [<ffffffff813fb010>] ? __device_suspend_late+0xa0/0x180
[ 181.196324] [<ffffffff813fb10e>] ? async_suspend_late+0x1e/0xa0
[ 181.196326] [<ffffffff8108b973>] ? async_run_entry_fn+0x43/0x160
[ 181.196330] [<ffffffff81083a5d>] ? process_one_work+0x14d/0x3f0
[ 181.196332] [<ffffffff81084463>] ? worker_thread+0x53/0x480
[ 181.196334] [<ffffffff81084410>] ? rescuer_thread+0x300/0x300
[ 181.196338] [<ffffffff81089191>] ? kthread+0xc1/0xe0
[ 181.196341] [<ffffffff810890d0>] ? kthread_create_on_node+0x180/0x180
[ 181.196346] [<ffffffff81527898>] ? ret_from_fork+0x58/0x90
[ 181.196349] [<ffffffff810890d0>] ? kthread_create_on_node+0x180/0x180
[ 181.196350] ---[ end trace 8e339004db298838 ]---
[ 181.220094] PM: late freeze of devices complete after 47.936 msecs
[ 181.220972] PM: noirq freeze of devices complete after 0.875 msecs
[ 181.221577] ACPI: Preparing to enter system sleep state S4
[ 181.221886] PM: Saving platform NVS memory
[ 181.222702] Disabling non-boot CPUs ...
[ 181.222731] intel_pstate CPU 1 exiting
[ 181.224041] kvm: disabling virtualization on CPU1
[ 181.224680] smpboot: CPU 1 is now offline
[ 181.225121] intel_pstate CPU 2 exiting
[ 181.226407] kvm: disabling virtualization on CPU2
[ 181.227025] smpboot: CPU 2 is now offline
[ 181.227441] intel_pstate CPU 3 exiting
[ 181.227728] Broke affinity for irq 19
[ 181.227747] Broke affinity for irq 41
[ 181.228771] kvm: disabling virtualization on CPU3
[ 181.228793] smpboot: CPU 3 is now offline
[ 181.229624] PM: Creating hibernation image:
[ 181.563651] PM: Need to copy 379053 pages
[ 181.563655] PM: Normal pages needed: 379053 + 1024, available pages: 1697704
[ 182.472910] PM: Hibernation image created (379053 pages copied)
[ 181.232347] PM: Restoring platform NVS memory
[ 181.233171] Enabling non-boot CPUs ...
[ 181.233246] x86: Booting SMP configuration:
[ 181.233248] smpboot: Booting Node 0 Processor 1 APIC 0x1
[ 181.246771] kvm: enabling virtualization on CPU1
[ 181.249339] CPU1 is up
[ 181.249389] smpboot: Booting Node 0 Processor 2 APIC 0x2
[ 181.262313] kvm: enabling virtualization on CPU2
[ 181.264853] CPU2 is up
[ 181.264903] smpboot: Booting Node 0 Processor 3 APIC 0x3
[ 181.277831] kvm: enabling virtualization on CPU3
[ 181.280317] CPU3 is up
[ 181.288471] ACPI: Waking up from system sleep state S4
[ 182.340655] PM: noirq thaw of devices complete after 0.637 msecs
[ 182.378087] PM: early thaw of devices complete after 37.428 msecs
[ 182.378436] rtlwifi: rtlwifi: wireless switch is on
[ 182.451021] rtc_cmos 00:01: System wakeup disabled by ACPI
[ 182.697575] ata1: SATA link up 3.0 Gbps (SStatus 123 SControl 320)
[ 182.697617] ata2: SATA link up 6.0 Gbps (SStatus 133 SControl 300)
[ 182.699248] ata1.00: configured for UDMA/133
[ 182.699911] ata2.00: configured for UDMA/133
[ 182.699917] ahci 0000:00:1f.2: port does not support device sleep
[ 186.059539] PM: thaw of devices complete after 3685.338 msecs
[ 186.134292] i915 0000:00:02.0: BAR 6: [??? 0x00000000 flags 0x2] has bogus alignment
[ 186.134479] i915 0000:00:02.0: BAR 6: [??? 0x00000000 flags 0x2] has bogus alignment
[ 186.134992] i915 0000:00:02.0: BAR 6: [??? 0x00000000 flags 0x2] has bogus alignment
[ 186.135080] i915 0000:00:02.0: BAR 6: [??? 0x00000000 flags 0x2] has bogus alignment
[ 186.135266] acpi device:30: Cannot transition to power state D3cold for parent in (unknown)
[ 186.135950] pci_bus 0000:01: Allocating resources
[ 186.135974] pcieport 0000:00:1c.0: bridge window [mem 0x00100000-0x000fffff 64bit pref] to [bus 01] add_size 200000
[ 186.135980] i915 0000:00:02.0: BAR 6: [??? 0x00000000 flags 0x2] has bogus alignment
[ 186.136049] pcieport 0000:00:1c.0: res[15]=[mem 0x00100000-0x000fffff 64bit pref] get_res_add_size add_size 200000
[ 186.136072] pcieport 0000:00:1c.0: BAR 15: assigned [mem 0x9fb00000-0x9fcfffff 64bit pref]
[ 186.136174] i915 0000:00:02.0: BAR 6: [??? 0x00000000 flags 0x2] has bogus alignment
[ 186.136490] i915 0000:00:02.0: BAR 6: [??? 0x00000000 flags 0x2] has bogus alignment
[ 199.454497] Suspending console(s) (use no_console_suspend to debug)
[ 200.024190] sd 1:0:0:0: [sdb] Synchronizing SCSI cache
[ 200.024356] sd 0:0:0:0: [sda] Synchronizing SCSI cache
[ 200.025359] sd 1:0:0:0: [sdb] Stopping disk
[ 200.028701] sd 0:0:0:0: [sda] Stopping disk
[ 201.106085] PM: suspend of devices complete after 1651.336 msecs
[ 201.106591] ------------[ cut here ]------------
[ 201.106628] WARNING: CPU: 0 PID: 3725 at drivers/gpu/drm/i915/intel_display.c:7904 hsw_enable_pc8+0x659/0x7c0 [i915]()
[ 201.106628] SPLL enabled
[ 201.106656] Modules linked in: rfcomm ctr ccm bnep pci_stub vboxpci(O) vboxnetadp(O) vboxnetflt(O) vboxdrv(O) bridge stp llc xt_conntrack iptable_filter ipt_MASQUERADE nf_nat_masquerade_ipv4 iptable_nat nf_conntrack_ipv4 nf_defrag_ipv4 nf_nat_ipv4 nf_nat nf_conntrack xt_CHECKSUM xt_tcpudp iptable_mangle ip_tables x_tables nls_utf8 nls_cp437 vfat fat rtsx_usb_ms memstick snd_hda_codec_hdmi joydev mousedev hid_sensor_rotation hid_sensor_incl_3d hid_sensor_als hid_sensor_accel_3d hid_sensor_magn_3d hid_sensor_gyro_3d hid_sensor_trigger industrialio_triggered_buffer kfifo_buf industrialio hid_sensor_iio_common iTCO_wdt iTCO_vendor_support hid_multitouch x86_pkg_temp_thermal intel_powerclamp coretemp intel_rapl iosf_mbi kvm_intel kvm btusb hid_sensor_hub bluetooth uvcvideo videobuf2_vmalloc videobuf2_memops
[ 201.106694] videobuf2_core v4l2_common videodev media pcspkr evdev mac_hid arc4 psmouse serio_raw efivars i2c_i801 rtl8723be btcoexist rtl8723_common rtl_pci rtlwifi mac80211 snd_soc_rt5640 cfg80211 snd_soc_rl6231 snd_hda_codec_realtek i915 snd_soc_core snd_hda_codec_generic ideapad_laptop ac snd_compress dw_dmac sparse_keymap drm_kms_helper rfkill battery dw_dmac_core snd_hda_intel snd_pcm_dmaengine snd_soc_sst_acpi snd_hda_controller video 8250_dw regmap_i2c snd_hda_codec drm snd_hwdep snd_pcm spi_pxa2xx_platform i2c_designware_platform soc_button_array snd_timer i2c_designware_core snd i2c_algo_bit soundcore shpchp lpc_ich button processor fuse ipv6 autofs4 ext4 crc16 jbd2 mbcache btrfs xor raid6_pq algif_skcipher af_alg dm_crypt dm_mod sg usbhid sd_mod rtsx_usb_sdmmc rtsx_usb crct10dif_pclmul
[ 201.106711] crc32_pclmul crc32c_intel ghash_clmulni_intel aesni_intel aes_x86_64 lrw gf128mul glue_helper ablk_helper cryptd ahci libahci libata xhci_pci ehci_pci xhci_hcd ehci_hcd scsi_mod usbcore usb_common thermal fan thermal_sys hwmon i2c_hid hid i2c_core sdhci_acpi sdhci mmc_core gpio_lynxpoint
[ 201.106714] CPU: 0 PID: 3725 Comm: kworker/u16:25 Tainted: G W O 4.0.4+ #14
[ 201.106715] Hardware name: LENOVO 20344/INVALID, BIOS 96CN29WW(V1.15) 10/16/2014
[ 201.106720] Workqueue: events_unbound async_run_entry_fn
[ 201.106723] 0000000000000000 ffffffffa0706f68 ffffffff81522198 ffff880064dd7c88
[ 201.106725] ffffffff8106c5b1 ffff880251460000 ffff880250f83b68 ffff880250f83b78
[ 201.106727] ffff880250f83800 0000000000000002 ffffffff8106c62a ffffffffa071407c
[ 201.106728] Call Trace:
[ 201.106737] [<ffffffff81522198>] ? dump_stack+0x40/0x50
[ 201.106740] [<ffffffff8106c5b1>] ? warn_slowpath_common+0x81/0xb0
[ 201.106742] [<ffffffff8106c62a>] ? warn_slowpath_fmt+0x4a/0x50
[ 201.106765] [<ffffffffa06ae349>] ? hsw_enable_pc8+0x659/0x7c0 [i915]
[ 201.106776] [<ffffffffa0643ee0>] ? intel_suspend_complete+0xe0/0x6e0 [i915]
[ 201.106786] [<ffffffffa0644501>] ? i915_drm_suspend_late+0x21/0x90 [i915]
[ 201.106797] [<ffffffffa0644690>] ? i915_pm_poweroff_late+0x40/0x40 [i915]
[ 201.106802] [<ffffffff813fa7ba>] ? dpm_run_callback+0x4a/0x100
[ 201.106805] [<ffffffff813fb010>] ? __device_suspend_late+0xa0/0x180
[ 201.106809] [<ffffffff813fb10e>] ? async_suspend_late+0x1e/0xa0
[ 201.106811] [<ffffffff8108b973>] ? async_run_entry_fn+0x43/0x160
[ 201.106813] [<ffffffff81083a5d>] ? process_one_work+0x14d/0x3f0
[ 201.106815] [<ffffffff81084463>] ? worker_thread+0x53/0x480
[ 201.106818] [<ffffffff81084410>] ? rescuer_thread+0x300/0x300
[ 201.106821] [<ffffffff81089191>] ? kthread+0xc1/0xe0
[ 201.106824] [<ffffffff810890d0>] ? kthread_create_on_node+0x180/0x180
[ 201.106827] [<ffffffff81527898>] ? ret_from_fork+0x58/0x90
[ 201.106830] [<ffffffff810890d0>] ? kthread_create_on_node+0x180/0x180
[ 201.106832] ---[ end trace 8e339004db298839 ]---
[ 201.130052] PM: late suspend of devices complete after 23.960 msecs
[ 201.130725] ehci-pci 0000:00:1d.0: System wakeup enabled by ACPI
[ 201.130885] xhci_hcd 0000:00:14.0: System wakeup enabled by ACPI
[ 201.146986] PM: noirq suspend of devices complete after 16.930 msecs
[ 201.147591] ACPI: Preparing to enter system sleep state S3
[ 201.147942] PM: Saving platform NVS memory
[ 201.147948] Disabling non-boot CPUs ...
[ 201.147999] intel_pstate CPU 1 exiting
[ 201.149324] kvm: disabling virtualization on CPU1
[ 201.149337] smpboot: CPU 1 is now offline
[ 201.149640] intel_pstate CPU 2 exiting
[ 201.151096] kvm: disabling virtualization on CPU2
[ 201.151108] smpboot: CPU 2 is now offline
[ 201.152017] intel_pstate CPU 3 exiting
[ 201.153250] kvm: disabling virtualization on CPU3
[ 201.153256] smpboot: CPU 3 is now offline
[ 201.156229] ACPI: Low-level resume complete
[ 201.156307] PM: Restoring platform NVS memory
[ 201.160033] CPU0 microcode updated early to revision 0x1c, date = 2014-07-03
[ 201.160190] Enabling non-boot CPUs ...
[ 201.160241] x86: Booting SMP configuration:
[ 201.160243] smpboot: Booting Node 0 Processor 1 APIC 0x1
[ 201.172665] kvm: enabling virtualization on CPU1
[ 201.174982] CPU1 is up
[ 201.175013] smpboot: Booting Node 0 Processor 2 APIC 0x2
[ 201.187569] CPU2 microcode updated early to revision 0x1c, date = 2014-07-03
[ 201.188796] kvm: enabling virtualization on CPU2
[ 201.191130] CPU2 is up
[ 201.191158] smpboot: Booting Node 0 Processor 3 APIC 0x3
[ 201.203297] kvm: enabling virtualization on CPU3
[ 201.205679] CPU3 is up
[ 201.210414] ACPI: Waking up from system sleep state S3
[ 201.224617] ehci-pci 0000:00:1d.0: System wakeup disabled by ACPI
[ 201.332523] xhci_hcd 0000:00:14.0: System wakeup disabled by ACPI
[ 201.332634] PM: noirq resume of devices complete after 121.623 msecs
[ 201.372718] PM: early resume of devices complete after 40.058 msecs
[ 201.372892] rtlwifi: rtlwifi: wireless switch is on
[ 201.373270] sd 0:0:0:0: [sda] Starting disk
[ 201.373271] sd 1:0:0:0: [sdb] Starting disk
[ 201.445954] rtc_cmos 00:01: System wakeup disabled by ACPI
[ 201.692510] ata2: SATA link up 6.0 Gbps (SStatus 133 SControl 300)
[ 201.694719] ata2.00: configured for UDMA/133
[ 201.694724] ahci 0000:00:1f.2: port does not support device sleep
[ 201.836724] usb 2-4: reset high-speed USB device number 2 using xhci_hcd
[ 201.890158] psmouse serio1: synaptics: queried max coordinates: x [..5702], y [..4730]
[ 201.930768] psmouse serio1: synaptics: queried min coordinates: x [1242..], y [1124..]
[ 202.076784] usb 2-5: reset full-speed USB device number 3 using xhci_hcd
[ 202.205100] usb 2-5: ep 0x2 - rounding interval to 64 microframes, ep desc says 80 microframes
[ 202.316799] usb 2-7: reset full-speed USB device number 5 using xhci_hcd
[ 202.444945] usb 2-7: No LPM exit latency info found, disabling LPM.
[ 202.556817] usb 2-8: reset full-speed USB device number 6 using xhci_hcd
[ 202.908691] usb 2-6: reset high-speed USB device number 4 using xhci_hcd
[ 203.932602] ata1: SATA link up 3.0 Gbps (SStatus 123 SControl 320)
[ 204.044890] ata1.00: configured for UDMA/133
[ 206.228698] PM: resume of devices complete after 4855.892 msecs
[ 206.380738] i915 0000:00:02.0: BAR 6: [??? 0x00000000 flags 0x2] has bogus alignment
[ 206.383152] i915 0000:00:02.0: BAR 6: [??? 0x00000000 flags 0x2] has bogus alignment
[ 206.385775] i915 0000:00:02.0: BAR 6: [??? 0x00000000 flags 0x2] has bogus alignment
[ 206.388066] i915 0000:00:02.0: BAR 6: [??? 0x00000000 flags 0x2] has bogus alignment
[ 206.390415] acpi device:30: Cannot transition to power state D3cold for parent in (unknown)
[ 206.393078] pci_bus 0000:01: Allocating resources
[ 206.393098] i915 0000:00:02.0: BAR 6: [??? 0x00000000 flags 0x2] has bogus alignment
[ 206.395470] i915 0000:00:02.0: BAR 6: [??? 0x00000000 flags 0x2] has bogus alignment
[ 206.397927] i915 0000:00:02.0: BAR 6: [??? 0x00000000 flags 0x2] has bogus alignment
[ 206.518516] Restarting kernel threads ... done.
[ 206.518812] PM: Basic memory bitmaps freed
[ 206.518816] Restarting tasks ... done.
There is one more occasional Kernel Oops (below), which I believe again has to do with Intel.
In my case, the laptop came with the Realtek Wireless device (details above in lspci output). Note: The machine has no wired interface.
While the Intel Wifi devices shipped with this laptop have their own share of problems, this device (rtl8723be) works out of the box. But only for a while. There is no certain pattern on what triggers the bug, but once triggered, the network just freezes. Nothing is logged.
If your Yoga 2 13 came with the RTL chip, the following workaround may help avoid the network issues.
Almost every boot, eventually, the kernel reports MCE errors. Not something I understand well, but so far, it hasn't caused any visible issues. And from what I have googled so far, nobodyseemstohavefixeditanywhere
So, with fingers crossed, lets just hope this never translates into a real problem.
What the kernel reports of the CPU's capabilities.
mcelog: failed to prefill DIMM database from DMI data
Hardware event. This is not a software error.
MCE 0
CPU 0 BANK 5
MISC 38a0000086 ADDR fef81880
TIME 1432455005 Sun May 24 13:40:05 2015
MCG status:
MCi status:
Error overflow
Uncorrected error
MCi_MISC register valid
MCi_ADDR register valid
Processor context corrupt
MCA: corrected filtering (some unreported errors in same region)
Generic CACHE Level-2 Generic Error
STATUS ee0000000040110a MCGSTATUS 0
MCGCAP c07 APICID 0 SOCKETID 0
CPUID Vendor Intel Family 6 Model 69
Hardware event. This is not a software error.
MCE 1
CPU 0 BANK 6
MISC 78a0000086 ADDR fef81780
TIME 1432455005 Sun May 24 13:40:05 2015
MCG status:
MCi status:
Uncorrected error
MCi_MISC register valid
MCi_ADDR register valid
Processor context corrupt
MCA: corrected filtering (some unreported errors in same region)
Generic CACHE Level-2 Generic Error
STATUS ae0000000040110a MCGSTATUS 0
MCGCAP c07 APICID 0 SOCKETID 0
CPUID Vendor Intel Family 6 Model 69
Hardware event. This is not a software error.
MCE 2
CPU 0 BANK 5
MISC 38a0000086 ADDR fef81880
TIME 1432455114 Sun May 24 13:41:54 2015
MCG status:
MCi status:
Error overflow
Uncorrected error
MCi_MISC register valid
MCi_ADDR register valid
Processor context corrupt
MCA: corrected filtering (some unreported errors in same region)
Generic CACHE Level-2 Generic Error
STATUS ee0000000040110a MCGSTATUS 0
MCGCAP c07 APICID 0 SOCKETID 0
CPUID Vendor Intel Family 6 Model 69
Hardware event. This is not a software error.
MCE 3
CPU 0 BANK 6
MISC 78a0000086 ADDR fef81780
TIME 1432455114 Sun May 24 13:41:54 2015
MCG status:
MCi status:
Uncorrected error
MCi_MISC register valid
MCi_ADDR register valid
Processor context corrupt
MCA: corrected filtering (some unreported errors in same region)
Generic CACHE Level-2 Generic Error
STATUS ae0000000040110a MCGSTATUS 0
MCGCAP c07 APICID 0 SOCKETID 0
CPUID Vendor Intel Family 6 Model 69
Since I just had cause to do this and it was harder than it needed to be due to bitrot in the public documentation I could find I thought I d write up how to get a modern bootloader onto older Atmel boards. These instructions are written for the AT91SAM9G20-EK though they should also apply to other Atmel boards of a similar generation.
These instructions are for booting from NAND since it s the default thing for the board, for this J34 should be fitted to enable the chip select and J33 disconnected to disable the dataflash. If there is something broken programmed into flash then booting while holding down BP4 should cause the second stage bootloader to trash itself and ensure the ROM bootloader puts itself into recovery mode, or just removing both J33 and J34 during power on will also ensure no second stage bootloader is found.
There is a ROM bootloader but it just loads a small region from the boot media and jumps into it which isn t enough for u-boot so there is a second stage bootloader called AT91Bootstrap. Download sources for current versions from github. If it (or a more sensibly written equivalent) is not yet merged upstream you ll need to apply this patch to get it to build with a modern compiler, or you could use an old toolchain (which you ll need in the next step anyway):
make at91sam9g20eknf_uboot_defconfig
make CROSS_COMPILE=arm-linux-gnueabihf-
producing binaries/at91sam9g20ek-nandflashboot-uboot-$ VERSION .bin. This configuration will look for u-boot at 0x40000 in the flash so we need a u-boot binary. Unfortunately modern compilers seem to produce binaries that fail with no output. This is normally a sign that they need the ABI specifying more clearly as above but I got fed up trying to spot what was missing so I used an old CodeSourcery 2013.05 release instead, hopefully future versions of u-boot will be able to build for this target with older toolchains. Grab a recent release (I used 2015.01) and build with:
cd $ UBOOT
make at91sam9g20ek_nandflash_defconfig
make CROSS_COMPILE=arm-linux-gnueabihf-
to get u-boot.bin.
These can then be flashed using the Atmel flashing tool SAM-BA. Start it and connect to the target (there is a Linux version, though it appears to rely on old versions of TCL/TK so if you get trouble starting it the easiest thing is to use the sacrificial Windows laptop you ve obtained in order to run the entertaining flashing tools companies sometimes provide without risking a real system, or in my case your shiny new laptop that you ve not yet installed Linux on). Start it then:
Connect SAM-BA to the device following the dialog on start.
Make sure you ve selected NandFlash in the memory type tabs in the center of the window.
Run the Enable NandFlash script.
Run the Erase All script.
Run the Send Boot File script and provide the at91bootstrap binary.
Set Send File Name to be the u-boot binary you built earlier and Address to be 0x40000.
Click Send File
Press the reset button
which should result in at91bootstrap output followed by u-boot output on the serial console. A similar process works for the AT91SAM9263, there the jumper you need is J19 (sadly u-boot does not flash pictures of cute animals or forested shorelines on the screen as the default Basic LCD Project 1.4 firmware does, I m not sure this full operating system thing is really delivering improved functionality).
I previously wrote about tracking a ship around the world, but never followed up with the practical details involved with shipping my life from the San Francisco Bay Area back to Belfast. So here they are, in the hope they provide a useful data point for anyone considering a similar move.
Firstly, move out. I was in a one bedroom apartment in Fremont, CA. At the time I was leaving the US I didn t have anywhere for my belongs to go - the hope was I d be back in the Bay Area, but there was a reasonable chance I was going to end up in Belfast or somewhere in England. So on January 24th 2014 I had my all of my belongings moved out and put into storage, pending some information about where I might be longer term. When I say all of my belongings I mean that; I took 2 suitcases and everything else went into storage. That means all the furniture for probably a 2 bed apartment (I d moved out of somewhere a bit larger) - the US doesn t really seem to go in for the concept of a furnished lease the same way as the UK does.
I had deliberately picked a moving company that could handle the move out, the storage and the (potential) shipping. They handed off to a 3rd party for the far end bit, but that was to be expected. Having only one contact to deal with throughout the process really helped.
Fast forward 8 months and on September 21st I contacted my storage company to ask about getting some sort of rough shipping quote and timescales to Belfast. The estimate came back as around a 4-6 week shipping time, which was a lot faster than I was expecting. However it turned out this was the slow option. On October 27th (delay largely due to waiting for confirmation of when I d definitely have keys on the new place) I gave the go ahead.
Container pickup (I ended up with exclusive use of a 20ft container - not quite full, but not worth part shipment) from the storage location was originally due on November 7th. Various delays at the Port of Oakland meant this didn t happen until November 17th. It then sat in Oakland until December 2nd. At that point the ETA into Southampton was January 8th. Various other delays, including a week off the coast of LA (yay West Coast Port Backups) meant that the ship finally arrived in Southampton on January 13th. It then had to get to Belfast and clear customs. On January 22nd 2015, 2 days shy of a year since I d seen them, my belongings and I were reunited.
So, on the face of it, the actual time on the ship was only slightly over 6 weeks, but all of the extra bits meant that the total time from Ship it to I have it was nearly 3 months. Which to be honest is more like what I was expecting. The lesson: don t forget to factor in delays at every stage.
The relocation cost in the region of US$8000. It was more than I d expected, but far cheaper than the cost of buying all my furniture again (plus the fact there were various things I couldn t easily replace that were in storage). That cost didn t cover the initial move into storage or the storage fees - it covered taking things out, packing them up for shipment and everything after that. Including delivery to a (UK) 3rd floor apartment at the far end and insurance. It s important to note that I d included this detail before shipment - the quote specifically mentioned it, which was useful when the local end tried to levy an additional charge for the 3rd floor aspect. They were fine once I showed them the quote as including that detail.
Getting an entire apartment worth of things I hadn t seen in so long really did feel a bit like a second Christmas. I d forgotten a lot of the things I had, and it was lovely to basically get a home in a container delivered.
Since 2009, I am persuing a personal programming project.
As I am not a professional programmer, I have spent quite a lot of that
time exploring options. I have thrown out about three or four prototype
implementations already. My last implementation seems to contain enough
accumulated wisdom to be actually useful. I am far from finished, but the path
I am walking now seems relatively sound.
So, what is this project about? I have set myself a rather ambitious
goal: I am trying to implement a two-way bridge between visual music notation
and braille music code. It is called BMC (Braille Music Compiler).
My problem: I am, as some of you might remember, 100% blind.
So I am trying to write a translator between something I will never
see directly, and its counterpart representation in a tactile encoding
I had to learn from scratch to be able to work on this project.
Braille music code is probably the most cryptic thing I have
ever tried to learn. It basically is a method to represent
a 2-dimensional structure like staff-notation as a
stream of characters encoded in 6-dot braille.
As the goal above states, I am ultimately trying to implement a converter
that works both ways. One of my prototypes already implemented
reading digital staff notation (MusicXML) and transcribing
it to Braille. However, to be able to actually understand all the concepts
involved, I ended up starting from the other end of the spectrum with
my new implementation: parsing braille music code and emitting
digital staff notation (LilyPondandMusicXML). This is a rather unique
feature, since while there is commercial (and very expensive) software out there
to convert MusicXML to braille music code, there is, as far as I know,
no system that allows to input un-annotated braille music code and
have it automatically converted to sighted music notation.
So the current state of things is, that we are able to read certain
braille music code formats, and output either reformatted (to new line-width)
braille music code, LilyPond or MusicXML.
The ultimate goal is to also implement a MusicXML reader, and convert
the data to something that can be output as braille music code.
While the initial description might not sound very hard, there
are a lot of complications arising from how braille music code works,
which make this quite a programming challenge. For one, braille music note and
rest values are ambigious. A braille music note or rest that looks like
a whole can mean a whole or 16th. A braille music note or rest that looks like
a half can mean a half or a 32nd. And so on. So each braille music code value
can have two meanings. The actual value can be caluclated with a recursive
algorithm that I have worked out from scratch over the years. The original
implementation was inspired by Samuel Thibault (thanks!) and has since then
evolved into something that does what we need, while trying to do that very
fast. Most input documents can be processed in almost no time, however,
time signatures with a value > 1 (such as 12/8) tend to make the number of
possible choices exploed quite heavily. I have found so far one piece from
J.S. Bach (BWV988 Variation 3) which takes about 1.5s on my 3GHz AMD (and the
code is already using several CPU cores).
Additionally, braille music code supports a form of "micro"-repetitions
which are not present in visual staff notation which effectively allow certain
musical patterns to be compressed if represented in braille.
Another algorithmically interesting part of BMC that I have started
to taclke just recently is the linebreaking problem. Braille music code has
some peculiar rules when it comes to breaking a measure of
musical material into several lines. I ended up adapting
Donald E. Knuth's algorithm from Breaking Paragraphs into Lines for
fixed-width text. In other words, I am ignoring the stretch/shrink
factors, while making use of different penalty values to find the perfect
solution for the problem of breaking a paragraph of braille music code into
several lines.
One thing that I have learnt from my perivous prototype (which was apparently
useful enough to already acquire some users) is that it is not enough to just
transcribe one format to another. I ultimately want to store meta information
about the braille that is presented to the user such that I can implement
interactive querying and editing features. Braille music code is complicated,
and one of the original motivations to work on software to deal with it was to
ease the learning curve. A user of BMC should be able to ask the system for a
description of a character at a certain position. The user interface (not
implemented yet) should allow to play a certain note interactively, or play the
measure under the cursor, or play the whole document, and if possible, have the
cursor scroll along while playback plays notes. These features are not
implemented in BMC yet, but they have been impleemnted in the previous prototype
and their usefulness is apparent. Also, when viewing a MusicXML document in
braille music code, certain non-structural changes like adding/removing
fingering annotations should be possible while preserving unhandled features of
the original MusicXML document.
This also has been implemented in the previous prototype, and is a goal
for BMC.
I need your help
The reason why I am explaining all of this here is that I need your help
for this project to succeed. Helping the blind to more easily work with
traditional music notation is a worthwhile goal to persue. There is no free
system around that really tries to adhere to the braille music code standard,
and aims to cover converting both ways. I have reached a level of conformance
that surpasses every implementation of the same problem that I have seen so far
on the net.
However, the primary audience of this software is going to be using Windows.
We desperately need a port to that OS, and a user interface resembling NotePad
with a lot fewer menu entires. We also need a GTK interface that does the same
thing on Linux. wxWindows is unfortunately out of question, since it does not
provide the same level of Accessibility on all the platforms it supports.
Ideally, we'd also have a Cocoa interface for OS X.
I am afraid there is no platform independent GUI framework that offers
the same level of Accessibility on all supported platforms. And since much of
our audience is going to rely on working Accessibility, it looks like we
need to implement three user interfaces to achieve this goal :-(.
I also desperately need code reviews and inspiration from fellow programmers.
BMC is a C++11 project heavily making use of Boost. If you are into one
of these things, please give it a whirl, and emit pull requests, no matter
how small they are. While I have learnt a lot in the last years, I am sure
there are many places that could use some fresh winds of thought by people that
are not me. I am suffering from what I call "the lone coder syndrome".
I also need (technical) writers to help me complete the pieces of documentation
that are already lying around. I have started to write a braille music tutorial
based on the underlying capabilities of BMC. In other words, the tutorial
includes examples which are being typeset in braille and staff notation, using
LilyPond as a rendering engine. However, something like a user manual is
missing, basically, because the user interface is missing. BMC is currently
"just" a command-line tool (well enough for me) that transcribes input files to
STDOUT. This is very good for testing the backend, which is all that has been
important to me in the last years.
However, BMC has reached a stage now where its functionality is likely useful
enough to be exposed to users. While I try to improve things steadily as I can,
I realize that I really need to put out this call for help to make any useful
progress in a foreseeable time.
If you think it is a worthwhile goal to help the blind to more easily
work with music notation, and also enable communication between
blind and sighted musicians in both ways, please take the time
and consider how you could help this project to advance. My email address
can be found on my GitHub page. Oh, and while you are over at GitHub,
make sure to star BMC if you think it is a nice project.
It would be nice if we could produce a end-user oriented release
before the end of this year.
After more than five years of being a Debian developer, here is my first post on Planet Debian!
I currently maintain 165 packages. My focus has changed since 2009, but those are still mostly sysadmin packages:
ctdb (under the pkg-samba umbrella), the clustered database used by samba
c-icap and c-icap-modules: a c-icap server mostly useful with squid and providing url blacklists and antivirus filtering
pkg-php-tools: easy packaging of PHP packages (PEAR, PECL and Composer) as .deb
124 php-horde* (Horde) packages: A groupware and webmail, written in PHP
12 PHP PEAR, Composer, or PECL packages (those are Horde dependencies)
I m mostly maintaining alone the above packages. Any help is appreciated!
python-ceres, graphite-carbon and graphite-web: Graphite is an high performance monitoring and graphing software. Jonas Genannt is maintaining the packages well and I only do review
20 shinken packages : a monitoring solution, compatible with nagios configuration files and written in python. Thibault Cohen is doing most of the packaging, and I give advice
svox: The TTS from Android (unfortunately non-free because of missing or outdated sources). This is now under the Debian Accessibility Team umbrella
kolabadmin: this is the last remaining piece from my former pkg-kolab membership (unfortunately kolab server won t be in jessie, you can help the team for Stretch)
Now that the first post is online, I will try to keep up!
I haven't blogged for a long time, but I've decided that I'm going to try to
write again, at least about technical stuff.
My plan was to blog about the projects I've been working on lately, the main
one being the setup of the latest version of Kolab with the systems
we already have at work, but I'll do that on the next days.
Today I'm just going to make a list of the tools I use on a daily basis and my
plans to start using additional ones in the near future.
Shells, Terminals and Text Editors
I do almost all my work on Z Shell sessions running inside tmux;
for terminal emulation I use gnome-terminal on X, VX
ConnectBot on Android systems and iTerm2
on Mac OS X.
For text editing I've been using Vim for a long time (even on Mobile
devices) and while I'm aware I don't know half of the things it can do, what I
know is good enough for my day to day needs.
In the past I also used Emacs as a programming editor and my main
tool to write HTML, SGML and XML, but since I haven't really needed an IDE for
a long time and I mainly use Lightweight Markup Languages I haven't
used it for a long time (I briefly tried to use Org mode, but for some
reason I ended up leaving it).
Documentation formats and tools
Since a long time ago I've been an advocate of Lightweight Markup
Languages; I started to use LaTeX and Lout, then moved
to SGML/XML formats (LinuxDoc and DocBook) and finally
moved to plain text based formats.
I started using Wiki formats (parsewiki) and soon moved to
reStructuredText; I also use other markup languages like
Markdown (for this blog, aka ikiwiki) and tried
MultiMarkdown to replace reStructuredText for general use,
but as I never liked Markdown syntax I didn't liked an extended version of it.
While I've been using ReStructuredText for a long time, I recently found
Asciidoctor and the Asciidoc format and I guess
I'll be using it instead of rst whenever I can (I still need to try the
slide backends and conversions to ODT, but if that works I guess I'll write
all my new documents using Asciidoc).
Programming languages
I'm not a developer, but I read and patch a lot of free software code written
on a lot of different programming languages (I wouldn't be able to write whole
programs on most of them, but thanks to Stack Overflow I'm
usually able to fix what I need).
Anyway, I'm able to program in some languages; I write a lot of shell
scripts and I go for Python and C when I need something
more complicated.
On the near future I plan to read about javascript programming
and nodejs (I'll probably need it at work) and I already started
looking at Haskell (I guess it was time to learn about functional
programming and after reading about it, it looks like haskell is the way to go
for me).
Version Control
For a long time I've been a Subversion user, at least for my own
projects, but seems that everything has moved to git now and I finally
started to use it (I even opened a github account) and plan to move
all my personal subversion repositories at home and at work to git,
including the move of all my debian packages from svn-buildpackage
to git-buildpackage.
Further Reading
With the previous plans in mind, I've started reading a couple of interesting books:
When running a TV station with both broadcast and web stream
distribution, it is useful to know that the stream is working. As I
am involved in the Norwegian open channel
Frikanalen as part of my
activity in the NUUG member
organisation, I wrote a script to use mplayer to connect to a
video stream, pick two images 35 seconds apart and compare them. If
the images are missing or identical, something is probably wrong with
the stream and an alarm should be triggered. The script is written as
a Nagios plugin, allowing us to use Nagios to run the check regularly
and sound the alarm when something is wrong. It is able to detect
both a hanging and a broken video stream.
I just uploaded the code for the script into the
Frikanalen
git repository on github. If you run a TV station with web
streaming, perhaps you can find it useful too.
Last year, the Frikanalen public TV station transformed into using
only Linux based free software to administrate, schedule and
distribute the TV content. The
source code for the entire TV
station is available from the Github project page. Everyone can
use it to send their content on national TV, and we provide both a web
GUI and a web API to
add
and schedule
content. And thanks to last weeks developer gathering and
following activity, we now have the schedule
available as
XMLTV too. Still a lot of work left to do, especially with the
process to add videos and with the scheduling, so your contribution is
most welcome. Perhaps you want to set up your own TV station?
The other day I demonstrated how to get your Github issues/bugs as an iCalendar feed.
I'm planning to take this concept further and I just whipped up another Python script, exposing Nagios issues as an iCalendar feed.
The script is nagios-icalendar. Usage is explained concisely in the README file, it takes just minutes to get up and running.
One interesting feature is that you can append a contact name to the URL and just get the issues for that contact, e.g.:
Screenshots
Here I demonstrate using Mozilla Lightning / Iceowl-extension to aggregate issues from Nagios, the Fedora instance of Bugzilla and Lumicall's Github issues into a single to-do list.
After releasing Weblate 2.0 with Bootstrap based UI, there was still lot of things to improve. Weblate 2.1 brought more consistency in using buttons with colors and icons. Weblate 2.2 will bring some improvements in other graphics elements.
One of thing which was for quite long in our issue tracker is to provide own renderer for SVG status badge. So far Weblate has offered either PNG badge or external SVG rendered by shields.io. Relying on external service was not good in a long term and also caused requests to third party server on many pages, what could be considered bad privacy wise.
Since this week, Weblate can render SVG badge on it's own and they are also matching current style used by other services (eg. Travis CI):
One last thing which really did not fit into new UI were activity charts. In past they were rendered as PNG on server side, but for upcoming releases we have switched to use Chartist javascript library and render them as SVG on client side. This way we can nicely style them to fit into page, they scale properly and also reduce server load. You can see them in action on Hosted Weblate server:
About a month ago, I
blogged
about extremon. As a reminder, ExtreMon is a
monitoring tool that allows you to view things as they are happening,
rather than with the ~5 minute delay that munin gives you, and also
avoiding the quad-state limitation of Nagios' "good", "bad", "ugly",
and "unknown" states. No, they're not really called that. Yes, I know
you knew that.
Anyway. In my blog post, I explained how you can set up ExtreMon, and I
also set up a fairly limited demo version on my own server. But I have
since realized that while it is functional, it doesn't actually show
why ExtreMon is so great. In an effort to remedy that, I present you an
example of what ExtreMon can do.
Let's start with a screenshot of the ExtreMon console at the customer
for which I spent time trying to figure out how to get it up and
running:
Click for full sized version. You'll note that even in that full-sized
version, many things are unreadable. This is because the ExtreMon
console allows one to move around (right mouse button drag for zoom;
left mouse button drag for moving around; control+RMB for rotate; center
mouse button to reset to default); so what matters is that everything
fits on the screen, not whether it is all readable (if you need to read,
you zoom).
The image shows 18 rectangles. Each rectangle represents a single
machine in this particular customer's HPC cluster. The top three
rectangles are the cluster's file servers; the rest are its high
performance nodes.
You'll note that the left fileserver has 8 processor cores (top row), 8
network cards (bottom row, left part), and it also shows information on
its memory usage (bottom row, small rectangle in the middle) as well as
its NFS client and server procedure calls (bottom row, slightly larger
rectangles to the right). This file server is the one on which I
installed ZFS a while
back; hence the
large amount of disks visible in the middle row. The leftmost disk is
the root filesystem (which is an ext4 off a hardware RAID1); the two
rightmost "disks" are the PCIe-attached SSDs which are used for the ZFS
L2ARC and write log. The other disks in this file server nicely show how
ZFS does write load balancing over all its disks.
The second file server has a hardware RAID1 on which it stores all its
data; as such, there is only one disk graph there. It is also somewhat
more limited in network, as it has only two NICs. It does, however, also
have 8 cores.
The last file server has no more than four processor cores; in addition,
it also does not have a hardware RAID controller, so it must use
software RAID over its four hard disks. This server is used for archival
purposes, mostly, since it is insufficient for most anything else.
As said, the other nodes are the "compute nodes", where the hard work is
done. Most of these compute nodes have 16 cores each; two have 12
instead. When this particular screenshot was taken, four of the nodes
(the ones showing red in their processor graphs) were hard at work; the
others seem to have been mostly idling. In addition to the familiar
memory, NFS (client only), network, and processor graphs, these nodes
also show a "swap space" graph (just below the memory one), which seems
fine for most nodes, except for the bottom left one (which shows a few
bars that are coloured yellow rather than green).
The green/yellow/red stuff is supposed to represent the "ok", "warning",
"bad" states that would be familiar from Nagios. In this particular
case, however, where "processor is busy all the time" is actually a
wanted state, a low amount of idleness on the part of the processor
isn't actually a problem, on the contrary. I did consider, therefore, to
modify the ExtreMon configuration so that the processor graphs would
not show red when the system was under high load; however, I found
that differences in colour like this actually makes it more easy to see,
at a glance, which machines are busy -- and that's one of the main
reasons why we wanted to set this up.
If you look carefully, you can find a particular processor core in the
graph which shows 100% usage for "idle", "system", and "softirq", at
the same time. Obviously that can't be the case, so there's a bug
somewhere. Frank seems to believe it is a bug in CollectD; I haven't
verified that. At any rate, though, this isn't usually a problem, due to
the high update frequency of ExtreMon.
The amount of data that's flowing through ExtreMon is amazing:
22 values for NFS (times two for the file servers) per server:
22x2x3+22x15
4 values for memory: 4x18
3 values for swap: 3x15
8 values per CPU core: 8x8x2+8x4+8x12x2+8x16x13
2 values per disk: 2x25+2+2x4
2 values per NIC: 2x8x12+2x2x2+2x4x4
Which renders a grand total of 2887 data points that are shown in this
particular screenshot; and then I'm not even counting all the
intermediate values, some of which also pass through ExtreMon. Nor am I
counting the extra bits which have since been added (this screenshot is
a few days old, now, and I'm still finetuning things). Yet even so,
ExtreMon manages to update those values once every few seconds, in the
worst case. As a result, the display isn't static for a moment,
constantly moving and updating data so that what you see is never out of
date for more than a second or two.
Awesome.
Review: The Ring of Charon, by Roger MacBride Allen
Series:
Hunted Earth #1
Publisher:
Tor
Copyright:
December 1990
ISBN:
0-8125-3014-4
Format:
Mass market
Pages:
500
Larry Chao is a junior scientist at a gravity research on Pluto, at the
very outer limits of human reach in the solar system. The facility is for
researching artificial gravity, which is one reason it's in the middle of
nowhere. Another is that their experimental generator is built in a ring
around Charon, and the close proximity of the two bodies is useful for
scientific observation. Unfortunately, there hasn't been much to observe.
They can create very short-lived gravity fields in very small areas, but
nothing like the artificial gravity that was the original promise of the
facility.
As a result, the government is shutting the facility down. The
authoritarian director, Simon Raphael, is... not exactly happy with that
decision, but resigned to it and running the facility to completion with a
sullen anger. When Larry makes a startling breakthrough at nearly the
last minute for the society, Simon is uninterested and hostile. This
leads Larry and his fellow scientist Sondra Berghoff to attempt a more
radical demonstration of Larry's success and prove to the rest of the
solar system that the facility should be kept open. That decision has a
far deeper impact on humanity and the solar system than they could have
possibly imagined.
The Ring of Charon and its sequel, Shattered Sphere, were
recommended to me as good harder science fiction. It took me a while to
track down copies in fact, it took an in-person trip to
Powell's. Once I found them, a relatively
straightforward, old-school science fiction novel seemed like just the
thing to read during my commute.
Allen delivers there. I'm not spoiling the main plot driver of the book
even though it's given away on the back cover, since it's some time in
coming in the novel. But The Ring of Charon turns into a
multi-viewpoint cross between a disaster novel and a scientific
investigation. Larry and Sondra stay central to the plot, of course, but
Allen adds a variety of other characters who are attempting to figure out
what happened to the solar system and then deal with the consequences:
everyone from scientists to pilots to communications officers in weird
surrealistic stations.
The science is mostly believable, apart from the scientific breakthrough
that motivates the plot. Characterization isn't absent completely, but
it's simple and unsubtle; dialogue is a bit wooden, characters aren't
entirely multidimensional, but Allen does a reasonably good job with both
pacing and the sense of mystery and investigation, and a surprisingly good
job portraying organizational politics.
As you might guess from the tone of my review, this is not the book to
reach for if you want something ground-breaking. It's a very
conventional, multi-viewpoint SF novel full of scientists and
investigation of unknown and possibly hostile phenomena. If you've read
much science fiction, you've read books like this before. But one thing
that Allen does surprisingly well, which makes The Ring of Charon
stand a bit above the pack, is that he doesn't write villains. Even
Simon, who goes out of his way to make the reader hate him at the start of
the book, becomes a surprisingly sympathetic character. The characters
who are usually villains or at least foils in books like this the smooth
PR person, the religious man, the blindly-focused scientist who isn't
interested in anyone else's theories never turn into caricatures, play
important roles in the plot, and turn out to be competent in their fields
of expertise.
There are actual villains, sort of, but I found myself feeling sympathetic
even towards them, at least in places. Allen takes a rather old SF dodge
to achieve conflict without an evil enemy, and, because of that, the end
of the book felt like a bit of an anticlimax. But I did like the feel of
the book where there isn't a good versus evil fight, just a wide variety
of people (and others) trying to understand and control the universe in
the best ways they know how.
I'm not sure I can quite recommend this book. The quality of the writing
is not particularly high, and I'm not generally a fan of the disaster
novel style of storytelling. But despite not being very original, there's
just something likable about it. It moves along reasonably well for a 500
page book, and it's refreshingly light on irritating stereotypes. I think
one has to be in the right mood when reading it and set expectations
accordingly, but it fit what I was looking for when I picked it up.
One warning, though: although The Ring of Charon reaches a climax,
the major plot conflict is not resolved at the end of this book, so you
may want to have the sequel around.
Followed by Shattered Sphere.
Rating: 6 out of 10
A few weeks ago I went to see Blade Runner: The Final Cut in a one-off
showing at the Tyneside Cinema. I've only
watched the Final Cut once and that viewing was a bit compromised, so it was
nice to see it properly, and on a massive screen with decent surround sound
too.
Whilst watching it I saw something that I thought might potentially have been a
visual reference to Scott's earlier movie, Alien. When Deckard is climbing
onto the roof of the Bradbury building, there's a decorative motif that to me,
looks very Giger-esque, biomechanical, a bit like a chest-burster.
click for full frame
I went back and took a screenshot from the Blu Ray at the same point. What do
you think?
As it happens, whilst the inner regions of the building in the movie are the
Bradbury building (or at least the entrance hall), I don't think the upper
exterior shots are.
Purge
There are a few other, well-known references to Alien in Blade Runner, although they are likely simply re-used effects rather than explicitly easter eggs. The display screen in Gaff's Spinner is re-used from the Narcissus (here's a comparison) and the ambience in Deckard's apartment also featured in the Nostromo's medical bay. Some enterprising person has put together a 12 hour session of that particular sound effect looping. There's a number of other comparisons and spots at this propsummit.com thread.
Multi-Stream Transport 4k Monitors and X
I'm sure you've seen a 4k monitor on a friends desk running Mac OS X
or Windows and are all ready to go get one so that you can use it
under Linux.
Once you've managed to acquire one, I'm afraid you'll discover that when
you plug it in, you're limited to 30Hz refresh rates at the full size,
unless you're running a kernel that is version 3.17 or later. And then...
Good Grief! What Is My Computer Doing!
Ok, so now you're running version 3.17 and when X starts up, it's like
you're using a gigantic version of Google Cardboard. Two copies of a
very tall, but very narrow screen greets you.
Welcome to MST island.
In order to drive these giant new panels at full speed, there isn't
enough bandwidth in the display hardware to individually paint each
pixel once during each frame. So, like all good hardware engineers,
they invented a clever hack.
This clever hack paints the screen in parallel. I'm assuming that
they've got two bits of display hardware, each one hooked up to half
of the monitor. Now, each paints only half of the pixels, avoiding
costly redesign of expensive silicon, at least that's my surmise.
In the olden days, if you did this, you'd end up running two monitor
cables to your computer, and potentially even having two video cards.
Today, thanks to the magic of Display Port Multi-Stream Transport, we
don't need all of that; instead, MST allows us to pack multiple
cables-worth of data into a single cable.
I doubt the inventors of MST intended it to be used to split a single
LCD panel into multiple "monitors", but hardware engineers are clever
folk and are more than capable of abusing standards like this when it
serves to save a buck.
Turning Two Back Into One
We've got lots of APIs that expose monitor information in the system,
and across which we might be able to wave our magic abstraction wand
to fix this:
The KMS API. This is the kernel interface which is used by all
graphics stuff, including user-space applications and the frame
buffer console. Solve the problem here and it works everywhere
automatically.
The libdrm API. This is just the KMS ioctls wrapped in a simple C
library. Fixing things here wouldn't make fbcons work, but would
at least get all of the window systems working.
Every 2D X driver. (Yeah, we're trying to replace all of these with
the one true X driver). Fixing the problem here would mean that
all X desktops would work. However, that's a lot of code to hack,
so we'll skip this.
The X server RandR code. More plausible than fixing every driver,
this also makes X desktops work.
The RandR library. If not in the X server itself, how about over in
user space in the RandR protocol library? Well, the problem here
is that we've now got two of them (Xlib and xcb), and the xcb one
is auto-generated from the protocol descriptions. Not plausible.
The Xinerama code in the X server. Xinerama is how we did
multi-monitor stuff before RandR existed. These days, RandR
provides Xinerama emulation, but we've been telling people to
switch to RandR directly.
Some new API. Awesome. Ok, so if we haven't fixed this in any
existing API we control (kernel/libdrm/X.org), then we effectively
dump the problem into the laps of the desktop and application
developers. Given how long it's taken them to adopt current RandR
stuff, providing yet another complication in their lives won't
make them very happy.
All Our APIs Suck
Dave Airlie merged MST support into the kernel for version 3.17 in the
simplest possible fashion -- pushing the problem out to user space. I
was initially vaguely tempted to go poke at it and try to fix things
there, but he eventually convinced me that it just wasn't
feasible.
It turns out that all of our fancy new modesetting APIs describe the
hardware in more detail than any application actually cares about. In
particular, we expose a huge array of hardware objects:
Subconnectors
Connectors
Outputs
Video modes
Crtcs
Encoders
Each of these objects exposes intimate details about the underlying
hardware -- which of them can work together, and which cannot; what
kinds of limits are there on data rates and formats; and pixel-level
timing details about blanking periods and refresh rates.
To make things work, some piece of code needs to actually hook things
up, and explain to the user why the configuration they want just isn't
possible.
The sticking point we reached was that when an MST monitor gets
plugged in, it needs two CRTCs to drive it. If one of those
is already in use by some other output, there's just no way you can
steal it for MST mode.
Another problem -- we expose EDID data and actual video mode
timings. Our MST monitor has two EDID blocks, one for each
half. They happen to describe how they're related, and how you should
configure them, but if we want to hide that from the application,
we'll have to pull those EDID blocks apart and construct a new
one. The same goes for video modes; we'll have to construct ones for
MST mode.
Every single one of our APIs exposes enough of this information to be
dangerous.
Every one, except Xinerama. All it talks about is a list of
rectangles, each of which represents a logical view into the
desktop. Did I mention we've been encouraging people to stop using
this? And that some of them listened to us? Foolishly?
Dave's Tiling Property
Dave hacked up the X server to parse the EDID strings and communicate
the layout information to clients through an output property. Then he
hacked up the gnome code to parse that property and build a RandR
configuration that would work.
Then, he changed to RandR Xinerama code to also parse the TILE
properties and to fix up the data seen by application from that.
This works well enough to get a desktop running correctly, assuming
that desktop uses Xinerama to fetch this data. Alas, gtk has been
"fixed" to use RandR if you have RandR version 1.3 or later. No
biscuit for us today.
Adding RandR Monitors
RandR doesn't have enough data types yet, so I decided that what we
wanted to do was create another one; maybe that would solve this
problem.
Ok, so what clients mostly want to know is which bits of the screen
are going to be stuck together and should be treated as a single
unit. With current RandR, that's some of the information included in a
CRTC. You pull the pixel size out of the associated mode, physical size out
of the associated outputs and the position from the CRTC itself.
Most of that information is available through Xinerama too; it's just
missing physical sizes and any kind of labeling to help the user
understand which monitor you're talking about.
The other problem with Xinerama is that it cannot be configured by
clients; the existing RandR implementation constructs the Xinerama
data directly from the RandR CRTC settings. Dave's Tiling property
changes edit that data to reflect the union of associated monitors as
a single Xinerama rectangle.
Allowing the Xinerama data to be configured by clients would fix our
4k MST monitor problem as well as solving the longstanding video wall,
WiDi and VNC troubles. All of those want to create logical monitor
areas within the screen under client control
What I've done is create a new RandR datatype, the "Monitor", which is
a rectangular area of the screen which defines a rectangular region of
the screen. Each monitor has the following data:
Name. This provides some way to identify the Monitor to the user.
I'm using X atoms for this as it made a bunch of things easier.
Primary boolean. This indicates whether the monitor is to be
considered the "primary" monitor, suitable for placing toolbars and
menus.
Pixel geometry (x, y, width, height). These locate the region
within the screen and define the pixel size.
Physical geometry (width-in-millimeters,
height-in-millimeters). These let the user know how big the pixels
will appear in this region.
List of outputs. (I think this is the clever bit)
There are three requests to define, delete and list monitors. And
that's it.
Now, we want the list of monitors to completely describe the
environment, and yet we don't want existing tools to break
completely. So, we need some way to automatically construct monitors
from the existing RandR state while still letting the user override
portions of it as needed to explain virtual or tiled outputs.
So, what I did was to let the client specify a list of outputs for
each monitor. All of the CRTCs which aren't associated with an output
in any client-defined monitor are then added to the list of monitors
reported back to clients. That means that clients need only define
monitors for things they understand, and they can leave the other bits
alone and the server will do something sensible.
The second tricky bit is that if you specify an empty rectangle at 0,0
for the pixel geometry, then the server will automatically compute the
geometry using the list of outputs provided. That means that if any of
those outputs get disabled or reconfigured, the Monitor associated
with them will appear to change as well.
Current Status
Gtk+ has been switched to use RandR for RandR versions 1.3 or
later. Locally, I hacked libXrandr to override the RandR version
through an environment variable, set that to 1.2 and Gtk+ happily
reverts back to Xinerama and things work fine. I suspect the plan here
will be to have it use the new Monitors when present as those provide
the same info that it was pulling out of RandR's CRTCs.
KDE appears to still use Xinerama data for this, so it "just works".
Where's the code
As usual, all of the code for this is in a collection of git
repositories in my home directory on fd.o:
RandR protocol changes
Here's the new sections added to randrproto.txt
1.5. Introduction to version 1.5 of the extension
Version 1.5 adds monitors
A 'Monitor' is a rectangular subset of the screen which represents
a coherent collection of pixels presented to the user.
Each Monitor is be associated with a list of outputs (which may be
empty).
When clients define monitors, the associated outputs are removed from
existing Monitors. If removing the output causes the list for that
monitor to become empty, that monitor will be deleted.
For active CRTCs that have no output associated with any
client-defined Monitor, one server-defined monitor will
automatically be defined of the first Output associated with them.
When defining a monitor, setting the geometry to all zeros will
cause that monitor to dynamically track the bounding box of the
active outputs associated with them
This new object separates the physical configuration of the hardware
from the logical subsets the screen that applications should
consider as single viewable areas.
1.5.1. Relationship between Monitors and Xinerama
Xinerama's information now comes from the Monitors instead of directly
from the CRTCs. The Monitor marked as Primary will be listed first.
5.6. Protocol Types added in version 1.5 of the extension
MONITORINFO name: ATOM
primary: BOOL
automatic: BOOL
x: INT16
y: INT16
width: CARD16
height: CARD16
width-in-millimeters: CARD32
height-in-millimeters: CARD32
outputs: LISTofOUTPUT
7.5. Extension Requests added in version 1.5 of the extension.
RRGetMonitors
window : WINDOW
timestamp: TIMESTAMP
monitors: LISTofMONITORINFO
Errors: Window
Returns the list of Monitors for the screen containing
'window'.
'timestamp' indicates the server time when the list of
monitors last changed.
RRSetMonitor
window : WINDOW
info: MONITORINFO
Errors: Window, Output, Atom, Value
Create a new monitor. Any existing Monitor of the same name is deleted.
'name' must be a valid atom or an Atom error results.
'name' must not match the name of any Output on the screen, or
a Value error results.
If 'info.outputs' is non-empty, and if x, y, width, height are all
zero, then the Monitor geometry will be dynamically defined to
be the bounding box of the geometry of the active CRTCs
associated with them.
If 'name' matches an existing Monitor on the screen, the
existing one will be deleted as if RRDeleteMonitor were called.
For each output in 'info.outputs, each one is removed from all
pre-existing Monitors. If removing the output causes the list of
outputs for that Monitor to become empty, then that Monitor will
be deleted as if RRDeleteMonitor were called.
Only one monitor per screen may be primary. If 'info.primary'
is true, then the primary value will be set to false on all
other monitors on the screen.
RRSetMonitor generates a ConfigureNotify event on the root
window of the screen.
RRDeleteMonitor
window : WINDOW
name: ATOM
Errors: Window, Atom, Value
Deletes the named Monitor.
'name' must be a valid atom or an Atom error results.
'name' must match the name of a Monitor on the screen, or a
Value error results.
RRDeleteMonitor generates a ConfigureNotify event on the root
window of the screen.
is enthusiasm contagious? I think so. a recent example: another advent
posting. gracias!
this posting is part of GDAC (gregoa's debian advent calendar), a project to
show the bright side of debian & why it's fun for me to contribute.
Munin is a great tool. If you can script it, you can monitor it with
munin. Unfortunately, however, munin is slow; that is, it will take
snapshots once every five minutes, and not look at systems in between.
If you have a short load spike that takes just a few seconds, chances
are pretty high munin missed it. It also comes with a great
webinterfacefrontendthing that allows you to dig deep in the history of
what you've been monitoring.
By the time munin tells you that your Kerberos KDCs are all down, you've
probably had each of your users call you several times to tell you that
they can't log in. You could use nagios or one of its brethren, but it
takes about a minute before such tools will notice these things, too.
Maybe use CollectD then? Rather than check once every several minutes,
CollectD will collect information every few seconds. Unfortunately,
however, due to the performance requirements to accomplish that (without
causing undue server load), writing scripts for CollectD is not as easy
as it is for Munin. In addition, webinterfacefrontendthings aren't
really part of the CollectD code (there are several, but most that I've
looked at are lacking in some respect), so usually if you're using
CollectD, you're missing out some.
And collectd doesn't do the nagios thing of actually telling you when
things go down.
So what if you could see it when things go bad?
At one customer, I came in contact with Frank, who
wrote ExtreMon, an amazing tool that allows you
to visualize the CollectD output as things are happening, in a
full-screen fully customizable visualization of the data. The problem is
that ExtreMon is rather... complex to set up. When I tried to talk Frank
into helping me getting things set up for myself so I could play with
it, I got a reply along the lines of...
well, extremon requires a lot of work right now... I really want to
fix foo and bar and quux before I start documenting things. Oh, and
there's also that part which is a dead end, really. Ask me in a few
months?
which is fair enough (I can't argue with some things being suboptimal),
but the code exists, and (as I can see every day at $CUSTOMER)
actually works. So I decided to just figure it out by myself. After
all, it's free software, so if it doesn't work I can just read the
censored code.
As the
manual
explains, ExtreMon is a plugin-based system; plugins can add information
to the "coven", read information from it, or both. A typical setup will
run several of them; e.g., you'd have the from_collectd plugin (which
parses the binary network protocol used by collectd) to get raw data
into the coven; you'd run several aggregator plugins (which take that
raw data and interpret it, allowing you do express things along the
lines of "if the system's load gets above X, set load.status to
warning"; and you'd run at least one output plugin so that you can
actually see the damn data somewhere.
While setting up ExtreMon as is isn't as easy as one would like, I did
manage to get it to work. Here's what I had to do.
You will need:
A monitor with a FullHD (or better) resolution. Currently, the display
frontend of ExtreMon assumes it has a FullHD display at all time.
Even if you have a lower resolution. Or a higher one.
Python3
OpenJDK 6 (or better)
First, we clone the ExtreMon git repository:
git clone https://github.com/m4rienf/ExtreMon.git extremon
cd extremon
There's a README there which explains the bare necessities on getting
the coven to work. Read it. Do what it says. It's not wrong. It's not
entirely complete, though; it fails to mention that you need to
install CollectD (which is required for its types.db)
Configure CollectD to have a line like Hostname "com.example.myhost"
rather than the (usual) FQDNLookup true. This is because extremon
uses the java-style reverse hostname, rather than the internet-style
FQDN.
Make sure the dump.py script outputs something from collectd. You'll
know when it shows something not containing "plugin" or "plugins" in the
name. If it doesn't, fiddle with the #x3. lines at the top of the
from_collectd file until it does. Note that ExtreMon uses inotify to
detect whether a plugin has been added to or modified in its plugins
directory; so you don't need to do anything special when updating
things.
Next, we build the java libraries (which we'll need for the display
thing later on):
cd java/extremon
mvn install
cd ../client/
mvn install
This will download half the Internet, build some java sources, and drop
the precompiled .jar files in your $HOME/.m2/repository.
We'll now build the display frontend. This is maintained in a separate
repository:
cd ../..
git clone https://github.com/m4rienf/ExtreMon-Display.git display
cd display
mvn install
This will download the other half of the Internet, and then fail,
because Frank forgot to add a few repositories. Patch (and push request)
on
github
With that patch, it will build, but things will still fail when trying
to sign a .jar file. I know of four ways on how to fix that particular
problem:
Add your passphrase for your java keystore, in cleartext, to the
pom.xml file. This is a terrible idea.
Pass your passphrase to maven, in cleartext, by using some command
line flags. This is not much better.
Ensure you use the maven-jarsigner-plugin 1.3.something or above, and
figure out how the maven encrypted passphrase store thing works. I
failed at that.
Give up on trying to have maven sign your jar file, and do it
manually. It's not that hard, after all.
If you're going with 1 through 3, you're on your own. For the last
option, however, here's what you do. First, you need a key:
keytool -genkeypair -alias extremontest
after you enter all the information that keytool will ask for, it will
generate a self-signed code signing certificate, valid for six months,
called extremontest. Producing a code signing certificate with longer
validity and/or one which is signed by an actual CA is left as an
exercise to the reader.
Now, we will sign the .jar file:
There. Who needs help from the internet to sign a .jar file? Well, apart
from this blog post, of course.
You will now want to copy your freshly-signed .jar file to a location
served by HTTPS. Yes, HTTPS, not HTTP; ExtreMon-Display will fail on
plain HTTP sites.
Download this SVG file,
and open it in an editor. Find all references to be.grep as well as
those to barbershop and replace them with your own prefix and
hostname. Store it along with the .jar file in a useful directory.
Download this JNLP file,
and store it on the same location (or you might want to actually open it
with "javaws" to see the very basic animated idleness of my system).
Open it in an editor, and replace any references to barbershop.grep.be
by the location where you've stored your signed .jar file.
Add the chalice_in_http plugin from the plugins directory. Make sure
to configure it correctly (by way of its first few comment lines) so
that its input and output filters are set up right.
Add the configuration snippet in section 2.1.3 of the manual (or
something functionally equivalent) to your webserver's configuration.
Make sure to have authentication chalice_in_http is an input
mechanism.
Add the chalice_out_http plugin from the plugins directory. Make
sure to configure it correctly (by way of its first few comment lines)
so that its input and output filters are set up right.
Add the configuration snippet in section 2.2.1 of the manual (or
something functionally equivalent) to your webserver's configuration.
Authentication isn't strictly required for the output plugin, but you
might wish for it anyway if you care whether the whole internet can see
your monitoring.
Now run javaws https://url/x3console.jnlp to start Extremon-Display.
At this point, I got stuck for several hours. Whenever I tried to run
x3mon, this java webstart thing would tell me simply that things failed.
When clicking on the "Details" button, I would find an error message
along the lines of "Could not connect (name must not be null)". It would
appear that the Java people believe this to be a proper error message
for a fairly large number of constraints, all of which are slightly
related to TLS connectivity. No, it's not the keystore. No, it's not an
API issue, either. Or any of the loads of other rabbit holes that I dug
myself in.
Instead, you should simply make sure you have Server Name Indication enabled. If you don't, the defaults in Java will cause it to
refuse to even try to talk to your webserver.
The ExtreMon github repository comes with a bunch of extra plugins; some
are special-case for the place where I first learned about it (and
should therefore probably be considered "examples"), others are
general-purpose plugins which implement things like "is the system
load within reasonable limits". Be sure to check them out.
Note also that while you'll probably be getting most of your data from
CollectD, you don't actually need to do that; you can write your own
plugins, completely bypassing collectd. Indeed, the from_collectd
thing we talked about earlier is, simply, also a plugin. At $CUSTOMER,
for instance, we have one plugin which simply downloads a file every so
often and checks it against a checksum, to verify that a particular
piece of nonlinear
software hasn't gone astray yet again. That doesn't need collectd.
The example above will get you a small white bar, the width of which is
defined by the cpu "idle" statistic, as reported by CollectD. You
probably want more. The manual (chapter 4, specifically) explains how to
do that.
Unfortunately, in order for things to work right, you need to pretty
much manually create an SVG file with a fairly strict structure. This is
the one thing which Frank tells me is a dead end and needs to be pretty
much rewritten. If you don't feel like spending several days manually
drawing a schematic representation of your network, you probably want to
wait until Frank's finished. If you don't mind, or if you're like me and
you're impatient, you'll be happy to know that you can use inkscape to
make the SVG file. You'll just have to use dialog behind ctrl+shift+X. A
lot.
Once you've done that though, you can see when your server is down.
Like, now. Before your customers call you.
Thanks to DSAs' deployment, now there is security.debian.org mirror in Japan. It means users who live in Asia/Pacific region are not annoyed with slow download speed for stable security update - anymore :)
New security.debian.org mirror is kindly hosted by Sakura Internet, Inc. ( ) as well as debian-mirror.sakura.ne.jp mirror server in Ishikari, Hokkaido ( ).