Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp442328ybv; Wed, 19 Feb 2020 02:45:29 -0800 (PST) X-Google-Smtp-Source: APXvYqwWLVqQ+uk60BHHbuXtlQJUjsrc2amv72g4u3yBi1jsu98goNMXEg7mPESiHuHYgPoqXbDC X-Received: by 2002:a9d:53c2:: with SMTP id i2mr17886746oth.43.1582109129058; Wed, 19 Feb 2020 02:45:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582109129; cv=none; d=google.com; s=arc-20160816; b=Q7cav8OxiLjwdR6xun+ca2m8WVwLHkuuI34Jrf7XqFZfRqz4Y5JMsKOSGWK+HxOkzr bkZL68ycLgIPhwxH2KEISNcDFqxsSiy/EgxQ3iA6fE3Zt/AQUnGHUobtbOKL12Q3X+2Y BkY50eTdCnNDzCE9iYfj2xGqg7QLtaavJQJPuUY/4zl5Z5cSR8HjWm2Cb9ar1tYaIQX5 eb9Yrl/+X5MXCZzJhZdXUsTHwBJmqzEdjwc2iRBsk/EN95hfG+kFXz9pRy9nUQKXjV2F NPqoSaz2aKoQ2td0qqBOT34/dyZlFf+h2aQpITE7dddZPaUf3rTO8E/TlqaadVT5v7Io IX5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject :dkim-signature; bh=uu178h4Sn9VpLsAwrPceV0KSap9/ps5hFk6MJzLCOtU=; b=lgG2ORZK6BuEhSFcONELT97TSCq98UMe/IQZt12ZRRAfqtf+aHnK/DsSaHW/uq+IhT K7ZH/sBtfRhKx2P8t1T64mDjTKPmhlH1lkgKGN2YbfL9f5X13fq/STiX/f1AcgjAkhGl PFxI9/a5FRA1IRWR31dP6+w3MnwV5rJ+sq7dYFXUZdBrfJ0WDWPvO07wk/5os/nSQTQn V4W+f3CCPZp4YEA6onD82CiQ/CitnEuMDi6DK5tbOCYThW+dLU7MI1lafDU1k/0okujq 9NQx4VYVAW67JnS7n8n7dgDW4ImqiUTf3gNdl8TR5wvz/s+qxw/NmSQImunNXBUWjqi9 xU7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@scylladb-com.20150623.gappssmtp.com header.s=20150623 header.b=02bdATzx; 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 q26si9217901oij.38.2020.02.19.02.45.16; Wed, 19 Feb 2020 02:45:29 -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=@scylladb-com.20150623.gappssmtp.com header.s=20150623 header.b=02bdATzx; 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 S1726682AbgBSKn4 (ORCPT + 99 others); Wed, 19 Feb 2020 05:43:56 -0500 Received: from mail-wm1-f68.google.com ([209.85.128.68]:40707 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726484AbgBSKn4 (ORCPT ); Wed, 19 Feb 2020 05:43:56 -0500 Received: by mail-wm1-f68.google.com with SMTP id t14so36887wmi.5 for ; Wed, 19 Feb 2020 02:43:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=scylladb-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:organization:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=uu178h4Sn9VpLsAwrPceV0KSap9/ps5hFk6MJzLCOtU=; b=02bdATzxAmoFVgM99p2MGiOluR4xHHNS4c5NfrSi5BxO4RkYbZ3BBjd1lob/gTFE92 nWHXI33K66qyD+N6M8F+E3140V4WAGc4yJzS9ZHjUEc6UlCzJbBvcs2R9HgVIFm8qxEc WaSoY4g4ZJ6vsivGbNfVQ1tMkz+VkFnfFspX0Z0B4vZvx9IYUJTVztOINVubutus35Qs 09Ci8IJE0V/r5OFWfFLh9GjgKLL08p6UjQnc0OYtYEK1u8vsICytra8wXW+0FfK/utAh /YWf8djFy29yAMuz6eDs3EQfZVIRpoffMgSUzReLi4Qaswtnv6vCecBFIQHyIP3RfTK8 CqZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:organization :message-id:date:user-agent:mime-version:in-reply-to :content-transfer-encoding:content-language; bh=uu178h4Sn9VpLsAwrPceV0KSap9/ps5hFk6MJzLCOtU=; b=P55iWJksDjIJFxgzmUDnuwmjSJ4jq/CHfJFjAlGzVpnpsy5/svPq6VmuLNQBkdFCYc bAxE6rD97V6AhBK5HEoRXsUxhZuDunfqT2rTxk30z9+MerL7CwpUXJE4Lampd1GimUU0 AG4tu5AmqSIKqbvpbi7SygxDVTFFbHooKav/xOK0194gdHX17FaOOfFIt6mkocOid3q/ uy/N/6aUz1TUcT8MYcCix6urVI+C5ZmaDkkjjl/BrDULfT3wiITR/P/SEnu0kpeC4t0b 6jrI7AUvOhws01rKGMJGN1GD9+8I5NbHZeaIzbrh6eVU9HYQfr5GG3UZrhoO1jPvpd6y 5qfw== X-Gm-Message-State: APjAAAUiASkdFm34Uis+GzFzYiYEUHnucD16AAyn7Qqy0qrWUTSLXF3Y d2k4y9yJjQ1Ft8EMdPkDBacPerdMX9U= X-Received: by 2002:a7b:cab1:: with SMTP id r17mr9217850wml.116.1582109034556; Wed, 19 Feb 2020 02:43:54 -0800 (PST) Received: from [10.0.0.1] (system.cloudius-systems.com. [199.203.229.89]) by smtp.gmail.com with ESMTPSA id h2sm2547507wrt.45.2020.02.19.02.43.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 19 Feb 2020 02:43:53 -0800 (PST) Subject: Re: [RFC] eventfd: add EFD_AUTORESET flag To: Stefan Hajnoczi Cc: Paolo Bonzini , Stefan Hajnoczi , linux-fsdevel@vger.kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Davide Libenzi , Alexander Viro References: <20200129172010.162215-1-stefanha@redhat.com> <66566792-58a4-bf65-6723-7d2887c84160@redhat.com> <20200212102912.GA464050@stefanha-x1.localdomain> <156cb709-282a-ddb6-6f34-82b4bb211f73@redhat.com> <20200219103704.GA1076032@stefanha-x1.localdomain> From: Avi Kivity Organization: ScyllaDB Message-ID: Date: Wed, 19 Feb 2020 12:43:51 +0200 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: <20200219103704.GA1076032@stefanha-x1.localdomain> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 19/02/2020 12.37, Stefan Hajnoczi wrote: > On Wed, Feb 12, 2020 at 12:54:30PM +0200, Avi Kivity wrote: >> On 12/02/2020 12.47, Paolo Bonzini wrote: >>> On 12/02/20 11:29, Stefan Hajnoczi wrote: >>>> On Wed, Feb 12, 2020 at 09:31:32AM +0100, Paolo Bonzini wrote: >>>>> On 29/01/20 18:20, Stefan Hajnoczi wrote: >>>>>> + /* Semaphore semantics don't make sense when autoreset is enabled */ >>>>>> + if ((flags & EFD_SEMAPHORE) && (flags & EFD_AUTORESET)) >>>>>> + return -EINVAL; >>>>>> + >>>>> I think they do, you just want to subtract 1 instead of setting the >>>>> count to 0. This way, writing 1 would be the post operation on the >>>>> semaphore, while poll() would be the wait operation. >>>> True! Then EFD_AUTORESET is not a fitting name. EFD_AUTOREAD or >>>> EFD_POLL_READS? >>> Avi's suggestion also makes sense. Switching the event loop from poll() >>> to IORING_OP_POLL_ADD would be good on its own, and then you could make >>> it use IORING_OP_READV for eventfds. >>> >>> In QEMU parlance, perhaps you need a different abstraction than >>> EventNotifier (let's call it WakeupNotifier) which would also use >>> eventfd but it would provide a smaller API. Thanks to the smaller API, >>> it would not need EFD_NONBLOCK, unlike the regular EventNotifier, and it >>> could either set up a poll() handler calling read(), or use >>> IORING_OP_READV when io_uring is in use. >>> >> Just to be clear, for best performance don't use IORING_OP_POLL_ADD, just >> IORING_OP_READ. That's what you say in the second paragraph but the first >> can be misleading. Actually it turns out that current uring OP_READ throws the work into a workqueue. Jens is fixing that now. > Thanks, that's a nice idea! I already have experimental io_uring fd > monitoring code written for QEMU and will extend it to use IORING_OP_READ. Note linux-aio can do IOCB_CMD_POLL, starting with 4.19.