public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jay Lan <jlan@engr.sgi.com>
To: johnpol@2ka.mipt.ru
Cc: Andrew Morton <akpm@osdl.org>,
	Guillaume Thouvenin <guillaume.thouvenin@bull.net>,
	greg@kroah.com, linux-kernel@vger.kernel.org,
	efocht@hpce.nec.com, linuxram@us.ibm.com, gh@us.ibm.com,
	elsa-devel@lists.sourceforge.net, aquynh@gmail.com,
	dean-list-linux-kernel@arctic.org, pj@sgi.com
Subject: Re: [patch 2.6.12-rc1-mm4] fork_connector: add a fork connector
Date: Sun, 10 Apr 2005 22:43:24 -0700	[thread overview]
Message-ID: <425A0E7C.8080900@engr.sgi.com> (raw)
In-Reply-To: <20050409102926.0cbf031c@zanzibar.2ka.mipt.ru>

[-- Attachment #1: Type: text/plain, Size: 1293 bytes --]

I based my listen program on the fclisten.c posted by Kaigai Kohei
with my own modification. Unfortunately i lost my test machine in the
lab. I will recreate the listen program Monday. The original listener
did not validate sequence number. It also prints length of data and
sequence number of every message it receives. My listener prints
only out-of-sequence error messages.

The fork generator fork-test.c was yours? I called it fork-test
and let it run continuously in while-loop:

# while 1
# ./fork-test 10000000
# sleep 1
# end

I let it do 10,000,000 times of fork continuously while the system
is running AIM7 and/or ubench.

The original fclisten.c and fork-test.c are attached for your reference.

- jay


Evgeniy Polyakov wrote:
> On Fri, 08 Apr 2005 20:31:20 -0700
> Jay Lan <jlan@engr.sgi.com> wrote:
> 
> 
>>With the patch you provide to me, i did not see the bugcheck
>>at cn_queue_wrapper() at the console.
>>
>>Unmatched sequence number messages still happened. We expect
>>to lose packets under system stressed situation, but i still
>>observed duplicate messages, which concerned me.
> 
> 
> What tool and what version do you use 
> as message generator and receiver?
> 
> 
>>Thanks,
>>  - jay
> 
> 
> 	Evgeniy Polyakov
> 
> Only failure makes us experts. -- Theo de Raadt

[-- Attachment #2: fclisten.c --]
[-- Type: text/plain, Size: 2442 bytes --]

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <asm/types.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <linux/netlink.h>

void usage(){
  puts("usage: fclisten <on|off>");
  puts("  Default -> listening fork-connector");
  puts("  on      -> fork-connector Enable");
  puts("  off     -> fork-connector Disable");
  exit(0);
}

#define MODE_LISTEN  (1)
#define MODE_ENABLE  (2)
#define MODE_DISABLE (3)

struct cb_id
{
  __u32                   idx;
  __u32                   val;
};

struct cn_msg
{
  struct cb_id            id;
  __u32                   seq;
  __u32                   ack;
  __u32                   len;            /* Length of the following data */
  __u8                    data[0];
};


int main(int argc, char *argv[]){
  char buf[4096];
  int mode, sockfd, len;
  struct sockaddr_nl ad;
  struct nlmsghdr *hdr = (struct nlmsghdr *)buf;
  struct cn_msg *msg = (struct cn_msg *)(buf+sizeof(struct nlmsghdr));
  
  switch(argc){
  case 1:
    mode = MODE_LISTEN;
    break;
  case 2:
    if (strcasecmp("on",argv[1])==0) {
      mode = MODE_ENABLE;
    }else if (strcasecmp("off",argv[1])==0){
      mode = MODE_DISABLE;
    }else{
      usage();
    }
    break;
  default:
    usage();
    break;
  }
  
  if( (sockfd=socket(PF_NETLINK, SOCK_RAW, NETLINK_NFLOG)) < 0 ){
    fprintf(stderr, "Fault on socket().\n");
    return( 1 );
  }
  ad.nl_family = AF_NETLINK;
  ad.nl_pad = 0;
  ad.nl_pid = getpid();
  ad.nl_groups = CN_IDX_FORK;
  if( bind(sockfd, (struct sockaddr *)&ad, sizeof(ad)) ){
    fprintf(stderr, "Fault on bind to netlink.\n");
    return( 2 );
  }

  if (mode==MODE_LISTEN) {
    while(-1){
      len = recvfrom(sockfd, buf, 4096, 0, NULL, NULL);
      printf("%d-byte recv Seq=%d\n", len, hdr->nlmsg_seq);
    }
  }else{
    ad.nl_family = AF_NETLINK;
    ad.nl_pad = 0;
    ad.nl_pid = 0;
    ad.nl_groups = 1;
    
    hdr->nlmsg_len = sizeof(struct nlmsghdr) + sizeof(struct cn_msg) + sizeof(int);
    hdr->nlmsg_type = 0;
    hdr->nlmsg_flags = 0;
    hdr->nlmsg_seq = 0;
    hdr->nlmsg_pid = getpid();
    msg->id.idx = 0xfeed;
    msg->id.val = 0xbeef;
    msg->seq = msg->ack = 0;
    msg->len = sizeof(int);

    if (mode==MODE_ENABLE){
      (*(int *)(msg->data)) = 1;
    } else {
      (*(int *)(msg->data)) = 0;
    }
    sendto(sockfd, buf, sizeof(struct nlmsghdr)+sizeof(struct cn_msg)+sizeof(int),
	   0, (struct sockaddr *)&ad, sizeof(ad));
  }
}

[-- Attachment #3: fork-test.c --]
[-- Type: text/plain, Size: 774 bytes --]

#include <sys/signal.h>
#include <sys/time.h>

int main(int argc, char *argv[])
{
        int pid;
        int i = 0, max = 100000;
        struct timeval tv0, tv1;
        struct timezone tz;
        long diff;

        if (argc >= 2)
                max = atoi(argv[1]);

        signal(SIGCHLD, SIG_IGN);

        gettimeofday(&tv0, &tz);
        while (i++ < max) {
                pid = fork();
                if (pid == 0) {
                        sleep(1);
                        exit (0);
                }
        }
        gettimeofday(&tv1, &tz);

        diff = (tv1.tv_sec - tv0.tv_sec)*1000000 + (tv1.tv_usec - tv0.tv_usec);

        printf("Average per process fork+exit time is %ld usecs [diff=%lu, max=%d].\n", diff/max, diff, max);
        return 0;
}


  reply	other threads:[~2005-04-11  5:47 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-03-31 13:59 [patch 2.6.12-rc1-mm4] fork_connector: add a fork connector Guillaume Thouvenin
2005-03-31 22:44 ` Andrew Morton
2005-04-01  0:10   ` Jay Lan
2005-04-01  7:52     ` Evgeniy Polyakov
2005-04-07 22:40       ` Jay Lan
2005-04-07 22:47         ` Jay Lan
2005-04-08 10:24           ` Evgeniy Polyakov
2005-04-08 10:52             ` Evgeniy Polyakov
2005-04-08 20:27               ` Jay Lan
2005-04-08 22:08                 ` Jay Lan
2005-04-08 22:18                   ` Evgeniy Polyakov
2005-04-09  3:31                     ` Jay Lan
2005-04-09  6:29                       ` Evgeniy Polyakov
2005-04-11  5:43                         ` Jay Lan [this message]
2005-04-11  6:44                           ` Evgeniy Polyakov
2005-04-11  6:51                             ` Andrew Morton
2005-04-11  7:31                               ` Evgeniy Polyakov
2005-03-31 22:53 ` Andrew Morton
2005-04-01 10:56 ` Guillaume Thouvenin

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=425A0E7C.8080900@engr.sgi.com \
    --to=jlan@engr.sgi.com \
    --cc=akpm@osdl.org \
    --cc=aquynh@gmail.com \
    --cc=dean-list-linux-kernel@arctic.org \
    --cc=efocht@hpce.nec.com \
    --cc=elsa-devel@lists.sourceforge.net \
    --cc=gh@us.ibm.com \
    --cc=greg@kroah.com \
    --cc=guillaume.thouvenin@bull.net \
    --cc=johnpol@2ka.mipt.ru \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxram@us.ibm.com \
    --cc=pj@sgi.com \
    /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