From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DBC2DC433F5 for ; Wed, 30 Mar 2022 14:58:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237082AbiC3PAG (ORCPT ); Wed, 30 Mar 2022 11:00:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242336AbiC3PAF (ORCPT ); Wed, 30 Mar 2022 11:00:05 -0400 Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC9456143 for ; Wed, 30 Mar 2022 07:58:19 -0700 (PDT) Received: by mail-ed1-x52f.google.com with SMTP id h1so24779940edj.1 for ; Wed, 30 Mar 2022 07:58:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=szeredi.hu; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ZiX19yj7rEkzPFMkYa7W7ck7Ox5YrAfpCSVo96Az6NM=; b=T8Rc+oBPOZgq0XPxdMz0JJpY1xqGKX6LTjxbDbcRUVmDDfhDHp0YvqSWB5eKD/PBVl HZBf5fASFNxSNZphwLd/Nenr/v6/iTHw8+62kMQNZWTiiZeBgeqW3SgVxM5bPjYGT+8R 6QlgRlaZna6fPACXnf/t8Tz+9wzbSMRm47exI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ZiX19yj7rEkzPFMkYa7W7ck7Ox5YrAfpCSVo96Az6NM=; b=pK478st89/zzC4ZigZwoLmHLNJxeJS1LmwdoyKFCXmbn6M8TvRAlMQGHw31dx79iyU TB5VQKXUoVywhJ3uqsQcmxvsH6wrg0Y/sMglzVB3HoibL0h+7RT33bYfRTBa2pOJ7o4C RvkSszuybxBEoCzYz78higBy8Uj3f1d1s+fVv6uhBAvpJ05iFVnYKXuPw/RXAJDfabp2 iYJ0VJJ5BTWpn5gNWKhqeiG0CL5yAf9dA4hiyXndqHNuLzzlzjdBt+wt89pKbhVFQAS6 xV6jkbE/xAg+DnSia0Reha3AVR64AoyoIz14tTNCawHNg8DFTHEu5fFhrcY8BCkl9z1Q vXIw== X-Gm-Message-State: AOAM531WZkOrndwIrS+0/NoMiY/DQzFUXfhBVhnEycla190YsHEGT6wJ G8njlP7Akq/TScJb6EBiG0JEtTfHS9kgBVNQ9SYX0gaJb9ki6g== X-Google-Smtp-Source: ABdhPJzWP8iq3PX0QHG0Tywq5vSn2uSYILQEThbQUo6ZmsdfiafO9PUlY9xn8qovPL6G2zzdhm8pKuctf8Ov9sogBKM= X-Received: by 2002:a50:fe07:0:b0:419:323:baee with SMTP id f7-20020a50fe07000000b004190323baeemr10912780edt.221.1648652298232; Wed, 30 Mar 2022 07:58:18 -0700 (PDT) MIME-Version: 1.0 References: <8145e724-d960-dd85-531e-16e564a02f05@kernel.dk> <115fc7d1-9b9c-712b-e75d-39b2041df437@kernel.dk> <89322bd1-5e6f-bcc6-7974-ffd22363a165@kernel.dk> <0c5745ab-5d3d-52c1-6a1d-e5e33d4078b5@kernel.dk> <52dca413-61b3-8ded-c4cc-dd6c8e8de1ed@kernel.dk> <23b62cca-8ec5-f250-e5a3-7e9ed983e190@kernel.dk> In-Reply-To: From: Miklos Szeredi Date: Wed, 30 Mar 2022 16:58:06 +0200 Message-ID: Subject: Re: io_uring_prep_openat_direct() and link/drain To: Jens Axboe Cc: io-uring@vger.kernel.org Content-Type: multipart/mixed; boundary="0000000000009856d205db70c6b8" Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org --0000000000009856d205db70c6b8 Content-Type: text/plain; charset="UTF-8" Next issue: seems like file slot reuse is not working correctly. Attached program compares reads using io_uring with plain reads of proc files. In the below example it is using two slots alternately but the number of slots does not seem to matter, read is apparently always using a stale file (the prior one to the most recent open on that slot). See how the sizes of the files lag by two lines: root@kvm:~# ./procreads procreads: /proc/1/stat: ok (313) procreads: /proc/2/stat: ok (149) procreads: /proc/3/stat: read size mismatch 313/150 procreads: /proc/4/stat: read size mismatch 149/154 procreads: /proc/5/stat: read size mismatch 150/161 procreads: /proc/6/stat: read size mismatch 154/171 ... Any ideas? Thanks, Miklos --0000000000009856d205db70c6b8 Content-Type: text/x-csrc; charset="US-ASCII"; name="procreads.c" Content-Disposition: attachment; filename="procreads.c" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_l1dovtuo0 I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxmY250bC5oPgojaW5jbHVkZSA8c3RyaW5nLmg+ CiNpbmNsdWRlIDxzdGRsaWIuaD4KI2luY2x1ZGUgPGRpcmVudC5oPgojaW5jbHVkZSA8dW5pc3Rk Lmg+CiNpbmNsdWRlIDxlcnIuaD4KI2luY2x1ZGUgImxpYnVyaW5nLmgiCgojZGVmaW5lIENIRUNL X05FR0VSUihfZXhwcikgXAoJKHsgdHlwZW9mKF9leHByKSBfcmV0ID0gKF9leHByKTsgaWYgKF9y ZXQgPCAwKSB7IGVycm5vID0gLV9yZXQ7IGVycigxLCAjX2V4cHIpOyB9IF9yZXQ7IH0pCiNkZWZp bmUgQ0hFQ0tfTlVMTChfZXhwcikgXAoJKHsgdHlwZW9mKF9leHByKSBfcmV0ID0gKF9leHByKTsg aWYgKF9yZXQgPT0gTlVMTCkgeyBlcnJ4KDEsICNfZXhwciAiIHJldHVybmVkIE5VTEwiKTsgfSBf cmV0OyB9KQoKc3NpemVfdCByZWFkZmlsZV91cmluZyhzdHJ1Y3QgaW9fdXJpbmcgKn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