From: Zach Brown <zab@zabbo.net>
To: linux-kernel@vger.kernel.org
Cc: Jes Sorensen <jes@trained-monkey.org>
Subject: Re: [BETA] First test release of Tigon3 driver
Date: Wed, 27 Feb 2002 13:37:55 -0500 [thread overview]
Message-ID: <20020227133755.H30524@erasmus.off.net> (raw)
In-Reply-To: <20020227125611.A20415@stud.ntnu.no> <20020227.040653.58455636.davem@redhat.com> <20020227132454.B24996@stud.ntnu.no> <20020227.042845.54186884.davem@redhat.com> <20020227.042845.54186884.davem@redhat.com>; <20020227170321.B22422@stud.ntnu.no> <3C7D0510.2C300D12@redhat.com>
In-Reply-To: <3C7D0510.2C300D12@redhat.com>; from arjanv@redhat.com on Wed, Feb 27, 2002 at 04:10:56PM +0000
> > Any programs or anything that could do a serious stresstest? (Both hosts
> > are Dell PowerEdge 2550, RedHat Linux 7.2).
>
> google for nttcp
> runs a nice tcp performance test...
I dig on gensink:
http://jes.home.cern.ch/jes/gensink/
the attached hack gives it the ability to tx with sendfile() from a
ftruncate()ed tmpfile based on the presence of a 5th argument, which can
be fun with scatter/csum capable cards. I've put up some rpms for the
lazy:
http://www.zabbo.net/rpms/gensink/
5aa66dfd7749c77cb58de22fad96de gensink-4.1-1sendfile.i386.rpm
04912a63bda95a79b6b835f340c924c2 gensink-4.1-1sendfile.src.rpm
enjoy.
- z
diff -urN gensink-4.1.orig/gen4.c gensink-4.1/gen4.c
--- gensink-4.1.orig/gen4.c Wed May 16 10:08:01 2001
+++ gensink-4.1/gen4.c Wed Feb 27 10:24:27 2002
@@ -48,20 +48,101 @@
#include <sys/ioctl.h>
+#include <sys/sendfile.h>
+
+void sendfile_loop(int s, int rec_len)
+{
+ char *tmpdir_default = "/tmp";
+ char template[PATH_MAX];
+ char *tmpdir;
+ int fd;
+ int i;
+ ssize_t bytes_written;
+ off_t offset;
+
+ tmpdir = getenv("TMPDIR");
+ if ( tmpdir == NULL )
+ tmpdir = tmpdir_default;
+
+ snprintf(template, PATH_MAX, "%s/XXXXXX", tmpdir);
+
+ fd = mkstemp(template);
+ if ( fd < 0 ) {
+ perror("couldn't mkstemp() sendfile() backing file");
+ exit(-1);
+ }
+
+ unlink(template);
+
+ if ( ftruncate(fd, RECORD_BUFFER_SIZE + rec_len) < 0 ) {
+ perror("frunctate() backing file");
+ exit(-1);
+ }
+
+ offset = 0;
+
+ for (i = 1; i < 4000000; i++)
+ {
+ /* loop writing blocks */
+ if ((bytes_written = sendfile(s,fd,&offset,rec_len)) < 0)
+ oops("write");
+ if ((bytes = bytes + bytes_written) >= REPORT_FREQ)
+ {
+ report(1, "source", bytes);
+ bytes = 0;
+ }
+
+ if ( offset >= RECORD_BUFFER_SIZE )
+ offset = 0;
+ }
+
+ close(fd);
+}
+
+void write_loop(int s, int rec_len)
+{
+ char *record_buffer, *orig_record_ptr;
+ int i, bytes_written;
+
+ record_buffer = (char *)malloc(RECORD_BUFFER_SIZE + rec_len);
+ if (!record_buffer) {
+ fprintf(stderr, "Unable to allocate memory for transmit buffer\n");
+ exit(-1);
+ }
+
+ orig_record_ptr = record_buffer;
+ memset(record_buffer, 0, RECORD_BUFFER_SIZE);
+
+ for (i = 1; i < 4000000; i++)
+ {
+ /* loop writing blocks */
+ if ((bytes_written = write(s,record_buffer,rec_len)) < 0)
+ oops("write");
+ if ((bytes = bytes + bytes_written) >= REPORT_FREQ)
+ {
+ report(1, "source", bytes);
+ bytes = 0;
+ }
+ record_buffer += rec_len;
+ if ((unsigned long)record_buffer > (unsigned long)(orig_record_ptr + RECORD_BUFFER_SIZE))
+ record_buffer = orig_record_ptr;
+ }
+ free(orig_record_ptr);
+}
+
int main(argc, argv)
int argc;
char *argv[];
{
struct sockaddr_in saddr;
- char *record_buffer, *orig_record_ptr;
char reptext[256], *hostname;
- int portnum, rec_len, bytes_written;
- int i;
+ int portnum, rec_len;
+ int use_sendfile = 0;
/* check argument count */
- if(argc != 5)
+ if(argc < 5 || argc > 6)
{
- fprintf(stderr,"Usage: %s server_host server_port record_length setsockopt\n", argv[0]);
+ fprintf(stderr, "Usage: %s server_host server_port record_length setsockopt [use_sendfile_boolean]\n", argv[0]);
exit(-1);
}
@@ -73,16 +154,11 @@
exit(-1);
}
- record_buffer = (char *)malloc(RECORD_BUFFER_SIZE + rec_len);
- if (!record_buffer) {
- fprintf(stderr, "Unable to allocate memory for transmit buffer\n");
- exit(-1);
- }
- orig_record_ptr = record_buffer;
- memset(record_buffer, 0, RECORD_BUFFER_SIZE);
-
max = atoi(argv[4]);
+ if ( argc == 6 )
+ use_sendfile = atoi(argv[5]);
+
strcpy(reptext,"");
/* get the record length */
strncat(reptext, " reclen=", 255 - strlen(reptext));
@@ -122,24 +198,17 @@
printf("Max seg TCP : %d\n",maxseg);
+ printf("sending with %s\n",
+ use_sendfile ? "sendfile(2)" : "write(2)");
+
/* initialise reporting */
report_start(reptext,1,0,1,argv);
report(1, "source", 0);
- for (i = 1; i < 4000000; i++)
- {
- /* loop writing blocks */
- if ((bytes_written = write(s,record_buffer,rec_len)) < 0)
- oops("write");
- if ((bytes = bytes + bytes_written) >= REPORT_FREQ)
- {
- report(1, "source", bytes);
- bytes = 0;
- }
- record_buffer += rec_len;
- if ((unsigned long)record_buffer > (unsigned long)(orig_record_ptr + RECORD_BUFFER_SIZE))
- record_buffer = orig_record_ptr;
- }
- free(orig_record_ptr);
+ if ( use_sendfile )
+ sendfile_loop(s, rec_len);
+ else
+ write_loop(s, rec_len);
+
return 0;
}
next prev parent reply other threads:[~2002-02-27 18:38 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-02-26 0:59 [BETA] First test release of Tigon3 driver David S. Miller
2002-02-26 3:43 ` nick
2002-02-26 4:40 ` David S. Miller
2002-02-26 11:22 ` Sebastian Heidl
2002-02-26 11:24 ` David S. Miller
2002-02-26 11:39 ` Sebastian Heidl
2002-02-26 13:13 ` David S. Miller
2002-02-26 13:57 ` Thomas Langås
2002-02-26 14:59 ` David S. Miller
2002-02-26 15:40 ` Thomas Langås
2002-02-26 16:09 ` __skb_dequeue irq race ? Bjorn Wesen
2002-02-27 2:56 ` [BETA] First test release of Tigon3 driver David S. Miller
[not found] ` <20020227102450.B23121@stud.ntnu.no>
2002-02-27 9:31 ` David S. Miller
2002-02-27 11:05 ` Thomas Langås
2002-02-27 11:34 ` David S. Miller
2002-02-27 11:56 ` Thomas Langås
2002-02-27 12:06 ` David S. Miller
2002-02-27 12:24 ` Thomas Langås
2002-02-27 12:28 ` David S. Miller
2002-02-27 16:03 ` Thomas Langås
2002-02-27 16:10 ` Arjan van de Ven
2002-02-27 17:25 ` Thomas Langås
2002-02-27 18:37 ` Zach Brown [this message]
2002-02-27 18:46 ` Zach Brown
2002-02-27 19:42 ` Thomas Langås
2002-02-27 16:30 ` Chris Friesen
2002-02-26 17:22 ` Greg KH
2002-02-27 4:13 ` David S. Miller
2002-02-26 18:08 ` Pasi Kärkkäinen
2002-02-27 2:12 ` David S. Miller
-- strict thread matches above, loose matches on Subject: below --
2002-03-12 0:57 Timothy Ngo
2002-03-12 1:21 ` Alan Cox
2002-03-12 6:47 ` David S. Miller
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=20020227133755.H30524@erasmus.off.net \
--to=zab@zabbo.net \
--cc=jes@trained-monkey.org \
--cc=linux-kernel@vger.kernel.org \
/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