Knowledge (XXG)

splice (system call)

Source 📝

22: 165:. A pipe buffer is an in-kernel memory buffer that is opaque to the userspace process. A user process can splice the contents of a source file into this pipe buffer, then splice the pipe buffer into the destination file, all without moving any data through userspace. 873:
with sockets, the network controller (NIC) should support DMA, otherwise splice() will not deliver a large performance improvement. The reason for this is that each page of the pipe will just fill up to frame size (1460 bytes of the available 4096 bytes per page).
157:, one can move data from one file descriptor to another without incurring any copies from user space into kernel space, which is usually required to enforce system security and also to keep a simple interface for processes to read and write to files. 145:
performance. As linear addresses do not necessarily correspond to contiguous physical addresses, this may not be possible in all cases and on all hardware combinations.
141:
moves or copies data between a pipe and user space. Ideally, splice and vmsplice work by remapping pages and do not actually copy any data, which may improve
980: 39: 955: 861:
is the last part of the trilogy. It duplicates one pipe to another, enabling forks in the way applications are connected with pipes.
105: 86: 58: 1029: 43: 853:
can map an application data area into a pipe (or vice versa), thus allowing transfers between pipes and user memory where
65: 72: 32: 54: 930: 1034: 79: 974: 959: 162: 132: 173: 1023: 142: 902: 192: 128: 21: 200: 181: 907: 997: 1007: 135:
and a pipe without a round trip to user space. The related system call
191:
splice implementation borrows some ideas from an original proposal by
1013: 1003: 616:/* splice the data in the pipe (in kernel memory) into the file. */ 934: 196: 188: 124: 15: 478:/* splice the file into the pipe (data in kernel memory). */ 1004:
Two new system calls: splice() and sync_file_range()
195:in 1998. The splice system calls first appeared in 46:. Unsourced material may be challenged and removed. 857:transfers between a file descriptor and a pipe. 292:/* Splice flags (not laid down in stone yet). */ 845:is one of three system calls that complete the 137: 8: 933:. kerneltrap.org. 2006-04-21. Archived from 199:kernel version 2.6.17 and were written by 287:Some constants that are of interest are: 180:in a 2006 email, which was included in a 106:Learn how and when to remove this message 338:This is an example of splice in action: 919: 979:: CS1 maint: archived copy as title ( 972: 931:"Linux: Explaining splice() and tee()" 7: 925: 923: 325:#define SPLICE_F_GIFT 0x08 316:#define SPLICE_F_MORE 0x04 307:#define SPLICE_F_NONBLOCK 0x02 298:#define SPLICE_F_MOVE 0x01 44:adding citations to reliable sources 343:/* Transfer from disk to a log. */ 14: 881:Not all filesystem types support 20: 31:needs additional citations for 878:does not support UDP sockets. 1: 1051: 838:Complementary system calls 131:that moves data between a 304:#ifndef SPLICE_F_NONBLOCK 55:"Splice" system call 340: 289: 210: 889:sockets do not support 1030:Linux kernel features 1014:Some new system calls 322:#ifndef SPLICE_F_GIFT 313:#ifndef SPLICE_F_MORE 295:#ifndef SPLICE_F_MOVE 40:improve this article 1000:(kernelnewbies.org) 998:Linux kernel 2.6.17 161:works by using the 116: 115: 108: 90: 1042: 985: 984: 978: 970: 968: 967: 958:. Archived from 952: 946: 945: 943: 942: 927: 892: 888: 884: 877: 872: 860: 856: 852: 848: 844: 833: 830: 827: 824: 821: 818: 815: 812: 809: 806: 803: 800: 797: 794: 791: 788: 785: 782: 779: 776: 773: 770: 767: 764: 761: 758: 755: 752: 749: 746: 743: 740: 737: 734: 731: 728: 725: 722: 719: 716: 713: 710: 707: 704: 701: 698: 695: 692: 689: 686: 683: 680: 677: 674: 671: 668: 665: 662: 659: 656: 653: 650: 647: 644: 641: 638: 635: 632: 629: 626: 623: 620: 617: 614: 611: 608: 605: 602: 599: 596: 593: 590: 587: 584: 581: 578: 575: 572: 569: 566: 563: 560: 557: 554: 551: 548: 545: 542: 539: 536: 533: 530: 527: 524: 521: 518: 515: 512: 509: 506: 503: 500: 497: 494: 491: 488: 485: 482: 479: 476: 473: 470: 467: 464: 461: 458: 455: 452: 449: 446: 443: 440: 437: 434: 431: 428: 425: 422: 419: 416: 413: 410: 407: 404: 401: 398: 395: 392: 389: 386: 383: 380: 377: 374: 371: 368: 365: 362: 359: 356: 353: 350: 347: 344: 329: 326: 323: 320: 317: 314: 311: 308: 305: 302: 299: 296: 293: 283: 280: 277: 274: 271: 268: 265: 262: 259: 256: 253: 250: 247: 244: 241: 238: 235: 232: 229: 226: 223: 220: 217: 214: 179: 160: 156: 140: 121: 111: 104: 100: 97: 91: 89: 48: 24: 16: 1050: 1049: 1045: 1044: 1043: 1041: 1040: 1039: 1020: 1019: 994: 989: 988: 971: 965: 963: 956:"Archived copy" 954: 953: 949: 940: 938: 929: 928: 921: 916: 899: 890: 886: 882: 875: 870: 867: 858: 854: 850: 846: 842: 840: 835: 834: 831: 828: 825: 822: 819: 816: 813: 810: 807: 804: 801: 798: 795: 792: 789: 786: 783: 780: 777: 774: 771: 768: 765: 762: 759: 756: 753: 750: 747: 744: 741: 738: 735: 732: 729: 726: 723: 720: 717: 714: 711: 708: 705: 702: 699: 696: 693: 690: 687: 684: 681: 678: 675: 672: 669: 666: 663: 660: 657: 654: 651: 648: 645: 642: 639: 636: 633: 630: 627: 624: 621: 618: 615: 612: 609: 606: 603: 600: 597: 594: 591: 588: 585: 582: 579: 576: 573: 570: 567: 564: 561: 558: 555: 552: 549: 546: 543: 540: 537: 534: 531: 528: 525: 522: 519: 516: 513: 510: 507: 504: 501: 498: 495: 492: 489: 486: 483: 480: 477: 474: 471: 468: 465: 462: 459: 456: 453: 450: 447: 444: 441: 438: 435: 432: 429: 426: 423: 420: 417: 414: 411: 408: 405: 402: 399: 396: 393: 390: 387: 384: 381: 378: 375: 372: 369: 366: 363: 360: 357: 354: 351: 348: 345: 342: 336: 331: 330: 327: 324: 321: 318: 315: 312: 309: 306: 303: 300: 297: 294: 291: 285: 284: 281: 278: 275: 272: 269: 266: 263: 260: 257: 254: 251: 248: 245: 242: 239: 236: 233: 230: 227: 224: 221: 218: 215: 212: 209: 177: 171: 158: 154: 151: 136: 133:file descriptor 119: 112: 101: 95: 92: 49: 47: 37: 25: 12: 11: 5: 1048: 1046: 1038: 1037: 1032: 1022: 1021: 1018: 1017: 1011: 1001: 993: 992:External links 990: 987: 986: 947: 918: 917: 915: 912: 911: 910: 905: 898: 895: 866: 863: 849:architecture. 839: 836: 341: 335: 332: 290: 211: 208: 205: 174:Linus Torvalds 170: 167: 150: 147: 114: 113: 28: 26: 19: 13: 10: 9: 6: 4: 3: 2: 1047: 1036: 1033: 1031: 1028: 1027: 1025: 1015: 1012: 1009: 1005: 1002: 999: 996: 995: 991: 982: 976: 962:on 2016-03-04 961: 957: 951: 948: 937:on 2013-05-21 936: 932: 926: 924: 920: 913: 909: 906: 904: 901: 900: 896: 894: 879: 864: 862: 837: 706:SPLICE_F_MOVE 700:SPLICE_F_MORE 553:SPLICE_F_MOVE 547:SPLICE_F_MORE 339: 333: 288: 206: 204: 202: 198: 194: 190: 185: 183: 175: 168: 166: 164: 148: 146: 144: 139: 134: 130: 126: 122: 110: 107: 99: 88: 85: 81: 78: 74: 71: 67: 64: 60: 57: –  56: 52: 51:Find sources: 45: 41: 35: 34: 29:This article 27: 23: 18: 17: 1035:System calls 964:. Retrieved 960:the original 950: 939:. Retrieved 935:the original 880: 868: 865:Requirements 855:sys_splice() 841: 337: 286: 186: 172: 152: 118: 117: 102: 93: 83: 76: 69: 62: 50: 38:Please help 33:verification 30: 903:System call 869:When using 193:Larry McVoy 163:pipe buffer 129:system call 1024:Categories 966:2016-02-28 941:2014-04-27 914:References 851:vmsplice() 358:log_handle 349:log_blocks 201:Jens Axboe 182:KernelTrap 176:described 138:vmsplice() 127:-specific 96:March 2011 66:newspapers 1016:(LWN.net) 908:Zero-copy 885:. Also, 688:fd_offset 207:Prototype 184:article. 975:cite web 897:See also 891:splice() 883:splice() 876:splice() 871:splice() 847:splice() 843:splice() 742:to_write 694:to_write 625:to_write 604:to_write 589:to_write 541:to_write 487:to_write 421:to_write 273:unsigned 178:splice() 159:splice() 155:splice() 149:Workings 120:splice() 1008:LWN.net 887:AF_UNIX 781:filedes 769:filedes 652:filedes 529:filedes 445:filedes 403:filedes 334:Example 258:off_out 213:ssize_t 169:Origins 80:scholar 823:return 811:return 682:handle 664:handle 646:splice 523:offset 508:splice 418:size_t 388:size_t 382:offset 379:loff_t 364:handle 355:struct 328:#endif 319:#endif 310:#endif 301:#endif 264:size_t 252:loff_t 246:fd_out 237:off_in 231:loff_t 216:splice 82:  75:  68:  61:  53:  859:tee() 817:errno 775:close 763:close 685:-> 676:& 667:-> 619:while 520:& 481:while 279:flags 225:fd_in 197:Linux 189:Linux 153:With 125:Linux 123:is a 87:JSTOR 73:books 981:link 802:< 757:pipe 739:else 733:pipe 730:goto 721:< 658:NULL 628:> 610:size 586:else 580:pipe 577:goto 568:< 535:NULL 490:> 469:goto 460:< 439:pipe 427:size 391:size 187:The 59:news 799:ret 787:out 748:ret 718:ret 640:ret 595:ret 565:ret 502:ret 472:out 457:ret 433:ret 412:ret 409:int 400:int 370:int 346:int 276:int 267:len 243:int 222:int 143:I/O 42:by 1026:: 977:}} 973:{{ 922:^ 893:. 793:if 784:); 772:); 745:-= 712:if 709:); 691:), 670:fd 592:-= 559:if 556:); 514:fd 451:if 448:); 373:fd 282:); 203:. 1010:) 1006:( 983:) 969:. 944:. 832:} 829:; 826:0 820:; 814:- 808:) 805:0 796:( 790:: 778:( 766:( 760:: 754:} 751:; 736:; 727:) 724:0 715:( 703:| 697:, 679:( 673:, 661:, 655:, 649:( 643:= 637:{ 634:) 631:0 622:( 613:; 607:= 601:} 598:; 583:; 574:) 571:0 562:( 550:| 544:, 538:, 532:, 526:, 517:, 511:( 505:= 499:{ 496:) 493:0 484:( 475:; 466:) 463:0 454:( 442:( 436:= 430:; 424:= 415:; 406:; 397:{ 394:) 385:, 376:, 367:, 361:* 352:( 270:, 261:, 255:* 249:, 240:, 234:* 228:, 219:( 109:) 103:( 98:) 94:( 84:· 77:· 70:· 63:· 36:.

Index


verification
improve this article
adding citations to reliable sources
"Splice" system call
news
newspapers
books
scholar
JSTOR
Learn how and when to remove this message
Linux
system call
file descriptor
vmsplice()
I/O
pipe buffer
Linus Torvalds
KernelTrap
Linux
Larry McVoy
Linux
Jens Axboe
System call
Zero-copy


"Linux: Explaining splice() and tee()"
the original
"Archived copy"

Text is available under the Creative Commons Attribution-ShareAlike License. Additional terms may apply.