sock.c (d04fb13c9fcdad850c0fcaeb155863de3d8169a0) sock.c (76a9ebe811fb3d0605cb084f1ae6be5610541865)
1/*
2 * INET An implementation of the TCP/IP protocol suite for the LINUX
3 * operating system. INET is implemented using the BSD Socket
4 * interface as the means of communication with the user level.
5 *
6 * Generic socket support routines. Memory allocators, socket lock/release
7 * handler for protocols to use and generic option handler.
8 *

--- 984 unchanged lines hidden (view full) ---

993 break;
994#endif
995
996 case SO_MAX_PACING_RATE:
997 if (val != ~0U)
998 cmpxchg(&sk->sk_pacing_status,
999 SK_PACING_NONE,
1000 SK_PACING_NEEDED);
1/*
2 * INET An implementation of the TCP/IP protocol suite for the LINUX
3 * operating system. INET is implemented using the BSD Socket
4 * interface as the means of communication with the user level.
5 *
6 * Generic socket support routines. Memory allocators, socket lock/release
7 * handler for protocols to use and generic option handler.
8 *

--- 984 unchanged lines hidden (view full) ---

993 break;
994#endif
995
996 case SO_MAX_PACING_RATE:
997 if (val != ~0U)
998 cmpxchg(&sk->sk_pacing_status,
999 SK_PACING_NONE,
1000 SK_PACING_NEEDED);
1001 sk->sk_max_pacing_rate = val;
1001 sk->sk_max_pacing_rate = (val == ~0U) ? ~0UL : val;
1002 sk->sk_pacing_rate = min(sk->sk_pacing_rate,
1003 sk->sk_max_pacing_rate);
1004 break;
1005
1006 case SO_INCOMING_CPU:
1007 sk->sk_incoming_cpu = val;
1008 break;
1009

--- 321 unchanged lines hidden (view full) ---

1331
1332#ifdef CONFIG_NET_RX_BUSY_POLL
1333 case SO_BUSY_POLL:
1334 v.val = sk->sk_ll_usec;
1335 break;
1336#endif
1337
1338 case SO_MAX_PACING_RATE:
1002 sk->sk_pacing_rate = min(sk->sk_pacing_rate,
1003 sk->sk_max_pacing_rate);
1004 break;
1005
1006 case SO_INCOMING_CPU:
1007 sk->sk_incoming_cpu = val;
1008 break;
1009

--- 321 unchanged lines hidden (view full) ---

1331
1332#ifdef CONFIG_NET_RX_BUSY_POLL
1333 case SO_BUSY_POLL:
1334 v.val = sk->sk_ll_usec;
1335 break;
1336#endif
1337
1338 case SO_MAX_PACING_RATE:
1339 v.val = sk->sk_max_pacing_rate;
1339 /* 32bit version */
1340 v.val = min_t(unsigned long, sk->sk_max_pacing_rate, ~0U);
1340 break;
1341
1342 case SO_INCOMING_CPU:
1343 v.val = sk->sk_incoming_cpu;
1344 break;
1345
1346 case SO_MEMINFO:
1347 {

--- 885 unchanged lines hidden (view full) ---

2233 return true;
2234
2235 sk_enter_memory_pressure(sk);
2236 sk_stream_moderate_sndbuf(sk);
2237 return false;
2238}
2239EXPORT_SYMBOL(sk_page_frag_refill);
2240
1341 break;
1342
1343 case SO_INCOMING_CPU:
1344 v.val = sk->sk_incoming_cpu;
1345 break;
1346
1347 case SO_MEMINFO:
1348 {

--- 885 unchanged lines hidden (view full) ---

2234 return true;
2235
2236 sk_enter_memory_pressure(sk);
2237 sk_stream_moderate_sndbuf(sk);
2238 return false;
2239}
2240EXPORT_SYMBOL(sk_page_frag_refill);
2241
2242int sk_alloc_sg(struct sock *sk, int len, struct scatterlist *sg,
2243 int sg_start, int *sg_curr_index, unsigned int *sg_curr_size,
2244 int first_coalesce)
2245{
2246 int sg_curr = *sg_curr_index, use = 0, rc = 0;
2247 unsigned int size = *sg_curr_size;
2248 struct page_frag *pfrag;
2249 struct scatterlist *sge;
2250
2251 len -= size;
2252 pfrag = sk_page_frag(sk);
2253
2254 while (len > 0) {
2255 unsigned int orig_offset;
2256
2257 if (!sk_page_frag_refill(sk, pfrag)) {
2258 rc = -ENOMEM;
2259 goto out;
2260 }
2261
2262 use = min_t(int, len, pfrag->size - pfrag->offset);
2263
2264 if (!sk_wmem_schedule(sk, use)) {
2265 rc = -ENOMEM;
2266 goto out;
2267 }
2268
2269 sk_mem_charge(sk, use);
2270 size += use;
2271 orig_offset = pfrag->offset;
2272 pfrag->offset += use;
2273
2274 sge = sg + sg_curr - 1;
2275 if (sg_curr > first_coalesce && sg_page(sge) == pfrag->page &&
2276 sge->offset + sge->length == orig_offset) {
2277 sge->length += use;
2278 } else {
2279 sge = sg + sg_curr;
2280 sg_unmark_end(sge);
2281 sg_set_page(sge, pfrag->page, use, orig_offset);
2282 get_page(pfrag->page);
2283 sg_curr++;
2284
2285 if (sg_curr == MAX_SKB_FRAGS)
2286 sg_curr = 0;
2287
2288 if (sg_curr == sg_start) {
2289 rc = -ENOSPC;
2290 break;
2291 }
2292 }
2293
2294 len -= use;
2295 }
2296out:
2297 *sg_curr_size = size;
2298 *sg_curr_index = sg_curr;
2299 return rc;
2300}
2301EXPORT_SYMBOL(sk_alloc_sg);
2302
2241static void __lock_sock(struct sock *sk)
2242 __releases(&sk->sk_lock.slock)
2243 __acquires(&sk->sk_lock.slock)
2244{
2245 DEFINE_WAIT(wait);
2246
2247 for (;;) {
2248 prepare_to_wait_exclusive(&sk->sk_lock.wq, &wait,

--- 495 unchanged lines hidden (view full) ---

2744 sk->sk_stamp = SK_DEFAULT_STAMP;
2745 atomic_set(&sk->sk_zckey, 0);
2746
2747#ifdef CONFIG_NET_RX_BUSY_POLL
2748 sk->sk_napi_id = 0;
2749 sk->sk_ll_usec = sysctl_net_busy_read;
2750#endif
2751
2303static void __lock_sock(struct sock *sk)
2304 __releases(&sk->sk_lock.slock)
2305 __acquires(&sk->sk_lock.slock)
2306{
2307 DEFINE_WAIT(wait);
2308
2309 for (;;) {
2310 prepare_to_wait_exclusive(&sk->sk_lock.wq, &wait,

--- 495 unchanged lines hidden (view full) ---

2806 sk->sk_stamp = SK_DEFAULT_STAMP;
2807 atomic_set(&sk->sk_zckey, 0);
2808
2809#ifdef CONFIG_NET_RX_BUSY_POLL
2810 sk->sk_napi_id = 0;
2811 sk->sk_ll_usec = sysctl_net_busy_read;
2812#endif
2813
2752 sk->sk_max_pacing_rate = ~0U;
2753 sk->sk_pacing_rate = ~0U;
2814 sk->sk_max_pacing_rate = ~0UL;
2815 sk->sk_pacing_rate = ~0UL;
2754 sk->sk_pacing_shift = 10;
2755 sk->sk_incoming_cpu = -1;
2756
2757 sk_rx_queue_clear(sk);
2758 /*
2759 * Before updating sk_refcnt, we must commit prior changes to memory
2760 * (Documentation/RCU/rculist_nulls.txt for details)
2761 */

--- 660 unchanged lines hidden ---
2816 sk->sk_pacing_shift = 10;
2817 sk->sk_incoming_cpu = -1;
2818
2819 sk_rx_queue_clear(sk);
2820 /*
2821 * Before updating sk_refcnt, we must commit prior changes to memory
2822 * (Documentation/RCU/rculist_nulls.txt for details)
2823 */

--- 660 unchanged lines hidden ---