Re: [systemd-devel] make systemd service takes cpu exclusively

2014-12-01 Thread Lennart Poettering
On Wed, 19.11.14 20:05, Andrei Borzenkov (arvidj...@gmail.com) wrote:

 В Tue, 18 Nov 2014 06:25:43 +
 Cao, XinX xinx@intel.com пишет:
 
  Hi, Umut   David,
  
  My project needs the Graphical desktop to display on monitor as fast as 
  possible, but I found lots of unrelated services( such as sound, network, 
  ... ) are competing CPU even they are explicitly After graphical service. 
  And this competion delays the startup of graphical desktop process. So, my 
  opinion is to make graphical related programs runs first and  the other 
  unrelated services only starts after graphical program finished startup. 
 
 Let me guess. Your Graphical desktop is defined of simple or forking,
 right? So from systemd point of view service is started as soon as
 process is forked and it proceeds with starting further service defined
 After this one.

One minor correction: forking actually is supposed to provide
propery synchronization too, as daemons that use double-forking to
daemonize should return in the parent only after the daemon is fully
initialized. THis is in fact what classic sysv init scripts rely on to
properly serialize startup of services that need to talk to each
other.

Lennart

-- 
Lennart Poettering, Red Hat
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] make systemd service takes cpu exclusively

2014-11-27 Thread Cao, XinX
Hi, 

Yes, you are right. My service is defined as simple. And I changed it 
to notify, seems that I can make the other services  now successfully start 
after it finished startup. But I'm confused who will call sd_notify to send 
READY=1? I can't find the related code in system. Or the program itself?
For example, if the [Service] part of my service file is like this:

[Service]
Type=notify
NotifyAccess = all
   ExecStart = /usr/bin/abcdef
   ... ...

In this service , if I want to use notify type, need I add something 
like sd_notify(0,READY=1) in the code of abcdef ?



-Original Message-
From: Andrei Borzenkov [mailto:arvidj...@gmail.com] 
Sent: Thursday, November 20, 2014 01:06
To: Cao, XinX
Cc: Umut Tezduyar Lindskog; systemd-devel@lists.freedesktop.org
Subject: Re: [systemd-devel] make systemd service takes cpu exclusively

В Tue, 18 Nov 2014 06:25:43 +
Cao, XinX xinx@intel.com пишет:

 Hi, Umut   David,
   
   My project needs the Graphical desktop to display on monitor as fast as 
 possible, but I found lots of unrelated services( such as sound, network, ... 
 ) are competing CPU even they are explicitly After graphical service. And 
 this competion delays the startup of graphical desktop process. So, my 
 opinion is to make graphical related programs runs first and  the other 
 unrelated services only starts after graphical program finished startup. 

Let me guess. Your Graphical desktop is defined of simple or forking, right? So 
from systemd point of view service is started as soon as process is forked and 
it proceeds with starting further service defined After this one.

The problem with After is that it is effective only if systemd can know when 
service startup is completed. And in general it is possible only with types 
dbus or notify (and cooperating server). In case of GUI you do not even have 
single process representing service, depending on definition of Graphical 
desktop.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] make systemd service takes cpu exclusively

2014-11-27 Thread Mantas Mikulėnas
On Thu, Nov 27, 2014 at 12:56 PM, Cao, XinX xinx@intel.com wrote:

 Hi,

 Yes, you are right. My service is defined as simple. And I changed
 it to notify, seems that I can make the other services  now successfully
 start after it finished startup. But I'm confused who will call sd_notify
 to send READY=1? I can't find the related code in system. Or the program
 itself?


Yes, it has to be added to your program. That's the whole point of
Type=notify, after all – systemd can't know when your program is ready
unless the program tells it so.

-- 
Mantas Mikulėnas graw...@gmail.com
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] make systemd service takes cpu exclusively

2014-11-27 Thread Andrei Borzenkov
В Thu, 27 Nov 2014 12:44:50 +
Cao, XinX xinx@intel.com пишет:

 But it’s very strange, for I can’t find “sd_notify” or 
 “sd_notifyf” in my program, but seems that notify type can still work. So are 
 there any other functions able to do this ?

