Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

scsi: fnic: Use mempool for receive frames

The receive frames are constantly replenished so we should rather use a
mempool here.

fip_frame_queue is an rxq. Deallocate it in fnic_free_rxq().

Tested-by: Karan Tilak Kumar <kartilak@cisco.com>
Reviewed-by: Sesidhar Baddela <sebaddel@cisco.com>
Reviewed-by: Arulprabhu Ponnusamy <arulponn@cisco.com>
Reviewed-by: Gian Carlo Boffa <gcboffa@cisco.com>
Reviewed-by: Arun Easi <aeasi@cisco.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Karan Tilak Kumar <kartilak@cisco.com>
Co-developed-by: Hannes Reinecke <hare@kernel.org>
Link: https://patch.msgid.link/20260217223943.7938-1-kartilak@cisco.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Karan Tilak Kumar and committed by
Martin K. Petersen
0e07baae 6de23f81

+66 -22
+3 -1
drivers/scsi/fnic/fnic.h
··· 438 438 struct list_head tx_queue; 439 439 mempool_t *frame_pool; 440 440 mempool_t *frame_elem_pool; 441 + mempool_t *frame_recv_pool; 441 442 struct work_struct tport_work; 442 443 struct list_head tport_event_list; 443 444 ··· 542 541 } 543 542 void __fnic_set_state_flags(struct fnic *, unsigned long, unsigned long); 544 543 void fnic_dump_fchost_stats(struct Scsi_Host *, struct fc_host_statistics *); 545 - void fnic_free_txq(struct list_head *head); 544 + void fnic_free_txq(struct fnic *fnic); 545 + void fnic_free_rxq(struct fnic *fnic); 546 546 int fnic_get_desc_by_devid(struct pci_dev *pdev, char **desc, 547 547 char **subsys_desc); 548 548 void fnic_fdls_link_status_change(struct fnic *fnic, int linkup);
+37 -17
drivers/scsi/fnic/fnic_fcs.c
··· 291 291 if (fnic->stop_rx_link_events) { 292 292 list_del(&cur_frame->links); 293 293 spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags); 294 - kfree(cur_frame->fp); 294 + mempool_free(cur_frame->fp, fnic->frame_recv_pool); 295 295 mempool_free(cur_frame, fnic->frame_elem_pool); 296 296 return; 297 297 } ··· 317 317 fnic_fdls_recv_frame(&fnic->iport, cur_frame->fp, 318 318 cur_frame->frame_len, fchdr_offset); 319 319 320 - kfree(cur_frame->fp); 320 + mempool_free(cur_frame->fp, fnic->frame_recv_pool); 321 321 mempool_free(cur_frame, fnic->frame_elem_pool); 322 322 } 323 323 spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags); ··· 337 337 if (fnic->stop_rx_link_events) { 338 338 list_del(&cur_frame->links); 339 339 spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags); 340 - kfree(cur_frame->fp); 341 - kfree(cur_frame); 340 + mempool_free(cur_frame->fp, fnic->frame_recv_pool); 341 + mempool_free(cur_frame, fnic->frame_elem_pool); 342 342 return; 343 343 } 344 344 ··· 355 355 list_del(&cur_frame->links); 356 356 357 357 if (fdls_fip_recv_frame(fnic, cur_frame->fp)) { 358 - kfree(cur_frame->fp); 359 - kfree(cur_frame); 358 + mempool_free(cur_frame->fp, fnic->frame_recv_pool); 359 + mempool_free(cur_frame, fnic->frame_elem_pool); 360 360 } 361 361 } 362 362 spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags); ··· 375 375 376 376 eh = (struct ethhdr *) fp; 377 377 if ((eh->h_proto == cpu_to_be16(ETH_P_FIP)) && (fnic->iport.usefip)) { 378 - fip_fr_elem = (struct fnic_frame_list *) 379 - kzalloc_obj(struct fnic_frame_list, GFP_ATOMIC); 378 + fip_fr_elem = mempool_alloc(fnic->frame_elem_pool, GFP_ATOMIC); 380 379 if (!fip_fr_elem) 381 380 return 0; 381 + memset(fip_fr_elem, 0, sizeof(struct fnic_frame_list)); 382 382 fip_fr_elem->fp = fp; 383 383 spin_lock_irqsave(&fnic->fnic_lock, flags); 384 384 list_add_tail(&fip_fr_elem->links, &fnic->fip_frame_queue); ··· 538 538 return; 539 539 540 540 drop: 541 - kfree(fp); 541 + mempool_free(fp, fnic->frame_recv_pool); 542 542 } 543 543 544 544 static int fnic_rq_cmpl_handler_cont(struct vnic_dev *vdev, ··· 591 591 int ret; 592 592 593 593 len = FNIC_FRAME_HT_ROOM; 594 - buf = kmalloc(len, GFP_ATOMIC); 594 + buf = mempool_alloc(fnic->frame_recv_pool, GFP_ATOMIC); 595 595 if (!buf) { 596 596 FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, 597 597 "Unable to allocate RQ buffer of size: %d\n", len); ··· 609 609 fnic_queue_rq_desc(rq, buf, pa, len); 610 610 return 0; 611 611 free_buf: 612 - kfree(buf); 612 + mempool_free(buf, fnic->frame_recv_pool); 613 613 return ret; 614 614 } 615 615 ··· 621 621 dma_unmap_single(&fnic->pdev->dev, buf->dma_addr, buf->len, 622 622 DMA_FROM_DEVICE); 623 623 624 - kfree(rq_buf); 624 + mempool_free(rq_buf, fnic->frame_recv_pool); 625 625 buf->os_buf = NULL; 626 626 } 627 627 ··· 836 836 return 0; 837 837 } 838 838 839 - void fnic_free_txq(struct list_head *head) 839 + void fnic_free_txq(struct fnic *fnic) 840 840 { 841 841 struct fnic_frame_list *cur_frame, *next; 842 842 843 - list_for_each_entry_safe(cur_frame, next, head, links) { 843 + list_for_each_entry_safe(cur_frame, next, &fnic->tx_queue, links) { 844 844 list_del(&cur_frame->links); 845 - kfree(cur_frame->fp); 846 - kfree(cur_frame); 845 + mempool_free(cur_frame->fp, fnic->frame_pool); 846 + mempool_free(cur_frame, fnic->frame_elem_pool); 847 + } 848 + } 849 + 850 + void fnic_free_rxq(struct fnic *fnic) 851 + { 852 + struct fnic_frame_list *cur_frame, *next; 853 + 854 + list_for_each_entry_safe(cur_frame, next, &fnic->frame_queue, links) { 855 + list_del(&cur_frame->links); 856 + mempool_free(cur_frame->fp, fnic->frame_recv_pool); 857 + mempool_free(cur_frame, fnic->frame_elem_pool); 858 + } 859 + 860 + if (fnic->config.flags & VFCF_FIP_CAPABLE) { 861 + list_for_each_entry_safe(cur_frame, next, 862 + &fnic->fip_frame_queue, links) { 863 + list_del(&cur_frame->links); 864 + mempool_free(cur_frame->fp, fnic->frame_recv_pool); 865 + mempool_free(cur_frame, fnic->frame_elem_pool); 866 + } 847 867 } 848 868 } 849 869 ··· 918 898 dma_unmap_single(&fnic->pdev->dev, buf->dma_addr, buf->len, 919 899 DMA_TO_DEVICE); 920 900 921 - kfree(buf->os_buf); 901 + mempool_free(buf->os_buf, fnic->frame_pool); 922 902 buf->os_buf = NULL; 923 903 } 924 904
+25 -3
drivers/scsi/fnic/fnic_main.c
··· 40 40 static struct kmem_cache *fnic_io_req_cache; 41 41 static struct kmem_cache *fdls_frame_cache; 42 42 static struct kmem_cache *fdls_frame_elem_cache; 43 + static struct kmem_cache *fdls_frame_recv_cache; 43 44 static LIST_HEAD(fnic_list); 44 45 static DEFINE_SPINLOCK(fnic_list_lock); 45 46 static DEFINE_IDA(fnic_ida); ··· 555 554 mempool_destroy(fnic->io_req_pool); 556 555 mempool_destroy(fnic->frame_pool); 557 556 mempool_destroy(fnic->frame_elem_pool); 557 + mempool_destroy(fnic->frame_recv_pool); 558 558 for (i = 0; i < FNIC_SGL_NUM_CACHES; i++) 559 559 mempool_destroy(fnic->io_sgl_pool[i]); 560 560 ··· 930 928 } 931 929 fnic->frame_elem_pool = pool; 932 930 931 + pool = mempool_create_slab_pool(FDLS_MIN_FRAMES, 932 + fdls_frame_recv_cache); 933 + if (!pool) { 934 + err = -ENOMEM; 935 + goto err_out_fdls_frame_recv_pool; 936 + } 937 + fnic->frame_recv_pool = pool; 938 + 933 939 /* setup vlan config, hw inserts vlan header */ 934 940 fnic->vlan_hw_insert = 1; 935 941 fnic->vlan_id = 0; ··· 1095 1085 } 1096 1086 vnic_dev_notify_unset(fnic->vdev); 1097 1087 err_out_fnic_notify_set: 1088 + mempool_destroy(fnic->frame_recv_pool); 1089 + err_out_fdls_frame_recv_pool: 1098 1090 mempool_destroy(fnic->frame_elem_pool); 1099 1091 err_out_fdls_frame_elem_pool: 1100 1092 mempool_destroy(fnic->frame_pool); ··· 1169 1157 timer_delete_sync(&fnic->enode_ka_timer); 1170 1158 timer_delete_sync(&fnic->vn_ka_timer); 1171 1159 1172 - fnic_free_txq(&fnic->fip_frame_queue); 1173 1160 fnic_fcoe_reset_vlans(fnic); 1174 1161 } 1175 1162 ··· 1188 1177 list_del(&fnic->list); 1189 1178 spin_unlock_irqrestore(&fnic_list_lock, flags); 1190 1179 1191 - fnic_free_txq(&fnic->frame_queue); 1192 - fnic_free_txq(&fnic->tx_queue); 1180 + fnic_free_rxq(fnic); 1181 + fnic_free_txq(fnic); 1193 1182 1194 1183 vnic_dev_notify_unset(fnic->vdev); 1195 1184 fnic_free_intr(fnic); ··· 1298 1287 goto err_create_fdls_frame_cache_elem; 1299 1288 } 1300 1289 1290 + fdls_frame_recv_cache = kmem_cache_create("fdls_frame_recv", 1291 + FNIC_FRAME_HT_ROOM, 1292 + 0, SLAB_HWCACHE_ALIGN, NULL); 1293 + if (!fdls_frame_recv_cache) { 1294 + pr_err("fnic fdls frame recv cach create failed\n"); 1295 + err = -ENOMEM; 1296 + goto err_create_fdls_frame_recv_cache; 1297 + } 1298 + 1301 1299 fnic_event_queue = 1302 1300 alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM, "fnic_event_wq"); 1303 1301 if (!fnic_event_queue) { ··· 1359 1339 if (pc_rscn_handling_feature_flag == PC_RSCN_HANDLING_FEATURE_ON) 1360 1340 destroy_workqueue(reset_fnic_work_queue); 1361 1341 err_create_reset_fnic_workq: 1342 + kmem_cache_destroy(fdls_frame_recv_cache); 1343 + err_create_fdls_frame_recv_cache: 1362 1344 destroy_workqueue(fnic_event_queue); 1363 1345 err_create_fnic_workq: 1364 1346 kmem_cache_destroy(fdls_frame_elem_cache);
+1 -1
drivers/scsi/fnic/fnic_scsi.c
··· 777 777 */ 778 778 if (ret) { 779 779 spin_unlock_irqrestore(&fnic->fnic_lock, flags); 780 - fnic_free_txq(&fnic->tx_queue); 780 + fnic_free_txq(fnic); 781 781 goto reset_cmpl_handler_end; 782 782 } 783 783