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.

Merge tag 'for-linus-4.16a-rc2-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip

Pull xen fixes from Juergen Gross:

- fixes for the Xen pvcalls frontend driver

- fix for booting Xen pv domains

- fix for the xenbus driver user interface

* tag 'for-linus-4.16a-rc2-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip:
pvcalls-front: wait for other operations to return when release passive sockets
pvcalls-front: introduce a per sock_mapping refcount
x86/xen: Calculate __max_logical_packages on PV domains
xenbus: track caller request id

+101 -114
+1
arch/x86/include/asm/smp.h
··· 129 129 void cpu_disable_common(void); 130 130 void native_smp_prepare_boot_cpu(void); 131 131 void native_smp_prepare_cpus(unsigned int max_cpus); 132 + void calculate_max_logical_packages(void); 132 133 void native_smp_cpus_done(unsigned int max_cpus); 133 134 void common_cpu_up(unsigned int cpunum, struct task_struct *tidle); 134 135 int native_cpu_up(unsigned int cpunum, struct task_struct *tidle);
+8 -2
arch/x86/kernel/smpboot.c
··· 1281 1281 cpu_set_state_online(me); 1282 1282 } 1283 1283 1284 - void __init native_smp_cpus_done(unsigned int max_cpus) 1284 + void __init calculate_max_logical_packages(void) 1285 1285 { 1286 1286 int ncpus; 1287 1287 1288 - pr_debug("Boot done\n"); 1289 1288 /* 1290 1289 * Today neither Intel nor AMD support heterogenous systems so 1291 1290 * extrapolate the boot cpu's data to all packages. ··· 1292 1293 ncpus = cpu_data(0).booted_cores * topology_max_smt_threads(); 1293 1294 __max_logical_packages = DIV_ROUND_UP(nr_cpu_ids, ncpus); 1294 1295 pr_info("Max logical packages: %u\n", __max_logical_packages); 1296 + } 1297 + 1298 + void __init native_smp_cpus_done(unsigned int max_cpus) 1299 + { 1300 + pr_debug("Boot done\n"); 1301 + 1302 + calculate_max_logical_packages(); 1295 1303 1296 1304 if (x86_has_numa_in_package) 1297 1305 set_sched_topology(x86_numa_in_package_topology);
+2
arch/x86/xen/smp.c
··· 122 122 123 123 if (xen_hvm_domain()) 124 124 native_smp_cpus_done(max_cpus); 125 + else 126 + calculate_max_logical_packages(); 125 127 126 128 if (xen_have_vcpu_info_placement) 127 129 return;
+85 -112
drivers/xen/pvcalls-front.c
··· 60 60 bool active_socket; 61 61 struct list_head list; 62 62 struct socket *sock; 63 + atomic_t refcount; 63 64 union { 64 65 struct { 65 66 int irq; ··· 93 92 } passive; 94 93 }; 95 94 }; 95 + 96 + static inline struct sock_mapping *pvcalls_enter_sock(struct socket *sock) 97 + { 98 + struct sock_mapping *map; 99 + 100 + if (!pvcalls_front_dev || 101 + dev_get_drvdata(&pvcalls_front_dev->dev) == NULL) 102 + return ERR_PTR(-ENOTCONN); 103 + 104 + map = (struct sock_mapping *)sock->sk->sk_send_head; 105 + if (map == NULL) 106 + return ERR_PTR(-ENOTSOCK); 107 + 108 + pvcalls_enter(); 109 + atomic_inc(&map->refcount); 110 + return map; 111 + } 112 + 113 + static inline void pvcalls_exit_sock(struct socket *sock) 114 + { 115 + struct sock_mapping *map; 116 + 117 + map = (struct sock_mapping *)sock->sk->sk_send_head; 118 + atomic_dec(&map->refcount); 119 + pvcalls_exit(); 120 + } 96 121 97 122 static inline int get_request(struct pvcalls_bedata *bedata, int *req_id) 98 123 { ··· 396 369 if (addr->sa_family != AF_INET || sock->type != SOCK_STREAM) 397 370 return -EOPNOTSUPP; 398 371 399 - pvcalls_enter(); 400 - if (!pvcalls_front_dev) { 401 - pvcalls_exit(); 402 - return -ENOTCONN; 403 - } 372 + map = pvcalls_enter_sock(sock); 373 + if (IS_ERR(map)) 374 + return PTR_ERR(map); 404 375 405 376 bedata = dev_get_drvdata(&pvcalls_front_dev->dev); 406 - 407 - map = (struct sock_mapping *)sock->sk->sk_send_head; 408 - if (!map) { 409 - pvcalls_exit(); 410 - return -ENOTSOCK; 411 - } 412 377 413 378 spin_lock(&bedata->socket_lock); 414 379 ret = get_request(bedata, &req_id); 415 380 if (ret < 0) { 416 381 spin_unlock(&bedata->socket_lock); 417 - pvcalls_exit(); 382 + pvcalls_exit_sock(sock); 418 383 return ret; 419 384 } 420 385 ret = create_active(map, &evtchn); 421 386 if (ret < 0) { 422 387 spin_unlock(&bedata->socket_lock); 423 - pvcalls_exit(); 388 + pvcalls_exit_sock(sock); 424 389 return ret; 425 390 } 426 391 ··· 442 423 smp_rmb(); 443 424 ret = bedata->rsp[req_id].ret; 444 425 bedata->rsp[req_id].req_id = PVCALLS_INVALID_ID; 445 - pvcalls_exit(); 426 + pvcalls_exit_sock(sock); 446 427 return ret; 447 428 } 448 429 ··· 507 488 if (flags & (MSG_CONFIRM|MSG_DONTROUTE|MSG_EOR|MSG_OOB)) 508 489 return -EOPNOTSUPP; 509 490 510 - pvcalls_enter(); 511 - if (!pvcalls_front_dev) { 512 - pvcalls_exit(); 513 - return -ENOTCONN; 514 - } 491 + map = pvcalls_enter_sock(sock); 492 + if (IS_ERR(map)) 493 + return PTR_ERR(map); 515 494 bedata = dev_get_drvdata(&pvcalls_front_dev->dev); 516 - 517 - map = (struct sock_mapping *) sock->sk->sk_send_head; 518 - if (!map) { 519 - pvcalls_exit(); 520 - return -ENOTSOCK; 521 - } 522 495 523 496 mutex_lock(&map->active.out_mutex); 524 497 if ((flags & MSG_DONTWAIT) && !pvcalls_front_write_todo(map)) { 525 498 mutex_unlock(&map->active.out_mutex); 526 - pvcalls_exit(); 499 + pvcalls_exit_sock(sock); 527 500 return -EAGAIN; 528 501 } 529 502 if (len > INT_MAX) ··· 537 526 tot_sent = sent; 538 527 539 528 mutex_unlock(&map->active.out_mutex); 540 - pvcalls_exit(); 529 + pvcalls_exit_sock(sock); 541 530 return tot_sent; 542 531 } 543 532 ··· 602 591 if (flags & (MSG_CMSG_CLOEXEC|MSG_ERRQUEUE|MSG_OOB|MSG_TRUNC)) 603 592 return -EOPNOTSUPP; 604 593 605 - pvcalls_enter(); 606 - if (!pvcalls_front_dev) { 607 - pvcalls_exit(); 608 - return -ENOTCONN; 609 - } 594 + map = pvcalls_enter_sock(sock); 595 + if (IS_ERR(map)) 596 + return PTR_ERR(map); 610 597 bedata = dev_get_drvdata(&pvcalls_front_dev->dev); 611 - 612 - map = (struct sock_mapping *) sock->sk->sk_send_head; 613 - if (!map) { 614 - pvcalls_exit(); 615 - return -ENOTSOCK; 616 - } 617 598 618 599 mutex_lock(&map->active.in_mutex); 619 600 if (len > XEN_FLEX_RING_SIZE(PVCALLS_RING_ORDER)) ··· 626 623 ret = 0; 627 624 628 625 mutex_unlock(&map->active.in_mutex); 629 - pvcalls_exit(); 626 + pvcalls_exit_sock(sock); 630 627 return ret; 631 628 } 632 629 ··· 640 637 if (addr->sa_family != AF_INET || sock->type != SOCK_STREAM) 641 638 return -EOPNOTSUPP; 642 639 643 - pvcalls_enter(); 644 - if (!pvcalls_front_dev) { 645 - pvcalls_exit(); 646 - return -ENOTCONN; 647 - } 640 + map = pvcalls_enter_sock(sock); 641 + if (IS_ERR(map)) 642 + return PTR_ERR(map); 648 643 bedata = dev_get_drvdata(&pvcalls_front_dev->dev); 649 - 650 - map = (struct sock_mapping *) sock->sk->sk_send_head; 651 - if (map == NULL) { 652 - pvcalls_exit(); 653 - return -ENOTSOCK; 654 - } 655 644 656 645 spin_lock(&bedata->socket_lock); 657 646 ret = get_request(bedata, &req_id); 658 647 if (ret < 0) { 659 648 spin_unlock(&bedata->socket_lock); 660 - pvcalls_exit(); 649 + pvcalls_exit_sock(sock); 661 650 return ret; 662 651 } 663 652 req = RING_GET_REQUEST(&bedata->ring, req_id); ··· 679 684 bedata->rsp[req_id].req_id = PVCALLS_INVALID_ID; 680 685 681 686 map->passive.status = PVCALLS_STATUS_BIND; 682 - pvcalls_exit(); 687 + pvcalls_exit_sock(sock); 683 688 return 0; 684 689 } 685 690 ··· 690 695 struct xen_pvcalls_request *req; 691 696 int notify, req_id, ret; 692 697 693 - pvcalls_enter(); 694 - if (!pvcalls_front_dev) { 695 - pvcalls_exit(); 696 - return -ENOTCONN; 697 - } 698 + map = pvcalls_enter_sock(sock); 699 + if (IS_ERR(map)) 700 + return PTR_ERR(map); 698 701 bedata = dev_get_drvdata(&pvcalls_front_dev->dev); 699 702 700 - map = (struct sock_mapping *) sock->sk->sk_send_head; 701 - if (!map) { 702 - pvcalls_exit(); 703 - return -ENOTSOCK; 704 - } 705 - 706 703 if (map->passive.status != PVCALLS_STATUS_BIND) { 707 - pvcalls_exit(); 704 + pvcalls_exit_sock(sock); 708 705 return -EOPNOTSUPP; 709 706 } 710 707 ··· 704 717 ret = get_request(bedata, &req_id); 705 718 if (ret < 0) { 706 719 spin_unlock(&bedata->socket_lock); 707 - pvcalls_exit(); 720 + pvcalls_exit_sock(sock); 708 721 return ret; 709 722 } 710 723 req = RING_GET_REQUEST(&bedata->ring, req_id); ··· 728 741 bedata->rsp[req_id].req_id = PVCALLS_INVALID_ID; 729 742 730 743 map->passive.status = PVCALLS_STATUS_LISTEN; 731 - pvcalls_exit(); 744 + pvcalls_exit_sock(sock); 732 745 return ret; 733 746 } 734 747 ··· 740 753 struct xen_pvcalls_request *req; 741 754 int notify, req_id, ret, evtchn, nonblock; 742 755 743 - pvcalls_enter(); 744 - if (!pvcalls_front_dev) { 745 - pvcalls_exit(); 746 - return -ENOTCONN; 747 - } 756 + map = pvcalls_enter_sock(sock); 757 + if (IS_ERR(map)) 758 + return PTR_ERR(map); 748 759 bedata = dev_get_drvdata(&pvcalls_front_dev->dev); 749 760 750 - map = (struct sock_mapping *) sock->sk->sk_send_head; 751 - if (!map) { 752 - pvcalls_exit(); 753 - return -ENOTSOCK; 754 - } 755 - 756 761 if (map->passive.status != PVCALLS_STATUS_LISTEN) { 757 - pvcalls_exit(); 762 + pvcalls_exit_sock(sock); 758 763 return -EINVAL; 759 764 } 760 765 ··· 764 785 goto received; 765 786 } 766 787 if (nonblock) { 767 - pvcalls_exit(); 788 + pvcalls_exit_sock(sock); 768 789 return -EAGAIN; 769 790 } 770 791 if (wait_event_interruptible(map->passive.inflight_accept_req, 771 792 !test_and_set_bit(PVCALLS_FLAG_ACCEPT_INFLIGHT, 772 793 (void *)&map->passive.flags))) { 773 - pvcalls_exit(); 794 + pvcalls_exit_sock(sock); 774 795 return -EINTR; 775 796 } 776 797 } ··· 781 802 clear_bit(PVCALLS_FLAG_ACCEPT_INFLIGHT, 782 803 (void *)&map->passive.flags); 783 804 spin_unlock(&bedata->socket_lock); 784 - pvcalls_exit(); 805 + pvcalls_exit_sock(sock); 785 806 return ret; 786 807 } 787 808 map2 = kzalloc(sizeof(*map2), GFP_ATOMIC); ··· 789 810 clear_bit(PVCALLS_FLAG_ACCEPT_INFLIGHT, 790 811 (void *)&map->passive.flags); 791 812 spin_unlock(&bedata->socket_lock); 792 - pvcalls_exit(); 813 + pvcalls_exit_sock(sock); 793 814 return -ENOMEM; 794 815 } 795 816 ret = create_active(map2, &evtchn); ··· 798 819 clear_bit(PVCALLS_FLAG_ACCEPT_INFLIGHT, 799 820 (void *)&map->passive.flags); 800 821 spin_unlock(&bedata->socket_lock); 801 - pvcalls_exit(); 822 + pvcalls_exit_sock(sock); 802 823 return ret; 803 824 } 804 825 list_add_tail(&map2->list, &bedata->socket_mappings); ··· 820 841 /* We could check if we have received a response before returning. */ 821 842 if (nonblock) { 822 843 WRITE_ONCE(map->passive.inflight_req_id, req_id); 823 - pvcalls_exit(); 844 + pvcalls_exit_sock(sock); 824 845 return -EAGAIN; 825 846 } 826 847 827 848 if (wait_event_interruptible(bedata->inflight_req, 828 849 READ_ONCE(bedata->rsp[req_id].req_id) == req_id)) { 829 - pvcalls_exit(); 850 + pvcalls_exit_sock(sock); 830 851 return -EINTR; 831 852 } 832 853 /* read req_id, then the content */ ··· 841 862 clear_bit(PVCALLS_FLAG_ACCEPT_INFLIGHT, 842 863 (void *)&map->passive.flags); 843 864 pvcalls_front_free_map(bedata, map2); 844 - pvcalls_exit(); 865 + pvcalls_exit_sock(sock); 845 866 return -ENOMEM; 846 867 } 847 868 newsock->sk->sk_send_head = (void *)map2; ··· 853 874 clear_bit(PVCALLS_FLAG_ACCEPT_INFLIGHT, (void *)&map->passive.flags); 854 875 wake_up(&map->passive.inflight_accept_req); 855 876 856 - pvcalls_exit(); 877 + pvcalls_exit_sock(sock); 857 878 return ret; 858 879 } 859 880 ··· 944 965 struct sock_mapping *map; 945 966 __poll_t ret; 946 967 947 - pvcalls_enter(); 948 - if (!pvcalls_front_dev) { 949 - pvcalls_exit(); 968 + map = pvcalls_enter_sock(sock); 969 + if (IS_ERR(map)) 950 970 return EPOLLNVAL; 951 - } 952 971 bedata = dev_get_drvdata(&pvcalls_front_dev->dev); 953 972 954 - map = (struct sock_mapping *) sock->sk->sk_send_head; 955 - if (!map) { 956 - pvcalls_exit(); 957 - return EPOLLNVAL; 958 - } 959 973 if (map->active_socket) 960 974 ret = pvcalls_front_poll_active(file, bedata, map, wait); 961 975 else 962 976 ret = pvcalls_front_poll_passive(file, bedata, map, wait); 963 - pvcalls_exit(); 977 + pvcalls_exit_sock(sock); 964 978 return ret; 965 979 } 966 980 ··· 967 995 if (sock->sk == NULL) 968 996 return 0; 969 997 970 - pvcalls_enter(); 971 - if (!pvcalls_front_dev) { 972 - pvcalls_exit(); 973 - return -EIO; 998 + map = pvcalls_enter_sock(sock); 999 + if (IS_ERR(map)) { 1000 + if (PTR_ERR(map) == -ENOTCONN) 1001 + return -EIO; 1002 + else 1003 + return 0; 974 1004 } 975 - 976 1005 bedata = dev_get_drvdata(&pvcalls_front_dev->dev); 977 - 978 - map = (struct sock_mapping *) sock->sk->sk_send_head; 979 - if (map == NULL) { 980 - pvcalls_exit(); 981 - return 0; 982 - } 983 1006 984 1007 spin_lock(&bedata->socket_lock); 985 1008 ret = get_request(bedata, &req_id); 986 1009 if (ret < 0) { 987 1010 spin_unlock(&bedata->socket_lock); 988 - pvcalls_exit(); 1011 + pvcalls_exit_sock(sock); 989 1012 return ret; 990 1013 } 991 1014 sock->sk->sk_send_head = NULL; ··· 1010 1043 /* 1011 1044 * We need to make sure that sendmsg/recvmsg on this socket have 1012 1045 * not started before we've cleared sk_send_head here. The 1013 - * easiest (though not optimal) way to guarantee this is to see 1014 - * that no pvcall (other than us) is in progress. 1046 + * easiest way to guarantee this is to see that no pvcalls 1047 + * (other than us) is in progress on this socket. 1015 1048 */ 1016 - while (atomic_read(&pvcalls_refcount) > 1) 1049 + while (atomic_read(&map->refcount) > 1) 1017 1050 cpu_relax(); 1018 1051 1019 1052 pvcalls_front_free_map(bedata, map); 1020 1053 } else { 1054 + wake_up(&bedata->inflight_req); 1055 + wake_up(&map->passive.inflight_accept_req); 1056 + 1057 + while (atomic_read(&map->refcount) > 1) 1058 + cpu_relax(); 1059 + 1021 1060 spin_lock(&bedata->socket_lock); 1022 1061 list_del(&map->list); 1023 1062 spin_unlock(&bedata->socket_lock);
+1
drivers/xen/xenbus/xenbus.h
··· 76 76 struct list_head list; 77 77 wait_queue_head_t wq; 78 78 struct xsd_sockmsg msg; 79 + uint32_t caller_req_id; 79 80 enum xsd_sockmsg_type type; 80 81 char *body; 81 82 const struct kvec *vec;
+1
drivers/xen/xenbus/xenbus_comms.c
··· 309 309 goto out; 310 310 311 311 if (req->state == xb_req_state_wait_reply) { 312 + req->msg.req_id = req->caller_req_id; 312 313 req->msg.type = state.msg.type; 313 314 req->msg.len = state.msg.len; 314 315 req->body = state.body;
+3
drivers/xen/xenbus/xenbus_xs.c
··· 227 227 req->state = xb_req_state_queued; 228 228 init_waitqueue_head(&req->wq); 229 229 230 + /* Save the caller req_id and restore it later in the reply */ 231 + req->caller_req_id = req->msg.req_id; 230 232 req->msg.req_id = xs_request_enter(req); 231 233 232 234 mutex_lock(&xb_write_mutex); ··· 312 310 req->num_vecs = num_vecs; 313 311 req->cb = xs_wake_up; 314 312 313 + msg.req_id = 0; 315 314 msg.tx_id = t.id; 316 315 msg.type = type; 317 316 msg.len = 0;