Re: [PATCH net-next 2/2] net:add socket option for low latencypolling

From: Eric Dumazet
Date: Tue Jun 11 2013 - 10:45:42 EST


On Tue, 2013-06-11 at 17:24 +0300, Eliezer Tamir wrote:
> adds a socket option for low latency polling.
> This allows overriding the global sysctl value with a per-socket one.
>
> Signed-off-by: Eliezer Tamir <eliezer.tamir@xxxxxxxxxxxxxxx>
> ---
>
>
> -static inline cycles_t ll_end_time(void)
> +static inline cycles_t ll_end_time(struct sock *sk)
> {
> - return TSC_MHZ * ACCESS_ONCE(sysctl_net_ll_poll) + get_cycles();
> + return TSC_MHZ * ACCESS_ONCE(sk->sk_ll_usec) + get_cycles();
> }

Hmm, sk_ll_usec is an unsigned int.

(cycles_t)TSC_MHZ * ACCESS_ONCE(sk->sk_ll_usec) + get_cycles();

>
> +#ifdef CONFIG_NET_LL_RX_POLL
> + case SO_LL:
> + if (!capable(CAP_NET_ADMIN))
> + ret = -EACCES;
> + else {
> + unsigned long ulval;

Why an "unsigned long" ?


> +
> + if (!copy_from_user(&ulval, optval, sizeof(ulval))
> + && ulval >= 0)
> + sk->sk_ll_usec = ulval;
> +
> + else
> + ret = -EINVAL;

Just use
sk->sk_ll_usec = val;

> +
> + }
> + break;
> +#endif
> default:
> ret = -ENOPROTOOPT;
> break;
> @@ -944,6 +961,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
>
> union {
> int val;
> + unsigned long ulval;

Why an unsigned long ? 32bit are more than enough.

> struct linger ling;
> struct timeval tm;
> } v;
> @@ -1170,6 +1188,13 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
> v.val = sock_flag(sk, SOCK_SELECT_ERR_QUEUE);
> break;
>
> +#ifdef CONFIG_NET_LL_RX_POLL
> + case SO_LL:
> + len = sizeof(v.ulval);
> + v.ulval = sk->sk_ll_usec;
> + break;
> +#endif
> +



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