From patchwork Tue Jun 11 21:14:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Tsirakis X-Patchwork-Id: 10988299 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7045E13AF for ; Tue, 11 Jun 2019 21:16:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 631182855A for ; Tue, 11 Jun 2019 21:16:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 57C85288D1; Tue, 11 Jun 2019 21:16:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C4ECD288D0 for ; Tue, 11 Jun 2019 21:16:17 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hao6E-0003VS-Kl; Tue, 11 Jun 2019 21:14:34 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hao6C-0003VN-Mo for xen-devel@lists.xenproject.org; Tue, 11 Jun 2019 21:14:32 +0000 X-Inumbo-ID: e76792cc-8c8d-11e9-8980-bc764e045a96 Received: from mail-qk1-x742.google.com (unknown [2607:f8b0:4864:20::742]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id e76792cc-8c8d-11e9-8980-bc764e045a96; Tue, 11 Jun 2019 21:14:31 +0000 (UTC) Received: by mail-qk1-x742.google.com with SMTP id g18so8648917qkl.3 for ; Tue, 11 Jun 2019 14:14:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=ZWlQYcXiYq4K+TsBHQ76oJw3abz884c7rNhqBJDQvhY=; b=KzzJUiqqlWXmAXq5oChFYRxLoSmE+ijyAhUK9nJ8OyWiql9f5h6WwQoMHZ51YyZYfu MxYDUiGDTT5GSxQL780aeAZ8LX5beYdXBK6CHmntMRwqKbeEa4wXmUS4t9weUeI5JHQK lXJAEFjqydtrL6Lw+45AbuMoYRkBxPUR1QEQpqE1w2R2vbDWkaHM3UrMKO+z40K+kid0 XjX1lhbasV7crh7EiKXzQctP8DUXvLtirlpQFFhrnF4IyyMwPjfMQP4MOOKGbCb5N+hY 0c1OJtQ4EQ/joNJ8Jy0vvRE6iyWhSYEdiCmEgSDnEpewghEfkk8qR+/X5jjHwd2cpeMu VjzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=ZWlQYcXiYq4K+TsBHQ76oJw3abz884c7rNhqBJDQvhY=; b=I3XgWb1Uenf/1TaEOIa8m0X92XiGuQvumjfD1UW9bVdjlH766r1SpKa5AGZhf8JCwd WdHBG9dzp6KuACyvqeHmbUsi8Cj9esgR5JvwmiXfU/Z+l+IkYhTSU/75qSKZ2MME6HQI 16m/skbLyD0J89yjX+71xQj4Hk12LoPfeWa9yoCCQCuUT1l6ce9RLzzqi8sSqQ2lgNuT +Q1DwPTQU7lFZafJkI9qG0CV7LARMuDfdqd+6AwiK2MQiBGPQegdI8g+OwwSg+cdjvLb LbbT7NThmCR9Rz5+ZHNhhdVLwJZ+1nf/pADgZPxD/6VufLic5BeXgROScpKBCFGnGI2T lCEQ== X-Gm-Message-State: APjAAAUG2Ub5A44Qn1BmiE25EisjtmzpuAmV4H/cuMAz9xPXEi9XUWwr GoRyJnvlNyJTL0t5wjW2sWnM3JEqKYI= X-Google-Smtp-Source: APXvYqwi/Hp4L3catgRh/hI46DGvgqjaCvZ1OPd41JWpg/d6ozbPFfNyzZyH+Q0k2Rxe/jFfHYLFHQ== X-Received: by 2002:a37:9885:: with SMTP id a127mr42207785qke.230.1560287670745; Tue, 11 Jun 2019 14:14:30 -0700 (PDT) Received: from niko-Latitude-E7470.fios-router.home (pool-108-54-183-56.nycmny.fios.verizon.net. [108.54.183.56]) by smtp.gmail.com with ESMTPSA id 34sm10070811qtq.59.2019.06.11.14.14.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Jun 2019 14:14:30 -0700 (PDT) From: Nicholas Tsirakis X-Google-Original-From: Nicholas Tsirakis To: xen-devel@lists.xenproject.org Date: Tue, 11 Jun 2019 17:14:26 -0400 Message-Id: X-Mailer: git-send-email 2.17.1 Subject: [Xen-devel] [PATCH v2 1/2] argo: warn sendv() caller when ring is full X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Nicholas Tsirakis , Christopher Clark MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP In its current state, if the destination ring is full, sendv() will requeue the message and return the rc of pending_requeue(), which will return 0 on success. This prevents the caller from distinguishing the difference between a successful write and a message that needs to be resent at a later time. Instead, capture the -EAGAIN value returned from ringbuf_insert() and *only* overwrite it if the rc of pending_requeue() is non-zero. This allows the caller to make intelligent decisions on -EAGAIN and still be alerted if the pending message fails to requeue. Signed-off-by: Nicholas Tsirakis --- xen/common/argo.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/xen/common/argo.c b/xen/common/argo.c index 13052b9239..2f874a570d 100644 --- a/xen/common/argo.c +++ b/xen/common/argo.c @@ -2048,9 +2048,13 @@ sendv(struct domain *src_d, xen_argo_addr_t *src_addr, message_type, &len); if ( ret == -EAGAIN ) { + int rc; + argo_dprintk("argo_ringbuf_sendv failed, EAGAIN\n"); /* requeue to issue a notification when space is there */ - ret = pending_requeue(dst_d, ring_info, src_id.domain_id, len); + rc = pending_requeue(dst_d, ring_info, src_id.domain_id, len); + if ( rc ) + ret = rc; } spin_unlock(&ring_info->L3_lock); From patchwork Tue Jun 11 21:14:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Tsirakis X-Patchwork-Id: 10988297 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6DE6C13AF for ; Tue, 11 Jun 2019 21:16:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5EA5B28420 for ; Tue, 11 Jun 2019 21:16:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 522AB2846D; Tue, 11 Jun 2019 21:16:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C645B288D0 for ; Tue, 11 Jun 2019 21:16:01 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hao6R-0003XJ-UU; Tue, 11 Jun 2019 21:14:47 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hao6Q-0003Wc-Gb for xen-devel@lists.xenproject.org; Tue, 11 Jun 2019 21:14:46 +0000 X-Inumbo-ID: ef879ab1-8c8d-11e9-8980-bc764e045a96 Received: from mail-qt1-x843.google.com (unknown [2607:f8b0:4864:20::843]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id ef879ab1-8c8d-11e9-8980-bc764e045a96; Tue, 11 Jun 2019 21:14:45 +0000 (UTC) Received: by mail-qt1-x843.google.com with SMTP id p15so8941521qtl.3 for ; Tue, 11 Jun 2019 14:14:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=bSxMQeoBCOzKfYSpv+gnDmnsvRm8sBZinCauBKMr1/Y=; b=EENHGxscZHQrfjSiPRgvpABR+PbMI5Da3HCxzTEHHvM6jZbYCR7TcZiT01hhKGEirI n5xm+2e56s7NqhSVVS3p5f01/MLrQGZonboTiC1iKQhat10zQyekPQvW6ES72wxpwQgH ut1ckxK3dJk5WnrM4CcQr2LXlt3TOb7M7m20CieTkPa644gk2Z0Aa2zasvvEMscpTMqT dHThNWmhNcZX1EaqeMJu/cZy3/pZur+lC8LlfgDHlOD2lzUktCCKMPGLjCB6kbAui3rR GNyyvzk1l40xBtlhdOEya7QQ0WbA17YH5jDpZFScUXdV55vU+26AdkhHVnuNu3QFhZW6 qgow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=bSxMQeoBCOzKfYSpv+gnDmnsvRm8sBZinCauBKMr1/Y=; b=KuCBIQwIhs5OSRmN7r2VWLWIm2+Bx2GgQzlJKT8PS3g5fJ7JFAU3aQj+98XO86pJJ+ 6y2arQBKF6nujs22M+vgggwHKPlVvsvNrXOLBaCajXUgfWNU4ZuQeCoXTKDUkJjNNOIl DPrEQyf8jvAF0nlXfnkWaj9TbDkzr0sv2isyQ+OMpSTqKG6TJJK8Sn8cA71TZaYjH9Gi Gtb1o7IgRNHBLJRGPBrIEO5teCgxnJZCXlMDug7DMWOBinC2/FuCGvYsCcvZ4VbNRlla nk4tmqKZntvJhPwj5dQ8rUFKfxi9hp+krTpMruxbhXcGTfI6c2lyFJffFNwGkZaNtwNa J2FQ== X-Gm-Message-State: APjAAAWo2j8B1s8ud4N0tsX7o85YOMR4DkSLHb8+W/WuEC3JfIzCV9N2 rOW2RSMRaHChrUNXhqIG+RFWiyL7UjY= X-Google-Smtp-Source: APXvYqxfyabkq4sck5usPj/YZ/r2yJf56HhbR82VdimvJAdI+VM4JgvUI1EAfJT8rJ/Kk6g7L+5Gpg== X-Received: by 2002:ac8:3271:: with SMTP id y46mr28324467qta.185.1560287684480; Tue, 11 Jun 2019 14:14:44 -0700 (PDT) Received: from niko-Latitude-E7470.fios-router.home (pool-108-54-183-56.nycmny.fios.verizon.net. [108.54.183.56]) by smtp.gmail.com with ESMTPSA id 34sm10070811qtq.59.2019.06.11.14.14.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Jun 2019 14:14:44 -0700 (PDT) From: Nicholas Tsirakis X-Google-Original-From: Nicholas Tsirakis To: xen-devel@lists.xenproject.org Date: Tue, 11 Jun 2019 17:14:27 -0400 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Subject: [Xen-devel] [PATCH v2 2/2] argo: correctly report pending message length X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Nicholas Tsirakis , Christopher Clark MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP When a message is requeue'd in Xen's internal queue, the queue entry contains the length of the message so that Xen knows to send a VIRQ to the respective domain when enough space frees up in the ring. Due to a small bug, however, Xen doesn't populate the length of the msg if a given write fails, so this length is always reported as zero. This causes Xen to spurriously wake up a domain even when the ring doesn't have enough space. This patch makes sure that the msg len is properly reported by populating it in the event of a write failure. Signed-off-by: Nicholas Tsirakis --- xen/common/argo.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/xen/common/argo.c b/xen/common/argo.c index 2f874a570d..31baf4beed 100644 --- a/xen/common/argo.c +++ b/xen/common/argo.c @@ -766,26 +766,20 @@ static int ringbuf_insert(const struct domain *d, struct argo_ring_info *ring_info, const struct argo_ring_id *src_id, xen_argo_iov_t *iovs, unsigned int niov, uint32_t message_type, - unsigned long *out_len) + unsigned int len) { xen_argo_ring_t ring; struct xen_argo_ring_message_header mh = { }; int sp, ret; - unsigned int len = 0; xen_argo_iov_t *piov; XEN_GUEST_HANDLE(uint8) NULL_hnd = { }; ASSERT(LOCKING_L3(d, ring_info)); /* - * Obtain the total size of data to transmit -- sets the 'len' variable - * -- and sanity check that the iovs conform to size and number limits. * Enforced below: no more than 'len' bytes of guest data * (plus the message header) will be sent in this operation. */ - ret = iov_count(iovs, niov, &len); - if ( ret ) - return ret; /* * Upper bound check the message len against the ring size. @@ -983,8 +977,6 @@ ringbuf_insert(const struct domain *d, struct argo_ring_info *ring_info, * versus performance cost could be added to decide that here. */ - *out_len = len; - return ret; } @@ -1976,7 +1968,7 @@ sendv(struct domain *src_d, xen_argo_addr_t *src_addr, struct argo_ring_id src_id; struct argo_ring_info *ring_info; int ret = 0; - unsigned long len = 0; + unsigned int len = 0; argo_dprintk("sendv: (%u:%x)->(%u:%x) niov:%u type:%x\n", src_addr->domain_id, src_addr->aport, dst_addr->domain_id, @@ -2044,8 +2036,16 @@ sendv(struct domain *src_d, xen_argo_addr_t *src_addr, { spin_lock(&ring_info->L3_lock); + /* + * Obtain the total size of data to transmit -- sets the 'len' variable + * -- and sanity check that the iovs conform to size and number limits. + */ + ret = iov_count(iovs, niov, &len); + if ( ret ) + return ret; + ret = ringbuf_insert(dst_d, ring_info, &src_id, iovs, niov, - message_type, &len); + message_type, len); if ( ret == -EAGAIN ) { int rc;