Skip to content

Commit 27a884d

Browse files
acmelDavid S. Miller
authored andcommitted
[SK_BUFF]: Convert skb->tail to sk_buff_data_t
So that it is also an offset from skb->head, reduces its size from 8 to 4 bytes on 64bit architectures, allowing us to combine the 4 bytes hole left by the layer headers conversion, reducing struct sk_buff size to 256 bytes, i.e. 4 64byte cachelines, and since the sk_buff slab cache is SLAB_HWCACHE_ALIGN... :-) Many calculations that previously required that skb->{transport,network, mac}_header be first converted to a pointer now can be done directly, being meaningful as offsets or pointers. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent be8bd86 commit 27a884d

110 files changed

Lines changed: 396 additions & 329 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎arch/ia64/sn/kernel/xpnet.c‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -264,15 +264,15 @@ xpnet_receive(partid_t partid, int channel, struct xpnet_message *msg)
264264

265265
dev_dbg(xpnet, "<skb->head=0x%p skb->data=0x%p skb->tail=0x%p "
266266
"skb->end=0x%p skb->len=%d\n", (void *) skb->head,
267-
(void *) skb->data, (void *) skb->tail, (void *) skb->end,
267+
(void *)skb->data, skb_tail_pointer(skb), (void *)skb->end,
268268
skb->len);
269269

270270
skb->protocol = eth_type_trans(skb, xpnet_device);
271271
skb->ip_summed = CHECKSUM_UNNECESSARY;
272272

273273
dev_dbg(xpnet, "passing skb to network layer; \n\tskb->head=0x%p "
274274
"skb->data=0x%p skb->tail=0x%p skb->end=0x%p skb->len=%d\n",
275-
(void *) skb->head, (void *) skb->data, (void *) skb->tail,
275+
(void *)skb->head, (void *)skb->data, skb_tail_pointer(skb),
276276
(void *) skb->end, skb->len);
277277

278278

@@ -475,7 +475,7 @@ xpnet_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
475475

476476
dev_dbg(xpnet, ">skb->head=0x%p skb->data=0x%p skb->tail=0x%p "
477477
"skb->end=0x%p skb->len=%d\n", (void *) skb->head,
478-
(void *) skb->data, (void *) skb->tail, (void *) skb->end,
478+
(void *)skb->data, skb_tail_pointer(skb), (void *)skb->end,
479479
skb->len);
480480

481481

@@ -497,7 +497,7 @@ xpnet_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
497497

498498
/* get the beginning of the first cacheline and end of last */
499499
start_addr = ((u64) skb->data & ~(L1_CACHE_BYTES - 1));
500-
end_addr = L1_CACHE_ALIGN((u64) skb->tail);
500+
end_addr = L1_CACHE_ALIGN((u64)skb_tail_pointer(skb));
501501

502502
/* calculate how many bytes to embed in the XPC message */
503503
embedded_bytes = 0;
@@ -573,7 +573,7 @@ xpnet_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
573573
msg->magic = XPNET_MAGIC;
574574
msg->size = end_addr - start_addr;
575575
msg->leadin_ignore = (u64) skb->data - start_addr;
576-
msg->tailout_ignore = end_addr - (u64) skb->tail;
576+
msg->tailout_ignore = end_addr - (u64)skb_tail_pointer(skb);
577577
msg->buf_pa = __pa(start_addr);
578578

