~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/net/rds/tcp_recv.c

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /net/rds/tcp_recv.c (Version linux-6.12-rc7) and /net/rds/tcp_recv.c (Version linux-6.1.114)


** Warning: Cannot open xref database.

  1 /*                                                  1 
  2  * Copyright (c) 2006, 2017 Oracle and/or its     
  3  *                                                
  4  * This software is available to you under a c    
  5  * licenses.  You may choose to be licensed un    
  6  * General Public License (GPL) Version 2, ava    
  7  * COPYING in the main directory of this sourc    
  8  * OpenIB.org BSD license below:                  
  9  *                                                
 10  *     Redistribution and use in source and bi    
 11  *     without modification, are permitted pro    
 12  *     conditions are met:                        
 13  *                                                
 14  *      - Redistributions of source code must     
 15  *        copyright notice, this list of condi    
 16  *        disclaimer.                             
 17  *                                                
 18  *      - Redistributions in binary form must     
 19  *        copyright notice, this list of condi    
 20  *        disclaimer in the documentation and/    
 21  *        provided with the distribution.         
 22  *                                                
 23  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT W    
 24  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMIT    
 25  * MERCHANTABILITY, FITNESS FOR A PARTICULAR P    
 26  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTH    
 27  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER L    
 28  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARIS    
 29  * CONNECTION WITH THE SOFTWARE OR THE USE OR     
 30  * SOFTWARE.                                      
 31  *                                                
 32  */                                               
 33 #include <linux/kernel.h>                         
 34 #include <linux/slab.h>                           
 35 #include <net/tcp.h>                              
 36 #include <trace/events/sock.h>                    
 37                                                   
 38 #include "rds.h"                                  
 39 #include "tcp.h"                                  
 40                                                   
 41 static struct kmem_cache *rds_tcp_incoming_sla    
 42                                                   
 43 static void rds_tcp_inc_purge(struct rds_incom    
 44 {                                                 
 45         struct rds_tcp_incoming *tinc;            
 46         tinc = container_of(inc, struct rds_tc    
 47         rdsdebug("purging tinc %p inc %p\n", t    
 48         skb_queue_purge(&tinc->ti_skb_list);      
 49 }                                                 
 50                                                   
 51 void rds_tcp_inc_free(struct rds_incoming *inc    
 52 {                                                 
 53         struct rds_tcp_incoming *tinc;            
 54         tinc = container_of(inc, struct rds_tc    
 55         rds_tcp_inc_purge(inc);                   
 56         rdsdebug("freeing tinc %p inc %p\n", t    
 57         kmem_cache_free(rds_tcp_incoming_slab,    
 58 }                                                 
 59                                                   
 60 /*                                                
 61  * this is pretty lame, but, whatever.            
 62  */                                               
 63 int rds_tcp_inc_copy_to_user(struct rds_incomi    
 64 {                                                 
 65         struct rds_tcp_incoming *tinc;            
 66         struct sk_buff *skb;                      
 67         int ret = 0;                              
 68                                                   
 69         if (!iov_iter_count(to))                  
 70                 goto out;                         
 71                                                   
 72         tinc = container_of(inc, struct rds_tc    
 73                                                   
 74         skb_queue_walk(&tinc->ti_skb_list, skb    
 75                 unsigned long to_copy, skb_off    
 76                 for (skb_off = 0; skb_off < sk    
 77                         to_copy = iov_iter_cou    
 78                         to_copy = min(to_copy,    
 79                                                   
 80                         if (skb_copy_datagram_    
 81                                 return -EFAULT    
 82                                                   
 83                         rds_stats_add(s_copy_t    
 84                         ret += to_copy;           
 85                                                   
 86                         if (!iov_iter_count(to    
 87                                 goto out;         
 88                 }                                 
 89         }                                         
 90 out:                                              
 91         return ret;                               
 92 }                                                 
 93                                                   
 94 /*                                                
 95  * We have a series of skbs that have fragment    
 96  * bitmap.  They must add up to the exact size    
 97  * use the skb helpers to copy those into the     
 98  * congestion bitmap for the remote address of    
 99  * the congestion core that the bitmap has bee    
100  * sleepers.                                      
101  *                                                
102  * This is racing with sending paths which are    
103  * bitmap indicates that their recipient is co    
104  */                                               
105                                                   
106 static void rds_tcp_cong_recv(struct rds_conne    
107                               struct rds_tcp_i    
108 {                                                 
109         struct sk_buff *skb;                      
110         unsigned int to_copy, skb_off;            
111         unsigned int map_off;                     
112         unsigned int map_page;                    
113         struct rds_cong_map *map;                 
114         int ret;                                  
115                                                   
116         /* catch completely corrupt packets */    
117         if (be32_to_cpu(tinc->ti_inc.i_hdr.h_l    
118                 return;                           
119                                                   
120         map_page = 0;                             
121         map_off = 0;                              
122         map = conn->c_fcong;                      
123                                                   
124         skb_queue_walk(&tinc->ti_skb_list, skb    
125                 skb_off = 0;                      
126                 while (skb_off < skb->len) {      
127                         to_copy = min_t(unsign    
128                                         skb->l    
129                                                   
130                         BUG_ON(map_page >= RDS    
131                                                   
132                         /* only returns 0 or -    
133                         ret = skb_copy_bits(sk    
134                                 (void *)map->m    
135                                 to_copy);         
136                         BUG_ON(ret != 0);         
137                                                   
138                         skb_off += to_copy;       
139                         map_off += to_copy;       
140                         if (map_off == PAGE_SI    
141                                 map_off = 0;      
142                                 map_page++;       
143                         }                         
144                 }                                 
145         }                                         
146                                                   
147         rds_cong_map_updated(map, ~(u64) 0);      
148 }                                                 
149                                                   
150 struct rds_tcp_desc_arg {                         
151         struct rds_conn_path *conn_path;          
152         gfp_t gfp;                                
153 };                                                
154                                                   
155 static int rds_tcp_data_recv(read_descriptor_t    
156                              unsigned int offs    
157 {                                                 
158         struct rds_tcp_desc_arg *arg = desc->a    
159         struct rds_conn_path *cp = arg->conn_p    
160         struct rds_tcp_connection *tc = cp->cp    
161         struct rds_tcp_incoming *tinc = tc->t_    
162         struct sk_buff *clone;                    
163         size_t left = len, to_copy;               
164                                                   
165         rdsdebug("tcp data tc %p skb %p offset    
166                  len);                            
167                                                   
168         /*                                        
169          * tcp_read_sock() interprets partial     
170          * processing.                            
171          */                                       
172         while (left) {                            
173                 if (!tinc) {                      
174                         tinc = kmem_cache_allo    
175                                                   
176                         if (!tinc) {              
177                                 desc->error =     
178                                 goto out;         
179                         }                         
180                         tc->t_tinc = tinc;        
181                         rdsdebug("allocated ti    
182                         rds_inc_path_init(&tin    
183                                           &cp-    
184                         tinc->ti_inc.i_rx_lat_    
185                                         local_    
186                                                   
187                         /*                        
188                          * XXX * we might be a    
189                          * we've already seria    
190                          */                       
191                         skb_queue_head_init(&t    
192                 }                                 
193                                                   
194                 if (left && tc->t_tinc_hdr_rem    
195                         to_copy = min(tc->t_ti    
196                         rdsdebug("copying %zu     
197                                  skb);            
198                         skb_copy_bits(skb, off    
199                                       (char *)    
200                                                   
201                                                   
202                                       to_copy)    
203                         tc->t_tinc_hdr_rem -=     
204                         left -= to_copy;          
205                         offset += to_copy;        
206                                                   
207                         if (tc->t_tinc_hdr_rem    
208                                 /* could be 0     
209                                 tc->t_tinc_dat    
210                                         be32_t    
211                                 tinc->ti_inc.i    
212                                         local_    
213                         }                         
214                 }                                 
215                                                   
216                 if (left && tc->t_tinc_data_re    
217                         to_copy = min(tc->t_ti    
218                                                   
219                         clone = pskb_extract(s    
220                         if (!clone) {             
221                                 desc->error =     
222                                 goto out;         
223                         }                         
224                                                   
225                         skb_queue_tail(&tinc->    
226                                                   
227                         rdsdebug("skb %p data     
228                                  "clone %p dat    
229                                  skb, skb->dat    
230                                  clone, clone-    
231                                                   
232                         tc->t_tinc_data_rem -=    
233                         left -= to_copy;          
234                         offset += to_copy;        
235                 }                                 
236                                                   
237                 if (tc->t_tinc_hdr_rem == 0 &&    
238                         struct rds_connection     
239                                                   
240                         if (tinc->ti_inc.i_hdr    
241                                 rds_tcp_cong_r    
242                         else                      
243                                 rds_recv_incom    
244                                                   
245                                                   
246                                                   
247                                                   
248                         tc->t_tinc_hdr_rem = s    
249                         tc->t_tinc_data_rem =     
250                         tc->t_tinc = NULL;        
251                         rds_inc_put(&tinc->ti_    
252                         tinc = NULL;              
253                 }                                 
254         }                                         
255 out:                                              
256         rdsdebug("returning len %zu left %zu s    
257                  len, left, skb->len,             
258                  skb_queue_len(&tc->t_sock->sk    
259         return len - left;                        
260 }                                                 
261                                                   
262 /* the caller has to hold the sock lock */        
263 static int rds_tcp_read_sock(struct rds_conn_p    
264 {                                                 
265         struct rds_tcp_connection *tc = cp->cp    
266         struct socket *sock = tc->t_sock;         
267         read_descriptor_t desc;                   
268         struct rds_tcp_desc_arg arg;              
269                                                   
270         /* It's like glib in the kernel! */       
271         arg.conn_path = cp;                       
272         arg.gfp = gfp;                            
273         desc.arg.data = &arg;                     
274         desc.error = 0;                           
275         desc.count = 1; /* give more than one     
276                                                   
277         tcp_read_sock(sock->sk, &desc, rds_tcp    
278         rdsdebug("tcp_read_sock for tc %p gfp     
279                  desc.error);                     
280                                                   
281         return desc.error;                        
282 }                                                 
283                                                   
284 /*                                                
285  * We hold the sock lock to serialize our rds_    
286  * data_ready.                                    
287  *                                                
288  * if we fail to allocate we're in trouble.. b    
289  * trying again to see if the VM can free up s    
290  */                                               
291 int rds_tcp_recv_path(struct rds_conn_path *cp    
292 {                                                 
293         struct rds_tcp_connection *tc = cp->cp    
294         struct socket *sock = tc->t_sock;         
295         int ret = 0;                              
296                                                   
297         rdsdebug("recv worker path [%d] tc %p     
298                  cp->cp_index, tc, sock);         
299                                                   
300         lock_sock(sock->sk);                      
301         ret = rds_tcp_read_sock(cp, GFP_KERNEL    
302         release_sock(sock->sk);                   
303                                                   
304         return ret;                               
305 }                                                 
306                                                   
307 void rds_tcp_data_ready(struct sock *sk)          
308 {                                                 
309         void (*ready)(struct sock *sk);           
310         struct rds_conn_path *cp;                 
311         struct rds_tcp_connection *tc;            
312                                                   
313         trace_sk_data_ready(sk);                  
314         rdsdebug("data ready sk %p\n", sk);       
315                                                   
316         read_lock_bh(&sk->sk_callback_lock);      
317         cp = sk->sk_user_data;                    
318         if (!cp) { /* check for teardown race     
319                 ready = sk->sk_data_ready;        
320                 goto out;                         
321         }                                         
322                                                   
323         tc = cp->cp_transport_data;               
324         ready = tc->t_orig_data_ready;            
325         rds_tcp_stats_inc(s_tcp_data_ready_cal    
326                                                   
327         if (rds_tcp_read_sock(cp, GFP_ATOMIC)     
328                 rcu_read_lock();                  
329                 if (!rds_destroy_pending(cp->c    
330                         queue_delayed_work(rds    
331                 rcu_read_unlock();                
332         }                                         
333 out:                                              
334         read_unlock_bh(&sk->sk_callback_lock);    
335         ready(sk);                                
336 }                                                 
337                                                   
338 int rds_tcp_recv_init(void)                       
339 {                                                 
340         rds_tcp_incoming_slab = KMEM_CACHE(rds    
341         if (!rds_tcp_incoming_slab)               
342                 return -ENOMEM;                   
343         return 0;                                 
344 }                                                 
345                                                   
346 void rds_tcp_recv_exit(void)                      
347 {                                                 
348         kmem_cache_destroy(rds_tcp_incoming_sl    
349 }                                                 
350                                                   

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php