Re: [systemd-devel] how to let systemd hibernate start/stop the swap area?

2023-03-30 Thread Barry



> On 31 Mar 2023, at 00:51, Michael Chapman  wrote:
> 
> On Fri, 31 Mar 2023, Phillip Susi wrote:
>> 
>> Michael Chapman  writes:
>> 
>>> What specifically is the difference between:
>>> 
>>> * swap does not exist at all;
>>> * swap is full of data that will not be swapped in for weeks or months;
>> 
>> That's the wrong question.
> 
> Nevertheless it was the question I was faced with. I had servers with a 
> huge amount of memory, a fair bit of swap, and ALL of that swap filled 
> with stuff that would need to be entirely swapped back in at some point at 
> a moments notice.
> 
> The solution was simple: turn off swap. Now there was no "swap everything 
> back in" penalty, and since there was plenty of RAM anyway the change had 
> little impact on the behaviour of the rest of the system.

If you want to run in ram only then you must turn off the kernel overcommit.
Have you done that? If not then you risk processes getting SEGV signals.

There is a lot of moving parts that affect the robustness of a big server.
Swap is one of them that is important to allow efficient use of all the
hardware resources.

I work on servers with 400G of ram, but it is all used. Swap is a critical part 
of tuning
the performance with the network heavy work load that disk I/O impacts.

Barry

> 



[systemd-devel] How to make vtable entry as SD_BUS_VTABLE_UNPRIVILEGED

2023-03-30 Thread Lal, Arun
Hi All,

In file systemd\src\libsystemd\sd-bus\bus-objects.c function check_access has 
the following check:

/* If the member is marked UNPRIVILEGED let's grant access */
if (c->vtable->flags & SD_BUS_VTABLE_UNPRIVILEGED)
return 0;

Can someone tell me how to set the flag as SD_BUS_VTABLE_UNPRIVILEGED?

This is because I want a non-root user to make dbus method call. As of now this 
get's blocked in check_access function.
I would like to allow this by satisfying the condition c->vtable->flags & 
SD_BUS_VTABLE_UNPRIVILEGED

Regards,
Arun Lal K M


Re: [systemd-devel] how to let systemd hibernate start/stop the swap area?

2023-03-30 Thread Michael Chapman
On Fri, 31 Mar 2023, Phillip Susi wrote:
> 
> Michael Chapman  writes:
> 
> > What specifically is the difference between:
> >
> > * swap does not exist at all;
> > * swap is full of data that will not be swapped in for weeks or months;
> 
> That's the wrong question.

Nevertheless it was the question I was faced with. I had servers with a 
huge amount of memory, a fair bit of swap, and ALL of that swap filled 
with stuff that would need to be entirely swapped back in at some point at 
a moments notice.

The solution was simple: turn off swap. Now there was no "swap everything 
back in" penalty, and since there was plenty of RAM anyway the change had 
little impact on the behaviour of the rest of the system.


Re: [systemd-devel] how to let systemd hibernate start/stop the swap area?

2023-03-30 Thread Phillip Susi


Michael Chapman  writes:

> What specifically is the difference between:
>
> * swap does not exist at all;
> * swap is full of data that will not be swapped in for weeks or months;

That's the wrong question.  The question is, what is the difference
between having NO swap, and having some swap that you don't use much of?
The answer to that is that there will be a non zero amount of anonymous
memory allocated to processes that hardly ever touch it, and that can be
tossed out to swap to provide more memory to use for, if nothing else,
caching files that ARE being accessed.  Now that amount may not be much
if you usually have plenty of free ram, but it won't be zero.

I too have long gone without a swap partition because the small benefit
of having a little more ram to cache files did not justify the risk of
going into thrashing mode when some process went haywire, but if that
problem has been solved, and you want a swap partition for hibernation
anyhow, then you may as well keep it mounted all the time since
unmounting it when you aren't about to hibernate costs *something* and
gains *nothing*.



Re: [systemd-devel] how to let systemd hibernate start/stop the swap area?

2023-03-30 Thread Michael Chapman
On Fri, 31 Mar 2023, Luca Boccassi wrote:
[...]
> No, it does not make "little difference", there are entire subsystems
> which are much worse off, if not completely useless, without swap.
> Post-cgroupsv2 memory controller things are considerably different on
> this front, and old "common wisdom" no longer applies.

What are some examples here?

