Merge git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
[cascardo/linux.git] / include / net / sock.h
index 37d6cc5..2210fec 100644 (file)
@@ -54,8 +54,8 @@
 #include <linux/security.h>
 #include <linux/slab.h>
 #include <linux/uaccess.h>
+#include <linux/page_counter.h>
 #include <linux/memcontrol.h>
-#include <linux/res_counter.h>
 #include <linux/static_key.h>
 #include <linux/aio.h>
 #include <linux/sched.h>
@@ -273,6 +273,7 @@ struct cg_proto;
   *    @sk_rcvtimeo: %SO_RCVTIMEO setting
   *    @sk_sndtimeo: %SO_SNDTIMEO setting
   *    @sk_rxhash: flow hash received from netif layer
+  *    @sk_incoming_cpu: record cpu processing incoming packets
   *    @sk_txhash: computed flow hash for use on transmit
   *    @sk_filter: socket filtering instructions
   *    @sk_protinfo: private area, net family specific, when not using slab
@@ -350,6 +351,12 @@ struct sock {
 #ifdef CONFIG_RPS
        __u32                   sk_rxhash;
 #endif
+       u16                     sk_incoming_cpu;
+       /* 16bit hole
+        * Warned : sk_incoming_cpu can be set from softirq,
+        * Do not use this hole without fully understanding possible issues.
+        */
+
        __u32                   sk_txhash;
 #ifdef CONFIG_NET_RX_BUSY_POLL
        unsigned int            sk_napi_id;
@@ -833,6 +840,11 @@ static inline int sk_backlog_rcv(struct sock *sk, struct sk_buff *skb)
        return sk->sk_backlog_rcv(sk, skb);
 }
 
+static inline void sk_incoming_cpu_update(struct sock *sk)
+{
+       sk->sk_incoming_cpu = raw_smp_processor_id();
+}
+
 static inline void sock_rps_record_flow_hash(__u32 hash)
 {
 #ifdef CONFIG_RPS
@@ -897,6 +909,7 @@ static inline void sock_rps_reset_rxhash(struct sock *sk)
                if (!__rc) {                                            \
                        *(__timeo) = schedule_timeout(*(__timeo));      \
                }                                                       \
+               sched_annotate_sleep();                                         \
                lock_sock(__sk);                                        \
                __rc = __condition;                                     \
                __rc;                                                   \
@@ -1061,7 +1074,7 @@ enum cg_proto_flags {
 };
 
 struct cg_proto {
-       struct res_counter      memory_allocated;       /* Current allocated memory. */
+       struct page_counter     memory_allocated;       /* Current allocated memory. */
        struct percpu_counter   sockets_allocated;      /* Current number of sockets. */
        int                     memory_pressure;
        long                    sysctl_mem[3];
@@ -1213,34 +1226,26 @@ static inline void memcg_memory_allocated_add(struct cg_proto *prot,
                                              unsigned long amt,
                                              int *parent_status)
 {
-       struct res_counter *fail;
-       int ret;
+       page_counter_charge(&prot->memory_allocated, amt);
 
-       ret = res_counter_charge_nofail(&prot->memory_allocated,
-                                       amt << PAGE_SHIFT, &fail);
-       if (ret < 0)
+       if (page_counter_read(&prot->memory_allocated) >
+           prot->memory_allocated.limit)
                *parent_status = OVER_LIMIT;
 }
 
 static inline void memcg_memory_allocated_sub(struct cg_proto *prot,
                                              unsigned long amt)
 {
-       res_counter_uncharge(&prot->memory_allocated, amt << PAGE_SHIFT);
-}
-
-static inline u64 memcg_memory_allocated_read(struct cg_proto *prot)
-{
-       u64 ret;
-       ret = res_counter_read_u64(&prot->memory_allocated, RES_USAGE);
-       return ret >> PAGE_SHIFT;
+       page_counter_uncharge(&prot->memory_allocated, amt);
 }
 
 static inline long
 sk_memory_allocated(const struct sock *sk)
 {
        struct proto *prot = sk->sk_prot;
+
        if (mem_cgroup_sockets_enabled && sk->sk_cgrp)
-               return memcg_memory_allocated_read(sk->sk_cgrp);
+               return page_counter_read(&sk->sk_cgrp->memory_allocated);
 
        return atomic_long_read(prot->memory_allocated);
 }
@@ -1254,7 +1259,7 @@ sk_memory_allocated_add(struct sock *sk, int amt, int *parent_status)
                memcg_memory_allocated_add(sk->sk_cgrp, amt, parent_status);
                /* update the root cgroup regardless */
                atomic_long_add_return(amt, prot->memory_allocated);
-               return memcg_memory_allocated_read(sk->sk_cgrp);
+               return page_counter_read(&sk->sk_cgrp->memory_allocated);
        }
 
        return atomic_long_add_return(amt, prot->memory_allocated);
@@ -1873,29 +1878,6 @@ static inline int skb_copy_to_page_nocache(struct sock *sk, char __user *from,
        return 0;
 }
 
-static inline int skb_copy_to_page(struct sock *sk, char __user *from,
-                                  struct sk_buff *skb, struct page *page,
-                                  int off, int copy)
-{
-       if (skb->ip_summed == CHECKSUM_NONE) {
-               int err = 0;
-               __wsum csum = csum_and_copy_from_user(from,
-                                                    page_address(page) + off,
-                                                           copy, 0, &err);
-               if (err)
-                       return err;
-               skb->csum = csum_block_add(skb->csum, csum, skb->len);
-       } else if (copy_from_user(page_address(page) + off, from, copy))
-               return -EFAULT;
-
-       skb->len             += copy;
-       skb->data_len        += copy;
-       skb->truesize        += copy;
-       sk->sk_wmem_queued   += copy;
-       sk_mem_charge(sk, copy);
-       return 0;
-}
-
 /**
  * sk_wmem_alloc_get - returns write allocations
  * @sk: socket
@@ -2277,16 +2259,6 @@ bool sk_ns_capable(const struct sock *sk,
 bool sk_capable(const struct sock *sk, int cap);
 bool sk_net_capable(const struct sock *sk, int cap);
 
-/*
- *     Enable debug/info messages
- */
-extern int net_msg_warn;
-#define NETDEBUG(fmt, args...) \
-       do { if (net_msg_warn) printk(fmt,##args); } while (0)
-
-#define LIMIT_NETDEBUG(fmt, args...) \
-       do { if (net_msg_warn && net_ratelimit()) printk(fmt,##args); } while(0)
-
 extern __u32 sysctl_wmem_max;
 extern __u32 sysctl_rmem_max;