linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Guillaume Thouvenin <guillaume.thouvenin@bull.net>
To: Andrew Morton <akpm@osdl.org>
Cc: Kaigai Kohei <kaigai@ak.jp.nec.com>,
	Evgeniy Polyakov <johnpol@2ka.mipt.ru>,
	hadi@cyberus.ca, tgraf@suug.ch,
	Marcelo Tosatti <marcelo.tosatti@cyclades.com>,
	"David S. Miller" <davem@redhat.com>,
	jlan@sgi.com, LSE-Tech <lse-tech@lists.sourceforge.net>,
	lkml <linux-kernel@vger.kernel.org>,
	Netlink List <netdev@oss.sgi.com>,
	elsa-devel <elsa-devel@lists.sourceforge.net>
Subject: Re: [Lse-tech] Re: A common layer for Accounting packages
Date: Wed, 02 Mar 2005 10:25:49 +0100	[thread overview]
Message-ID: <1109755549.32740.8.camel@frecb000711.frec.bull.fr> (raw)
In-Reply-To: <20050302010614.2a8bb483.akpm@osdl.org>

On Wed, 2005-03-02 at 01:06 -0800, Andrew Morton wrote: 
> Guillaume Thouvenin <guillaume.thouvenin@bull.net> wrote:
> >
> >   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. 
> > 
> > ...
> >  ------------------------------------------------------------------------------
> >  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?

I can't explain it for the moment. I will run test more than once to see
if this difference is still here.

> 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;
}



  reply	other threads:[~2005-03-02  9:27 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-02-19  0:51 A common layer for Accounting packages Jay Lan
2005-02-19  1:16 ` Andrew Morton
2005-02-21  6:51   ` Guillaume Thouvenin
2005-02-22 20:11     ` [Lse-tech] " Jay Lan
2005-02-23  7:30       ` Guillaume Thouvenin
2005-02-21  7:54   ` Kaigai Kohei
2005-02-22 20:26     ` Jay Lan
2005-02-23  7:07       ` Kaigai Kohei
2005-02-23  7:20         ` Andrew Morton
2005-02-23  8:33           ` Guillaume Thouvenin
2005-02-23  8:51             ` Andrew Morton
2005-02-23  9:30               ` Guillaume Thouvenin
2005-02-23  9:36                 ` Andrew Morton
2005-02-23 19:11             ` Jay Lan
2005-02-24  7:42               ` Guillaume Thouvenin
2005-02-23  9:50           ` Tim Schmielau
2005-02-24 22:27             ` Jay Lan
2005-02-23 11:29           ` Kaigai Kohei
2005-02-23 20:48         ` Jay Lan
2005-02-25  5:07           ` Kaigai Kohei
2005-02-25  5:28             ` Andrew Morton
2005-02-25 17:32               ` Jay Lan
2005-02-25 17:45                 ` Chris Wright
2005-02-25 18:11                   ` Jay Lan
2005-02-25 21:30                 ` Andrew Morton
2005-02-25 22:18                   ` Jay Lan
2005-02-27  9:49               ` Marcelo Tosatti
2005-02-27 15:20                 ` KaiGai Kohei
2005-02-27 14:03                   ` Marcelo Tosatti
2005-02-27 19:27                     ` David S. Miller
2005-02-28  1:59                     ` Kaigai Kohei
2005-02-28  2:32                       ` Thomas Graf
2005-02-28  5:17                       ` Evgeniy Polyakov
2005-02-28  7:20                       ` Guillaume Thouvenin
2005-02-28  7:39                         ` Andrew Morton
2005-02-28  8:04                           ` Evgeniy Polyakov
2005-02-28 12:10                           ` jamal
2005-02-28  9:29                             ` Marcelo Tosatti
2005-02-28 13:20                             ` Thomas Graf
2005-02-28 13:40                               ` jamal
2005-02-28 13:53                                 ` Thomas Graf
2005-02-28  9:52                                   ` Marcelo Tosatti
2005-02-28 14:10                                   ` jamal
2005-02-28 14:25                                     ` Thomas Graf
2005-02-28 15:31                                       ` jamal
2005-02-28 16:17                                         ` Evgeniy Polyakov
2005-03-01  8:21                                           ` Guillaume Thouvenin
2005-03-01 13:38                                             ` Kaigai Kohei
2005-03-01 13:53                                               ` Guillaume Thouvenin
2005-03-01 14:17                                                 ` Evgeniy Polyakov
2005-03-02  4:50                                               ` Paul Jackson
2005-03-02  8:58                                               ` Guillaume Thouvenin
2005-03-02  9:06                                                 ` Andrew Morton
2005-03-02  9:25                                                   ` Guillaume Thouvenin [this message]
2005-03-02 15:30                                                   ` Paul Jackson
2005-03-01 20:40                             ` Paul Jackson
2005-02-24  1:25         ` Paul Jackson
2005-02-24  1:56           ` Jay Lan
2005-02-24  2:07             ` Paul Jackson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1109755549.32740.8.camel@frecb000711.frec.bull.fr \
    --to=guillaume.thouvenin@bull.net \
    --cc=akpm@osdl.org \
    --cc=davem@redhat.com \
    --cc=elsa-devel@lists.sourceforge.net \
    --cc=hadi@cyberus.ca \
    --cc=jlan@sgi.com \
    --cc=johnpol@2ka.mipt.ru \
    --cc=kaigai@ak.jp.nec.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lse-tech@lists.sourceforge.net \
    --cc=marcelo.tosatti@cyclades.com \
    --cc=netdev@oss.sgi.com \
    --cc=tgraf@suug.ch \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).