Sorry, I do not understand this. Could you try to rephrase?

 Thanks~~
 
 From: Mantas Mikulėnas [mailto:graw...@gmail.com]
 Sent: Thursday, November 27, 2014 20:15
 To: Cao, XinX
 Cc: systemd-devel@lists.freedesktop.org
 Subject: Re: [systemd-devel] make systemd service takes cpu exclusively
 
 On Thu, Nov 27, 2014 at 12:56 PM, Cao, XinX 
 xinx@intel.commailto:xinx@intel.com wrote:
 Hi,
 
 Yes, you are right. My service is defined as simple. And I changed it 
 to notify, seems that I can make the other services  now successfully start 
 after it finished startup. But I'm confused who will call sd_notify to send 
 READY=1? I can't find the related code in system. Or the program itself?
 
 Yes, it has to be added to your program. That's the whole point of 
 Type=notify, after all – systemd can't know when your program is ready unless 
 the program tells it so.
 
 --
 Mantas Mikulėnas graw...@gmail.commailto:graw...@gmail.com

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] make systemd service takes cpu exclusively

2014-11-27 Thread Tomasz Torcz
On Thu, Nov 27, 2014 at 12:44:50PM +, Cao, XinX wrote:
 But it’s very strange, for I can’t find “sd_notify” or
 “sd_notifyf” in my program, but seems that notify type can still work. So are
 there any other functions able to do this ?   Thanks~~

  Are you sure it's working?  If you specify notify for non-notify program,
it will start OK, but will get killed after 90s (by default).


-- 
Tomasz Torcz   Never underestimate the bandwidth of a station
xmpp: zdzich...@chrome.plwagon filled with backup tapes. -- Jim Gray

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] make systemd service takes cpu exclusively

2014-11-19 Thread Andrei Borzenkov
В Tue, 18 Nov 2014 06:25:43 +
Cao, XinX xinx@intel.com пишет:

 Hi, Umut   David,
   
   My project needs the Graphical desktop to display on monitor as fast as 
 possible, but I found lots of unrelated services( such as sound, network, ... 
 ) are competing CPU even they are explicitly After graphical service. And 
 this competion delays the startup of graphical desktop process. So, my 
 opinion is to make graphical related programs runs first and  the other 
 unrelated services only starts after graphical program finished startup. 

Let me guess. Your Graphical desktop is defined of simple or forking,
right? So from systemd point of view service is started as soon as
process is forked and it proceeds with starting further service defined
After this one.

The problem with After is that it is effective only if systemd can know
when service startup is completed. And in general it is possible only
with types dbus or notify (and cooperating server). In case of GUI you
do not even have single process representing service, depending on
definition of Graphical desktop.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] make systemd service takes cpu exclusively

2014-11-17 Thread Cao, XinX
Hi, everybody,

As we all know that currently systemd puts all the services into a 
run_queue, and lets them run together as possible as it can. However, this 
mechanism also brings in a problem, which means all the services will contend 
for CPU, and systemd is unable to make sure one service has priority ONE  and 
only itself takes the CPU when this service is starting.

For example, if we want to make sure a.service runs firstly , and 
all the other services runs after  a.service is finished.

So, does anybody know if systemd has this kind of mechanism?  If 
not, can we create a way to do this and add this feature into systemd? Or  is 
this idea possible?  I think this is very usefull under some situations.

Thanks~
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] make systemd service takes cpu exclusively

2014-11-17 Thread David Herrmann
Hi

On Mon, Nov 17, 2014 at 9:40 AM, Cao, XinX xinx@intel.com wrote:
 Hi, everybody,



 As we all know that currently systemd puts all the services into
 a run_queue, and lets them run together as possible as it can. However, this
 mechanism also brings in a problem, which means all the services will
 contend for CPU, and systemd is unable to make sure one service has priority
 ONE  and only itself takes the CPU when this service is starting.



 For example, if we want to make sure a.service runs firstly ,
 and all the other services runs after  a.service is finished.



 So, does anybody know if systemd has this kind of mechanism?  If
 not, can we create a way to do this and add this feature into systemd? Or
 is this idea possible?  I think this is very usefull under some situations.

You could use explicit ordering (see Before= and After=) to make your
unit run almost exclusively. But this will cause a significant
bottle-neck during boot and is not recommended at all. The question
really is _why_ you want that unit to be run before anything else.