What specifically is the difference between:

* swap does not exist at all;
* swap is full of data that will not be swapped in for weeks or months;

?

Either way, nothing more can be swapped out, and nothing will get swapped 
in.

If everything fits in RAM, as far as I can see the only thing allowing 
"non-guest processes" to be swapped out is that I'd get slightly more 
available RAM for buffers and cache. But as I noted in the other thread, 
I've already got enough of that!

So what advantage would there be to me to enable swap? I started off this 
thread with a disadvantage, so there would have to be a *big* advantage to 
counter that.

I am well aware that "you should always have swap" is good general advice 
for most users. But it's important to remember there are exceptions to it! 
Lennart suggested one such situation is where you're running everything 
off RAM anyway. I suggest another such situation is where you have 
sufficient RAM that your entire workload comfortably fits within it.


Re: [systemd-devel] how to let systemd hibernate start/stop the swap area?

2023-03-30 Thread Phillip Susi


Lennart Poettering  writes:

> oomd/PSI looks at memory allocation latencies to determine memory
> pressure. Since you disallow anonymous memory to be paged out and thus
> increase IO on file backed memory you increase the latencies
> unnecessarily, thus making oomd trigger earlier.

Did this get changed in the last few years?  Because I'm sure it used to
be based on the total commit limit, and so OOM wouldn't start killing
until your swap was full, which didn't happen until the system was
thrashing itself to uselessness for 20 minutes already.

If this has been fixed then I guess it's time for me to start using swap
again.

What happens if you use zswap?  Will hibernation try to save things to
there instead of a real disk swap?  It might be nice to have zswap for
normal use and the on disk swap for hibernate.



Re: [systemd-devel] how to let systemd hibernate start/stop the swap area?

2023-03-30 Thread Luca Boccassi
On Thu, 30 Mar 2023 at 11:09, Michael Chapman  wrote:
>
> On Thu, 30 Mar 2023, Luca Boccassi wrote:
> > On Thu, 30 Mar 2023 at 10:15, Michael Chapman  
> > wrote:
> > >
> > > On Thu, 30 Mar 2023, Lennart Poettering wrote:
> > > > On Mi, 29.03.23 13:53, Christoph Anton Mitterer (cales...@scientia.org) 
> > > > wrote:
> > > >
> > > > > > > That's a bad idea btw. I'd advise you not to do that: on modern
> > > > > > > systems you want swap, since it makes anonymous memory 
> > > > > > > reclaimable.
> > > > > > > I
> > > > > > > am not sure where you are getting this idea from that swap was
> > > > > > > bad.
> > > > >
> > > > > Well I haven't said it's bad, but I guess it depends on the use case
> > > > > any available RAM.
> > > >
> > > > In almost all scenarios you want swap, regardless if little RAM or a
> > > > lot. For specialist cases where you run everything from memory, and
> > > > not even programs are backed by disk there might be exceptions. But
> > > > that#s almost never the case.
> > >
> > > One specific case where I deliberately chose _not_ to use swap: large
> > > hypervisors with local storage.
> > >
> > > With swap on the host enabled, all that ended up happening was that local
> > > IO activity caused idle guest memory to be gradually swapped out.
> > > Eventually all of the swap space filled up, and the system was exactly
> > > where it would have been had it not had any swap space configured in the
> > > first place -- except that it was now _a lot_ slower to migrate those
> > > swapped-out guests to other hypervisors.
> > >
> > > - Michael
> >
> > The solution there is to ensure the cgroup configuration for the
> > slices where the guests run have memory.swap.max=0, rather than
> > disabling it for the whole system.
>
> Perhaps, but given the rest of processes on the system need just a few
> hundred MB max, and the server has hundreds of GB of RAM, it really makes
> little difference. Turning off swap altogether is plain _simpler_.

No, it does not make "little difference", there are entire subsystems
which are much worse off, if not completely useless, without swap.
Post-cgroupsv2 memory controller things are considerably different on
this front, and old "common wisdom" no longer applies.


Re: [systemd-devel] systemd-networkd: switch between several static network setups on wired connection

2023-03-30 Thread Kevin P. Fleming
On Thu, Mar 30, 2023, at 09:35, f...@igh.de wrote:

