On Wed, Oct 14, 2009 at 04:43:57PM +0800, Peter Teoh wrote:
> In linux kernel, the SKB design is to facilitate the zerocopy
> processing of network packets.   Does the concept likewise exists in
> the present Opensolaris?
> 
> According to:
> 
> http://opensolaris.org/os/community/networking/docs/dtrace_networking_cookbook/
> 
> there is a zerocopy.d script to facilitate the analysis.   Anyone
> provide me a copy of that?

Sure, I've attached a copy. However, there have been changes to the
code paths that the script instruments, so some tweaking might be
required.

> My preliminary analysis through probing in various API (like
> ip_tcp_input, ip_input etc) is that it is not zerocopy yet, is that
> correct?

Zero copy is supported and is used by sendfile(3ext).

Cheers,
Anders
#!/usr/sbin/dtrace -s
#pragma D option flowindent

/* 
 * TCP Zero Copy monitoring dscript.
 *
 * Code contributed by  Alex Peng
 *
 *  The author notes: " This script mointors TCP's ZeroCopy feature, shows what 
happens
 *  at different components, e.g., STREAM head, TCP, IP (ill), mblk etc.".
 */
tcp_t   *tcp;
conn_t  *connp;
ire_t   *ire;
ill_t   *ill;
queue_t *q;
mblk_t  *mp;
struct stdata   *stp;
file_t  *fp;
vnode_t *vp;
struct sonode   *so;

fbt::tcp_zcopy_check:entry
{
        trace(execname);
        stack();
        tcp = (tcp_t *)arg0;
        printf("\n");
        printf("tcp: \t%p\n", tcp);
        printf("connp: \t%p\n", (conn_t *)tcp->tcp_connp);
        printf("tcp->tcp_snd_zcopy_on: \t%d\n", tcp->tcp_snd_zcopy_on);
        self->trace_zchck = 1;
}


fbt::tcp_zcopy_check:return
/self->trace_zchck/
{
        printf("\n");
        printf("zc_enabled: \t%d\n", arg1);
        printf("tcp->tcp_snd_zcopy_on: \t%d\n", tcp->tcp_snd_zcopy_on);
}

fbt::snf_segmap:entry
/self->trace_zchck/
{
        fp = (file_t *)arg0;
        vp = (vnode_t *)fp->f_vnode;
        stp = (stdata_t *)vp->v_stream;
/*      trace(execname); */
        printf("\nstp->sd_copyflag: \t%x\n", stp->sd_copyflag);
}

/*
fbt::sostream_direct:entry
/self->trace_zchck/
{
        so = (struct sonode *)arg0;
        stp = so->so_vnode->v_stream;
        trace(execname);
        printf("\nstp->sd_copyflag: \t%x\n", stp->sd_copyflag);
}
*/

fbt::kstrwritemp:entry
/self->trace_zchck/
{
        mp = (mblk_t *)arg1;
        trace(execname);
        printf("\n");
        printf("mblk2dblk dblk struioflag: \t");
        printf("db->db_struioflag: \t%d\n", mp->b_datap->db_struioflag);
        printf("msg lenth: \t%d\n", mp->b_wptr - mp->b_rptr);
}

fbt::tcp_send_data:entry
/self->trace_zchck/
{
        trace(execname);
/*      stack(); */
/*      tcp = (tcp_t *)arg0; */
        q = (queue_t *)arg1;
        mp = (mblk_t *)arg2;
        connp = tcp->tcp_connp;
        stp = q->q_stream;

        printf("\n");
        printf("STREAM head copyflag \t");
        printf("stp->sd_copyflag: \t%x\n", stp->sd_copyflag);
        printf("tcp: \t%p\n", tcp);
        printf("tcp->tcp_snd_zcopy_on: \t%d\n", tcp->tcp_snd_zcopy_on);
        printf("tcp->tcp_snd_zcopy_aware: \t%d\n", tcp->tcp_snd_zcopy_aware);
        printf("tcp->tcp_connp: \t%p\n", connp);
        printf("\n");
}

fbt::ire_to_ill:entry
/self->trace_zchck/
{
        ire = (ire_t *)arg0;
        printf("\n");
        printf("ire: \t%p\n", ire);
        printf("\n");
}

fbt::ire_to_ill:return
/self->trace_zchck/
{
        ill = (ill_t *)arg1;
        printf("\n");
        printf("ill: \t%p\n", ill);
        printf("\n");
        printf("ill_name: \t%s\n", stringof(ill->ill_name));
        printf("ill_capabilities: \t%x\n", ill->ill_capabilities);
        printf("ill_zerocopy_capab->version: \t%d\n", 
ill->ill_zerocopy_capab->ill_zerocopy_version);
        printf("ill_zerocopy_capab->flags: \t%d\n", 
ill->ill_zerocopy_capab->ill_zerocopy_flags);
        printf("\n");
}


fbt::tcp_send_data:return
/self->trace_zchck/
{
        self->trace_zchck = 0;
}

fbt:sockfs::entry,
fbt:tcp::entry,
fbt:ip::entry,
fbt:hook::entry,
fbt:ipf::entry,
fbt:bge::entry
/self->trace_zchck/
{}

fbt:sockfs::return,
fbt:tcp::return,
fbt:ip::return,
fbt:hook::return,
fbt:ipf::return,
fbt:bge::return
/self->trace_zchck/
{
        trace(arg1);
}

END
/self->trace_zchck/
{
        self->trace_zchck = 0;
        exit(0);
}
_______________________________________________
networking-discuss mailing list
[email protected]

Reply via email to