lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <200704131846.16358.wpk@dst-labs.com>
Date:	Fri, 13 Apr 2007 18:46:16 +0200
From:	Witold Krecicki <wpk@...-labs.com>
To:	linux-kernel@...r.kernel.org
Subject: Oddness with reading /proc/net/tcp

Reading data from /proc/net/tcp is slower with progress of reading data, 
tested on system with >200k active connections.

Sample code:
#include <stdio.h>
#include <sys/time.h>
#include <unistd.h>

int main(int argc, char ** argv)
{
  struct timeval starttime, endtime;
  FILE * fd;
  char buf[1024*1024*4];
  int pk;
  fd=fopen("/proc/net/tcp","r");
  gettimeofday(&starttime,0);
  pk=0;
  while (!feof(fd) && pk<10000)
    {
      fread(buf, 1, 1024, fd);
      pk++;
      if (pk%512==0)
      {
        gettimeofday(&endtime,0);
        printf("%d %ld\n",pk, (endtime.tv_usec-starttime.tv_usec) 
+1000000*(endtime.tv_sec - starttime.tv_sec));
        gettimeofday(&starttime,0);
      }
    }
  fclose(fd);
  return 0;
}

Result:
$ time ./a.out
512 231781
1024 1057159
1536 1726530
2048 2474851
2560 3236269
3072 3856587
3584 3438862
4096 3108675
4608 3500559
5120 4090534
5632 4612594
6144 5135624
6656 5266945
7168 5491547
7680 6355916
8192 6661789
8704 7095428
9216 7565589
9728 7982981

real    1m27.347s
user    0m0.024s
sys     1m27.309s

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