From patchwork Mon Jul 1 21:42:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 11026769 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 7CA921890 for ; Mon, 1 Jul 2019 21:42:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 720B028765 for ; Mon, 1 Jul 2019 21:42:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 65E9728786; Mon, 1 Jul 2019 21:42:43 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0B9B028765 for ; Mon, 1 Jul 2019 21:42:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726951AbfGAVmm (ORCPT ); Mon, 1 Jul 2019 17:42:42 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:41277 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726678AbfGAVmm (ORCPT ); Mon, 1 Jul 2019 17:42:42 -0400 Received: by mail-pf1-f194.google.com with SMTP id m30so7176473pff.8 for ; Mon, 01 Jul 2019 14:42:42 -0700 (PDT) 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:mime-version:content-transfer-encoding; bh=OMIB+NJ9pk5Mr/BbVFnvI+yoF7k9qUYHjOCtdJ2IJpI=; b=l3CZaK0pGRnXWFc8XxmUAKmIkBN52yY0f5o56rCNTdyYQO3RZd/DUrHnMTzY3lN0J2 OA+y3VeRngO5EAxQJWksKgKcISpnys7EyW84DprFhxx2dnCTHVeSPsBSznKZCR3yuj1J ILCH9tks7xL+bJRlaxZ8yPfF1otfX7obZ2/WFyc7lUUVCuSlAOSVCQf9CLF99uePxq1q +tGKXuYS3Ez6/z2dko2hwoWoaLN8rp1f0xOaVNbQWqp5XxtFi+FBAoEaM4nBeEsYtqL/ I660WFDaxhx4y5VMlghFTcEA1T4pZDS2dvajrz9khpC72vatPfiuhYJzSGhv9nj81A3H 6EXA== X-Gm-Message-State: APjAAAU/kdyt9rw71XQGx5h7xImnj7iR4dPKmYar4klPZTQTnzARRN1s /eOXb/Us+0dZoPGv1OVcnCQ= X-Google-Smtp-Source: APXvYqx+bYBeyktv1qxlchYk3UE9z3gF2k6QVEkvqXMXim8t/1hwlmR1paFZIvPUYu2Q8XkWEQioPw== X-Received: by 2002:a17:90a:26ef:: with SMTP id m102mr1552532pje.50.1562017361582; Mon, 01 Jul 2019 14:42:41 -0700 (PDT) Received: from desktop-bart.svl.corp.google.com ([2620:15c:2cd:202:4308:52a3:24b6:2c60]) by smtp.gmail.com with ESMTPSA id c83sm15892282pfb.111.2019.07.01.14.42.40 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 01 Jul 2019 14:42:40 -0700 (PDT) From: Bart Van Assche To: Jens Axboe Cc: linux-block@vger.kernel.org, Bart Van Assche , Stefan Hajnoczi , Roman Penyaev Subject: [PATCH liburing 1/2] __io_uring_get_cqe(): Use io_uring_for_each_cqe() Date: Mon, 1 Jul 2019 14:42:31 -0700 Message-Id: <20190701214232.29338-2-bvanassche@acm.org> X-Mailer: git-send-email 2.22.0.410.gd8fdbe21b5-goog In-Reply-To: <20190701214232.29338-1-bvanassche@acm.org> References: <20190701214232.29338-1-bvanassche@acm.org> MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use io_uring_for_each_cqe() inside __io_uring_get_cqe() such that it becomes possible to test the io_uring_for_each_cqe() implementation from inside the liburing project. Cc: Stefan Hajnoczi Cc: Roman Penyaev Signed-off-by: Bart Van Assche --- src/queue.c | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/src/queue.c b/src/queue.c index 85e0c1e0d10f..bec363fc0ebf 100644 --- a/src/queue.c +++ b/src/queue.c @@ -14,26 +14,14 @@ static int __io_uring_get_cqe(struct io_uring *ring, struct io_uring_cqe **cqe_ptr, int wait) { - struct io_uring_cq *cq = &ring->cq; - const unsigned mask = *cq->kring_mask; unsigned head; int ret; - *cqe_ptr = NULL; - head = *cq->khead; do { - /* - * It's necessary to use a read_barrier() before reading - * the CQ tail, since the kernel updates it locklessly. The - * kernel has the matching store barrier for the update. The - * kernel also ensures that previous stores to CQEs are ordered - * with the tail update. - */ - read_barrier(); - if (head != *cq->ktail) { - *cqe_ptr = &cq->cqes[head & mask]; + io_uring_for_each_cqe(ring, head, *cqe_ptr) + break; + if (*cqe_ptr) break; - } if (!wait) break; ret = io_uring_enter(ring->ring_fd, 0, 1,