>   [Match]
>   name = eth0
>   SSID = my-wifi
>
> would that mean, that "my-wifi" must be accessible via that interface
> (AND logic) or could that mean we configure "eth0" while "my-wifi" is
> visible on any interface (OR logic)? I had hoped for the latter. 

It is AND logic only (with some Match conditions begin negatable in their own 
right). This Match configuration would be unlikely to ever trigger, unless 
somehow SSID 'my-wifi' is reachable on interface 'eth0'.


Re: [systemd-devel] systemd-networkd: switch between several static network setups on wired connection

2023-03-30 Thread fi
Hi Alvin,

On 2023-03-29 22:55, Alvin Šipraga wrote:
> Hi Torsten,
>
> On Wed, Mar 29, 2023 at 02:58:05PM +0200, f...@igh.de wrote:
> >
> > Dear Systemd Folx,
> >
> >
> >
> > I have a laptop that I run at different locations with different
> > networks. I want to have static(!) network setup (address, gateway, DNS,
> > NTP) for my wired adapter on these networks. I can define setup for
> > each of them in a .network file matching my interface (eth0), but only
> > the alphabetically first of them is taken into account.
> >
> > For now I create a symbolic link to the desired config and restart
> > systemd-netword.
> >
> > Is there a more straight forward way for chosing the actual setup, for
> > instance using networkctl?
>
> Unless you have something that networkd can notice is different about
> the interface from one location to another (cf. [Match] in the
> systemd.network(5) man page [1]), you will have to give it a kick in
> order to change its behaviour.

thanks for clarification. I was afraid that I had missed something.

Obviously that behavior results from the concept to ignore all but the
first matching configuration. Presumably it would have remarkable
design impact to put them into a list to chose from.

> But restarting the entire daemon is not strictly necessary. You can
> update the symlink you described and then run 'networkctl reload' to
> make it reload the .network and .link files. I think you will then have
> to run 'networkctl reconfigure eth0' as well.
>
> [1] 
> https://www.freedesktop.org/software/systemd/man/systemd.network.html#%5BMatch%5D%20Section%20Options

you are right - that is much more elegant.

> > Might there also be a chance to automatically chose a wired setup
> > depending on a local SSID visible?
>
> SSID is a wireless thing so it will not be something that a wired
> interface can match on.

I had not fully understood the logic of matching. If we had

  [Match]
  name = eth0
  SSID = my-wifi

would that mean, that "my-wifi" must be accessible via that interface
(AND logic) or could that mean we configure "eth0" while "my-wifi" is
visible on any interface (OR logic)? I had hoped for the latter. 

> But for wireless interfaces you can achieve what
> you want much better by using SSID= in the [Match] section.

yes of course :-) But wired connections have their advantages.

Best Regards

Torsten


-- 

Torsten Finke
f...@igh.de

Ingenieurgemeinschaft IgH
Gesellschaft für Ingenieurleistungen mbH
Heinz-Bäcker-Str. 34
D-45356 Essen



Re: [systemd-devel] how to let systemd hibernate start/stop the swap area?

2023-03-30 Thread Michael Chapman
On Thu, 30 Mar 2023, Greg KH wrote:
> On Thu, Mar 30, 2023 at 09:09:19PM +1100, Michael Chapman wrote:
> > On Thu, 30 Mar 2023, Luca Boccassi wrote:
> > > On Thu, 30 Mar 2023 at 10:15, Michael Chapman  
> > > wrote:
> > > >
> > > > On Thu, 30 Mar 2023, Lennart Poettering wrote:
> > > > > On Mi, 29.03.23 13:53, Christoph Anton Mitterer 
> > > > > (cales...@scientia.org) wrote:
> > > > >
> > > > > > > > That's a bad idea btw. I'd advise you not to do that: on modern
> > > > > > > > systems you want swap, since it makes anonymous memory 
> > > > > > > > reclaimable.
> > > > > > > > I
> > > > > > > > am not sure where you are getting this idea from that swap was
> > > > > > > > bad.
> > > > > >
> > > > > > Well I haven't said it's bad, but I guess it depends on the use case
> > > > > > any available RAM.
> > > > >
> > > > > In almost all scenarios you want swap, regardless if little RAM or a
> > > > > lot. For specialist cases where you run everything from memory, and
> > > > > not even programs are backed by disk there might be exceptions. But
> > > > > that#s almost never the case.
> > > >
> > > > One specific case where I deliberately chose _not_ to use swap: large
> > > > hypervisors with local storage.
> > > >
> > > > With swap on the host enabled, all that ended up happening was that 
> > > > local
> > > > IO activity caused idle guest memory to be gradually swapped out.
> > > > Eventually all of the swap space filled up, and the system was exactly
> > > > where it would have been had it not had any swap space configured in the
> > > > first place -- except that it was now _a lot_ slower to migrate those
> > > > swapped-out guests to other hypervisors.
> > > >
> > > > - Michael
> > > 
> > > The solution there is to ensure the cgroup configuration for the
> > > slices where the guests run have memory.swap.max=0, rather than
> > > disabling it for the whole system.
> > 
> > Perhaps, but given the rest of processes on the system need just a few 
> > hundred MB max, and the server has hundreds of GB of RAM, it really makes 
> > little difference. Turning off swap altogether is plain _simpler_.
> 
> So you penalize the runtime performance of guests for the infrequent
> migration delay?  Sounds like a bad trade-off for any real workload
> those guests are doing.  Shouldn't the goal of the system be to solve
> the problem the guests are trying to solve instead of being optimized
> for the infrequent administration tasks?

