From patchwork Wed Apr 1 13:30:59 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 47079 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f72.google.com (mail-la0-f72.google.com [209.85.215.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 0EB6121416 for ; Sat, 11 Apr 2015 09:53:48 +0000 (UTC) Received: by lamp14 with SMTP id p14sf9094752lam.3 for ; Sat, 11 Apr 2015 02:53:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:delivered-to:from:to:date :message-id:cc:subject:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version :content-type:content-transfer-encoding:errors-to:sender :x-original-sender:x-original-authentication-results:mailing-list; bh=NzphOZPFPJFVLwyn0sAXyo56tELPRgJE+YnH/OVM4os=; b=b12WJHe/EtOgjwAESbpFLLNI9wezTxon/PUB2s3LuNwu8+8aYJ589ILe+H7JHvbEP4 y4qheC3dapaPeZwtWajyNGob+JlPSxKKOutP3QdKdJZFC4bv521AJYtdgwVI3REhi+hZ 1EqvwN88iP9xqXNJ0Ck0griIZvI/znU2qu8AT745vmqYfZZWyBkzrwOBeWW9lg46I5nN SH1ySstn/AFMUxkt/F+Fheky2GRaW1KhdnK9B0b4E/HkHgiVuKw+G/Sn39eco7BhchFQ mUaQiDuWI/4PPrhyU4jYUjKlO7kiq2ECSEyUbQiZN8g9eVlVvZL+mVGeACQI12AapObg LwVw== X-Gm-Message-State: ALoCoQlS31m9t+YblO8LhkUQ2OLOk3KyM4b4qKn6r5bXyvsRADdHa5arlvUvftEPvKDn2XZNrgpa X-Received: by 10.112.151.146 with SMTP id uq18mr997101lbb.20.1428746026637; Sat, 11 Apr 2015 02:53:46 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.36.199 with SMTP id s7ls452616laj.57.gmail; Sat, 11 Apr 2015 02:53:46 -0700 (PDT) X-Received: by 10.152.238.43 with SMTP id vh11mr4988454lac.45.1428746026353; Sat, 11 Apr 2015 02:53:46 -0700 (PDT) Received: from mail-lb0-f182.google.com (mail-lb0-f182.google.com. [209.85.217.182]) by mx.google.com with ESMTPS id s12si3485272lbm.84.2015.04.11.02.53.46 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 11 Apr 2015 02:53:46 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.182 as permitted sender) client-ip=209.85.217.182; Received: by lbbuc2 with SMTP id uc2so29115331lbb.2 for ; Sat, 11 Apr 2015 02:53:46 -0700 (PDT) X-Received: by 10.112.140.231 with SMTP id rj7mr4889575lbb.76.1428746026264; Sat, 11 Apr 2015 02:53:46 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.67.65 with SMTP id l1csp230779lbt; Sat, 11 Apr 2015 02:53:45 -0700 (PDT) X-Received: by 10.140.87.10 with SMTP id q10mr6460967qgd.67.1428746024687; Sat, 11 Apr 2015 02:53:44 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id n82si4367761qkh.57.2015.04.11.02.53.44; Sat, 11 Apr 2015 02:53:44 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Received: by lists.linaro.org (Postfix, from userid 109) id ED04C6354C; Sat, 11 Apr 2015 09:53:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from ip-10-142-244-252.ec2.internal (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 74DAF65132; Sat, 11 Apr 2015 09:52:19 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 520FD64F9E; Wed, 1 Apr 2015 13:31:12 +0000 (UTC) Received: from mail-la0-f45.google.com (mail-la0-f45.google.com [209.85.215.45]) by lists.linaro.org (Postfix) with ESMTPS id 9BA9764F9E for ; Wed, 1 Apr 2015 13:31:11 +0000 (UTC) Received: by lagg8 with SMTP id g8so36679803lag.1 for ; Wed, 01 Apr 2015 06:31:10 -0700 (PDT) X-Received: by 10.112.163.229 with SMTP id yl5mr35530878lbb.60.1427895070149; Wed, 01 Apr 2015 06:31:10 -0700 (PDT) Received: from localhost.localdomain (ppp91-76-169-66.pppoe.mtu-net.ru. [91.76.169.66]) by mx.google.com with ESMTPSA id fg11sm421304lbc.15.2015.04.01.06.31.08 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 01 Apr 2015 06:31:08 -0700 (PDT) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Wed, 1 Apr 2015 16:30:59 +0300 Message-Id: <1427895059-13898-1-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 1.9.1 X-Mailman-Approved-At: Wed, 01 Apr 2015 13:41:43 +0000 X-Topics: patch Cc: petri.savolainen@nokia.com Subject: [lng-odp] [PATCH] linux-generic: sched fix polling input queue X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: maxim.uvarov@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.182 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Commit: 8fa64fb9fc4e43fbd9d3c226ed89229863bdb771 linux-generic: scheduler: restructured queue and pktio integration Implement race with schedule termination and polling input queue. This patch locks pktio while doing poll to prevent destroy linked queue in the middle of this poll. Signed-off-by: Maxim Uvarov --- .../linux-generic/include/odp_packet_io_internal.h | 2 ++ platform/linux-generic/odp_packet_io.c | 39 +++++++++++++++++----- 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/platform/linux-generic/include/odp_packet_io_internal.h b/platform/linux-generic/include/odp_packet_io_internal.h index 18b59ef..804ceda 100644 --- a/platform/linux-generic/include/odp_packet_io_internal.h +++ b/platform/linux-generic/include/odp_packet_io_internal.h @@ -88,6 +88,8 @@ static inline pktio_entry_t *get_pktio_entry(odp_pktio_t pktio) int pktin_poll(pktio_entry_t *entry); +int __odp_pktio_recv(odp_pktio_t id, odp_packet_t pkt_table[], int len); + #ifdef __cplusplus } #endif diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c index e7d3c1b..391a8b3 100644 --- a/platform/linux-generic/odp_packet_io.c +++ b/platform/linux-generic/odp_packet_io.c @@ -382,7 +382,7 @@ static int deq_loopback(pktio_entry_t *pktio_entry, odp_packet_t pkts[], return nbr; } -int odp_pktio_recv(odp_pktio_t id, odp_packet_t pkt_table[], int len) +int __odp_pktio_recv(odp_pktio_t id, odp_packet_t pkt_table[], int len) { pktio_entry_t *pktio_entry = get_pktio_entry(id); int pkts; @@ -391,7 +391,6 @@ int odp_pktio_recv(odp_pktio_t id, odp_packet_t pkt_table[], int len) if (pktio_entry == NULL) return -1; - lock_entry(pktio_entry); switch (pktio_entry->s.type) { case ODP_PKTIO_TYPE_SOCKET_BASIC: pkts = recv_pkt_sock_basic(&pktio_entry->s.pkt_sock, @@ -413,7 +412,6 @@ int odp_pktio_recv(odp_pktio_t id, odp_packet_t pkt_table[], int len) break; } - unlock_entry(pktio_entry); if (pkts < 0) return pkts; @@ -423,6 +421,20 @@ int odp_pktio_recv(odp_pktio_t id, odp_packet_t pkt_table[], int len) return pkts; } +int odp_pktio_recv(odp_pktio_t id, odp_packet_t pkt_table[], int len) +{ + pktio_entry_t *pktio_entry = get_pktio_entry(id); + int ret = -1; + + if (pktio_entry == NULL) + return -1; + + lock_entry(pktio_entry); + ret = __odp_pktio_recv(id, pkt_table, len); + unlock_entry(pktio_entry); + + return ret; +} static int enq_loopback(pktio_entry_t *pktio_entry, odp_packet_t pkt_tbl[], unsigned len) { @@ -681,13 +693,26 @@ int pktin_poll(pktio_entry_t *entry) odp_packet_t pkt_tbl[QUEUE_MULTI_MAX]; odp_buffer_hdr_t *hdr_tbl[QUEUE_MULTI_MAX]; int num, num_enq, i; + queue_entry_t *qentry; + pktio_entry_t *pktio_entry; if (odp_unlikely(is_free(entry))) return -1; - num = odp_pktio_recv(entry->s.handle, pkt_tbl, QUEUE_MULTI_MAX); + pktio_entry = get_pktio_entry(entry->s.handle); + + lock_entry(pktio_entry); + if (entry->s.inq_default == ODP_QUEUE_INVALID) { + unlock_entry(pktio_entry); + return -1; + } + + qentry = queue_to_qentry(entry->s.inq_default); + + num = __odp_pktio_recv(entry->s.handle, pkt_tbl, QUEUE_MULTI_MAX); if (num < 0) { + unlock_entry(pktio_entry); ODP_ERR("Packet recv error\n"); return -1; } @@ -707,12 +732,10 @@ int pktin_poll(pktio_entry_t *entry) } } - if (num_enq) { - queue_entry_t *qentry; - qentry = queue_to_qentry(entry->s.inq_default); + if (num_enq) queue_enq_multi(qentry, hdr_tbl, num_enq); - } + unlock_entry(pktio_entry); return 0; }