All of lore.kernel.org
 help / color / mirror / Atom feed
* [linux-lvm] swap on lvm cache
@ 2016-04-26 22:35 Xen
  2016-04-27  8:38 ` Zdenek Kabelac
  0 siblings, 1 reply; 3+ messages in thread
From: Xen @ 2016-04-26 22:35 UTC (permalink / raw)
  To: LVM general discussion and development

Just a weird question here.

Since swap should ordinarily be encrypted if you encrypt any part of 
your data at all, I have opted at this point to either put it inside a 
volume that might end up getting cached, or to disable that cache and 
put the swap in its place.

What I am saying is that in my current scheme there is going to be a 
small cache drive and one part of the cache drive is going to serve 
unencrypted data and the other part is going to serve encrypted data.

Supposing that, the swap would be in the encrypted part. But using cache 
(lvmcache) on swap is completely ludicrous right?

Swap content might change so fast and so often that with regular 
parameters (that would need to be identical for the entire encrypted 
container) it would never make it to the cache.

More, accessing swap means loading it into RAM and then clearing the 
swap part. Therefore, theoretically perhaps unless the promotion values 
are 0, there would never be any benefit because swap is always write 
once read once.

Then again, that means there is no pain in adding swap to it either, 
because it will never get cached.

Maybe it could be considered an innocent or innocuous element. Doesn't 
hurt you, doesn't provide any benefit. In Dutch we say "Baat het niet, 
dan schaadt het niet."

Alternatively you could put the swap on the SSD (in this case) and not 
have any cache for the other part of the drive. What do you think? It 
makes no sense and it makes no difference, right.

Regards, Bart.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [linux-lvm] swap on lvm cache
  2016-04-26 22:35 [linux-lvm] swap on lvm cache Xen
@ 2016-04-27  8:38 ` Zdenek Kabelac
  2016-04-27 10:32   ` Xen
  0 siblings, 1 reply; 3+ messages in thread
From: Zdenek Kabelac @ 2016-04-27  8:38 UTC (permalink / raw)
  To: linux-lvm

On 27.4.2016 00:35, Xen wrote:
> Just a weird question here.
>
> Since swap should ordinarily be encrypted if you encrypt any part of your data
> at all, I have opted at this point to either put it inside a volume that might
> end up getting cached, or to disable that cache and put the swap in its place.
>
> What I am saying is that in my current scheme there is going to be a small
> cache drive and one part of the cache drive is going to serve unencrypted data
> and the other part is going to serve encrypted data.
>
> Supposing that, the swap would be in the encrypted part. But using cache
> (lvmcache) on swap is completely ludicrous right?

Hi

Yes, it would be seriously bad idea to use 'swap' on cached LV...

There are already unsolved issues with plain devices and swapping :)
and you want to put caching logic into this stack.

> Alternatively you could put the swap on the SSD (in this case) and not have
> any cache for the other part of the drive. What do you think? It makes no
> sense and it makes no difference, right.

Regards

Zdenek

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [linux-lvm] swap on lvm cache
  2016-04-27  8:38 ` Zdenek Kabelac
@ 2016-04-27 10:32   ` Xen
  0 siblings, 0 replies; 3+ messages in thread
From: Xen @ 2016-04-27 10:32 UTC (permalink / raw)
  To: LVM general discussion and development

Zdenek Kabelac schreef op 27-04-2016 8:38:

> Yes, it would be seriously bad idea to use 'swap' on cached LV...
> 
> There are already unsolved issues with plain devices and swapping :)
> and you want to put caching logic into this stack.

I just think it would never promote it to the cache ;-). Unless the same 
blocks are written repeatedly with different memory. But typically every 
write is followed by a read. I don't think the same regions of swap are 
constantly reused. If your system is not heavily swapping, usually it 
would be rather stable. On heavy swap though you might find that the 
cache might start to promote it, but it also means the values constantly 
change.

Question: if a block has been promoted through reading (for example) 
(since reading promotion is usually lower (faster)) and is then written 
to, does this mean the cache for it is updated and then written through 
(or back)? I suppose it would. Let's assume that is the only sensible 
thing.

That means you could have swap blocks promoted due to heavy swapping 
(and hence reading) and if you have writeback, it would still make a 
modicum of sense since then it would actually cause hits to go to the 
cache instead of the slower disk.

I mean I could test it. I could just load a few programs heavy on 
memory, so that I can fully fill my cache (swap I mean) and then I could 
start alt-tabbing through these programs as a test. And then I would 
need statistics on lvmcache hits. You say there are issues but I am more 
than willing to crash my system for it :p.

For example, swap on thin LVM works fine. Although the swap filesystem 
is not cleared with swapoff. This can be changed with the --discard 
option, and then it is cleared.

Any discarded swap would instantly discard it from the LVM cache, 
likely, but not necessarily. If that happened then the promotion counter 
would never rise.

It is hard to find information on LVMcache. I don't know enough about 
dmcache to know its relation. I will just ask two short questions in a 
new email.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-04-27 10:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-26 22:35 [linux-lvm] swap on lvm cache Xen
2016-04-27  8:38 ` Zdenek Kabelac
2016-04-27 10:32   ` Xen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.