<s>
zswap	B-Application
is	O
a	O
Linux	B-Operating_System
kernel	I-Operating_System
feature	O
that	O
provides	O
a	O
compressed	O
write-back	O
cache	B-General_Concept
for	O
swapped	B-Architecture
pages	O
,	O
as	O
a	O
form	O
of	O
virtual	B-General_Concept
memory	I-General_Concept
compression	I-General_Concept
.	O
</s>
<s>
Instead	O
of	O
moving	O
memory	B-General_Concept
pages	I-General_Concept
to	O
a	O
swap	O
device	O
when	O
they	O
are	O
to	O
be	O
swapped	B-Architecture
out	O
,	O
zswap	B-Application
performs	O
their	O
compression	B-General_Concept
and	O
then	O
stores	O
them	O
into	O
a	O
memory	B-General_Concept
pool	I-General_Concept
dynamically	O
allocated	O
in	O
the	O
system	O
RAM	B-Architecture
.	O
</s>
<s>
Later	O
writeback	O
to	O
the	O
actual	O
swap	O
device	O
is	O
deferred	O
or	O
even	O
completely	O
avoided	O
,	O
resulting	O
in	O
a	O
significantly	O
reduced	O
I/O	B-General_Concept
for	O
Linux	B-Operating_System
systems	O
that	O
require	O
swapping	O
;	O
the	O
tradeoff	O
is	O
the	O
need	O
for	O
additional	O
CPU	B-Device
cycles	O
to	O
perform	O
the	O
compression	B-General_Concept
.	O
</s>
<s>
As	O
a	O
result	O
of	O
reduced	O
I/O	B-General_Concept
,	O
zswap	B-Application
offers	O
advantages	O
to	O
various	O
devices	O
that	O
use	O
flash-based	B-Device
storage	I-Device
,	O
including	O
embedded	B-Architecture
devices	I-Architecture
,	O
netbooks	B-Device
and	O
similar	O
low-end	O
hardware	O
devices	O
,	O
as	O
well	O
as	O
to	O
other	O
devices	O
that	O
use	O
solid-state	B-Device
drives	I-Device
(	O
SSDs	B-Device
)	O
for	O
storage	O
.	O
</s>
<s>
Flash	B-Device
memory	I-Device
has	O
a	O
limited	O
lifespan	O
due	O
to	O
its	B-Error_Name
nature	I-Error_Name
,	O
so	O
avoiding	O
it	O
to	O
be	O
used	O
for	O
providing	O
swap	O
space	O
prevents	O
it	O
from	O
wearing	O
out	O
quickly	O
.	O
</s>
<s>
zswap	B-Application
is	O
integrated	O
into	O
the	O
rest	O
of	O
Linux	B-Operating_System
kernel	I-Operating_System
's	O
virtual	B-Architecture
memory	I-Architecture
subsystem	O
using	O
the	O
API	B-General_Concept
provided	O
by	O
frontswap	O
,	O
which	O
is	O
a	O
mechanism	O
of	O
the	O
Linux	B-Operating_System
kernel	I-Operating_System
that	O
abstracts	O
various	O
types	O
of	O
storage	O
that	O
can	O
be	O
used	O
as	O
swap	O
space	O
.	O
</s>
<s>
As	O
a	O
result	O
,	O
zswap	B-Application
operates	O
as	O
a	O
backend	O
driver	O
for	O
frontswap	O
by	O
providing	O
what	O
is	O
internally	O
visible	O
as	O
a	O
pseudo-RAM	O
device	O
.	O
</s>
<s>
In	O
other	O
words	O
,	O
the	O
frontswap	O
API	B-General_Concept
makes	O
zswap	B-Application
capable	O
of	O
intercepting	O
memory	B-General_Concept
pages	I-General_Concept
while	O
they	O
are	O
being	O
swapped	B-Architecture
out	O
,	O
and	O
capable	O
of	O
intercepting	O
page	B-General_Concept
faults	I-General_Concept
for	O
the	O
already	O
swapped	B-Architecture
pages	O
;	O
the	O
access	O
to	O
those	O
two	O
paths	O
allows	O
zswap	B-Application
to	O
act	O
as	O
a	O
compressed	O
write-back	O
cache	B-General_Concept
for	O
swapped	B-Architecture
pages	O
.	O
</s>
<s>
Internally	O
,	O
zswap	B-Application
uses	O
compression	B-General_Concept
modules	B-Application
provided	O
by	O
the	O
Linux	B-Operating_System
kernel	I-Operating_System
's	O
crypto	B-Application
API	I-Application
,	O
which	O
makes	O
it	O
possible	O
,	O
for	O
example	O
,	O
to	O
offload	O
the	O
compression	B-General_Concept
tasks	O
from	O
the	O
main	O
CPU	B-Device
using	O
any	O
of	O
the	O
hardware	O
compression	B-General_Concept
accelerators	B-General_Concept
supported	O
by	O
the	O
Linux	B-Operating_System
kernel	I-Operating_System
.	O
</s>
<s>
The	O
selection	O
of	O
the	O
desired	O
compression	B-General_Concept
module	B-Application
can	O
be	O
performed	O
dynamically	O
at	O
the	O
boot	O
time	O
through	O
the	O
value	O
of	O
kernel	B-Operating_System
boot	O
parameter	O
;	O
if	O
not	O
specified	O
,	O
it	O
selects	O
the	O
Lempel	B-Language
–	I-Language
Ziv	I-Language
–	I-Language
Oberhumer	I-Language
(	O
LZO	B-Language
)	O
compression	B-General_Concept
.	O
</s>
<s>
As	O
of	O
version	O
3.13	O
of	O
the	O
Linux	B-Operating_System
kernel	I-Operating_System
,	O
zswap	B-Application
also	O
needs	O
to	O
be	O
explicitly	O
enabled	O
by	O
specifying	O
value	O
for	O
the	O
kernel	B-Operating_System
boot	O
parameter	O
.	O
</s>
<s>
The	O
maximum	O
size	O
of	O
the	O
memory	B-General_Concept
pool	I-General_Concept
used	O
by	O
zswap	B-Application
is	O
configurable	O
through	O
the	O
parameter	O
,	O
which	O
specifies	O
the	O
maximum	O
percentage	O
of	O
total	O
system	O
RAM	B-Architecture
that	O
can	O
be	O
occupied	O
by	O
the	O
pool	O
.	O
</s>
<s>
The	O
memory	B-General_Concept
pool	I-General_Concept
is	O
not	O
preallocated	O
to	O
its	O
configured	O
maximum	O
size	O
,	O
and	O
instead	O
grows	O
and	O
shrinks	O
as	O
required	O
.	O
</s>
<s>
When	O
the	O
configured	O
maximum	O
pool	O
size	O
is	O
reached	O
as	O
the	O
result	O
of	O
performed	O
swapping	O
,	O
or	O
when	O
growing	O
the	O
pool	O
is	O
impossible	O
due	O
to	O
an	O
out-of-memory	B-General_Concept
condition	O
,	O
swapped	B-Architecture
pages	O
are	O
evicted	O
from	O
the	O
memory	B-General_Concept
pool	I-General_Concept
to	O
a	O
swap	O
device	O
on	O
the	O
least	B-General_Concept
recently	I-General_Concept
used	I-General_Concept
(	O
LRU	O
)	O
basis	O
.	O
</s>
<s>
This	O
approach	O
makes	O
zswap	B-Application
a	O
true	O
swap	O
cache	B-General_Concept
,	O
as	O
the	O
oldest	O
cached	O
pages	O
are	O
evicted	O
to	O
a	O
swap	O
device	O
once	O
the	O
cache	B-General_Concept
is	O
full	O
,	O
making	O
room	O
for	O
newer	O
swapped	B-Architecture
pages	O
to	O
be	O
compressed	O
and	O
cached	O
.	O
</s>
<s>
zbud	O
is	O
a	O
special-purpose	O
memory	B-General_Concept
allocator	I-General_Concept
used	O
internally	O
by	O
zswap	B-Application
for	O
storing	O
compressed	O
pages	O
,	O
implemented	O
as	O
a	O
rewrite	O
of	O
the	O
zbud	O
allocator	O
used	O
by	O
the	O
Oracle	B-Application
's	O
zcache	B-Application
,	O
which	O
is	O
another	O
virtual	B-General_Concept
memory	I-General_Concept
compression	I-General_Concept
implementation	O
for	O
the	O
Linux	B-Operating_System
kernel	I-Operating_System
.	O
</s>
<s>
Internally	O
,	O
zbud	O
works	O
by	O
storing	O
up	O
to	O
two	O
compressed	O
pages	O
(	O
"	O
buddies	B-General_Concept
"	O
,	O
hence	O
the	O
allocator	O
name	O
)	O
per	O
physical	O
memory	B-General_Concept
page	I-General_Concept
,	O
which	O
brings	O
both	O
advantages	O
due	O
to	O
easy	O
coalescing	O
and	O
reusing	O
of	O
freed	O
space	O
,	O
and	O
disadvantages	O
due	O
to	O
possible	O
lower	O
memory	O
utilization	O
.	O
</s>
<s>
However	O
,	O
as	O
a	O
result	O
of	O
its	O
design	O
,	O
zbud	O
cannot	O
allocate	B-General_Concept
more	O
memory	O
space	O
than	O
it	O
would	O
be	O
originally	O
occupied	O
by	O
the	O
uncompressed	B-General_Concept
pages	O
.	O
</s>
<s>
Both	O
zswap	B-Application
and	O
zbud	O
were	O
created	O
by	O
Seth	O
Jennings	O
.	O
</s>
<s>
The	O
first	O
public	O
announcement	O
was	O
in	O
December	O
2012	O
,	O
and	O
the	O
development	O
continued	O
until	O
May	O
2013	O
at	O
which	O
point	O
the	O
codebase	B-General_Concept
reached	O
its	O
maturity	O
although	O
still	O
having	O
the	O
status	O
of	O
an	O
experimental	O
kernel	B-Operating_System
feature	O
.	O
</s>
<s>
zswap	B-Application
(	O
together	O
with	O
zbud	O
)	O
was	O
merged	O
into	O
the	O
Linux	B-Operating_System
kernel	I-Operating_System
mainline	O
in	O
kernel	B-Operating_System
version	O
3.11	O
,	O
which	O
was	O
released	O
on	O
September	O
2	O
,	O
2013	O
.	O
</s>
<s>
Since	O
version	O
3.15	O
of	O
the	O
Linux	B-Operating_System
kernel	I-Operating_System
,	O
which	O
was	O
released	O
on	O
June	O
8	O
,	O
2014	O
,	O
zswap	B-Application
properly	O
supports	O
multiple	O
swap	O
devices	O
.	O
</s>
<s>
One	O
of	O
the	O
alternatives	O
to	O
zswap	B-Application
is	O
zram	B-Application
,	O
which	O
provides	O
a	O
similar	O
but	O
still	O
different	O
"	O
swap	O
compressed	O
pages	O
to	O
RAM	B-Architecture
"	O
mechanism	O
to	O
the	O
Linux	B-Operating_System
kernel	I-Operating_System
.	O
</s>
<s>
The	O
main	O
difference	O
is	O
that	O
zram	B-Application
provides	O
a	O
compressed	O
block	O
device	O
using	O
RAM	B-Architecture
for	O
storing	O
data	O
,	O
which	O
acts	O
as	O
a	O
regular	O
and	O
separate	O
swap	O
device	O
.	O
</s>
<s>
In	O
comparison	O
,	O
zswap	B-Application
acts	O
as	O
a	O
RAM-based	O
cache	B-General_Concept
for	O
swap	O
devices	O
.	O
</s>
<s>
This	O
provides	O
zswap	B-Application
with	O
an	O
eviction	O
mechanism	O
for	O
less	O
used	O
swapped	B-Architecture
pages	O
,	O
which	O
zram	B-Application
lacked	O
until	O
the	O
introduction	O
of	O
in	O
kernel	B-Operating_System
version	O
4.14	O
.	O
</s>
<s>
Though	O
,	O
as	O
a	O
result	O
of	O
its	O
design	O
,	O
at	O
least	O
one	O
already	O
existing	O
swap	O
device	O
is	O
required	O
for	O
zswap	B-Application
to	O
be	O
used	O
.	O
</s>