Err... how is ensuring the guests actually stay in memory "penalising 
their runtime performance"? If anything, it's exactly the opposite!

Note that the hypervisor wouldn't have been overprovisioned. If it were, 
say, a 256 GB server, I might only put 200 GB of guests on it. That still 
leaves around 50 GB for page cache, which is more than enough!

Adding a few GB of swap to the system would hardly make a difference.


Re: [systemd-devel] how to let systemd hibernate start/stop the swap area?

2023-03-30 Thread Greg KH
On Thu, Mar 30, 2023 at 09:09:19PM +1100, Michael Chapman wrote:
> On Thu, 30 Mar 2023, Luca Boccassi wrote:
> > On Thu, 30 Mar 2023 at 10:15, Michael Chapman  
> > wrote:
> > >
> > > On Thu, 30 Mar 2023, Lennart Poettering wrote:
> > > > On Mi, 29.03.23 13:53, Christoph Anton Mitterer (cales...@scientia.org) 
> > > > wrote:
> > > >
> > > > > > > That's a bad idea btw. I'd advise you not to do that: on modern
> > > > > > > systems you want swap, since it makes anonymous memory 
> > > > > > > reclaimable.
> > > > > > > I
> > > > > > > am not sure where you are getting this idea from that swap was
> > > > > > > bad.
> > > > >
> > > > > Well I haven't said it's bad, but I guess it depends on the use case
> > > > > any available RAM.
> > > >
> > > > In almost all scenarios you want swap, regardless if little RAM or a
> > > > lot. For specialist cases where you run everything from memory, and
> > > > not even programs are backed by disk there might be exceptions. But
> > > > that#s almost never the case.
> > >
> > > One specific case where I deliberately chose _not_ to use swap: large
> > > hypervisors with local storage.
> > >
> > > With swap on the host enabled, all that ended up happening was that local
> > > IO activity caused idle guest memory to be gradually swapped out.
> > > Eventually all of the swap space filled up, and the system was exactly
> > > where it would have been had it not had any swap space configured in the
> > > first place -- except that it was now _a lot_ slower to migrate those
> > > swapped-out guests to other hypervisors.
> > >
> > > - Michael
> > 
> > The solution there is to ensure the cgroup configuration for the
> > slices where the guests run have memory.swap.max=0, rather than
> > disabling it for the whole system.
> 
> Perhaps, but given the rest of processes on the system need just a few 
> hundred MB max, and the server has hundreds of GB of RAM, it really makes 
> little difference. Turning off swap altogether is plain _simpler_.

So you penalize the runtime performance of guests for the infrequent
migration delay?  Sounds like a bad trade-off for any real workload
those guests are doing.  Shouldn't the goal of the system be to solve
the problem the guests are trying to solve instead of being optimized
for the infrequent administration tasks?

good luck!

greg k-h


Re: [systemd-devel] how to let systemd hibernate start/stop the swap area?