579579
dev_dbg(xpnet, "sending XPC message to %d:%d\nmsg->buf_pa="

‎drivers/atm/he.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1901,13 +1901,13 @@ he_service_rbrq(struct he_dev *he_dev, int group)
19011901
case ATM_AAL0:
19021902
/* 2.10.1.5 raw cell receive */
19031903
skb->len = ATM_AAL0_SDU;
1904-
skb->tail = skb->data + skb->len;
1904+
skb_set_tail_pointer(skb, skb->len);
19051905
break;
19061906
case ATM_AAL5:
19071907
/* 2.10.1.2 aal5 receive */
19081908

19091909
skb->len = AAL5_LEN(skb->data, he_vcc->pdu_len);
1910-
skb->tail = skb->data + skb->len;
1910+
skb_set_tail_pointer(skb, skb->len);
19111911
#ifdef USE_CHECKSUM_HW
19121912
if (vcc->vpi == 0 && vcc->vci >= ATM_NOT_RSV_VCI) {
19131913
skb->ip_summed = CHECKSUM_COMPLETE;

‎drivers/atm/idt77252.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1816,7 +1816,8 @@ push_rx_skb(struct idt77252_dev *card, struct sk_buff *skb, int queue)
18161816
u32 handle;
18171817
u32 addr;
18181818

1819-
skb->data = skb->tail = skb->head;
1819+
skb->data = skb->head;
1820+
skb_reset_tail_pointer(skb);
18201821
skb->len = 0;
18211822

18221823
skb_reserve(skb, 16);

‎drivers/atm/nicstar.c‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2208,7 +2208,7 @@ static void dequeue_rx(ns_dev *card, ns_rsqe *rsqe)
22082208
if (i == 1 && ns_rsqe_eopdu(rsqe))
22092209
*((u32 *) sb->data) |= 0x00000002;
22102210
skb_put(sb, NS_AAL0_HEADER);
2211-
memcpy(sb->tail, cell, ATM_CELL_PAYLOAD);
2211+
memcpy(skb_tail_pointer(sb), cell, ATM_CELL_PAYLOAD);
22122212
skb_put(sb, ATM_CELL_PAYLOAD);
22132213
ATM_SKB(sb)->vcc = vcc;
22142214
__net_timestamp(sb);
@@ -2252,7 +2252,8 @@ static void dequeue_rx(ns_dev *card, ns_rsqe *rsqe)
22522252
vc->rx_iov = iovb;
22532253
NS_SKB(iovb)->iovcnt = 0;
22542254
iovb->len = 0;
2255-
iovb->tail = iovb->data = iovb->head;
2255+
iovb->data = iovb->head;
2256+
skb_reset_tail_pointer(iovb);
22562257
NS_SKB(iovb)->vcc = vcc;
22572258
/* IMPORTANT: a pointer to the sk_buff containing the small or large
22582259
buffer is stored as iovec base, NOT a pointer to the
@@ -2265,7 +2266,8 @@ static void dequeue_rx(ns_dev *card, ns_rsqe *rsqe)
22652266
recycle_iovec_rx_bufs(card, (struct iovec *) iovb->data, NS_MAX_IOVECS);
22662267
NS_SKB(iovb)->iovcnt = 0;
22672268
iovb->len = 0;
2268-
iovb->tail = iovb->data = iovb->head;
2269+
iovb->data = iovb->head;
2270+
skb_reset_tail_pointer(iovb);
22692271
NS_SKB(iovb)->vcc = vcc;
22702272
}
22712273
iov = &((struct iovec *) iovb->data)[NS_SKB(iovb)->iovcnt++];
@@ -2489,7 +2491,7 @@ static void dequeue_rx(ns_dev *card, ns_rsqe *rsqe)
24892491
{
24902492
lb = (struct sk_buff *) iov->iov_base;
24912493
tocopy = min_t(int, remaining, iov->iov_len);
2492-
memcpy(hb->tail, lb->data, tocopy);
2494+
memcpy(skb_tail_pointer(hb), lb->data, tocopy);
24932495
skb_put(hb, tocopy);
24942496
iov++;
24952497
remaining -= tocopy;

‎drivers/infiniband/hw/amso1100/c2.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,8 @@ static void c2_rx_error(struct c2_port *c2_port, struct c2_element *elem)
439439
}
440440

441441
/* Setup the skb for reuse since we're dropping this pkt */
442-
elem->skb->tail = elem->skb->data = elem->skb->head;
442+
elem->skb->data = elem->skb->head;
443+
skb_reset_tail_pointer(elem->skb);
443444

444445
/* Zero out the rxp hdr in the sk_buff */
445446
memset(elem->skb->data, 0, sizeof(*rxp_hdr));
@@ -521,7 +522,7 @@ static void c2_rx_interrupt(struct net_device *netdev)
521522
* "sizeof(struct c2_rxp_hdr)".
522523
*/
523524
skb->data += sizeof(*rxp_hdr);
524-
skb->tail = skb->data + buflen;
525+
skb_set_tail_pointer(skb, buflen);
525526
skb->len = buflen;
526527
skb->protocol = eth_type_trans(skb, netdev);
527528

‎drivers/isdn/i4l/isdn_net.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,7 @@ isdn_net_log_skb(struct sk_buff * skb, isdn_net_local * lp)
881881

882882
addinfo[0] = '\0';
883883
/* This check stolen from 2.1.72 dev_queue_xmit_nit() */
884-
if (p < skb->data || p >= skb->tail) {
884+
if (p < skb->data || skb->network_header >= skb->tail) {
885885
/* fall back to old isdn_net_log_packet method() */
886886
char * buf = skb->data;
887887

‎drivers/media/dvb/dvb-core/dvb_net.c‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,7 @@ static void dvb_net_ule( struct net_device *dev, const u8 *buf, size_t buf_len )
600600
/* Check CRC32, we've got it in our skb already. */
601601
unsigned short ulen = htons(priv->ule_sndu_len);
602602
unsigned short utype = htons(priv->ule_sndu_type);
603+
const u8 *tail;
603604
struct kvec iov[3] = {
604605
{ &ulen, sizeof ulen },
605606
{ &utype, sizeof utype },
@@ -613,10 +614,11 @@ static void dvb_net_ule( struct net_device *dev, const u8 *buf, size_t buf_len )
613614
}
614615

615616
ule_crc = iov_crc32(ule_crc, iov, 3);
616-
expected_crc = *((u8 *)priv->ule_skb->tail - 4) << 24 |
617-
*((u8 *)priv->ule_skb->tail - 3) << 16 |
618-
*((u8 *)priv->ule_skb->tail - 2) << 8 |
619-
*((u8 *)priv->ule_skb->tail - 1);
617+
tail = skb_tail_pointer(priv->ule_skb);
618+
expected_crc = *(tail - 4) << 24 |
619+
*(tail - 3) << 16 |
620+
*(tail - 2) << 8 |
621+
*(tail - 1);
620622
if (ule_crc != expected_crc) {
621623
printk(KERN_WARNING "%lu: CRC32 check FAILED: %08x / %08x, SNDU len %d type %#x, ts_remain %d, next 2: %x.\n",
622624
priv->ts_count, ule_crc, expected_crc, priv->ule_sndu_len, priv->ule_sndu_type, ts_remain, ts_remain > 2 ? *(unsigned short *)from_where : 0);

‎drivers/net/cris/eth_v10.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1348,7 +1348,7 @@ e100_rx(struct net_device *dev)
13481348

13491349
#ifdef ETHDEBUG
13501350
printk("head = 0x%x, data = 0x%x, tail = 0x%x, end = 0x%x\n",
1351-
skb->head, skb->data, skb->tail, skb->end);
1351+
skb->head, skb->data, skb_tail_pointer(skb), skb->end);
13521352
printk("copying packet to 0x%x.\n", skb_data_ptr);
13531353
#endif
13541354

‎drivers/net/cxgb3/sge.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1325,13 +1325,13 @@ static void write_ofld_wr(struct adapter *adap, struct sk_buff *skb,
13251325
flits = skb_transport_offset(skb) / 8;
13261326
sgp = ndesc == 1 ? (struct sg_ent *)&d->flit[flits] : sgl;
13271327
sgl_flits = make_sgl(skb, sgp, skb_transport_header(skb),
1328-
skb->tail - skb_transport_header(skb),
1328+
skb->tail - skb->transport_header,
13291329
adap->pdev);
13301330
if (need_skb_unmap()) {
13311331
setup_deferred_unmapping(skb, adap->pdev, sgp, sgl_flits);
13321332
skb->destructor = deferred_unmap_destructor;
13331333
((struct unmap_info *)skb->cb)->len = (skb->tail -
1334-
skb_transport_header(skb));
1334+
skb->transport_header);
13351335
}
13361336

13371337
write_wr_hdr_sgl(ndesc, skb, d, pidx, q, sgl, flits, sgl_flits,
@@ -1353,7 +1353,7 @@ static inline unsigned int calc_tx_descs_ofld(const struct sk_buff *skb)
13531353
return 1; /* packet fits as immediate data */
13541354

13551355
flits = skb_transport_offset(skb) / 8; /* headers */
1356-
if (skb->tail != skb_transport_header(skb))
1356+
if (skb->tail != skb->transport_header)
13571357
cnt++;
13581358
return flits_to_desc(flits + sgl_len(cnt));
13591359
}

‎drivers/net/e1000/e1000_main.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3304,7 +3304,7 @@ e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
33043304
* NOTE: this is a TSO only workaround
33053305
* if end byte alignment not correct move us
33063306
* into the next dword */
3307-
if ((unsigned long)(skb->tail - 1) & 4)
3307+
if ((unsigned long)(skb_tail_pointer(skb) - 1) & 4)
33083308
break;
33093309
/* fall through */
33103310
case e1000_82571:
@@ -4388,7 +4388,7 @@ e1000_clean_rx_irq_ps(struct e1000_adapter *adapter,
43884388
PCI_DMA_FROMDEVICE);
43894389
vaddr = kmap_atomic(ps_page->ps_page[0],
43904390
KM_SKB_DATA_SOFTIRQ);
4391-
memcpy(skb->tail, vaddr, l1);
4391+
memcpy(skb_tail_pointer(skb), vaddr, l1);
43924392
kunmap_atomic(vaddr, KM_SKB_DATA_SOFTIRQ);
43934393
pci_dma_sync_single_for_device(pdev,
43944394
ps_page_dma->ps_page_dma[0],

0 commit comments

Comments
 (0)