Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1898174ybv; Thu, 6 Feb 2020 11:52:34 -0800 (PST) X-Google-Smtp-Source: APXvYqz3z5vucRLPq/S7Y9K9mBZl5/hpWFuvlWxONmofDxpBSHaKCCWYi//9N/UYJ8Q+Reld3bZT X-Received: by 2002:a05:6808:a8a:: with SMTP id q10mr7825433oij.66.1581018753956; Thu, 06 Feb 2020 11:52:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581018753; cv=none; d=google.com; s=arc-20160816; b=UPAFsrJ/BQhkyJ9WcARwNAEbfqtOL5KQW9fcwK3LkyxNrLwj2m7zmZGfrpNlWvf579 9CwIJaKROiOInz5keO2FHi1uIGdObZLv5BZKEYbhXHnHSG2/emKp/7V74n7FbsC+Yg5j GYTniXXPcia5Tb3z0rA+plps/6zxGSMdvy06jGZFXl8tRLL6gjOkVpHvR8I3RBg8OOm+ SA4szCiEQ0nJ8lVOHtBdXRQC5LdjMl85qCzyRo0aWrMS9GJJLYZPtlG5dcYyUTmfi5T6 YoavodXPL0QeQK8fNROc94/4nTv/9/l79+u4U9a7ck4uDSXIG6G/nPV2Q9PQA9wA/Nlb 7Lgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:references:cc:to:from:subject:dkim-signature; bh=H6h85xrCfg+hq6R4St/F+34IPqni6BUTXg8rGkhGCqQ=; b=yzpMz6nlGNMruyskqEteTVuexRC1G+5PlatSme3U3n0oszCPUtZ5OVxfz76OyTCYDb c3pwO+qoE+QpdyfOGMHxtGkPnDwj6F5i2rjsHSq+bp+WCao/P18GvZENod7Z4gaX8hQx j9HrnO7LGjg9bHfvTawjjv4jy3itN+YZmwRRsoW8QpaPnLCWkoo3P3jsX9R8Ak4Zrorq wBM8lPCtZgz8tCrxMATOu1VciJVioZ57+N1XXdw5vG7t38XfAeblCZ7lPGtJjoH3R87Q Ey7E2LZuGLTTG5m/h3EahPLLGDwjITV7gF/Jpvpwd/NnHVHHYcjUFUlr464YkoVrgQJG QIsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=Q9k3KnQN; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d2si323785ote.9.2020.02.06.11.52.21; Thu, 06 Feb 2020 11:52:33 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=Q9k3KnQN; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727831AbgBFTvF (ORCPT + 99 others); Thu, 6 Feb 2020 14:51:05 -0500 Received: from mail-il1-f195.google.com ([209.85.166.195]:46459 "EHLO mail-il1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727698AbgBFTvF (ORCPT ); Thu, 6 Feb 2020 14:51:05 -0500 Received: by mail-il1-f195.google.com with SMTP id t17so6214683ilm.13 for ; Thu, 06 Feb 2020 11:51:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=subject:from:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=H6h85xrCfg+hq6R4St/F+34IPqni6BUTXg8rGkhGCqQ=; b=Q9k3KnQN2MHUn79kvbULiVAbY+4cFTtPF/F3gh6x7uSxqpUcFm0p6E/yCHrIFXvg46 4A5NeT5FMnwxqoumUYbKuOEah8w5ge5yuuGRGq8esjq3d9SrDBtZQA1hKzf4uK39fCed lM7QKQPAfUVJ91eDFB8ZTpdkKbhLaeam4VPoFrX3VJNyBZwYByq/4PHXfwRatGXtYJfj a3Xhxq8/YTPDw8j+aVer4RAs0Wbd0wV5Xfq+9KLMh2vrmEhlrjixv3qQ+3Pf1XOP2Bvm hTuLKoxmS72hl1NpKX4FRcQ78ds7PLvHrgo2IY7pcbt7A9k6B8XJUxLpuLQ+KPRhLFMk RO0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=H6h85xrCfg+hq6R4St/F+34IPqni6BUTXg8rGkhGCqQ=; b=Oh1gw4RIhqlIu6TCRy6eKjz3rxXUKQWf0+L3CTxnc0BTDARIJxDUynIPFjtxvu+r0y XuBfOl0niK8irscI5ECLiZXe0Ez3JXi0LclKIdohTGe/LPsmH3YCppexpULBeb+7VkB8 tpzZxh8INvMS2UiPRuwJXbTh+7Tf3LlCwEIqWiK273P9yjKjVx8HRhx0RNpm5Z8t4Ygp KxjrevzoFXWez3bL8R6GX64En9yiLRG+tZ1BRsDuyun58GCwUpOnHqmtgGEenSP6A72k PgOtpNneKMLr4AAdOlkEe1R3hN+KngtODFpHGdOB0nMhIhiNeFTjU2e1BsPucXfdLzBT K/5w== X-Gm-Message-State: APjAAAUqCmT10CF8vIVMiugtiFm5Db1DO4TSAKFaL6yCfEpXVPnTQSAh JnPXq7HZG51btjrTLHNXgpIld6kciFk= X-Received: by 2002:a92:990b:: with SMTP id p11mr5554087ili.254.1581018664583; Thu, 06 Feb 2020 11:51:04 -0800 (PST) Received: from [192.168.1.159] ([65.144.74.34]) by smtp.gmail.com with ESMTPSA id t2sm267414ild.34.2020.02.06.11.51.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 06 Feb 2020 11:51:04 -0800 (PST) Subject: Re: [PATCH liburing v2 0/1] test: add epoll test case From: Jens Axboe To: Stefano Garzarella Cc: linux-kernel@vger.kernel.org, io-uring@vger.kernel.org References: <20200131142943.120459-1-sgarzare@redhat.com> Message-ID: <548cb67b-bb43-c22a-f3c6-e707e2c07c13@kernel.dk> Date: Thu, 6 Feb 2020 12:51:03 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2/6/20 12:15 PM, Jens Axboe wrote: > On 2/6/20 10:33 AM, Stefano Garzarella wrote: >> >> >> On Fri, Jan 31, 2020 at 4:39 PM Jens Axboe wrote: >>> >>> On 1/31/20 7:29 AM, Stefano Garzarella wrote: >>>> Hi Jens, >>>> this is a v2 of the epoll test. >>>> >>>> v1 -> v2: >>>> - if IORING_FEAT_NODROP is not available, avoid to overflow the CQ >>>> - add 2 new tests to test epoll with IORING_FEAT_NODROP >>>> - cleanups >>>> >>>> There are 4 sub-tests: >>>> 1. test_epoll >>>> 2. test_epoll_sqpoll >>>> 3. test_epoll_nodrop >>>> 4. test_epoll_sqpoll_nodrop >>>> >>>> In the first 2 tests, I try to avoid to queue more requests than we have room >>>> for in the CQ ring. These work fine, I have no faults. >>> >>> Thanks! >>> >>>> In the tests 3 and 4, if IORING_FEAT_NODROP is supported, I try to submit as >>>> much as I can until I get a -EBUSY, but they often fail in this way: >>>> the submitter manages to submit everything, the receiver receives all the >>>> submitted bytes, but the cleaner loses completion events (I also tried to put a >>>> timeout to epoll_wait() in the cleaner to be sure that it is not related to the >>>> patch that I send some weeks ago, but the situation doesn't change, it's like >>>> there is still overflow in the CQ). >>>> >>>> Next week I'll try to investigate better which is the problem. >>> >>> Does it change if you have an io_uring_enter() with GETEVENTS set? I wonder if >>> you just pruned the CQ ring but didn't flush the internal side. >> >> If I do io_uring_enter() with GETEVENTS set and wait_nr = 0 it solves >> the issue, I think because we call io_cqring_events() that flushes the >> overflow list. >> >> At this point, should we call io_cqring_events() (that flushes the >> overflow list) in io_uring_poll()? >> I mean something like this: >> >> diff --git a/fs/io_uring.c b/fs/io_uring.c >> index 77f22c3da30f..2769451af89a 100644 >> --- a/fs/io_uring.c >> +++ b/fs/io_uring.c >> @@ -6301,7 +6301,7 @@ static __poll_t io_uring_poll(struct file *file, poll_table *wait) >> if (READ_ONCE(ctx->rings->sq.tail) - ctx->cached_sq_head != >> ctx->rings->sq_ring_entries) >> mask |= EPOLLOUT | EPOLLWRNORM; >> - if (READ_ONCE(ctx->rings->cq.head) != ctx->cached_cq_tail) >> + if (!io_cqring_events(ctx, false)) >> mask |= EPOLLIN | EPOLLRDNORM; >> >> return mask; > > That's not a bad idea, would just have to verify that it is indeed safe > to always call the flushing variant from there. Double checked, and it should be fine. We may be invoked with ctx->uring_lock held, but that's fine. -- Jens Axboe