From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out0-148.mail.aliyun.com (out0-148.mail.aliyun.com [140.205.0.148]) by dpdk.org (Postfix) with ESMTP id 60E5D322C; Fri, 10 Aug 2018 20:42:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alibaba-inc.com; s=default; t=1533926527; h=Date:From:To:Message-ID:Subject:MIME-Version:Content-Type; bh=LrR+tkSbUnECy70HFR18cUPXYBZOQ8SkYOZJFFYood0=; b=eILHHRNu+iw5I6IMqruRVlNDTVOMo8iTKC1JHwJqGLQAny2dzZk2tWDdvNdW04FRX+O9VG9AqHq/9WfVtik1yvMKoaDEEsit5oCApqDjEPGCf4SQCwNO7E5TqqPI+4nv8WeSuz0JM1UduQb47NfcX1UjFmk/J/XS8pYxyOjlzAk= X-Alimail-AntiSpam: AC=PASS; BC=-1|-1; BR=01201311R121e4; CH=green; FP=0|-1|-1|-1|0|-1|-1|-1; HT=e01l07423; MF=h.liu@alibaba-inc.com; NM=1; PH=DW; RN=3; SR=0; TI=W4_5335686_DEFAULT_0A9323E5_1533926453392_o7001c302o; Received: from WS-web (h.liu@alibaba-inc.com[W4_5335686_DEFAULT_0A9323E5_1533926453392_o7001c302o]) by e01l07384.eu6 at Sat, 11 Aug 2018 02:41:36 +0800 Date: Sat, 11 Aug 2018 02:41:36 +0800 From: "=?UTF-8?B?5YiY6L6J?=" To: "Hui Liu" , "dev" Cc: "dev" Message-ID: X-Mailer: [Alimail-Mailagent revision 7][W4_5335686][DEFAULT][Chrome] MIME-Version: 1.0 References: , <20180809093115.GA23324@bricha3-MOBL.ger.corp.intel.com> In-Reply-To: <20180809093115.GA23324@bricha3-MOBL.ger.corp.intel.com> x-aliyun-mail-creator: W4_5335686_DEFAULT_NTMTW96aWxsYS81LjAgKE1hY2ludG9zaDsgSW50ZWwgTWFjIE9TIFggMTBfMTJfNikgQXBwbGVXZWJLaXQvNTM3LjM2IChLSFRNTCwgbGlrZSBHZWNrbykgQ2hyb21lLzY3LjAuMzM5Ni45OSBTYWZhcmkvNTM3LjM2XQ Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: base64 X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: [dpdk-dev] =?utf-8?b?5Zue5aSN77yaIFF1ZXN0aW9ucyBhYm91dCBUWCBkZXNj?= =?utf-8?q?riptors_run_out_occasionally?= X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: =?UTF-8?B?5YiY6L6J?= List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Aug 2018 18:42:10 -0000 SGkgQnJ1Y2UsCgpUaGFuayB5b3UgZm9yIHlvdXIgaW5mb3JtYXRpb24hIEkgd2lsbCB0cnkgZGlm ZmVyZW50IGZpcm13YXJlIHZlcnNpb24gYW5kIGFsc28gZG91YmxlIGNoZWNrIG91ciBhcHBsaWNh dGlvbiBjb2RlIGFuZCBzZWUgaWYgdGhlcmUgaXMgYW55IHBvdGVudGlhbCBpbmNvcnJlY3QgbWVt b3J5IGFjY2Vzcy4gV2lsbCB1cGRhdGUgaWYgSSBzZWUgYW55dGhpbmcuCgpCZXN0IFJlZ2FyZHMs Ckh1aQoKCgotLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t LS0tLS0tLS0tLS0tLS0tLS0K5Y+R5Lu25Lq677yaQnJ1Y2UgUmljaGFyZHNvbiA8YnJ1Y2Uucmlj aGFyZHNvbkBpbnRlbC5jb20+CuWPkemAgeaXtumXtO+8mjIwMTjlubQ45pyIOeaXpSjmmJ/mnJ/l m5spIDAyOjMxCuaUtuS7tuS6uu+8mkh1aSBMaXUgPGh1aWxpdTAyMTNAZ21haWwuY29tPgrmioTj gIDpgIHvvJpkZXYgPGRldkBkcGRrLm9yZz4K5Li744CA6aKY77yaUmU6IFtkcGRrLWRld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mb3IgdGhl IE5JQyB0byByZWFkLCB0aGUgREQgYml0IGlzIGNsZWFyZWQuClNvZnR3YXJlIGtub3dzIHRoZSBO SUMgaGFzIGZpbmlzaGVkIHdpdGggdGhhdCBkZXNjcmlwdG9yIGJ5IGNoZWNraW5nIGZvcgp0aGUg REQgYml0IGJlaW5nIHNldCBieSB0aGUgTklDLiBJZiB0aGUgREQgYml0IGlzIG5vdCBiZWluZyBz ZXQsIHRoZW4gdGhlCnByb2JsZW0gaXMgbGlrZWx5IG9uIHRoZSBOSUMgc2lkZS4gW1BvdGVudGlh bCBzb2Z0d2FyZSBpc3N1ZXMgdGhhdCBjb3VsZApjYXVzZSB0aGlzIG1pZ2h0IGJlIGJ1ZmZlciBl LmcuIG92ZXJmbG93cyB3aGVyZSB3ZSBvdmVyd3JpdGUgYSBERCBiaXQgc2V0CmJ5IHRoZSBOSUMs IG9yIHdoZXJlIHdlIGFyZSBwb2xsaW5nIGFuIGluY29ycmVjdCBhZGRyZXNzLCBldGMuIGV0Yy5d CgpSZWdhcmRzLAovQnJ1Y2UKCg== >From stephen@networkplumber.org Fri Aug 10 21:47:22 2018 Return-Path: Received: from mail-pl0-f65.google.com (mail-pl0-f65.google.com [209.85.160.65]) by dpdk.org (Postfix) with ESMTP id DE23D2BF4 for ; Fri, 10 Aug 2018 21:47:21 +0200 (CEST) Received: by mail-pl0-f65.google.com with SMTP id d5-v6so4458199pll.4 for ; Fri, 10 Aug 2018 12:47:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=tcy2GJOSF20IBE4+/Edyhl/qQDDdF8MF/w3MZsv0klU=; b=Mr3LQOmzAwQccu+HPO/xOtNBIvSXOMhRW0eQwEuHFEhNwBZRLIwcSpcvSPO+9jhgGy GCKPn5UJYDTHE2+h0t3Kpy0K34JfkZZRUphOjyXXm15YfBmxBiVn8RrV71u53thcX7ON 5qGDb9uqkl+0ZAZKyHA5qZSEsoNH7XJZwZ7yKQ7LCjaiCaNlNvggkgTkZcJVxf4iIF5l W9mH+Tllu04K+7CWxfTyHJNSGYFkwYZAyY9r2L25aqfM43JslMY433D1jdjQe1UDlWmW jUn2FriiyaRYjolwFsuq86fjpiyIJJ31fKTv9st8jsH5OgjOpJz2JBwGN7mj1w0eyDgA 1rnw== 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=tcy2GJOSF20IBE4+/Edyhl/qQDDdF8MF/w3MZsv0klU=; b=XJpighamAFW9g8UzL1gu2f+m20vIcs4mZ3NNg0sUcbz4NuLXSVPPCJu7UH+GFORNsJ 5HUisjTDi0RkSSEA14icUUZqGt2/qelcSDAlwDsta54QW9AZB+ojB/TA7MrYAlhfAwu3 o+yqYw4h6wFq+3qqrxLkWf2XXl7HfgCH1zlO2E9HIpO50t7uDD6YVMd4JXSjdq3Ue9BP 9oXUjpHI9VAUu9W5tTtIvYcqIjyIh2nTk71t7BhyKGFL/7JaEdO6Xr3mc3eaMnixfP9g ujSqGbsBWPAc4b/fOX+Bv5oh3Ds3VbUsR5c5IGBr6xJxw8ymgfU99hyfpR0lXO2c4FVv 4/1w== X-Gm-Message-State: AOUpUlH/XO/bYwnvTxcX/sLdGrP8jNIq+Dp7ZbClbjSFnOLEsqFWpFev vPnUhrfwEc4igFqbjrhFjmQ1babmJlk= X-Google-Smtp-Source: AA+uWPwEpD50gC7xCfa883SDqbzz08uMZ4M3wrhqwZUoKdUKBcnHxL5tSLdNCpvdzXBQIE9KB0Z+Jw== X-Received: by 2002:a17:902:bb85:: with SMTP id m5-v6mr7171910pls.46.1533930440707; Fri, 10 Aug 2018 12:47:20 -0700 (PDT) Received: from xeon-e3.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id 77-v6sm17268076pga.40.2018.08.10.12.47.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Aug 2018 12:47:19 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Stephen Hemminger Date: Fri, 10 Aug 2018 12:47:08 -0700 Message-Id: <20180810194708.15944-1-stephen@networkplumber.org> X-Mailer: git-send-email 2.18.0 Subject: [dpdk-dev] [PATCH] netvsc: resize event buffer as needed X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Aug 2018 19:47:22 -0000 The event buffer was changed to be a fixed size value, but it is not large enough for a forwarding stress test. And that change was buggy because it left calls to rte_free() for a pointer that was not setup with rte_malloc(). This would cause pool to get corrupted. This version of event buffer code uses malloc/realloc to size the event buffer as needed. Malloc is preferred over rte_malloc because the event buffer does not need to be used for DMA and huge page is a limited resource. Fixes: 530af95a7849 ("bus/vmbus: avoid signalling host on read") Signed-off-by: Stephen Hemminger --- drivers/net/netvsc/hn_rxtx.c | 49 +++++++++++++++++++++++++----------- drivers/net/netvsc/hn_var.h | 2 +- 2 files changed, 35 insertions(+), 16 deletions(-) diff --git a/drivers/net/netvsc/hn_rxtx.c b/drivers/net/netvsc/hn_rxtx.c index 02ef27e363cc..6ecaca89ea5d 100644 --- a/drivers/net/netvsc/hn_rxtx.c +++ b/drivers/net/netvsc/hn_rxtx.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -718,16 +719,22 @@ struct hn_rx_queue *hn_rx_queue_alloc(struct hn_data *hv, { struct hn_rx_queue *rxq; - rxq = rte_zmalloc_socket("HN_RXQ", - sizeof(*rxq) + HN_RXQ_EVENT_DEFAULT, + rxq = rte_zmalloc_socket("HN_RXQ", sizeof(*rxq), RTE_CACHE_LINE_SIZE, socket_id); - if (rxq) { - rxq->hv = hv; - rxq->chan = hv->channels[queue_id]; - rte_spinlock_init(&rxq->ring_lock); - rxq->port_id = hv->port_id; - rxq->queue_id = queue_id; + if (!rxq) + return NULL; + + rxq->hv = hv; + rxq->chan = hv->channels[queue_id]; + rte_spinlock_init(&rxq->ring_lock); + rxq->port_id = hv->port_id; + rxq->queue_id = queue_id; + rxq->event_buf = malloc(HN_RXQ_EVENT_DEFAULT); + if (!rxq->event_buf) { + rte_free(rxq); + return NULL; } + return rxq; } @@ -776,7 +783,7 @@ hn_dev_rx_queue_setup(struct rte_eth_dev *dev, fail: rte_ring_free(rxq->rx_ring); - rte_free(rxq->event_buf); + free(rxq->event_buf); rte_free(rxq); return -ENOMEM; } @@ -796,7 +803,7 @@ hn_dev_rx_queue_release(void *arg) rxq->mb_pool = NULL; if (rxq != rxq->hv->primary) { - rte_free(rxq->event_buf); + free(rxq->event_buf); rte_free(rxq); } } @@ -853,19 +860,31 @@ void hn_process_events(struct hn_data *hv, uint16_t queue_id) for (;;) { const struct vmbus_chanpkt_hdr *pkt; - uint32_t len = HN_RXQ_EVENT_DEFAULT; + uint32_t len = malloc_usable_size(rxq->event_buf); const void *data; +retry: ret = rte_vmbus_chan_recv_raw(rxq->chan, rxq->event_buf, &len); if (ret == -EAGAIN) break; /* ring is empty */ - else if (ret == -ENOBUFS) - rte_exit(EXIT_FAILURE, "event buffer not big enough (%u < %u)", - HN_RXQ_EVENT_DEFAULT, len); - else if (ret <= 0) + if (unlikely(ret == -ENOBUFS)) { + /* event buffer not large enough to read ring */ + + PMD_DRV_LOG(DEBUG, + "event buffer expansion (need %u)", len); + rxq->event_buf = realloc(rxq->event_buf, len); + if (rxq->event_buf) + goto retry; + /* out of memory, no more events now */ + break; + } + + if (unlikely(ret <= 0)) { + /* This indicates a failure to communicate (or worse) */ rte_exit(EXIT_FAILURE, "vmbus ring buffer error: %d", ret); + } bytes_read += ret; pkt = (const struct vmbus_chanpkt_hdr *)rxq->event_buf; diff --git a/drivers/net/netvsc/hn_var.h b/drivers/net/netvsc/hn_var.h index f7ff8585bc1c..0430f450cf37 100644 --- a/drivers/net/netvsc/hn_var.h +++ b/drivers/net/netvsc/hn_var.h @@ -77,7 +77,7 @@ struct hn_rx_queue { struct hn_stats stats; uint64_t ring_full; - uint8_t event_buf[]; + void *event_buf; }; -- 2.18.0