If you only want to prioritize one unit, have a look at man
systemd.resource-control. It provides a huge set of options to
configure your units. You have quite fine control over CPU shares etc.
Specifically the StartupCPUShares= option might be of interest to you.

Thanks
David
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] make systemd service takes cpu exclusively

2014-11-17 Thread Umut Tezduyar Lindskog
Hi XinX

On Mon, Nov 17, 2014 at 9:40 AM, Cao, XinX xinx@intel.com wrote:
 Hi, everybody,



 As we all know that currently systemd puts all the services into
 a run_queue, and lets them run together as possible as it can. However, this
 mechanism also brings in a problem, which means all the services will
 contend for CPU, and systemd is unable to make sure one service has priority
 ONE  and only itself takes the CPU when this service is starting.

What exactly is the problem when they all want to get the CPU?




 For example, if we want to make sure a.service runs firstly ,
 and all the other services runs after  a.service is finished.



 So, does anybody know if systemd has this kind of mechanism?  If
 not, can we create a way to do this and add this feature into systemd? Or
 is this idea possible?  I think this is very usefull under some situations.

It really depends on your use case and what you consider with
a.service runs first.

If you only want to start the service first, then you can always add
After=a.service directive to other services that are starting at the
same time. But this is pretty static information. You have to do this
for every time you change your priority service.

You could also prioritize a service by changing their
StartupCPUShares= but this is not truly stopping other services from
being scheduled in. Maybe they get the minimum CPU, but they still do.

Lennart has recently considered to change the startup queue to
prioritized startup queue where a prioritized service will be forked
off before other services -
http://lists.freedesktop.org/archives/systemd-devel/2014-October/024315.html.

Umut




 Thanks~


 ___
 systemd-devel mailing list
 systemd-devel@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/systemd-devel

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] make systemd service takes cpu exclusively

2014-11-17 Thread Cao, XinX
Hi, Umut   David,

My project needs the Graphical desktop to display on monitor as fast as 
possible, but I found lots of unrelated services( such as sound, network, ... ) 
are competing CPU even they are explicitly After graphical service. And this 
competion delays the startup of graphical desktop process. So, my opinion is to 
make graphical related programs runs first and  the other unrelated services 
only starts after graphical program finished startup. I will check  
StartupCPUShares= this item and I hope it's helpful for me.

Thanks

-Original Message-
From: Umut Tezduyar Lindskog [mailto:u...@tezduyar.com] 
Sent: Monday, November 17, 2014 17:51
To: Cao, XinX
Cc: systemd-devel@lists.freedesktop.org
Subject: Re: [systemd-devel] make systemd service takes cpu exclusively

Hi XinX

On Mon, Nov 17, 2014 at 9:40 AM, Cao, XinX xinx@intel.com wrote:
 Hi, everybody,



 As we all know that currently systemd puts all the 
 services into a run_queue, and lets them run together as possible as 
 it can. However, this mechanism also brings in a problem, which means 
 all the services will contend for CPU, and systemd is unable to make 
 sure one service has priority ONE  and only itself takes the CPU when this 
 service is starting.

What exactly is the problem when they all want to get the CPU?




 For example, if we want to make sure a.service runs 
 firstly , and all the other services runs after  a.service is finished.



 So, does anybody know if systemd has this kind of 
 mechanism?  If not, can we create a way to do this and add this 
 feature into systemd? Or is this idea possible?  I think this is very usefull 
 under some situations.

It really depends on your use case and what you consider with a.service runs 
first.

If you only want to start the service first, then you can always add 
After=a.service directive to other services that are starting at the same time. 
But this is pretty static information. You have to do this for every time you 
change your priority service.

You could also prioritize a service by changing their StartupCPUShares= but 
this is not truly stopping other services from being scheduled in. Maybe they 
get the minimum CPU, but they still do.

Lennart has recently considered to change the startup queue to prioritized 
startup queue where a prioritized service will be forked off before other 
services - 
http://lists.freedesktop.org/archives/systemd-devel/2014-October/024315.html.

Umut




 Thanks~


 ___
 systemd-devel mailing list
 systemd-devel@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/systemd-devel

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel