At first I thought this was a Linux bug, but actually, it the result of a crazy default setting for wake on LAN. By default, wake on unicast packet and magic packet are both enabled. If there was some network activity which caused ordinary unicast packets to arrive while the computer was sleeping, it woke up. That's why I found that with a minimal X setup using twm, the wakeups only happened if I was running a web browser.
This setting can be seen by running
sudo ethtool eth0. Its output included:
Supports Wake-on: pumbg
From the ethtool man page:
u Wake on unicast messages
g Wake on MagicPacket™
The solution was adding
ethtool -s eth0 wol dto
/etc/rc.localto disable wake on LAN. Then
sudo ethtool eth0would report
Wake-on: d, which means "Disable (wake on nothing).". It's possible to also use
d, which should only enable wake on magic packet.
The GA-P35-DS3R rev 1.0 motherboard F13 BIOS does not seem to have any options for changing wake on LAN settings, so this seems to be the only way to do it. I had already disabled wake on LAN in Windows via the Advanced settings in Device Manager. That setting persisted until standby power was cut.
It sure seemed like a Linux bug at first, so here's the Ubuntu bug I reported. Now I just wish Linux would tell me the wake reason. If something told me these wakeups were a result of wake on LAN, I would have wasted a lot less time on this.