2023-03-30 Thread Michael Chapman
On Thu, 30 Mar 2023, Luca Boccassi wrote:
> On Thu, 30 Mar 2023 at 10:15, Michael Chapman  wrote:
> >
> > On Thu, 30 Mar 2023, Lennart Poettering wrote:
> > > On Mi, 29.03.23 13:53, Christoph Anton Mitterer (cales...@scientia.org) 
> > > wrote:
> > >
> > > > > > That's a bad idea btw. I'd advise you not to do that: on modern
> > > > > > systems you want swap, since it makes anonymous memory reclaimable.
> > > > > > I
> > > > > > am not sure where you are getting this idea from that swap was
> > > > > > bad.
> > > >
> > > > Well I haven't said it's bad, but I guess it depends on the use case
> > > > any available RAM.
> > >
> > > In almost all scenarios you want swap, regardless if little RAM or a
> > > lot. For specialist cases where you run everything from memory, and
> > > not even programs are backed by disk there might be exceptions. But
> > > that#s almost never the case.
> >
> > One specific case where I deliberately chose _not_ to use swap: large
> > hypervisors with local storage.
> >
> > With swap on the host enabled, all that ended up happening was that local
> > IO activity caused idle guest memory to be gradually swapped out.
> > Eventually all of the swap space filled up, and the system was exactly
> > where it would have been had it not had any swap space configured in the
> > first place -- except that it was now _a lot_ slower to migrate those
> > swapped-out guests to other hypervisors.
> >
> > - Michael
> 
> The solution there is to ensure the cgroup configuration for the
> slices where the guests run have memory.swap.max=0, rather than
> disabling it for the whole system.

Perhaps, but given the rest of processes on the system need just a few 
hundred MB max, and the server has hundreds of GB of RAM, it really makes 
little difference. Turning off swap altogether is plain _simpler_.


Re: [systemd-devel] how to let systemd hibernate start/stop the swap area?

2023-03-30 Thread Luca Boccassi
On Thu, 30 Mar 2023 at 10:15, Michael Chapman  wrote:
>
> On Thu, 30 Mar 2023, Lennart Poettering wrote:
> > On Mi, 29.03.23 13:53, Christoph Anton Mitterer (cales...@scientia.org) 
> > wrote:
> >
> > > > > That's a bad idea btw. I'd advise you not to do that: on modern
> > > > > systems you want swap, since it makes anonymous memory reclaimable.
> > > > > I
> > > > > am not sure where you are getting this idea from that swap was
> > > > > bad.
> > >
> > > Well I haven't said it's bad, but I guess it depends on the use case
> > > any available RAM.
> >
> > In almost all scenarios you want swap, regardless if little RAM or a
> > lot. For specialist cases where you run everything from memory, and
> > not even programs are backed by disk there might be exceptions. But
> > that#s almost never the case.
>
> One specific case where I deliberately chose _not_ to use swap: large
> hypervisors with local storage.
>
> With swap on the host enabled, all that ended up happening was that local
> IO activity caused idle guest memory to be gradually swapped out.
> Eventually all of the swap space filled up, and the system was exactly
> where it would have been had it not had any swap space configured in the
> first place -- except that it was now _a lot_ slower to migrate those
> swapped-out guests to other hypervisors.
>
> - Michael

The solution there is to ensure the cgroup configuration for the
slices where the guests run have memory.swap.max=0, rather than
disabling it for the whole system.


Re: [systemd-devel] how to let systemd hibernate start/stop the swap area?

2023-03-30 Thread Michael Chapman
On Thu, 30 Mar 2023, Lennart Poettering wrote:
> On Mi, 29.03.23 13:53, Christoph Anton Mitterer (cales...@scientia.org) wrote:
> 
> > > > That's a bad idea btw. I'd advise you not to do that: on modern
> > > > systems you want swap, since it makes anonymous memory reclaimable.
> > > > I
> > > > am not sure where you are getting this idea from that swap was
> > > > bad.
> >
> > Well I haven't said it's bad, but I guess it depends on the use case
> > any available RAM.
> 
> In almost all scenarios you want swap, regardless if little RAM or a
> lot. For specialist cases where you run everything from memory, and
> not even programs are backed by disk there might be exceptions. But
> that#s almost never the case.

One specific case where I deliberately chose _not_ to use swap: large 
hypervisors with local storage.

With swap on the host enabled, all that ended up happening was that local 
IO activity caused idle guest memory to be gradually swapped out. 
Eventually all of the swap space filled up, and the system was exactly 
where it would have been had it not had any swap space configured in the 
first place -- except that it was now _a lot_ slower to migrate those 
swapped-out guests to other hypervisors.

- Michael