A common layer for Accounting packages
Subsystems (6)
It started with the need of CSA to handle end-of-process (eop) at do_exit() at exit.c. The hook at exit.c was BSD Accounting specific.
Since the need of Linux system accounting has gone beyond what BSD accounting provides, i think it is a good idea to create a thin layer of common code for various accounting packages, such as BSD accounting, CSA, ELSA, etc. The hook to do_exit() at exit.c was changed to invoke a routine in the common code which would then invoke those accounting packages that register to the acct_common to handle do_exit situation.
Here is the description of this acct_common patch:
1) two new files at include/linux/acct_common.h and kernel/acct_common.c
2) A new config flag CONFIG_ACCT_COMMON is created and CONFIG_BSD_PROCESS_ACCT and a future CSA config flag depend on it. I think it is a good idea to always have acct_common in the kernel; in that case, the new config flag may not be really necessary. I can go either way.
3) Accounting packages can register themselves to acct_common for callbacks. Only do_exit handling is defined now. BSD acct.c has been modified to register/unergister to acct_common.
4) The 'enhanced acct data collection' routines have been moved from acct.c to acct_common.c. Files used to #include <linux/acct.h> were modified to #include <linux/acct_common.h>.
This patch was generated against 2.6.11-rc3-mm2.
kernel/fork.c +1 -1
@@ -40,7 +40,7 @@#include <linux/audit.h> #include <linux/profile.h> #include <linux/rmap.h> -#include <linux/acct.h> +#include <linux/acct_common.h> #include <asm/pgtable.h> #include <asm/pgalloc.h>
fs/exec.c +1 -1
@@ -47,7 +47,7 @@#include <linux/security.h> #include <linux/syscalls.h> #include <linux/rmap.h> -#include <linux/acct.h> +#include <linux/acct_common.h> #include <asm/uaccess.h> #include <asm/mmu_context.h>
kernel/exit.c +2 -2
@@ -17,7 +17,7 @@#include <linux/key.h> #include <linux/security.h> #include <linux/cpu.h> -#include <linux/acct.h> +#include <linux/acct_common.h> #include <linux/file.h> #include <linux/binfmts.h> #include <linux/ptrace.h>
@@ -814,7 +814,7 @@ fastcall NORET_TYPE void do_exit(long co group_dead =atomic_dec_and_test (&tsk->signal->live);if (group_dead) {del_timer_sync (&tsk->signal->real_timer); -acct_process (code); +acct_do_exit (code, tsk); }exit_mm (tsk);
include/linux/acct_common.h new file +83 -0
83 lines not on this page · raw message
include/linux/acct.h +2 -6
@@ -119,14 +119,10 @@ struct acct_v3#ifdef CONFIG_BSD_PROCESS_ACCT struct super_block ;extern void acct_auto_close (struct super_block *sb); -extern void acct_process (long exitcode); -extern void acct_update_integrals (struct task_struct *tsk); -extern void acct_clear_integrals (struct task_struct *tsk); +extern void acct_process (long exitcode,void *data);#else #define acct_auto_close (x) do { } while (0) -#define acct_process (x) do { } while (0) -#define acct_update_integrals (x) do { } while (0) -#define acct_clear_integrals (task) do { } while (0) +#define acct_process (x,y) do { } while (0)#endif /*
kernel/acct.c +35 -30
86 lines not on this page · raw message
kernel/acct_common.c new file +166 -0
166 lines not on this page · raw message
kernel/Makefile +1 -0
@@ -16,6 +16,7 @@ obj-$(CONFIG_UID16) += uid16.o obj-$(CONFIG_MODULES) += module.o obj-$(CONFIG_KALLSYMS) += kallsyms.o obj-$(CONFIG_PM) += power/ +obj-$(CONFIG_ACCT_COMMON) += acct_common.o obj-$(CONFIG_BSD_PROCESS_ACCT) += acct.o obj-$(CONFIG_KEXEC) += kexec.o obj-$(CONFIG_COMPAT) += compat.o
init/Kconfig +11 -0
@@ -113,8 +113,19 @@ config POSIX_MQUEUE If unsure, say Y. +config ACCT_COMMON + bool "Accounting Comon Layer" + help + If you say Y here, an accounting common code is built into the + kernel. In addition to common code for various accounting + agents, such as BSD Process Accounting, CSA, ELSA, etc., this code + allows various accounting agents to register to it. + + If you ever need system accounting, you need this; so say Y. + config BSD_PROCESS_ACCT bool "BSD Process Accounting" + depends on ACCT_COMMON help If you say Y here, a user level program will be able to instruct the kernel (via a special system call) to write process accounting
kernel/sched.c +1 -1
@@ -48,7 +48,7 @@#include <linux/sysctl.h> #include <linux/syscalls.h> #include <linux/times.h> -#include <linux/acct.h> +#include <linux/acct_common.h> #include <asm/tlb.h> #include <asm/unistd.h>
Quoted 7 lines · Jay Lan
Since the need of Linux system accounting has gone beyond what BSD accounting provides, i think it is a good idea to create a thin layer of common code for various accounting packages, such as BSD accounting, CSA, ELSA, etc. The hook to
do_exit()atexit.cwas changed to invoke a routine in the common code which would then invoke those accounting packages that register to theacct_commonto handledo_exitsituation.
This all seems to be heading in the wrong direction. Do we really want to have lots of different system accounting packages all hooking into a generic we-cant-decide-what-to-do-so-we-added-some-pointless-overhead framework?
Can't we get _one_ accounting system in there, get it right, avoid the framework?
Quoted 9 lines · Andrew Morton
Quoted 7 lines · Jay Lan
Since the need of Linux system accounting has gone beyond what BSD accounting provides, i think it is a good idea to create a thin layer of common code for various accounting packages, such as BSD accounting, CSA, ELSA, etc. The hook to
do_exit()atexit.cwas changed to invoke a routine in the common code which would then invoke those accounting packages that register to theacct_commonto handledo_exitsituation.
Quoted 7 lines
This all seems to be heading in the wrong direction. Do we really want to have lots of different system accounting packages all hooking into a generic we-cant-decide-what-to-do-so-we-added-some-pointless-overhead framework?
Can't we get _one_ accounting system in there, get it right, avoid the framework?
Is it possible to just merge the BSD accounting and the CSA accounting
by adding in the current BSD per-process accounting structure some missing fields like the mm integral provided by the CSA patch?
ELSA is just a user of the accounting data. We need a hook in the do_fork() routine to manage group of processes, not to do accounting.
Guillaume
Hello, everyone.
Quoted 10 lines · Andrew Morton
Quoted 6 lines · Jay Lan
Since the need of Linux system accounting has gone beyond what BSD accounting provides, i think it is a good idea to create a thin layer of common code for various accounting packages, such as BSD accounting, CSA, ELSA, etc. The hook to
do_exit()atexit.cwas changed to invoke a routine in the common code which would then invoke those accounting packages that register to theacct_commonto handledo_exitsituation.
Quoted 7 lines
This all seems to be heading in the wrong direction. Do we really want to have lots of different system accounting packages all hooking into a generic we-cant-decide-what-to-do-so-we-added-some-pointless-overhead framework?
Can't we get _one_ accounting system in there, get it right, avoid the framework?
I think there are two issues about system accounting framework.
Issue: 1) How to define the appropriate unit for accounting ? Current BSD-accountiong make a collection per process accounting information. CSA make additionally a collection per process-aggregation accounting.
It is appropriate to make the fork-exit event handling framework for definition of the process-aggregation, such as PAGG.
This system-accounting per process-aggregation is quite useful, thought I tried the SGI's implementation named 'job' in past days.
Issue: 2) What items should be collected for accounting information ? BSD-accounting collects PID/UID/GID, User/Sys/Elapsed-Time, and # of minor/major page faults. SGI's CSA collects VM/RSS size on exit time, Integral-VM/RSS, and amount of block-I/O additionally.
I think it's hard to implement the accounting-engine as a kernel loadable module using any kinds of framework. Because, we must put callback functions into all around the kernel for this purpose.
Thus, I make a proposion as follows:
We should separate the process-aggregation functionality and collecting accounting informations.
Something of framework to implement process-aggregation is necessary. And, making a collection of accounting information should be merged into BSD-accounting and implemented as a part of monolithic kernel as Guillaume said.
Thanks.
Signature · 2 lines
Linux Promotion Center, NEC KaiGai Kohei <[email protected]>
Quoted 16 lines · Guillaume Thouvenin
Quoted 14 lines · Andrew Morton
Quoted 6 lines · Jay Lan
Since the need of Linux system accounting has gone beyond what BSD accounting provides, i think it is a good idea to create a thin layer of common code for various accounting packages, such as BSD accounting, CSA, ELSA, etc. The hook to
do_exit()atexit.cwas changed to invoke a routine in the common code which would then invoke those accounting packages that register to theacct_commonto handledo_exitsituation.This all seems to be heading in the wrong direction. Do we really want to have lots of different system accounting packages all hooking into a generic we-cant-decide-what-to-do-so-we-added-some-pointless-overhead framework?
Quoted 7 lines
Quoted 2 lines
Can't we get _one_ accounting system in there, get it right, avoid the framework?
Is it possible to just merge the BSD accounting and the CSA accounting
by adding in the current BSD per-process accounting structure some missing fields like the mm integral provided by the CSA patch?
Hi Guillaume,
All raw data CSA needs already stored in task_struct of the process.
Quoted 3 lines
ELSA is just a user of the accounting data. We need a hook in the
do_fork()routine to manage group of processes, not to do accounting.
I see at least three layers of functions in doing system accounting:
data collection, handling of the raw data, and presentation of the data to users.
We have merged the data collection part. :)
Handling of the raw data seems done in ELSA by user spaced daemon and you are proposing to add a hook at fork time. I am interested in learning your approach. How ELSA adds per process accounting data to your grouping (banks) when a process exit? How do you save accounting data you need in task_struct before it is disposed? BSD handles that through acct_process() hook at do_exit(). CSA also depends on a hook at do_exit() to merge per-process data to per-job data. How does ELSA handle this without a need of a do_exit() hook?
Thanks,
- jay
Quoted 14 lines
Guillaume
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Lse-tech mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/lse-tech
Quoted 19 lines · Kaigai Kohei
Hello, everyone.
Quoted 11 lines · Andrew Morton
Quoted 6 lines · Jay Lan
Since the need of Linux system accounting has gone beyond what BSD accounting provides, i think it is a good idea to create a thin layer of common code for various accounting packages, such as BSD accounting, CSA, ELSA, etc. The hook to
do_exit()atexit.cwas changed to invoke a routine in the common code which would then invoke those accounting packages that register to theacct_commonto handledo_exitsituation.This all seems to be heading in the wrong direction. Do we really
want to
Quoted 4 lines
have lots of different system accounting packages all hooking into a generic we-cant-decide-what-to-do-so-we-added-some-pointless-overhead framework?
Quoted 8 lines
Quoted 2 lines
Can't we get _one_ accounting system in there, get it right, avoid the framework?
I think there are two issues about system accounting framework.
Issue: 1) How to define the appropriate unit for accounting ? Current BSD-accountiong make a collection per process accounting information. CSA make additionally a collection per process-aggregation accounting.
The 'enhanced acct data collection' patches that were added to 2-6-11-rc* tree still do collection of per process data.
CSA added those per-process data to per-aggregation ("job") data structure at do_exit() time when a process termintes.
Quoted 4 lines
It is appropriate to make the fork-exit event handling framework for definition of the process-aggregation, such as PAGG.
Quoted 8 lines
This system-accounting per process-aggregation is quite useful, thought I tried the SGI's implementation named 'job' in past days.
Issue: 2) What items should be collected for accounting information ? BSD-accounting collects PID/UID/GID, User/Sys/Elapsed-Time, and # of minor/major page faults. SGI's CSA collects VM/RSS size on exit time, Integral-VM/RSS, and amount of block-I/O additionally.
These data are now collected in 2.6.11-rc* code. Note that these data are still per-process.
Quoted 8 lines
I think it's hard to implement the accounting-engine as a kernel loadable module using any kinds of framework. Because, we must put callback functions into all around the kernel for this purpose.
Thus, I make a proposion as follows:
We should separate the process-aggregation functionality and collecting accounting informations.
I totally agree with this! Actually that was what we have done. The data collection part of code has been unified.
Quoted 4 lines
Something of framework to implement process-aggregation is necessary. And, making a collection of accounting information should be merged into BSD-accounting and implemented as a part of monolithic kernel as Guillaume said.
This sounds good. I am interested in learning how ELSA saves off the per-process accounting data before the data got disposed. If that scheme works for CSA, we would be very happy to adopt the scheme. The current BSD scheme is very insufficient. The code is very BSD centric and it provides no way to handle process-aggregation.
Thanks,
- jay
Quoted 2 lines
Thanks.
Hi, Thanks for your comments.
Quoted 10 lines
Quoted 6 lines
I think there are two issues about system accounting framework.
Issue: 1) How to define the appropriate unit for accounting ? Current BSD-accountiong make a collection per process accounting information.
CSA make additionally a collection per process-aggregation accounting.The 'enhanced acct data collection' patches that were added to 2-6-11-rc* tree still do collection of per process data.
Hmm, I have not noticed this extension. But I made sure about it. The following your two patches implements enhanced data collection, didn't it?
- ChangeLog for 2.6.11-rc1
[PATCH] enhanced I/O accounting data patch [PATCH] enhanced Memory accounting data collection
Since making a collection per process accounting is unified to the stock kernel, I want to have a discussion about remaining half, "How to define the appropriate unit for accounting ?"
We can agree that only per process-accounting is so rigid, I think. Then, process-aggregation should be provided in one way or another.
[1] Is it necessary 'fork/exec/exit' event handling framework ?
The common agreement for the method of dealing with process aggregation has not been constructed yet, I understood. And, we will not able to integrate each process aggregation model because of its diverseness.
For example, a process which belong to JOB-A must not belong any other 'JOB-X' in CSA-model. But, In ELSA-model, a process in BANK-B can concurrently belong to BANK-B1 which is a child of BANK-B.
And, there are other defferences:
Whether a process not to belong to any process-aggregation is permitted or not ? Whether a process-aggregation should be inherited to child process or not ? (There is possibility not to be inherited in a rule-based process aggregation like CKRM)
Some process-aggregation model have own philosophy and implemantation, so it's hard to integrate. Thus, I think that common 'fork/exec/exit' event handling framework to implement any kinds of process-aggregation.
[2] What implementation should be adopted ?
I think registerable hooks on fork/execve/exit is necessary, not only exit() hook. Because a rule or policy based process-aggregation model requirees to catch the transition of a process status.
It might be enough to hook the exit() event only in process-accounting, but it's not kind for another customer.
Thus, I recommend SGI's PAGG.
In my understanding, the reason for not to include such a framework is that increase of unidentifiable (proprietary) modules is worried. But, SI can divert LSM to implemente process-aggregation if they ignore the LSM's original purpose, for example.
# I'm strongly opposed to such a movement as a SELinux's user :-)
So, I think such a fork/execve/exit hooks is harmless now. Is this the time to unify it?
Thanks.
Quoted 52 lines
CSA added those per-process data to per-aggregation ("job") data structure at
do_exit()time when a process termintes.Quoted 5 lines
It is appropriate to make the fork-exit event handling framework for definition
of the process-aggregation, such as PAGG.Quoted 8 lines
This system-accounting per process-aggregation is quite useful, thought I tried the SGI's implementation named 'job' in past days.
Issue: 2) What items should be collected for accounting information ? BSD-accounting collects PID/UID/GID, User/Sys/Elapsed-Time, and # of minor/major page faults. SGI's CSA collects VM/RSS size on exit time, Integral-VM/RSS, and amount of block-I/O additionally.
These data are now collected in 2.6.11-rc* code. Note that these data are still per-process.
Quoted 9 lines
I think it's hard to implement the accounting-engine as a kernel loadable module using any kinds of framework. Because, we must put callback functions
into all around the kernel for this purpose.Thus, I make a proposion as follows:
We should separate the process-aggregation functionality and collecting accounting informations.I totally agree with this! Actually that was what we have done. The data collection part of code has been unified.
Quoted 4 lines
Something of framework to implement process-aggregation is necessary. And, making a collection of accounting information should be merged into BSD-accounting and implemented as a part of monolithic kernel as Guillaume said.
This sounds good. I am interested in learning how ELSA saves off the per-process accounting data before the data got disposed. If that scheme works for CSA, we would be very happy to adopt the scheme. The current BSD scheme is very insufficient. The code is very BSD centric and it provides no way to handle process-aggregation.
Thanks,
- jayQuoted 2 lines
Thanks.
Signature · 2 lines
Linux Promotion Center, NEC KaiGai Kohei <[email protected]>
Quoted 9 lines · Kaigai Kohei
The common agreement for the method of dealing with process aggregation has not been constructed yet, I understood. And, we will not able to integrate each process aggregation model because of its diverseness.
For example, a process which belong to JOB-A must not belong any other 'JOB-X' in CSA-model. But, In ELSA-model, a process in BANK-B can concurrently belong to BANK-B1 which is a child of BANK-B.
Quoted 8 lines
And, there are other defferences:
Whether a process not to belong to any process-aggregation is permitted or not ? Whether a process-aggregation should be inherited to child process or not ? (There is possibility not to be inherited in a rule-based process aggregation like CKRM)Some process-aggregation model have own philosophy and implemantation, so it's hard to integrate. Thus, I think that common 'fork/exec/exit' event handling framework to implement any kinds of process-aggregation.
We really want to avoid doing such stuff in-kernel if at all possible, of course.
Is it not possible to implement the fork/exec/exit notifications to userspace so that a daemon can track the process relationships and perform aggregation based upon individual tasks' accounting? That's what one of the accounting systems is proposing doing, I believe.
(In fact, why do we even need the notifications? /bin/ps can work this stuff out).
Quoted 6 lines · Jay Lan
How ELSA adds per process accounting data
to your grouping (banks) when a process exit? How do you save accounting data you need intask_structbefore it is disposed? BSD handles that throughacct_process()hook atdo_exit(). CSA also depends on a hook atdo_exit()to merge per-process data to per-job data. How does ELSA handle this without a need of ado_exit()hook?
There are three parts in ELSA.
There is a job daemon that does process aggregation. It needs a hook
in the do_fork() routine to be able to manage group of processes. So this part handles process-aggregation by maintaining a complete picture of the process/thread hierarchy.
You can interact with the job daemon with classical IPC and message
operations. Thus we wrote a second part that is the interface between the user and the job daemon. Through this interface you can add and remove a process in/from a group, you can stop the job daemon and you can dump information in a file about current group of processes.
This file (that contains information about group of processes) is used
by ELSA, with the accounting file provided by the accton(8) command and the BSD accounting, to provide per-group of process accounting. So the third part of ELSA is a parser and also an analyzer.
The architecture of ELSA is as follow (I hope that the ASCII picture
will be readable):
KERNEL | USER SPACE
|
------------------- | ---------------
| 1. Fork connector | Netlink | 2. Job Daemon |
| |---------->| |
------------------- | ---------------
| ^
| | IPC -----------------
| ---->| 3. Interface |
| | (webmin, ...) |---
| --->| | |
| | ----------------- |
| Per-group of
Accounting File processes
(see accton(8)) accountingYou can see how it works on the following web page:
http://elsa.sourceforge.net/sample_session.html
In the session we're using the fork_history.ko which will be replace by the fork hook connector.
Best regards,
Guillaume
Quoted 10 lines · Andrew Morton
Quoted 9 lines · Kaigai Kohei
The common agreement for the method of dealing with process aggregation has not been constructed yet, I understood. And, we will not able to integrate each process aggregation model because of its diverseness.
For example, a process which belong to JOB-A must not belong any other 'JOB-X' in CSA-model. But, In ELSA-model, a process in BANK-B can concurrently belong to BANK-B1 which is a child of BANK-B.
Quoted 8 lines
Quoted 8 lines
And, there are other defferences:
Whether a process not to belong to any process-aggregation is permitted or not ? Whether a process-aggregation should be inherited to child process or not ? (There is possibility not to be inherited in a rule-based process aggregation like CKRM)Some process-aggregation model have own philosophy and implemantation, so it's hard to integrate. Thus, I think that common 'fork/exec/exit' event handling framework to implement any kinds of process-aggregation.
I can add "policies". With ELSA, a process belongs to one or several groups and if a process is removed from one group, its children still belong to the group. Thus a good idea could be to associate a "philosophy" to a group. For exemple, when a group of processes is created it can be tagged as UNIQUE or SHARED. UNIQUE means that a process that belongs to it could not be added in another group by opposition to SHARED. It's not needed inside the kernel.
Quoted 7 lines
We really want to avoid doing such stuff in-kernel if at all possible, of course.
Is it not possible to implement the fork/exec/exit notifications to userspace so that a daemon can track the process relationships and perform aggregation based upon individual tasks' accounting? That's what one of the accounting systems is proposing doing, I believe.
It's what I'm proposing. The problem is to be alerted when a new process is created in order to add it in the correct group of processes if the parent belongs to one (or several) groups. The notification can be done with the fork connector patch.
Quoted 2 lines
(In fact, why do we even need the notifications?
/bin/pscan work this stuff out).
Yes it can but the risk is to lose some forks no?
I think that /bin/ps is using the /proc interface. If we're polling the /proc to catch process creation we may lost some of them. With the fork connector we catch all forks and we can check that by using the sequence number (incremented by each fork) of the message.
Guillaume
Quoted 11 lines · Guillaume Thouvenin
...
Quoted 7 lines
We really want to avoid doing such stuff in-kernel if at all possible, of course.
Is it not possible to implement the fork/exec/exit notifications to userspace so that a daemon can track the process relationships and perform aggregation based upon individual tasks' accounting? That's what one of the accounting systems is proposing doing, I believe.
Quoted 4 lines
It's what I'm proposing. The problem is to be alerted when a new process is created in order to add it in the correct group of processes if the parent belongs to one (or several) groups. The notification can be done with the fork connector patch.
Yes, it sounds sane.
The 2.6.8.1 ELSA patch adds quite a bit of kernel code, but from what you're saying it seems like most of that has become redundant, and all you now need is the fork notifier. Is that correct?
That 2.6.8.1 ELSA patch looks reasonable to me - it only adds two lines to generic code and the rest looks pretty straightforward. Are we sure that this level of functionality is not sufficient for everyone else?
Quoted 8 lines
Quoted 2 lines
(In fact, why do we even need the notifications?
/bin/pscan work this stuff out).Yes it can but the risk is to lose some forks no?
I think that/bin/psis using the /proc interface. If we're polling the /proc to catch process creation we may lost some of them. With the fork connector we catch all forks and we can check that by using the sequence number (incremented by each fork) of the message.
Oh, I wasn't proposing that it all be done via existing /proc interfaces - I was just getting my head straight ;)
Quoted 10 lines · Andrew Morton
Quoted 4 lines
It's what I'm proposing. The problem is to be alerted when a new process is created in order to add it in the correct group of processes if the parent belongs to one (or several) groups. The notification can be done with the fork connector patch.
Yes, it sounds sane.
The 2.6.8.1 ELSA patch adds quite a bit of kernel code, but from what you're saying it seems like most of that has become redundant, and all you now need is the fork notifier. Is that correct?
Yes, that's correct. All I need is the fork connector patch. It needs
more work like, as you said, sending an on/off message down the netlink socket. I'm working on this (thank you very much Andrew for your comments).
I will run benchmarks found at http://bulk.fefe.de/scalability/ to see
how the fork connector impacts on the kernel.
All stuff that was previously done in kernel space and provided by the
2.6.8.1 ELSA patch has been moved in the ELSA user space daemon called "jobd".
Best,
Guillaume
Quoted 3 lines · Guillaume Thouvenin
I will run benchmarks found at http://bulk.fefe.de/scalability/ to see
how the fork connector impacts on the kernel.
The lmbench fork microbenchmark would suffice.
Quoted 3 lines
All stuff that was previously done in kernel space and provided by the
2.6.8.1 ELSA patch has been moved in the ELSA user space daemon called "jobd".
Excellent. Will it work?
Quoted 10 lines · Andrew Morton
We really want to avoid doing such stuff in-kernel if at all possible, of course.
Is it not possible to implement the fork/exec/exit notifications to userspace so that a daemon can track the process relationships and perform aggregation based upon individual tasks' accounting? That's what one of the accounting systems is proposing doing, I believe.
(In fact, why do we even need the notifications?
/bin/pscan work this stuff out).
I had started a proof of concept implementation that could reconstruct the whole process tree from userspace just from the BSD accounting currently in the kernel (+ the conceptual bug-fix that I misnamed "[RFC] "biological parent" pid"). This could do the whole job ID thing from userspace. Unfortunately, I haven't had time to work on it recently.
Also, doing per-job accounting might actually be more lightweight than per-process accounting, so I'm not at all opposed to unifying CSA and BSD accounting into one mechanism that just writes different file formats.
A complete framework seems like overkill to me, too.
Tim
Hi, Thanks for your comments.
Quoted 8 lines · Andrew Morton
Quoted 3 lines
Some process-aggregation model have own philosophy and implemantation, so it's hard to integrate. Thus, I think that common 'fork/exec/exit' event handling framework to implement any kinds of process-aggregation.
We really want to avoid doing such stuff in-kernel if at all possible, of course.
Quoted 7 lines
Is it not possible to implement the fork/exec/exit notifications to userspace so that a daemon can track the process relationships and perform aggregation based upon individual tasks' accounting? That's what one of the accounting systems is proposing doing, I believe.
(In fact, why do we even need the notifications?
/bin/pscan work this stuff out).
It's hard to prove that we can't implement the process-aggregation only in user-space, but there are some difficulties on imaplementation, I think.
For example, each process must have a tag or another identifier to explain what process-aggregation does it belong, but kernel does not support thoes kind of information, currently. Thus, we can't guarantee associating one process-aggregation with one process.
# /proc/<uid>/loginuid might be candidate, but it's out of original purpose.
We might be able to make alike system, but is it hard to implement strict process-aggregation without any kernel supports?
I think that well thought out kernel-modification is better than ad-hoc implementation on user-space.
Thanks.
Signature · 2 lines
Linux Promotion Center, NEC KaiGai Kohei <[email protected]>
Quoted 22 lines · Guillaume Thouvenin
Quoted 10 lines · Andrew Morton
Quoted 8 lines · Kaigai Kohei
The common agreement for the method of dealing with process aggregation has not been constructed yet, I understood. And, we will not able to integrate each process aggregation model because of its diverseness.
For example, a process which belong to JOB-A must not belong any other 'JOB-X' in CSA-model. But, In ELSA-model, a process in BANK-B can concurrently belong to BANK-B1 which is a child of BANK-B.
Quoted 8 lines
Quoted 8 lines
And, there are other defferences:
Whether a process not to belong to any process-aggregation is permitted or not ? Whether a process-aggregation should be inherited to child process or not ? (There is possibility not to be inherited in a rule-based process aggregation like CKRM)Some process-aggregation model have own philosophy and implemantation, so it's hard to integrate. Thus, I think that common 'fork/exec/exit' event handling framework to implement any kinds of process-aggregation.
Quoted 7 lines
I can add "policies". With ELSA, a process belongs to one or several groups and if a process is removed from one group, its children still belong to the group. Thus a good idea could be to associate a "philosophy" to a group. For exemple, when a group of processes is created it can be tagged as UNIQUE or SHARED. UNIQUE means that a process that belongs to it could not be added in another group by opposition to SHARED. It's not needed inside the kernel.
This makes sense to me. CSA can use the UNIQUE policy to enforce its "can't escape from job container" philisophy.
Quoted 11 lines
Quoted 9 lines
We really want to avoid doing such stuff in-kernel if at all possible, of course.
Is it not possible to implement the fork/exec/exit notifications to userspace so that a daemon can track the process relationships and perform aggregation based upon individual tasks' accounting? That's what one of the accounting systems is proposing doing, I believe.
Quoted 4 lines
It's what I'm proposing. The problem is to be alerted when a new process is created in order to add it in the correct group of processes if the parent belongs to one (or several) groups. The notification can be done with the fork connector patch.
I am not quite comfortable of ELSA requesting a fork hook this way. How many hooks in the stock kernel that are related to accounting? Can anyone answer this question? I know of 'acct_process()' in exit.c used by the BSD accounting and ELSA is requesting a hook in fork. If people raise the same question again a few years later, how many people will still remember this ELSA hook?
That was the reason i thought a central piece was a good idea. I would rather see the fork hook is coded in acct.c and then invokes a routine that handles what ELSA needs. If CSA would adopt the ELSA's daemon's approach, CSA may also need to use the fork hook.
Actually the acct_process() was modified not long ago to become a wrapper, which then invokes do_acct_process() which is completely BSD specific. The fork hook can be the same.
- jay
Quoted 12 lines
Quoted 4 lines
(In fact, why do we even need the notifications?
/bin/pscan work this stuff out).Yes it can but the risk is to lose some forks no? I think that
/bin/psis using the /proc interface. If we're polling the /proc to catch process creation we may lost some of them. With the
fork connector we catch all forks and we can check that by using the
sequence number (incremented by each fork) of the message.Guillaume
Quoted 10 lines · Kaigai Kohei
Hi, Thanks for your comments.
Quoted 8 lines
Quoted 6 lines
I think there are two issues about system accounting framework.
Issue: 1) How to define the appropriate unit for accounting ? Current BSD-accountiong make a collection per process accounting information.
CSA make additionally a collection per process-aggregation accounting.
Quoted 5 lines
Quoted 2 lines
The 'enhanced acct data collection' patches that were added to 2-6-11-rc* tree still do collection of per process data.
Hmm, I have not noticed this extension. But I made sure about it. The following your two patches implements enhanced data collection, didn't it?
Yes!
Quoted 17 lines
- ChangeLog for 2.6.11-rc1
[PATCH] enhanced I/O accounting data patch [PATCH] enhanced Memory accounting data collectionSince making a collection per process accounting is unified to the stock kernel, I want to have a discussion about remaining half, "How to define the appropriate unit for accounting ?"
We can agree that only per process-accounting is so rigid, I think. Then, process-aggregation should be provided in one way or another.[1] Is it necessary 'fork/exec/exit' event handling framework ?
The common agreement for the method of dealing with process aggregation has not been constructed yet, I understood. And, we will not able to integrate each process aggregation model because of its diverseness.
Quoted 8 lines
For example, a process which belong to JOB-A must not belong any other 'JOB-X' in CSA-model. But, In ELSA-model, a process in BANK-B can concurrently belong to BANK-B1 which is a child of BANK-B.
And, there are other defferences:
Whether a process not to belong to any process-aggregation is permitted or not ? Whether a process-aggregation should be inherited to child process or not ? (There is possibility not to be inherited in a rule-based process aggregation like CKRM)
Guillaume answered this question, and i think a policy would work.
Quoted 4 lines
Some process-aggregation model have own philosophy and implemantation, so it's hard to integrate. Thus, I think that common 'fork/exec/exit' event handling framework to implement any kinds of process-aggregation.
BSD needs an exit hook and ELSA needs a fork hook. I am still evaluating whether CSA can use the ELSA module. If CSA can use the ELSA module, CSA maybe would be fine with the fork hook.
Quoted 10 lines
[2] What implementation should be adopted ?
I think registerable hooks on fork/execve/exit is necessary, not only
exit()hook. Because a rule or policy based process-aggregation model requirees to catch the transition of a process status.
It might be enough to hook theexit()event only in process-accounting, but it's not kind for another customer.
Quoted 4 lines
Thus, I recommend SGI's PAGG.
In my understanding, the reason for not to include such a framework is that increase of unidentifiable (proprietary) modules is worried.
If we code the hooks explicitly in the kernel, such as in acct.c, then the concern of unidentifiable modules should be taken care of. A registerable framework was my preference. But if that causes concern, it would be fine for me to do it explicit way. An example is for acct_process() to invoke do_acct_process().
That means whoever intends to use even an existing hook needs to present their cases, i guess.
Thanks,
- jay
Quoted 63 lines
But, SI can divert LSM to implemente process-aggregation if they ignore the LSM's original purpose, for example.
# I'm strongly opposed to such a movement as a SELinux's user :-)So, I think such a fork/execve/exit hooks is harmless now. Is this the time to unify it?
Thanks.
Quoted 12 lines
CSA added those per-process data to per-aggregation ("job") data structure at
do_exit()time when a process termintes.Quoted 9 lines
It is appropriate to make the fork-exit event handling framework for definition
of the process-aggregation, such as PAGG.This system-accounting per process-aggregation is quite useful, thought I tried the SGI's implementation named 'job' in past days.
Quoted 11 lines
Quoted 4 lines
Issue: 2) What items should be collected for accounting information ? BSD-accounting collects PID/UID/GID, User/Sys/Elapsed-Time, and # of minor/major page faults. SGI's CSA collects VM/RSS size on exit time, Integral-VM/RSS, and amount of block-I/O additionally.
These data are now collected in 2.6.11-rc* code. Note that these data are still per-process.
Quoted 2 lines
I think it's hard to implement the accounting-engine as a kernel
loadable
Quoted 29 lines
Quoted 7 lines
module using any kinds of framework. Because, we must put callback functions
into all around the kernel for this purpose.Thus, I make a proposion as follows:
We should separate the process-aggregation functionality and collecting accounting informations.I totally agree with this! Actually that was what we have done. The data collection part of code has been unified.
Quoted 4 lines
Something of framework to implement process-aggregation is necessary. And, making a collection of accounting information should be merged into BSD-accounting and implemented as a part of monolithic kernel as Guillaume said.
This sounds good. I am interested in learning how ELSA saves off the per-process accounting data before the data got disposed. If that scheme works for CSA, we would be very happy to adopt the scheme. The current BSD scheme is very insufficient. The code is very BSD centric and it provides no way to handle process-aggregation.
Thanks,
- jayQuoted 2 lines
Thanks.
Quoted 1 line
So, I think such a fork/execve/exit hooks is harmless now.
I don't recall seeing any microbenchmarking of the impact on fork/exit of such hooks. You might find such a benchmark in lmbench, or at
http://bulk.fefe.de/scalability/.
Signature · 3 lines
I won't rest till it's the best ...
Programmer, Linux Scalability
Paul Jackson <[email protected]> 1.650.933.1373, 1.925.600.0401Hi Paul,
I think the microbenchmarking your link provides is irrelevant. Your link provides benchmarking of doing a fork.
However, we are talking about inserting a callback routine in a fork and/or an exit. The overhead is a function call and time spent in the routine. The callback routine can be configured to "do {} while (0)" if a certain CONFIG flag is not set.
Thanks,
- jay
Quoted 7 lines · Paul Jackson
Quoted 1 line
So, I think such a fork/execve/exit hooks is harmless now.
I don't recall seeing any microbenchmarking of the impact on fork/exit of such hooks. You might find such a benchmark in lmbench, or at
http://bulk.fefe.de/scalability/.
Quoted 1 line · Jay
I think the microbenchmarking your link provides is irrelevant.
In the cases such as you describe where it's just some sort of empty function call, then yes, I am willing to accept a wave of the hands and a simple explanation of how it's not significant. I've done the same myself ;).
What about the case where accounting is enabled, and thus actually has to do work?
How does that compare with just doing the traditional BSD accounting?
I presume in that case that the benchmarking is no longer irrelevant. Though if you can make a decent case that it is, I'm willing to listen.
Signature · 3 lines
I won't rest till it's the best ...
Programmer, Linux Scalability
Paul Jackson <[email protected]> 1.650.933.1373, 1.925.600.0401Quoted 6 lines · Jay Lan
Quoted 4 lines · Guillaume Thouvenin
It's what I'm proposing. The problem is to be alerted when a new process is created in order to add it in the correct group of processes if the parent belongs to one (or several) groups. The notification can be done with the fork connector patch.
Quoted 6 lines
I am not quite comfortable of ELSA requesting a fork hook this way. How many hooks in the stock kernel that are related to accounting? Can anyone answer this question? I know of '
acct_process()' inexit.cused by the BSD accounting and ELSA is requesting a hook in fork. If people raise the same question again a few years later, how many people will still remember this ELSA hook?
The fork connector is not related to accounting. It's a connector that
allows to send information to a user space application when a fork occurs in the kernel.
This information is used by ELSA by I think that this hook will be
used by some others user space applications and IMHO, it's not incompatible with a specific hook for accounting tool if needed.
Guillaume
Quoted 16 lines · Tim Schmielau
Quoted 10 lines · Andrew Morton
We really want to avoid doing such stuff in-kernel if at all possible, of course.
Is it not possible to implement the fork/exec/exit notifications to userspace so that a daemon can track the process relationships and perform aggregation based upon individual tasks' accounting? That's what one of the accounting systems is proposing doing, I believe.
(In fact, why do we even need the notifications?
/bin/pscan work this stuff out).
Quoted 4 lines
I had started a proof of concept implementation that could reconstruct the whole process tree from userspace just from the BSD accounting currently in the kernel (+ the conceptual bug-fix that I misnamed "[RFC] "biological parent" pid"). This could do the whole job ID thing from userspace. Unfortunately, I haven't had time to work on it recently.
Also, doing per-job accounting might actually be more lightweight than per-process accounting, so I'm not at all opposed to unifying CSA and BSD accounting into one mechanism that just writes different file formats.
Thanks, Tim!
After spending some time studying how ELSA works, it appeared to me that CSA still needs a hook for do_exit. Since people agreed that a complete framework was an overkill, i would be glad to submit another patch later just to provide a CSA exit-handling inside the acct_process().
Thanks,
- jay
Quoted 15 lines
A complete framework seems like overkill to me, too.
Tim
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Lse-tech mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/lse-tech
Sorry for this late reply.
Quoted 1 line
Quoted 1 line
[1] Is it necessary 'fork/exec/exit' event handling framework ?
...<ommited>...
Quoted 9 lines
Quoted 4 lines
Some process-aggregation model have own philosophy and implemantation, so it's hard to integrate. Thus, I think that common 'fork/exec/exit' event handling
framework to implement any kinds of process-aggregation.BSD needs an exit hook and ELSA needs a fork hook. I am still evaluating whether CSA can use the ELSA module. If CSA can use the ELSA module, CSA maybe would be fine with the fork hook.
If CSA can use an ELSA module, then we must modify the kernel-tree for ELSA's fork-connecter. This means it's hard to implement the fork/exec/exit event notification to userspace (,or any kernel module) without kernel-support. How CSA shoule be implemented is interesting and important, but should it be main subject in this discussion that such a kinds of kernel hook is necessary to implement process-accounting per process-aggregation reasonable ?
In my understanding, what Andrew Morton said is "If target functionality can implement in user space only, then we should not modify the kernel-tree". But, any kind of kernel support was required to handle process lifecycle events for the accounting per process-aggregation and so on, from our discussion.
I'm also opposed to an adhoc approach, like CSA depending on ELSA. We should walk hight road.
Thanks,
Signature · 2 lines
Linux Promotion Center, NEC KaiGai Kohei <[email protected]>
Quoted 3 lines · Kaigai Kohei
In my understanding, what Andrew Morton said is "If target functionality can
implement in user space only, then we should not modify the kernel-tree".
fork, exec and exit upcalls sound pretty good to me. As long as
a) they use the same common machinery and
b) they are next-to-zero cost if something is listening on the netlink socket but no accounting daemon is running.
Question is: is this sufficient for CSA?
Quoted 6 lines · Andrew Morton
Quoted 2 lines · Kaigai Kohei
In my understanding, what Andrew Morton said is "If target functionality can implement in user space only, then we should not modify the kernel-tree".
Quoted 8 lines
fork, exec and exit upcalls sound pretty good to me. As long as
a) they use the same common machinery and
b) they are next-to-zero cost if something is listening on the netlink socket but no accounting daemon is running.
Question is: is this sufficient for CSA?
Yes, fork, exec, and exit upcalls are sufficient for CSA.
The framework i proposed earlier should satisfy your requirement a and b, and provides upcalls needed by BSD, ELSA and CSA. Maybe i misunderstood your concern of the 'very light weight' framework i proposed besides being "overkill"?
- jay
Quoted 10 lines · * Jay Lan ([email protected]) wrote:
Quoted 9 lines · Andrew Morton
Quoted 3 lines · Kaigai Kohei
In my understanding, what Andrew Morton said is "If target functionality can
implement in user space only, then we should not modify the kernel-tree".fork, exec and exit upcalls sound pretty good to me. As long as
Quoted 8 lines
Quoted 6 lines
a) they use the same common machinery and
b) they are next-to-zero cost if something is listening on the netlink socket but no accounting daemon is running.
Question is: is this sufficient for CSA?
Yes, fork, exec, and exit upcalls are sufficient for CSA.
As soon as you want to throttle tasks at the Job level, this would be insufficient. But, IIRC, that's not one of PAGG/Job/CSA's requirements right?
thanks,
-chris
Signature · 1 line
Linux Security Modules http://lsm.immunix.org http://lsm.bkbits.net
Quoted 18 lines · Chris Wright
Quoted 16 lines · * Jay Lan ([email protected]) wrote:
Quoted 14 lines · Andrew Morton
Quoted 2 lines · Kaigai Kohei
In my understanding, what Andrew Morton said is "If target functionality can implement in user space only, then we should not modify the kernel-tree".
fork, exec and exit upcalls sound pretty good to me. As long as
a) they use the same common machinery and
b) they are next-to-zero cost if something is listening on the netlink socket but no accounting daemon is running.
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
Question is: is this sufficient for CSA?
Yes, fork, exec, and exit upcalls are sufficient for CSA.
As soon as you want to throttle tasks at the Job level, this would be insufficient. But, IIRC, that's not one of PAGG/Job/CSA's requirements right?
PAGG serves more than JOB+CSA.
I am looking into possiblity/feasibility of implementing JOB at userspace. However, even with JOB as a kernel module, the fork, exec and exit upcalls would be sufficient to support JOB+CSA.
Thanks,
- jay
Quoted 3 lines
thanks,
-chris
Quoted 15 lines · Jay Lan
Quoted 13 lines · Andrew Morton
Quoted 2 lines · Kaigai Kohei
In my understanding, what Andrew Morton said is "If target functionality can implement in user space only, then we should not modify the kernel-tree".
fork, exec and exit upcalls sound pretty good to me. As long as
a) they use the same common machinery and
b) they are next-to-zero cost if something is listening on the netlink socket but no accounting daemon is running.
Quoted 8 lines
Quoted 1 line
Question is: is this sufficient for CSA?
Yes, fork, exec, and exit upcalls are sufficient for CSA.
The framework i proposed earlier should satisfy your requirement a and b, and provides upcalls needed by BSD, ELSA and CSA. Maybe i misunderstood your concern of the 'very light weight' framework i proposed besides being "overkill"?
"upcall" is poorly defined.
What I meant was that ELSA can perform its function when the kernel merely sends asynchronous notifications of forks out to userspace via netlink.
Further, I'm wondering if CSA can perform its function with the same level of kernel support, perhaps with the addition of netlink-based notification of exec and exit as well.
The framework patch which you sent was designed to permit the addition of more kernel accounting code, which is heading in the opposite direction.
In other words: given that ELSA can do its thing via existing accounting interfaces and a fork notifier, why does CSA need to add lots more kernel code?
Quoted 35 lines · Andrew Morton
Quoted 14 lines · Jay Lan
Quoted 13 lines · Andrew Morton
Quoted 2 lines · Kaigai Kohei
In my understanding, what Andrew Morton said is "If target functionality can implement in user space only, then we should not modify the kernel-tree".
fork, exec and exit upcalls sound pretty good to me. As long as
a) they use the same common machinery and
b) they are next-to-zero cost if something is listening on the netlink socket but no accounting daemon is running.
Quoted 8 lines
Quoted 1 line
Question is: is this sufficient for CSA?
Yes, fork, exec, and exit upcalls are sufficient for CSA.
The framework i proposed earlier should satisfy your requirement a and b, and provides upcalls needed by BSD, ELSA and CSA. Maybe i misunderstood your concern of the 'very light weight' framework i proposed besides being "overkill"?
"upcall" is poorly defined.
What I meant was that ELSA can perform its function when the kernel merely sends asynchronous notifications of forks out to userspace via netlink.
Further, I'm wondering if CSA can perform its function with the same level of kernel support, perhaps with the addition of netlink-based notification of exec and exit as well.
Quoted 6 lines
The framework patch which you sent was designed to permit the addition of more kernel accounting code, which is heading in the opposite direction.
In other words: given that ELSA can do its thing via existing accounting interfaces and a fork notifier, why does CSA need to add lots more kernel code?
Here are some codes from do_exit() starting line 813 (based on 2.6.11-rc4-mm1):
813 acct_update_integrals(tsk);
814 update_mem_hiwater(tsk);
815 group_dead = atomic_dec_and_test(&tsk->signal->live);
816 if (group_dead) {817 del_timer_sync(&tsk->signal->real_timer);
818 acct_process(code);
819 }
820 exit_mm(tsk);
The acct_process() is called to save off BSD accounting data at line 818. The next statement at 820, tsk->mm is disposed and all data saved at tsk->mm is gone, including memory hiwater marks information saved at line 814. The complete tsk is disposed before exit of do_exit() routine.
In separate emails discussion thread among interested parties, i asked Guillaume to clarify this question. I suspect ELSA counts on BSD's acct_process() at line 818 to save most accounting data. If that is the case and since ELSA wants extended accounting data collection, a way to save the extended acct data would be essential to ELSA as well.
I can better asnwer your "why ELSA can do but CSA can't" question after i learn more from Guilluame.
Later,
- jay
Quoted 10 lines
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Lse-tech mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/lse-tech
Quoted 11 lines · Andrew Morton
Quoted 3 lines · Kaigai Kohei
In my understanding, what Andrew Morton said is "If target functionality can
implement in user space only, then we should not modify the kernel-tree".fork, exec and exit upcalls sound pretty good to me. As long as
a) they use the same common machinery and
b) they are next-to-zero cost if something is listening on the netlink socket but no accounting daemon is running.
b) would involved being able to avoid sending netlink messages in case there are no listeners. AFAIK that isnt possible currently, netlink sends packets unconditionally.
Am I wrong?
Hi,
Quoted 9 lines
Quoted 9 lines
Quoted 2 lines · Kaigai Kohei
In my understanding, what Andrew Morton said is "If target functionality can implement in user space only, then we should not modify the kernel-tree".
fork, exec and exit upcalls sound pretty good to me. As long as
a) they use the same common machinery and
Quoted 7 lines
Quoted 2 lines
b) they are next-to-zero cost if something is listening on the netlink socket but no accounting daemon is running.
b) would involved being able to avoid sending netlink messages in case there are no listeners. AFAIK that isnt possible currently, netlink sends packets unconditionally.
Am I wrong?
In current implementaion, you might be right.
But we should make an effort to achieve the requirement-(b) from now.
And, why can't netlink packets send always?
If there are fork/exec/exit hooks, and they call CSA or other process-grouping modules, then those modules will decide whether packets for interaction with the daemon should be sent or not.
In most considerable case, CSA's kernel-loadable-module using such hooks will not be loaded when no accounting daemon is running. Adversely, this module must be loaded when accounting daemon needs CSA's netlink packets.
Thus, it is only necessary to refer flag valiable and to execute conditional-jump when no-accounting daemon is running.
In my estimation, we must pay additional cost for an increment-operation, an decrement-op, an comparison-op and an conditional jump-op. It's enough lightweight, I think.
For example:
If CSA's module isn't loaded, 'privates_for_grouping' will be empty.
inline int on_fork_hook(task_struct *parent, task_struct *newtask){
rcu_read_lock();
if( !list_empty(&parent->privates_for_grouping) ){
..<Calling to any process grouping module>..; }
rcu_read_unlock();
}
Thanks,
Signature · 2 lines
Linux Promotion Center, NEC KaiGai Kohei <[email protected]>
Quoted 16 lines · KaiGai Kohei
Hi,
Quoted 14 lines
Quoted 12 lines
Quoted 3 lines · Kaigai Kohei
In my understanding, what Andrew Morton said is "If target functionality can
implement in user space only, then we should not modify the kernel-tree".fork, exec and exit upcalls sound pretty good to me. As long as
a) they use the same common machinery and
b) they are next-to-zero cost if something is listening on the netlink socket but no accounting daemon is running.
Quoted 8 lines
Quoted 5 lines
b) would involved being able to avoid sending netlink messages in case there are no listeners. AFAIK that isnt possible currently, netlink sends packets unconditionally.
Am I wrong?
In current implementaion, you might be right.
But we should make an effort to achieve the requirement-(b) from now.
Yep, the netlink people should be able to help - they known what would be required for not sending messages in case there is no listener registered.
Maybe its already possible? I have never used netlink myself.
Quoted 6 lines
And, why can't netlink packets send always?
If there are fork/exec/exit hooks, and they call CSA or other process-grouping modules,
then those modules will decide whether packets for interaction with the daemon should be
sent or not.
The netlink data will be sent to userspace at fork/exec/exit hooks - one wants to avoid that if there are no listeners, so setups which dont want to run the accounting daemon dont pay the cost of building and sending the information through netlink.
Thats what Andrew asked for if I understand correctly.
Quoted 8 lines
In most considerable case, CSA's kernel-loadable-module using such hooks will not be loaded
when no accounting daemon is running. Adversely, this module must be loaded when accounting
daemon needs CSA's netlink packets.
Thus, it is only necessary to refer flag valiable and to execute conditional-jump
when no-accounting daemon is running.
That would be one hack, although it is uglier than the pure netlink selection.
Quoted 8 lines
In my estimation, we must pay additional cost for an increment-operation, an decrement-op,
an comparison-op and an conditional jump-op. It's enough lightweight, I think.For example:
If CSA's module isn't loaded, 'privates_for_grouping' will be empty.
Quoted 7 lines
inline int
on_fork_hook(task_struct *parent, task_struct *newtask){
rcu_read_lock();if( !list_empty(&parent->privates_for_grouping) ){ ..<Calling to any process grouping module>..;}
rcu_read_unlock();
}
Andrew has been talking about sending data over netlink to implement the accounting at userspace, so this piece of code is out of the game, no?
David S. Miller
maintainerQuoted 2 lines · On Sun, 27 Feb 2005 11:03:55 -0300 Marcelo Tosatti…
Yep, the netlink people should be able to help - they known what would be required for not sending messages in case there is no listener registered.
Please CC: [email protected] to get some netlink discussions going if wanted.
Hello,
Quoted 4 lines · Marcelo Tosatti
Yep, the netlink people should be able to help - they known what would be required for not sending messages in case there is no listener registered.
Maybe its already possible? I have never used netlink myself.
If we notify the fork/exec/exit-events to user-space directly as you said, I don't think some hackings on netlink is necessary.
For example, such packets is sent only when /proc/sys/.../process_grouping is set, and user-side daemon set this value, and unset when daemon will exit. It's not necessary to take too seriously.
Quoted 8 lines
Quoted 6 lines
And, why can't netlink packets send always?
If there are fork/exec/exit hooks, and they call CSA or other process-grouping modules,
then those modules will decide whether packets for interaction with the daemon should be
sent or not.
Quoted 6 lines
The netlink data will be sent to userspace at fork/exec/exit hooks - one wants to avoid that if there are no listeners, so setups which dont want to run the accounting daemon dont pay the cost of building and sending the information through netlink.
Thats what Andrew asked for if I understand correctly.
Does it mean "netlink packets shouled be sent to userspace unconditionally." ? I have advocated steadfastly that fork/exec/exit hooks is necessary to support process-grouping and to account per process-grouping.
It intend to be decided whether packets should be sent or not by hooked functions, in my understanding.
Is it also one of the implementations whether using netlink-socket or not ?
Quoted 10 lines
Quoted 8 lines
In most considerable case, CSA's kernel-loadable-module using such hooks will not be loaded
when no accounting daemon is running. Adversely, this module must be loaded when accounting
daemon needs CSA's netlink packets.
Thus, it is only necessary to refer flag valiable and to execute conditional-jump
when no-accounting daemon is running.
Quoted 2 lines
That would be one hack, although it is uglier than the pure netlink selection.
No, I can't agree this opinion.
It means netlink-packets will be sent unconditionally when fork/exec/exit occur. Nobady can decide which packet is sent user-space, I think.
In addition, the definition of process grouping is lightweight in many cases. For example, CpuSet can define own process-group by one increment-operation.
I think it's not impossible to implement it in userspace, but it's not reasonable. An implementation as a kernel loadable module is reasonable and enough tiny.
Quoted 17 lines
Quoted 8 lines
In my estimation, we must pay additional cost for an increment-operation, an decrement-op,
an comparison-op and an conditional jump-op. It's enough lightweight, I think.For example:
If CSA's module isn't loaded, 'privates_for_grouping' will be empty.Quoted 7 lines
inline int
on_fork_hook(task_struct *parent, task_struct *newtask){
rcu_read_lock();if( !list_empty(&parent->privates_for_grouping) ){ ..<Calling to any process grouping module>..;}
rcu_read_unlock();
}
Quoted 2 lines
Andrew has been talking about sending data over netlink to implement the accounting at userspace, so this piece of code is out of the game, no?
Indeed, I'm not opposed to implement the accounting in userspace and using netlink-socket for kernel-daemon communication. But definition of process-grouping based on any grouping policy should be done in kernel space at reasonability viewpoint.
Thanks.
Signature · 2 lines
Linux Promotion Center, NEC KaiGai Kohei <[email protected]>
First of all, I'm not aware of the whole discussion, ignore this if it has been brought to attention already.
Quoted 4 lines
Quoted 4 lines
Yep, the netlink people should be able to help - they known what would be required for not sending messages in case there is no listener registered.
Maybe its already possible? I have never used netlink myself.
The easiest way is to use netlink_broadcast() and have userspace register to a netlink multicast group (set .nl_groups before connecting the socket). The netlink message will be sent to only those netlink sockets assigned to the group, no message will be send out if no userspace listeners has registered.
Did you have a look at the syscall enter/exit audit netlink hooks before trying to invent your own thing?
I can also give you some code if you want, I use it to track the path of skbs in the net stack. It puts events into a preallocated ring buffer and a separate kernel thread broadcasts them over netlink. The events can be enqueued in any context at the cost of a possible ring buffer overrun resulting in loss of events. It's just a debugging hack though.
Quoted 6 lines · Kaigai Kohei
Hello,
Quoted 3 lines · Marcelo Tosatti
Yep, the netlink people should be able to help - they known what would be required for not sending messages in case there is no listener registered.
Quoted 7 lines
Quoted 1 line
Maybe its already possible? I have never used netlink myself.
If we notify the fork/exec/exit-events to user-space directly as you said, I don't think some hackings on netlink is necessary.
For example, such packets is sent only when/proc/sys/.../process_groupingis set, and user-side daemon set this value, and unset when daemon will exit. It's not necessary to take too seriously.
Kernel accounting already was discussed in lkml week ago - I'm quite sure Guillaume Thouvenin created exactly that.
His module creates do_fork() hook and broadcasts various process' states over netlink.
Discussion at http://lkml.org/lkml/2005/2/17/87
Signature · 3 lines
Evgeniy Polyakov Crash is better than data corruption -- Arthur Grabowski
Quoted 11 lines · Kaigai Kohei
Quoted 4 lines · Marcelo Tosatti
Yep, the netlink people should be able to help - they known what would be required for not sending messages in case there is no listener registered.
Maybe its already possible? I have never used netlink myself.
If we notify the fork/exec/exit-events to user-space directly as you said, I don't think some hackings on netlink is necessary.
For example, such packets is sent only when/proc/sys/.../process_groupingis set, and user-side daemon set this value, and unset when daemon will exit. It's not necessary to take too seriously.
I wrote a new fork connector patch with a callback to enable/disable
messages in case there is or isn't listener. I will post it this week.
Basically there is a global variable that is manipulated with a
connector callback so a user space daemon can manipulate the variable. In the fork_connector() function you have:
static inline void fork_connector(pid_t parent, pid_t child)
{
static DEFINE_SPINLOCK(cn_fork_lock);
static __u32 seq; /* used to test if message is lost */
if (cn_fork_enable) {
[...]
cn_netlink_send(msg, CN_IDX_FORK);
}
}and in the cn_fork module (drivers/connector/cn_fork.c) the callback is defined as:
static void cn_fork_callback(void *data)
{
if (cn_already_initialized)
cn_fork_enable = cn_fork_enable ? 0 : 1;
} Ok the protocol is maybe too "basic" but with this mechanism the user
space application that uses the fork connector can start and stop the send of messages. This implementation needs somme improvements because currently, if two application are using the fork connector one can enable it and the other don't know if it is enable or not, but the idea is here I think.
Regards,
Guillaume
Quoted 7 lines · Guillaume Thouvenin
Ok the protocol is maybe too "basic" but with this mechanism the user
space application that uses the fork connector can start and stop the send of messages. This implementation needs somme improvements because currently, if two application are using the fork connector one can enable it and the other don't know if it is enable or not, but the idea is here I think.
Yes. But this problem can be solved in userspace, with a little library function and a bit of locking.
IOW: use the library to enable/disable the fork connector rather than directly doing syscalls.
It has the problem that if a client of that library crashes, the counter gets out of whack, but really, it's not all _that_ important, and to handle this properly in-kernel each client would need an open fd against some object so we can do the close-on-exit thing properly. You'd need to create a separate netlink socket for the purpose.
Quoted 12 lines · Andrew Morton
Quoted 7 lines · Guillaume Thouvenin
Ok the protocol is maybe too "basic" but with this mechanism the user
space application that uses the fork connector can start and stop the send of messages. This implementation needs somme improvements because currently, if two application are using the fork connector one can enable it and the other don't know if it is enable or not, but the idea is here I think.Yes. But this problem can be solved in userspace, with a little library function and a bit of locking.
Quoted 8 lines
IOW: use the library to enable/disable the fork connector rather than directly doing syscalls.
It has the problem that if a client of that library crashes, the counter gets out of whack, but really, it's not all _that_ important, and to handle this properly in-kernel each client would need an open fd against some object so we can do the close-on-exit thing properly. You'd need to create a separate netlink socket for the purpose.
Why dont just extend protocol a bit?
Add header after cn_msg, which will have get/set field and that is all. Properly using seq/ack fields userspace can avoid locks.
Signature · 3 lines
Evgeniy Polyakov Crash is better than data corruption -- Arthur Grabowski
I'm net ignorant, so just hit me with a cluebat if thats appropriate.
Quoted 5 lines · jamal
Havent seen the beginnings of this thread. But whatever you are trying to do seems to suggest some complexity that you are trying to workaround. What was wrong with just going ahead and just always invoking your
netlink_send()?
What overhead does the netlink_send() impose if there are no listeners?
Sure, it wont go anywhere, but the message will have to be assembled and sent anyway. Correct?
The way things are now, its necessary to make the decision to invoke or not netlink_send() due to the supposed overhead.
Thats what Guillaume is doing, and thats what will have to be done whenever one wants to send information through netlink from performance critical paths.
Can't the assembly/etc overhead associated with netlink_send() be avoided earlier, approaching zero-cost ?
Being able to get rid of the decision to invoke or not the sendmsg would be nice.
TIA
Quoted 27 lines
If there are nobody in user space (or
kernel) listening, it wont go anywhere.cheers,
jamalQuoted 20 lines · Andrew Morton
Quoted 7 lines · Guillaume Thouvenin
Ok the protocol is maybe too "basic" but with this mechanism the user
space application that uses the fork connector can start and stop the send of messages. This implementation needs somme improvements because currently, if two application are using the fork connector one can enable it and the other don't know if it is enable or not, but the idea is here I think.Yes. But this problem can be solved in userspace, with a little library function and a bit of locking.
IOW: use the library to enable/disable the fork connector rather than directly doing syscalls.
It has the problem that if a client of that library crashes, the counter gets out of whack, but really, it's not all _that_ important, and to handle this properly in-kernel each client would need an open fd against some object so we can do the close-on-exit thing properly. You'd need to create a separate netlink socket for the purpose.
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
Quoted 10 lines · Thomas Graf
* jamal <[email protected]> 2005-02-28 08:40
Quoted 3 lines
netlink broadcast or a wrapper around it.
Why even bother doing the check withnetlink_has_listeners()?To implement the master enable/disable switch they want. The messages don't get send out anyway but why bother doing all the work if nothing will get send out in the end? It implements a well defined flag controlled by open/close on fds (thus handles dying applications) stating whether the whole code should be enabled or disabled.
Yep - this far from "reinventing the wheel". ;)
Quoted 1 line
It is of course not needed to avoid sending unnecessary messages.
Thats the goal, thanks.
Havent seen the beginnings of this thread. But whatever you are trying to do seems to suggest some complexity that you are trying to workaround. What was wrong with just going ahead and just always invoking your netlink_send()? If there are nobody in user space (or kernel) listening, it wont go anywhere.
cheers,
jamal
Quoted 32 lines · Andrew Morton
Quoted 7 lines · Guillaume Thouvenin
Ok the protocol is maybe too "basic" but with this mechanism the user
space application that uses the fork connector can start and stop the send of messages. This implementation needs somme improvements because currently, if two application are using the fork connector one can enable it and the other don't know if it is enable or not, but the idea is here I think.Yes. But this problem can be solved in userspace, with a little library function and a bit of locking.
IOW: use the library to enable/disable the fork connector rather than directly doing syscalls.
It has the problem that if a client of that library crashes, the counter gets out of whack, but really, it's not all _that_ important, and to handle this properly in-kernel each client would need an open fd against some object so we can do the close-on-exit thing properly. You'd need to create a separate netlink socket for the purpose.
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Lse-tech mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/lse-tech
Quoted 4 lines
Havent seen the beginnings of this thread. But whatever you are trying to do seems to suggest some complexity that you are trying to workaround. What was wrong with just going ahead and just always invoking your
netlink_send()?
I guess parts of the wheel are broken and need to be reinvented ;->
Quoted 1 line
If there are nobody in user space (or kernel) listening, it wont go anywhere.
Additional you may want to extend netlink a bit to check whether there is a listener before creating the messages. The method to do so depends on whether you use netlink_send() or netlink_brodacast(). The latter is more flexiable because you can add more groups later on and the userspace applications can decicde which ones they want to listen to. Both methods handle dying clients perfectly fine, the association to the netlink socket gets destroyed as soon as the socket is closed. Therefore you can simply check mc_list of the netlink protocol you use to see if there are any listeners registered:
static inline int netlink_has_listeners(struct sock *sk)
{
int ret;
read_lock(&nl_table_lock);
ret = list_empty(&nl_table[sk->sk_protocol].mc_list)
read_unlock(&nl_table_lock);
return !ret;
}This is simplified and ignores the actual group assignments, i.e. you might want to extend it to have it check if there are listeners for a certain group.
netlink broadcast or a wrapper around it.
Why even bother doing the check with netlink_has_listeners()?
cheers,
jamal
Quoted 34 lines · Thomas Graf
Quoted 4 lines
Havent seen the beginnings of this thread. But whatever you are trying to do seems to suggest some complexity that you are trying to workaround. What was wrong with just going ahead and just always invoking your
netlink_send()?I guess parts of the wheel are broken and need to be reinvented ;->
Quoted 1 line
If there are nobody in user space (or kernel) listening, it wont go anywhere.
Additional you may want to extend netlink a bit to check whether there is a listener before creating the messages. The method to do so depends on whether you use
netlink_send()ornetlink_brodacast(). The latter is more flexiable because you can add more groups later on and the userspace applications can decicde which ones they want to listen to. Both methods handle dying clients perfectly fine, the association to the netlink socket gets destroyed as soon as the socket is closed. Therefore you can simply checkmc_listof the netlink protocol you use to see if there are any listeners registered:static inline int
netlink_has_listeners(struct sock *sk){ int ret; read_lock(&nl_table_lock); ret = list_empty(&nl_table[sk->sk_protocol].mc_list) read_unlock(&nl_table_lock); return !ret; }This is simplified and ignores the actual group assignments, i.e. you might want to extend it to have it check if there are listeners for a certain group.
* jamal <[email protected]> 2005-02-28 08:40
Quoted 3 lines
netlink broadcast or a wrapper around it.
Why even bother doing the check withnetlink_has_listeners()?
To implement the master enable/disable switch they want. The messages don't get send out anyway but why bother doing all the work if nothing will get send out in the end? It implements a well defined flag controlled by open/close on fds (thus handles dying applications) stating whether the whole code should be enabled or disabled. It is of course not needed to avoid sending unnecessary messages.
Quoted 11 lines · Thomas Graf
* jamal <[email protected]> 2005-02-28 08:40
Quoted 3 lines
netlink broadcast or a wrapper around it.
Why even bother doing the check withnetlink_has_listeners()?To implement the master enable/disable switch they want. The messages don't get send out anyway but why bother doing all the work if nothing will get send out in the end? It implements a well defined flag controlled by open/close on fds (thus handles dying applications) stating whether the whole code should be enabled or disabled. It is of course not needed to avoid sending unnecessary messages.
To justify writting the new code, I am assuming someone has actually sat down and in the minimal stuck their finger in the air
and said "yes, there is definetely wind there".
Which leadsto Marcello's question in other email:
Theres some overhead.
- Message needs to be built with skbs allocated (not the cn_xxx thing that seems to be invoked - I suspect that thing will build the skbs);
- the netlink table needs to be locked
-and searched and only then do you find theres nothing to send to.
The point i was making is if you actually had to post this question, then you must be running into some problems of complexity ;-> which implies to me that the delta overhead maybe worth it compared to introducing the complexity or any new code.
I wasnt involved in the discussion - I just woke up and saw the posting and was bored. So the justification for the optimization has probably been explained and it may be worth doing the check (but probably such check should go into whatever that cn_xxx is).
cheers,
jamal
* jamal <[email protected]> 2005-02-28 09:10
Quoted 13 lines · Thomas Graf
Quoted 11 lines
* jamal <[email protected]> 2005-02-28 08:40
Quoted 3 lines
netlink broadcast or a wrapper around it.
Why even bother doing the check withnetlink_has_listeners()?To implement the master enable/disable switch they want. The messages don't get send out anyway but why bother doing all the work if nothing will get send out in the end? It implements a well defined flag controlled by open/close on fds (thus handles dying applications) stating whether the whole code should be enabled or disabled. It is of course not needed to avoid sending unnecessary messages.
Quoted 3 lines
To justify writting the new code, I am assuming someone has actually sat down and in the minimal stuck their finger in the air
and said "yes, there is definetely wind there".
I did, not for this problem though. The code this idea comes from sends batched events of skb passing points to userspace. Not every call invokes has_listeneres() but rather the kernel thread processing the ring buffer sending the events to userspaces does. The result is globally cached in a atomic_t making it possible to check for it at zero-cost and really saving time and effort. I have no clue wether it does make sense in this case I just pointed out how to do it properly at my point of view.
Quoted 7 lines
Which leadsto Marcello's question in other email:
Theres some overhead.
- Message needs to be built with skbs allocated (not thecn_xxxthing that seems to be invoked - I suspect that thing will build the skbs);
- the netlink table needs to be locked
-and searched and only then do you find theres nothing to send to.
Quoted 8 lines
The point i was making is if you actually had to post this question, then you must be running into some problems of complexity ;-> which implies to me that the delta overhead maybe worth it compared to introducing the complexity or any new code.
I wasnt involved in the discussion - I just woke up and saw the posting and was bored. So the justification for the optimization has probably been explained and it may be worth doing the check (but probably such check should go into whatever thatcn_xxxis).
I wasn't involved in the discussion either.
Using rtmsg_ifinfo as example, the check should probably go in straight at the beginning _IFF_ rtmsg_ifinfo was subject to performance overhead which obviously isn't the case but just served as an example.
Quoted 1 line · Thomas Graf
* jamal <[email protected]> 2005-02-28 09:10
[..]
Quoted 6 lines
Quoted 3 lines
To justify writting the new code, I am assuming someone has actually sat down and in the minimal stuck their finger in the air
and said "yes, there is definetely wind there".I did, not for this problem though. The code this idea comes from sends batched events
I would bet the benefit you are seeing has to do with batching rather than such an optimization flag. Different ballgame.
I relooked at their code snippet, they dont even have skbs built nor even figured out what sock or PID. That work still needs to be done it seems in cn_netlink_send(). So probably all they need to do is move the check in cn_netlink_send() instead. This is assuming they are not scratching their heads with some realted complexities.
I am gonna disapear for a while; hopefully the original posters have gathered some ideas from what we discussed.
cheers,
jamal
Quoted 18 lines · On 28 Feb 2005 10:31:33 -0500 jamal <[email protected]> wrote:
Quoted 1 line · Thomas Graf
* jamal <[email protected]> 2005-02-28 09:10
[..]
Quoted 6 lines
Quoted 3 lines
To justify writting the new code, I am assuming someone has actually sat down and in the minimal stuck their finger in the air
and said "yes, there is definetely wind there".I did, not for this problem though. The code this idea comes from sends batched events
I would bet the benefit you are seeing has to do with batching rather than such an optimization flag. Different ballgame.
I relooked at their code snippet, they dont even have skbs built nor even figured out what sock or PID. That work still needs to be done it seems incn_netlink_send(). So probably all they need to do is move the check incn_netlink_send()instead. This is assuming they are not scratching their heads with some realted complexities.
Quoted 2 lines
I am gonna disapear for a while; hopefully the original posters have gathered some ideas from what we discussed.
As connector author, I still doubt it worth copying several lines from netlink_broadcast() before skb allocation in cn_netlink_send(). Of course it is easy and can be done, but I do not see any profit here. Atomic allocation is fast, if it succeds, but there are no groups/socket to send, skb will be freed, if allocation fails, then group check is useless.
I would prefer Guillaume Thouvenin as fork connector author to test his current implementation and show that connector's cost is negligible both with and without userspace listeners.
As far as I remember it is first entry in fork connector's TODO list.
Quoted 3 lines
cheers,
jamal
Evgeniy Polyakov
Only failure makes us experts. -- Theo de Raadt
Quoted 16 lines · Evgeniy Polyakov
Quoted 7 lines · On 28 Feb 2005 10:31:33 -0500 jamal <[email protected]> wrote:
I would bet the benefit you are seeing has to do with batching rather than such an optimization flag. Different ballgame.
I relooked at their code snippet, they dont even have skbs built nor even figured out what sock or PID. That work still needs to be done it seems incn_netlink_send(). So probably all they need to do is move the check incn_netlink_send()instead. This is assuming they are not scratching their heads with some realted complexities.[...]
As connector author, I still doubt it worth copying several lines fromnetlink_broadcast()before skb allocation incn_netlink_send(). Of course it is easy and can be done, but I do not see any profit here. Atomic allocation is fast, if it succeds, but there are no groups/socket to send, skb will be freed, if allocation fails, then group check is useless.
Quoted 4 lines
I would prefer Guillaume Thouvenin as fork connector author to test his current implementation and show that connector's cost is negligible both with and without userspace listeners.
As far as I remember it is first entry in fork connector's TODO list.
I tested without user space listeners and the cost is negligible. I will test with a user space listeners and see the results. I'm going to run the test this week after improving the mechanism that switch on/off the sending of the message.
Best regards,
Guillaume
Hello,
Quoted 4 lines
I tested without user space listeners and the cost is negligible. I will test with a user space listeners and see the results. I'm going to run the test this week after improving the mechanism that switch on/off the sending of the message.
I'm also trying to mesure the process-creation/destruction performance on following three environment.
Archtechture: i686 / Distribution: Fedora Core 3
* Kernel Preemption is DISABLE
* SMP kernel but UP-machine / Not Hyper Threading
[1] 2.6.11-rc4-mm1 normal
[2] 2.6.11-rc4-mm1 with PAGG based Process Accounting Module
[3] 2.6.11-rc4-mm1 with fork-connector notification (it's enabled)
When 367th-fork() was called after fork-connector notification, kernel was locked up. (User-Space-Listener has been also run until 366th-fork() notification was received)
Does this number have any sort of means ?
In my second trial, kernel was also locked up after 366th-fork() notification. Currently, I don't know its causition. Is there a person encounted it?
# I wanted to say "[2] is faster than [3]" when process-grouping is enable, but the plan came off. :(
Thanks.
Signature · 2 lines
Linux Promotion Center, NEC KaiGai Kohei <[email protected]>
Quoted 13 lines · Kaigai Kohei
Quoted 4 lines
I tested without user space listeners and the cost is negligible. I will test with a user space listeners and see the results. I'm going to run the test this week after improving the mechanism that switch on/off the sending of the message.
I'm also trying to mesure the process-creation/destruction performance on following three environment.
Archtechture: i686 / Distribution: Fedora Core 3
* Kernel Preemption is DISABLE
* SMP kernel but UP-machine / Not Hyper Threading
[1] 2.6.11-rc4-mm1 normal
[2] 2.6.11-rc4-mm1 with PAGG based Process Accounting Module
[3] 2.6.11-rc4-mm1 with fork-connector notification (it's enabled)
Quoted 2 lines
When 367th-fork() was called after fork-connector notification, kernel was locked up. (User-Space-Listener has been also run until 366th-fork() notification was received)
I don't see this limit on my computer. I'm currently running the lmbench with a new fork connector patch (one that enable/disable fork connector) on an SMP computer. I will send results and the new patch tomorrow because the test takes a while...
I'm using a small patch provided by Evgeniy and not included in the 2.6.11-rc4-mm1 tree.
Best regards,
Guillaume
connector.c +4 -5
@@ -168,12 +168,11 @@ group =NETLINK_CB ((skb)).groups; msg = (struct cn_msg *)NLMSG_DATA (nlh); -if (msg->len != nlh->nlmsg_len -sizeof (*msg) -sizeof (*nlh)) { +if (NLMSG_SPACE (msg->len +sizeof (*msg)) != nlh->nlmsg_len) {printk (KERN_ERR "skb does not have enough length: " -"requested msg->len=%u[%u], nlh->nlmsg_len=%u[%u], skb->len=%u[must be %u].\n" , - msg->len,NLMSG_SPACE (msg->len), - nlh->nlmsg_len, nlh->nlmsg_len -sizeof (*nlh), - skb->len, msg->len +sizeof (*msg)); +"requested msg->len=%u[%u], nlh->nlmsg_len=%u, skb->len=%u.\n" , + msg->len,NLMSG_SPACE (msg->len +sizeof (*msg)), + nlh->nlmsg_len, skb->len);kfree_skb (skb);return -EINVAL ; }
Quoted 17 lines · Guillaume Thouvenin
Quoted 13 lines · Kaigai Kohei
Quoted 4 lines
I tested without user space listeners and the cost is negligible. I will test with a user space listeners and see the results. I'm going to run the test this week after improving the mechanism that switch on/off the sending of the message.
I'm also trying to mesure the process-creation/destruction performance on following three environment.
Archtechture: i686 / Distribution: Fedora Core 3
* Kernel Preemption is DISABLE
* SMP kernel but UP-machine / Not Hyper Threading
[1] 2.6.11-rc4-mm1 normal
[2] 2.6.11-rc4-mm1 with PAGG based Process Accounting Module
[3] 2.6.11-rc4-mm1 with fork-connector notification (it's enabled)Quoted 2 lines
When 367th-fork() was called after fork-connector notification, kernel was locked up. (User-Space-Listener has been also run until 366th-fork() notification was received)
Quoted 7 lines
I don't see this limit on my computer. I'm currently running the lmbench with a new fork connector patch (one that enable/disable fork connector) on an SMP computer. I will send results and the new patch tomorrow because the test takes a while...
I'm using a small patch provided by Evgeniy and not included in the 2.6.11-rc4-mm1 tree.
2.6.11-rc4-mm1 tree does not have the latest connector. Various fixes were added, not only that.
I run the latest patch Guillaume sent to me(with small updates), fork bomb with more than 100k forks passed already without any freeze. I do not have numbers thought.
Quoted 23 lines
Best regards,
Guillaumeconnector.c +4
-5@@ -168,12 +168,11 @@ group =NETLINK_CB ((skb)).groups; msg = (struct cn_msg *)NLMSG_DATA (nlh); -if (msg->len != nlh->nlmsg_len -sizeof (*msg) -sizeof (*nlh)) { +if (NLMSG_SPACE (msg->len +sizeof (*msg)) != nlh->nlmsg_len) {printk (KERN_ERR "skb does not have enough length: " -"requested msg->len=%u[%u], nlh->nlmsg_len=%u[%u], skb->len=%u[must be %u].\n" , - msg->len,NLMSG_SPACE (msg->len), - nlh->nlmsg_len, nlh->nlmsg_len -sizeof (*nlh), - skb->len, msg->len +sizeof (*msg)); +"requested msg->len=%u[%u], nlh->nlmsg_len=%u, skb->len=%u.\n" , + msg->len,NLMSG_SPACE (msg->len +sizeof (*msg)), + nlh->nlmsg_len, skb->len);kfree_skb (skb);return -EINVAL ; }
Signature · 3 lines
Evgeniy Polyakov Crash is better than data corruption -- Arthur Grabowski
Quoted 2 lines · Jamal
What was wrong with just going ahead and just always invoking your
netlink_send()?
I think the hope was to reduce the cost of the accounting hook in fork to "next-to-zero" if accounting is not being used on that system.
See Andrew's query earlier:
Quoted 2 lines
b) they are next-to-zero cost if something is listening on the netlink socket but no accounting daemon is running.
Presumably sending an ignored packet costs something, quite possibly more than "next-to-zero".
Signature · 3 lines
I won't rest till it's the best ...
Programmer, Linux Scalability
Paul Jackson <[email protected]> 1.650.933.1373, 1.925.600.0401Just a thought - perhaps you could see if Jay can test the performance scaling of these changes on larger systems (8 to 64 CPUs, give or take, small for SGI, but big for some vendors.)
Things like a global lock, for example, might be harmless on smaller systems, but hurt big time on bigger systems. I don't know if you have any such constructs ... perhaps this doesn't matter.
At the very least, we need to know that performance and scaling are not significantly impacted, on systems not using accounting, either because it is obvious from the code, or because someone has tested it.
And if performance or scaling was impacted when accounting was enabled, then at least we would want to know how much performance was impacted, so that users would know what to expect when they use accounting.
Quoted 1 line
the process-creation/destruction performance on following three environment.
I think this is a good choice of what to measure, and where. Thank-you.
Quoted 1 line
kernel was also locked up after 366th-fork()
I have no idea what this is -- good luck finding it.
Signature · 3 lines
I won't rest till it's the best ...
Programmer, Linux Scalability
Paul Jackson <[email protected]> 1.650.933.1373, 1.925.600.0401Quoted 13 lines · Kaigai Kohei
Quoted 4 lines
I tested without user space listeners and the cost is negligible. I will test with a user space listeners and see the results. I'm going to run the test this week after improving the mechanism that switch on/off the sending of the message.
I'm also trying to mesure the process-creation/destruction performance on following three environment.
Archtechture: i686 / Distribution: Fedora Core 3
* Kernel Preemption is DISABLE
* SMP kernel but UP-machine / Not Hyper Threading
[1] 2.6.11-rc4-mm1 normal
[2] 2.6.11-rc4-mm1 with PAGG based Process Accounting Module
[3] 2.6.11-rc4-mm1 with fork-connector notification (it's enabled)
Quoted 2 lines
When 367th-fork() was called after fork-connector notification, kernel was locked up. (User-Space-Listener has been also run until 366th-fork() notification was received)
So I ran the lmbench with three different kernels with the fork
connector patch I just sent. Results are attached at the end of the mail and there are three different lines which are:
o First line is a linux-2.6.11-rc4-mm1-cnfork
o Second line is a linux-2.6.11-rc4-mm1
o Third line is a linux-2.6.11-rc4-mm1-cnfork with a user space application. The user space application listened during 15h and received 6496 messages.
Each test has been ran only once.
Best regards,
Guillaume
---
cd results && make summary percent 2>/dev/null | more
make[1]: Entering directory `/home/guill/benchmark/lmbench/lmbench-3.0-a4/results'
L M B E N C H 3 . 0 S U M M A R Y
------------------------------------
(Alpha software, do not distribute)
Basic system parameters
------------------------------------------------------------------------------
Host OS Description Mhz tlb cache mem scal
pages line par load
bytes
--------- ------------- ----------------------- ---- ----- ----- ------ ----
account Linux 2.6.11- i686-pc-linux-gnu 2765 63 128 2.4900 1
account Linux 2.6.11- i686-pc-linux-gnu 2765 67 128 2.4200 1
account Linux 2.6.11- i686-pc-linux-gnu 2765 69 128 2.4400 1Processor, Processes - times in microseconds - smaller is better
------------------------------------------------------------------------------
Host OS Mhz null null open slct sig sig fork exec sh
call I/O stat clos TCP inst hndl proc proc proc
--------- ------------- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
account Linux 2.6.11- 2765 0.17 0.26 3.57 4.19 16.9 0.51 2.31 162. 629. 2415 account Linux 2.6.11- 2765 0.16 0.26 3.56 4.17 17.6 0.50 2.30 163. 628. 2417 account Linux 2.6.11- 2765 0.16 0.27 3.67 4.25 17.6 0.51 2.28 176. 664. 2456
Basic integer operations - times in nanoseconds - smaller is better
-------------------------------------------------------------------
Host OS intgr intgr intgr intgr intgr
bit add mul div mod
--------- ------------- ------ ------ ------ ------ ------
account Linux 2.6.11- 0.1800 0.1700 4.9900 20.8 23.1 account Linux 2.6.11- 0.1800 0.1700 4.9900 20.8 23.1 account Linux 2.6.11- 0.1800 0.1700 4.9900 20.8 23.1
Basic float operations - times in nanoseconds - smaller is better
-----------------------------------------------------------------
Host OS float float float float
add mul div bogo
--------- ------------- ------ ------ ------ ------
account Linux 2.6.11- 1.7300 2.4800 15.5 15.4
account Linux 2.6.11- 1.7300 2.4800 15.5 15.6
account Linux 2.6.11- 1.7400 2.5000 15.7 15.6Basic double operations - times in nanoseconds - smaller is better
------------------------------------------------------------------
Host OS double double double double
add mul div bogo
--------- ------------- ------ ------ ------ ------
account Linux 2.6.11- 1.7300 2.4800 15.5 15.4 account Linux 2.6.11- 1.7300 2.4800 15.5 15.6 account Linux 2.6.11- 1.7400 2.5000 15.7 15.6
Context switching - times in microseconds - smaller is better
-------------------------------------------------------------------------
Host OS 2p/0K 2p/16K 2p/64K 8p/16K 8p/64K 16p/16K 16p/64K
ctxsw ctxsw ctxsw ctxsw ctxsw ctxsw ctxsw
--------- ------------- ------ ------ ------ ------ ------ ------- -------
account Linux 2.6.11- 5.1300 5.2900 4.9700 3.1700 10.9 6.30000 32.6 account Linux 2.6.11- 4.9000 5.2100 5.1600 4.4700 20.3 6.48000 27.7 account Linux 2.6.11- 4.8600 5.3000 4.9200 3.5600 20.5 6.87000 31.5
*Local* Communication latencies in microseconds - smaller is better
---------------------------------------------------------------------
Host OS 2p/0K Pipe AF UDP RPC/ TCP RPC/ TCP
ctxsw UNIX UDP TCP conn
--------- ------------- ----- ----- ---- ----- ----- ----- ----- ----
account Linux 2.6.11- 5.130 14.3 11.9 17.7 23.2 20.3 28.3 40. account Linux 2.6.11- 4.900 14.6 12.0 18.5 23.9 20.8 28.6 40. account Linux 2.6.11- 4.860 14.8 12.6 18.1 23.9 20.8 27.8 40.
File & VM system latencies in microseconds - smaller is better
-------------------------------------------------------------------------------
Host OS 0K File 10K File Mmap Prot Page 100fd
Create Delete Create Delete Latency Fault Fault selct
--------- ------------- ------ ------ ------ ------ ------- ----- ------- -----
account Linux 2.6.11- 18.9 16.1 65.6 33.5 15.4K 0.771 2.22520 16.4
account Linux 2.6.11- 18.8 16.3 64.2 33.2 15.7K 0.841 2.20690 16.5
account Linux 2.6.11- 19.2 16.4 65.4 33.5 15.7K 0.782 2.19950 16.4*Local* Communication bandwidths in MB/s - bigger is better
-----------------------------------------------------------------------------
Host OS Pipe AF TCP File Mmap Bcopy Bcopy Mem Mem
UNIX reread reread (libc) (hand) read write
--------- ------------- ---- ---- ---- ------ ------ ------ ------ ---- -----
account Linux 2.6.11- 664. 497. 369. 1468.8 1836.1 596.6 568.4 1819 779.7 account Linux 2.6.11- 671. 521. 338. 1481.6 1817.2 593.8 568.8 1838 783.0 account Linux 2.6.11- 667. 543. 372. 1469.4 1816.8 594.2 568.3 1818 783.0
Memory latencies in nanoseconds - smaller is better
(WARNING - may not be correct, check graphs)
------------------------------------------------------------------------------
Host OS Mhz L1 $ L2 $ Main mem Rand mem Guesses --------- ------------- --- ---- ---- -------- -------- ------- account Linux 2.6.11- 2765 0.7030 6.5710 140.6 246.7 account Linux 2.6.11- 2765 0.7090 6.6350 142.4 249.5 account Linux 2.6.11- 2765 0.7110 6.6340 142.5 249.5
make[1]: Leaving directory `/home/guill/benchmark/lmbench/lmbench-3.0-a4/results'
Quoted 11 lines · Guillaume Thouvenin
So I ran the lmbench with three different kernels with the fork
connector patch I just sent. Results are attached at the end of the mail and there are three different lines which are:(quoted diff) +0
-0o First line is a linux-2.6.11-rc4-mm1-cnfork o Second line is a linux-2.6.11-rc4-mm1 o Third line is a linux-2.6.11-rc4-mm1-cnfork with a user space application. The user space application listened during 15h and received 6496 messages.
Review
Quoted 10 lines
(quoted diff) +0
-0Each test has been ran only once. ------------------------------------------------------------------------------ Host OS Mhz null null open slct sig sig fork exec sh call I/O stat clos TCP inst hndl proc proc proc --------- ------------- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- account Linux 2.6.11- 2765 0.17 0.26 3.57 4.19 16.9 0.51 2.31 162. 629. 2415 account Linux 2.6.11- 2765 0.16 0.26 3.56 4.17 17.6 0.50 2.30 163. 628. 2417 account Linux 2.6.11- 2765 0.16 0.27 3.67 4.25 17.6 0.51 2.28 176. 664. 2456
This is the interesting bit, yes? 5-10% slowdown on fork is expected, but why was exec slower?
What does "The user space application listened during 15h" mean?
Quoted 23 lines · Andrew Morton
Quoted 11 lines · Guillaume Thouvenin
So I ran the lmbench with three different kernels with the fork
connector patch I just sent. Results are attached at the end of the mail and there are three different lines which are:(quoted diff) +0
-0o First line is a linux-2.6.11-rc4-mm1-cnfork o Second line is a linux-2.6.11-rc4-mm1 o Third line is a linux-2.6.11-rc4-mm1-cnfork with a user space application. The user space application listened during 15h and received 6496 messages.Review
Quoted 10 lines
(quoted diff) +0
-0Each test has been ran only once. ------------------------------------------------------------------------------ Host OS Mhz null null open slct sig sig fork exec sh call I/O stat clos TCP inst hndl proc proc proc --------- ------------- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- account Linux 2.6.11- 2765 0.17 0.26 3.57 4.19 16.9 0.51 2.31 162. 629. 2415 account Linux 2.6.11- 2765 0.16 0.26 3.56 4.17 17.6 0.50 2.30 163. 628. 2417 account Linux 2.6.11- 2765 0.16 0.27 3.67 4.25 17.6 0.51 2.28 176. 664. 2456
Quoted 2 lines
This is the interesting bit, yes? 5-10% slowdown on fork is expected, but why was exec slower?
I can't explain it for the moment. I will run test more than once to see if this difference is still here.
Quoted 1 line
What does "The user space application listened during 15h" mean?
It means that I ran the user space application before the test and
stop it 15 hours later (this morning for me). The test ran during 5h30mn.
The user space application increments a counter to show how many
processes have been created during a period of time. I have not use the user space daemon that manages group of processes because the it still uses the old mechanism (a signal sends from the do_fork()) and as I wanted to provide quick results, I used another user space application.
I attache the test program (get_fork_info.c) that I'm using at the end
of the mail to clearly show what it does.
I will run new tests with the real user space daemon but it will be
ready next week, sorry for the delay.
Best regards,
Guillaume
---
/*
* get_fork_info.c
*
* This program listens netlink interface to retreive information
* sends by the kernel when forking. It increments a counter for
* each forks and when the user hit CRL-C, it displays how many
* fork occured during the period.
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <signal.h>
#include <asm/types.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <linux/netlink.h>
#include <linux/connector.h>
#define CN_FORK_OFF 0
#define CN_FORK_ON 1
#define MESSAGE_SIZE (sizeof(struct nlmsghdr) + \ sizeof(struct cn_msg) + \ sizeof(int))
int sock;
unsigned long total_p;
struct timeval test_time;
static inline void switch_cn_fork(int sock, int action)
{
char buff[128]; /* must be > MESSAGE_SIZE */
struct nlmsghdr *hdr;
struct cn_msg *msg;
/* Clear the buffer */
memset(buff, '\0', sizeof(buff));
/* fill the message header */
hdr = (struct nlmsghdr *) buff;
hdr->nlmsg_len = MESSAGE_SIZE;
hdr->nlmsg_type = NLMSG_DONE;
hdr->nlmsg_flags = 0;
hdr->nlmsg_seq = 0;
hdr->nlmsg_pid = getpid();
/* the message */
msg = (struct cn_msg *) NLMSG_DATA(hdr);
msg->id.idx = CN_IDX_FORK;
msg->id.val = CN_VAL_FORK;
msg->seq = 0;
msg->ack = 0;
msg->len = sizeof(int);
msg->data[0] = action;
send(sock, hdr, hdr->nlmsg_len, 0);
}static void cleanup()
{
struct timeval tmp_time;
switch_cn_fork(sock, CN_FORK_OFF);
tmp_time = test_time;
gettimeofday(&test_time, NULL);
printf("%lu processes were created in %li seconds.\n",
total_p, test_time.tv_sec - tmp_time.tv_sec);
close(sock);
exit(EXIT_SUCCESS);
}int main()
{
int err;
struct sockaddr_nl sa; /* information for NETLINK interface */
/*
* To be able to quit the application properly we install a
* signal handler that catch the CTRL-C
*/
signal(SIGTERM, cleanup);
signal(SIGINT, cleanup);
/*
* Create an endpoint for communication. Use the kernel user
* interface device (PF_NETLINK) which is a datagram oriented
* service (SOCK_DGRAM). The protocol used is the netfilter/iptables
* ULOG protocol (NETLINK_NFLOG)
*/
sock = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_NFLOG);
if (sock == -1) {
perror("socket");
return -1;
}
sa.nl_family = AF_NETLINK;
sa.nl_groups = CN_IDX_FORK;
sa.nl_pid = getpid();
err = bind(sock, (struct sockaddr *) &sa,
sizeof(struct sockaddr_nl));
if (err == -1) {
perror("bind");
close(sock);
return -1;
}
switch_cn_fork(sock, CN_FORK_ON);
total_p = 0;
gettimeofday(&test_time, NULL);
for (;;) {
char buff[1024]; /* it's large enough */
struct nlmsghdr *hdr;
struct cn_msg *msg;
int len;
/* Clear the buffer */
memset(buff, '\0', sizeof(buff));
/* Listen */
len = recv(sock, buff, sizeof(buff), 0);
if (len == -1) {
perror("recv");
close(sock);
return -1;
}
/* point to the message header */
hdr = (struct nlmsghdr *) buff;
switch (hdr->nlmsg_type) {
case NLMSG_DONE:
msg = (struct cn_msg *) NLMSG_DATA(hdr);
total_p++;
#if 0
printf("[idx=0x%x seq=%u] %s\n", msg->id.idx,
msg->seq, msg->data);
#endif
break;
case NLMSG_ERROR:
printf("NLMSG_ERROR\n");
/* Fall through */
default:
break;
}
}
/*
* in fact we never reach this part of the code because there is an
* infinite loop above.
*/
cleanup();
return 0;
}Quoted 2 lines · Andrew
5-10% slowdown on fork is expected, but
why was exec slower?
Thanks for the summary, Andrew.
Guillaume (or anyone else tempted to do this) - it's a good idea, when posting 100 lines of data, to summarize with a line or two of words, as Andrew did here. It is far more efficient for one writer to do this, than each of a thousand readers.
Hmmm ... so why was exec slower?
Signature · 3 lines
I won't rest till it's the best ...
Programmer, Linux Scalability
Paul Jackson <[email protected]> 1.650.933.1373, 1.925.600.0401