Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[solved] swapon is SLOW in new kernels
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
jmattax
n00b
n00b


Joined: 17 Mar 2012
Posts: 7
Location: New Mexico, USA

PostPosted: Sun Mar 18, 2012 12:08 am    Post subject: [solved] swapon is SLOW in new kernels Reply with quote

I recently decided that I should build a new kernel since the one I was running was rather old. I got and configured gentoo-sources-3.2.1-r2 and booted them simply enough. However, my swap file now takes forever to load. Using the new kernel I get

Code:
uname -a
Linux gatita 3.2.1-gentoo-r2 #2 SMP Sat Mar 17 14:46:21 MDT 2012 x86_64 AMD Phenom(tm) II X4 925 Processor AuthenticAMD GNU/Linux

and after turning the swap off after booting
Code:
time swapon -v /var/swapfile
swapon on /var/swapfile
swapon: /var/swapfile: found swap signature: version 1, page-size 4, same byte order
swapon: /var/swapfile: pagesize=4096, swapsize=6442450944, devsize=6442450944

real    4m34.691s
user    0m0.001s
sys     0m1.395s


where as with my old kernel
Code:
uname -a
Linux gatita 2.6.30-gentoo-r5 #9 SMP Sun May 9 12:04:59 MDT 2010 x86_64 AMD Phenom(tm) II X4 925 Processor AuthenticAMD GNU/Linux

and after turning the swap off so I can time it coming back on
Code:
time swapon -v /var/swapfile
swapon on /var/swapfile
swapon: /var/swapfile: found swap signature: version 1, page-size 4, same byte order
swapon: /var/swapfile: pagesize=4096, swapsize=6442450944, devsize=6442450944


I can't figure out what the problem is here, but obviously I don't want to run the new kernel till I solve the problem since it means taking about 5 minutes to boot.


Last edited by jmattax on Fri Mar 23, 2012 1:03 am; edited 1 time in total
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21490

PostPosted: Sun Mar 18, 2012 12:17 am    Post subject: Reply with quote

Does it help if you use a swap partition? What type of filesystem is /var? Is /var on a spinning disk or solid state disk?
Back to top
View user's profile Send private message
jmattax
n00b
n00b


Joined: 17 Mar 2012
Posts: 7
Location: New Mexico, USA

PostPosted: Sun Mar 18, 2012 1:43 am    Post subject: Reply with quote

I'm not sure on the swap partition I'll have to install a new physical disk to test that, but I'll be able to do that tomorrow or later tonight.

/var is on an ext3 formatted solid state disk that has been running well for me with the old kernel for about a year.
Back to top
View user's profile Send private message
EatMeerkats
Apprentice
Apprentice


Joined: 15 Mar 2006
Posts: 234

PostPosted: Sun Mar 18, 2012 3:05 am    Post subject: Reply with quote

Weird, on a 3.2.11-gentoo kernel + ext4 on SSD, I get:

Code:
% time sudo swapon /swapfile
sudo swapon /swapfile  0.00s user 0.11s system 99% cpu 0.117 total
Back to top
View user's profile Send private message
jmattax
n00b
n00b


Joined: 17 Mar 2012
Posts: 7
Location: New Mexico, USA

PostPosted: Sun Mar 18, 2012 4:09 pm    Post subject: Reply with quote

EatMeerkats: What package is your kernel from? I show 3.2.1 as the most recent stable kernel version for gentoo-sources.

I'm still working on testing with a partition, I have a spare hard drive installed, and the BIOS and Windows see it, but Gentoo doesn't so I'm going down a rabbit trail trying to get it recognized.
Back to top
View user's profile Send private message
EatMeerkats
Apprentice
Apprentice


Joined: 15 Mar 2006
Posts: 234

PostPosted: Sun Mar 18, 2012 4:13 pm    Post subject: Reply with quote

Oh, I just unmaked the latest version in portage.
Back to top
View user's profile Send private message
jmattax
n00b
n00b


Joined: 17 Mar 2012
Posts: 7
Location: New Mexico, USA

PostPosted: Sun Mar 18, 2012 4:26 pm    Post subject: Reply with quote

I just mounted a swap partition in the new kernel it went right quick. It is about a third the size but otherwise the same.

Code:
time swapon -v /dev/sdb5
swapon on /dev/sdb5
swapon: /dev/sdb5: found swap signature: version 1, page-size 4, same byte order
swapon: /dev/sdb5: pagesize=4096, swapsize=2006933504, devsize=2006936064

real    0m0.005s
user    0m0.001s
sys     0m0.002s
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21490

PostPosted: Sun Mar 18, 2012 5:19 pm    Post subject: Reply with quote

jmattax wrote:
I just mounted a swap partition in the new kernel it went right quick. It is about a third the size but otherwise the same.
To be sure I understand, by "new kernel" in the post quoted here, you mean the 3.2.1-gentoo-r2 kernel that performs poorly with swap files performs well with swap partitions?
Back to top
View user's profile Send private message
jmattax
n00b
n00b


Joined: 17 Mar 2012
Posts: 7
Location: New Mexico, USA

PostPosted: Sun Mar 18, 2012 5:26 pm    Post subject: Reply with quote

Hu: that is correct, in the 3.2.1-gentoo-r2 time to swapon an about 6GB swap file is about 4:30 (with the time command no knowing where most of that is spent), while swapon for a 2GB partition is well under a second.

Code:

gatita gentoo-sources # time swapon -v /dev/sdb5
swapon on /dev/sdb5
swapon: /dev/sdb5: found swap signature: version 1, page-size 4, same byte order
swapon: /dev/sdb5: pagesize=4096, swapsize=2006933504, devsize=2006936064

real    0m0.005s
user    0m0.001s
sys     0m0.002s
gatita gentoo-sources # time swapon -v /var/swapfile
swapon on /var/swapfile
swapon: /var/swapfile: found swap signature: version 1, page-size 4, same byte order
swapon: /var/swapfile: pagesize=4096, swapsize=6442450944, devsize=6442450944

real    4m35.733s
user    0m0.001s
sys     0m1.808s
gatita gentoo-sources # uname -a
Linux gatita 3.2.1-gentoo-r2 #2 SMP Sat Mar 17 14:46:21 MDT 2012 x86_64 AMD Phenom(tm) II X4 925 Processor AuthenticAMD GNU/Linux


The strange thing here is that the time command doesn't seem to have any idea where the time is being spent turning the swap on for the swap file the user+sys time is under 2 seconds.
Back to top
View user's profile Send private message
jmattax
n00b
n00b


Joined: 17 Mar 2012
Posts: 7
Location: New Mexico, USA

PostPosted: Sun Mar 18, 2012 9:01 pm    Post subject: Reply with quote

I now have a little more information, using gentoo-sources-3.2.11 has the same symptoms as 3.2.1-r2. Also, I tested mounting a loopback device to see if that was the performance problem, but it wasn't.
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21490

PostPosted: Sun Mar 18, 2012 11:26 pm    Post subject: Reply with quote

If this is reproducible in vanilla kernels and is a regression relative to earlier 3.x kernels, I think your next step is to contact LKML to report it the kernel developers.
Back to top
View user's profile Send private message
jmattax
n00b
n00b


Joined: 17 Mar 2012
Posts: 7
Location: New Mexico, USA

PostPosted: Fri Mar 23, 2012 1:01 am    Post subject: Reply with quote

The memory management sublist of the LKML solved it for me. It required a patch to the kernel it involved changing the order of the statements in a conditional. Since they said that someone there didn't like it I'm going to post the text of it here.

--- a/mm/swapfile.c~swap-dont-do-discard-if-no-discard-option-added
+++ a/mm/swapfile.c
@@ -2103,7 +2103,7 @@ SYSCALL_DEFINE2(swapon, const char __use
p->flags |= SWP_SOLIDSTATE;
p->cluster_next = 1 + (random32() % p->highest_bit);
}
- if (discard_swap(p) == 0 && (swap_flags & SWAP_FLAG_DISCARD))
+ if ((swap_flags & SWAP_FLAG_DISCARD) && discard_swap(p) == 0)
p->flags |= SWP_DISCARDABLE;
}
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum