Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp3665389pxb; Fri, 4 Feb 2022 13:36:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJwMQQ5MSTj77LJQnNQoCggvojxSvyXJ3lna8B6yWiyNK/E5ajmO9PtFxr6jORBdKFWIV8XB X-Received: by 2002:a17:902:8c92:: with SMTP id t18mr5191449plo.11.1644010580826; Fri, 04 Feb 2022 13:36:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644010580; cv=none; d=google.com; s=arc-20160816; b=qnzlIRDkeLrug+YRb7tQ3euQ3nqBoCpry0oy341l94p862avlr5qxz5v5mqEg2mV3Y RKg6gPG72RcGhYZrMuhoJY1cAjc6y2N4BaF5Gs4t2HwwgkaVIYglhJtC3hFGLtPUd9oQ 7rdFAQlETLxefJKBOP5gdZUfdxiaoefQOk+52Z3F26uYkugxbYrDxGHN9nFkavAF9x1s dBvTfTvK+yOkeb+9wreM36G8b0H8/bPeuXGFeVHX5iATYpTwA36em7HEzqOfg/raCZuS ZRwEeZbFA/IGbSGxie5MH7wiaCWRH1P4FsQih9MxFDpskTUuD58icbc3B7hFwBscrWPB VADQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=EyQ3SSZvN2IJcNCZXWQlxMc6hz5l3B9sP2KWMPe8f/s=; b=i8IMjzOGhxQJ3SSfcmjwiyatBbjElmx5BBHtrbXqU4ftKpFKo8A7NTrfDPmc74AfA9 g/88enGlPVcNtPcC4BVf4b/fgUu/ovojWHIsLjNuZEX+wpjzeYzUFXlz1ZbRBPdMd+oS Wc9WYJW4DZfr5MhufEH6WvVpiVyFxyF304JfJripje0swGc8VVobPEGJ+VK4XpfQTnb2 1bOStBrdQe5FrQjafo/0VDTgIsmYomYq6HJ/oJAEi0UtGXr11WZ4us105wfe0VX68kZM zqKza+d5beR1AHe4ewSRpzjdz/mQP6laUDUYT9AWSK2XkBEKugKbLektvDHAo0DCmJQ5 LSQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=3GuGRfzx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ca11si2563816pjb.122.2022.02.04.13.36.07; Fri, 04 Feb 2022 13:36:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=3GuGRfzx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353026AbiBCRml (ORCPT + 99 others); Thu, 3 Feb 2022 12:42:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353005AbiBCRmj (ORCPT ); Thu, 3 Feb 2022 12:42:39 -0500 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E174FC06173B for ; Thu, 3 Feb 2022 09:42:38 -0800 (PST) Received: by mail-wm1-x336.google.com with SMTP id v123so2657949wme.2 for ; Thu, 03 Feb 2022 09:42:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=EyQ3SSZvN2IJcNCZXWQlxMc6hz5l3B9sP2KWMPe8f/s=; b=3GuGRfzx9kqB0UG895aLOKeX7j+CTmBLbeVt0s8w+w/X80aOiW2i7baXC4AfBAFmQ4 D1tB6azicXAzvwEvGlC3pKdbBid+AEajWmF6oEVbJi/pJkE4sYhdht9Ta7SvU0yawqFm 1hF5EAKCqp3YSyJRG45WVNUJocEyFCK7q/KIFRj2cSQWvHJKSKnkUC7Afhpke/fNdScA 3COCmazmdkM0bvLS5JI8jk+XNocl96M8UMiZDdYMXG/5WBxjpkuQq1HxgewwjJn9SVox nLAM+BxxYvOgKF+Jx+Qdr7Ev3sfDrF0C0cDF25/qLWGFb8/ETZf6US/BVw1PczOSrsE5 B1fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=EyQ3SSZvN2IJcNCZXWQlxMc6hz5l3B9sP2KWMPe8f/s=; b=WDx2iP0ul1SBeOPjOm6rcsWLhj+NZeez8muhd6ptCt+Rf/KA7PqZqtLOPUcHU0LJl6 RJRa1vJVwH+Wis4RIwRsXVlDs3uFdq++9+spnl0GnwXOjD2McgUdnLJs/gUi24C7oZm9 enyp5v3Du8zLMPUSud0A+XRmmsYkYuYdY6N5iOcE/sbP04vOxAGV//Z30aVwpMWwJJ8F i4Ubnry5oetCk8f/Q5y6pGG87Jn4ajc3GhkfUsXI76/dSxknJ+sdooyvT6c69HQsbUpM DzqoL89mk2IZUaU5+rzemuUW7TIAq3921zTG/wzn7j/s8nyt19RImV7Uv/IlloXvWCY0 IJiA== X-Gm-Message-State: AOAM5301n0t0OmuEGW0IxZHbWlavOPDYnVbYxD/KJAFsAmphCgbghrUY tQnmsRvYzpVLHcxYXB19hFYPIA== X-Received: by 2002:a05:600c:3229:: with SMTP id r41mr11396464wmp.181.1643910157535; Thu, 03 Feb 2022 09:42:37 -0800 (PST) Received: from ?IPv6:2a02:6b6d:f804:0:28c2:5854:c832:e580? ([2a02:6b6d:f804:0:28c2:5854:c832:e580]) by smtp.gmail.com with ESMTPSA id t5sm21575649wrw.92.2022.02.03.09.42.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 03 Feb 2022 09:42:37 -0800 (PST) Subject: Re: [External] Re: [PATCH 1/2] io_uring: avoid ring quiesce while registering/unregistering eventfd To: Jens Axboe , io-uring@vger.kernel.org, asml.silence@gmail.com, linux-kernel@vger.kernel.org Cc: fam.zheng@bytedance.com References: <20220203151153.574032-1-usama.arif@bytedance.com> <20220203151153.574032-2-usama.arif@bytedance.com> <87fca94e-3378-edbb-a545-a6ed8319a118@kernel.dk> <62f59304-1a0e-1047-f474-94097cb8b13e@bytedance.com> From: Usama Arif Message-ID: Date: Thu, 3 Feb 2022 17:42:36 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/02/2022 16:58, Jens Axboe wrote: > On 2/3/22 9:49 AM, Usama Arif wrote: >>> One thing that both mine and your version suffers from is if someone >>> does an eventfd unregister, and then immediately does an eventfd >>> register. If the rcu grace period hasn't passed, we'll get -EBUSY on >>> trying to do that, when I think the right behavior there would be to >>> wait for the grace period to pass. >>> >>> I do think we need to handle that gracefully, spurious -EBUSY is >>> impossible for an application to deal with. >> >> I don't think my version would suffer from this as its protected by >> locks? The mutex_unlock on ev_fd_lock in unregister happens only after >> the call_rcu. And the mutex is locked in io_eventfd_register at the >> start, so wouldnt get the -EBUSY if there is a register immediately >> after unregister? > > The call_rcu() just registers it for getting the callback when the grace > period has passed, it doesn't mean it's done by the time it returns. > Hence there's definitely a window where you can enter > io_uring_register() with the callback still being pending, and you'd get > -EBUSY from that. > Does using synchronize_rcu make sense? I have sent v3 with how that would look. I have kept cq_ev_fd under io_ev_fd as it will be useful in patch 3 when eventfd_async is added. Thanks, Usama