Callback sock_def_readable()

Text extracted form the original post here.


The default ->sk_data_ready() callback is sock_def_readable():

static void sock_def_readable(struct sock *sk, int len)
        struct socket_wq *wq;

        wq = rcu_dereference(sk->sk_wq);
        if (wq_has_sleeper(wq))
                wake_up_interruptible_sync_poll(&wq->wait, POLLIN | POLLPRI |
                                                POLLRDNORM | POLLRDBAND);
        sk_wake_async(sk, SOCK_WAKE_WAITD, POLL_IN);

which basically wakes up the process waiting for these data, for example, recv(), and let them process the data in ->sk_receive_queue.

Some protocol may override this, for example, netlink, see __netlink_kernel_create().

BTW, you can use perf top command to see which kernel function consumes most CPU cycles.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s