Date: Thu, 8 Feb 2007 18:15:00 GMT From: "Christian S.J. Peron" <csjp@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 114252 for review Message-ID: <200702081815.l18IF0OK070927@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=114252 Change 114252 by csjp@csjp_rnd01 on 2007/02/08 18:14:09 experimental prefetching code. Affected files ... .. //depot/projects/zcopybpf/utils/bpfnull/README#3 edit .. //depot/projects/zcopybpf/utils/bpfnull/bpfnull.c#14 edit Differences ... ==== //depot/projects/zcopybpf/utils/bpfnull/README#3 (text+ko) ==== @@ -2,7 +2,7 @@ bpfnull -- Process packets from BPF SYNOPSIS - bpfnull [-IwtTvz] [-i interface] [-f pcap out file] + bpfnull [-IwptTvz] [-i interface] [-f pcap out file] DESCRIPTION Process packets from BPF using new zerocopy or regular buffer method. A @@ -17,6 +17,8 @@ -t After packet has been received in packet buffer, touch BPF headers associated with EACH packet + -p Prefetch packet data into cache lines prior to processing it + -T Touch each byte associated with the packet for EACH packet -v Print debug or diagnostic messages to stderr ==== //depot/projects/zcopybpf/utils/bpfnull/bpfnull.c#14 (text+ko) ==== @@ -65,6 +65,7 @@ static int zflag; static int tflag; static int Tflag; +static int pflag; static u_char *bufa, *bufb; static int @@ -87,6 +88,8 @@ } } +#define CACHE_LINE_SIZE 32 + static void bpf_process_packets(struct bpf_zbuf *bz, char *bufname) { @@ -98,7 +101,14 @@ if (!wflag && !tflag && !Tflag) return; b = bp = bz->bz_bufa; - ep = bp + bz->bz_buflen; + p = ep = bp + bz->bz_buflen; + if (pflag) { + for (i = 0; i < bz->bz_buflen; + i += CACHE_LINE_SIZE) { + p += i; + __builtin_prefetch(p, 0, 2); + } + } while (bp < ep) { clen = bhp->bh_caplen; hlen = bhp->bh_hdrlen; @@ -107,7 +117,7 @@ phd.ts.tv_usec = bhp->bh_tstamp.tv_usec; phd.caplen = phd.len = bhp->bh_datalen; if (Tflag) { - for (i = 0; i < phd.caplen; i++) + for (i = 0; i < phd.len; i++) by = p[i]; bp += BPF_WORDALIGN(clen + hlen); continue; @@ -278,7 +288,7 @@ char ch; signal(SIGINT, (void *)handle_int); - while ((ch = getopt(argc, argv, "b:f:hIi:tTwvz")) != -1) { + while ((ch = getopt(argc, argv, "b:f:hIi:ptTwvz")) != -1) { switch (ch) { case 'b': bflag = atoi(optarg); @@ -293,6 +303,9 @@ case 'I': Iflag = 1; break; + case 'p': + pflag = 1; + break; case 't': tflag = 1; break;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200702081815.l18IF0OK070927>