Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp4994451pxb; Sun, 6 Feb 2022 10:00:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJz/kfpkqP/qfdoy1bpZwhMXWXmz1afJ5zKDeFmxm26WVQtkPk02twOxcVTd/qmOsUqYxWSH X-Received: by 2002:a17:907:3ea8:: with SMTP id hs40mr7166497ejc.48.1644170409257; Sun, 06 Feb 2022 10:00:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644170409; cv=none; d=google.com; s=arc-20160816; b=gc/6opptsFbn6j8EeYM5RWCVA3afMJJpnK3p0bPJChraMY4qMes3OeH+ARKkrTBRmh 58j6G7eb/2UeARlBTJGaNV8bqpWZTdlrCIbTZxyUmfLRmFiw0BSYxErd/VwAdj8dAyox Xk8ygS2AjBxzRCgOsETXTz10Oypyn6WANoaphUBwmejBiXsM3xHJK9IOR2D+PPnj9et2 wvbmTVtPISrMDb4drjtYqN6J6+k9Lb3Luz1nmAnqDufX/KBTLqs+57MKbRY/SEoOmSV9 ZY8viwISzNb/3L0pgoslfRr2PIzWAyc8OZRObYVy/QtR20VzSDv/jzWIKhvak7U96mxY 63YA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=CwFIDxLrsJY5AT/tU5NARbAaRxrN82m4ae2GxSdsQ8c=; b=DyKjWVsGwXPB1Z1PronXZ1i92N2XJByN4BpFxjBUn4KorryqcmcfTADjC3aW2orvjg 8O5irHi28fS6o0nc+75tqeqYCTzHBwbM5BH9o8332AeqXb0vYF4GKVz9z3LFDsBOJeIp L8onsqcrPY7yvD1ZtkhAFnJL1OA9eIvlmdw68we01jnaxgi8Q/BTc1b8KTT+iLY/vh7/ pPpg0A1tB9BxMORf6ugL3SC3m5sPRtdL2QKaKmIHE7NjNaHZ95cAiIipWui7nJN1fP4j htvPpv2i3zNZG1kuOGLt1TE0pOIMxfZQYE5Yx1OTWM+nY4m+7sTKm6vQw2jkxCeojxfS lRGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=nQb97wY9; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b10si5953947ede.201.2022.02.06.09.59.40; Sun, 06 Feb 2022 10:00:09 -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=@gmail.com header.s=20210112 header.b=nQb97wY9; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353657AbiBCTF1 (ORCPT + 99 others); Thu, 3 Feb 2022 14:05:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353655AbiBCTF0 (ORCPT ); Thu, 3 Feb 2022 14:05:26 -0500 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D142EC061714; Thu, 3 Feb 2022 11:05:25 -0800 (PST) Received: by mail-wm1-x333.google.com with SMTP id v123so2826469wme.2; Thu, 03 Feb 2022 11:05:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=CwFIDxLrsJY5AT/tU5NARbAaRxrN82m4ae2GxSdsQ8c=; b=nQb97wY9KEcqxWpoyLJkJ/f/hNH57GFALTHstDZYp7pVASl19cJlmJ/lGL7F9mPHon RuOPXG4wrlMeKMrGq+acrZFv1P0p6MtCTPO1J+w3gztVPOO8TwjPS2qk6TQHOoxG9wQE EGoa1aqhfMqUKC80+2bA9MXZp6Q+JcMMsnetT/32OHdWZup/WfWZwJ7H5B3MHL9Oz3V2 jVSF6Kf3NC3Itebp140aD6q9EoqJa78HmmARAojzGnnSyXvQaNPNaQRnb6uTABkB8a3S HVoJjIULRpncUjUZ5EM+BwMgalCXojb7sjrS4BejbYtBItcLg7wmDcEH4m5KS6ZtNs69 65DA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=CwFIDxLrsJY5AT/tU5NARbAaRxrN82m4ae2GxSdsQ8c=; b=eVPkBu82U2td41C3gAM7q26lrPGcACQdqhyaCmSkO2w3jca/b4aN5IFRaODROgKUCC o3FnDez5grlMnao8Irs7t+cBgQYs2CzVihYtdO+FClNJCS98MtoVt9Z7zXXagB8nNQ6L gysCrS0XFFy6PXkVsnGNG1fmW0FdKdheUyVEHdAXjftExYE2q7QvVL+hrYpocSksVXPj iccC7T1xHNvhog5FlCof/WF0EzbqRuzKPrPE9yUhCkjM7fjiJmJgdksYsfm8Q/V2GoOt GCaVjMEnsNnoCpJT/Z1AgedIf6q2UyzFp55XKBOQQx8r9YBufOovTHG+jFXEVJVdYCpI t5Rg== X-Gm-Message-State: AOAM5319rJdH2oZyFMjlFVjHz905/aIErl5vMhodsLqn6JR8sKnm8l8G Cc6Ilz/rZKhTdijUP61+LH0ajUYzj8g= X-Received: by 2002:a05:600c:3ce:: with SMTP id z14mr11389567wmd.128.1643915124287; Thu, 03 Feb 2022 11:05:24 -0800 (PST) Received: from [192.168.8.198] ([85.255.232.204]) by smtp.gmail.com with ESMTPSA id j19sm9226678wmq.17.2022.02.03.11.05.23 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 03 Feb 2022 11:05:23 -0800 (PST) Message-ID: Date: Thu, 3 Feb 2022 19:00:39 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [External] Re: [PATCH v3 2/3] io_uring: avoid ring quiesce while registering/unregistering eventfd Content-Language: en-US To: Jens Axboe , Usama Arif , io-uring@vger.kernel.org, linux-kernel@vger.kernel.org Cc: fam.zheng@bytedance.com References: <20220203174108.668549-1-usama.arif@bytedance.com> <20220203174108.668549-3-usama.arif@bytedance.com> <877d54b9-5baa-f0b5-23fe-25aef78e37c4@bytedance.com> From: Pavel Begunkov In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2/3/22 18:29, Jens Axboe wrote: > On 2/3/22 11:26 AM, Usama Arif wrote: >> Hmm, maybe i didn't understand you and Pavel correctly. Are you >> suggesting to do the below diff over patch 3? I dont think that would be >> correct, as it is possible that just after checking if ctx->io_ev_fd is >> present unregister can be called by another thread and set ctx->io_ev_fd >> to NULL that would cause a NULL pointer exception later? In the current >> patch, the check of whether ev_fd exists happens as the first thing >> after rcu_read_lock and the rcu_read_lock are extremely cheap i believe. > > They are cheap, but they are still noticeable at high requests/sec > rates. So would be best to avoid them. > > And yes it's obviously racy, there's the potential to miss an eventfd > notification if it races with registering an eventfd descriptor. But > that's not really a concern, as if you register with inflight IO > pending, then that always exists just depending on timing. The only > thing I care about here is that it's always _safe_. Hence something ala > what you did below is totally fine, as we're re-evaluating under rcu > protection. Indeed, the patch doesn't have any formal guarantees for propagation to already inflight requests, so this extra unsynchronised check doesn't change anything. I'm still more сurious why we need RCU and extra complexity when apparently there is no use case for that. If it's only about initial initialisation, then as I described there is a much simpler approach. -- Pavel Begunkov