Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp12533895rwd; Fri, 23 Jun 2023 07:24:01 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ53hVDeNaGglBpcE64QyNBiMUGq6nBNY94PJMxVRWuubUlJBkIEN+qMbwVbwKrkX+4CbgFm X-Received: by 2002:a17:902:d4d0:b0:1b6:797e:da62 with SMTP id o16-20020a170902d4d000b001b6797eda62mr16618285plg.30.1687530241390; Fri, 23 Jun 2023 07:24:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687530241; cv=none; d=google.com; s=arc-20160816; b=sBSEAa0+bE2pT1eWncY1Tr///Gnkm4prhFVI19gZqBj3Ombl5aUBO1XWTpb68Y3oZy YiiPSk2nzwBFqDbSR+16jOyZ1RU35SkVE/KIxca9+Y0iR2Ei7IIobpNOsRgvP5MMRmo5 nV9tY5hXJlALdtb6p9I7al2//uG7rnmtjcOooph9adogY1XJz+V5P4Flb13oMXGylcf+ CDIhHuaMCo/BZuGycmipKeNB6Kl/X9MCuQnNdQeTjlGSy7EEc/HBVz+myweGHbL/suTK Y8NURe1CBPZyJKC2wMdEnaTRuHgbvcAgj7Iio7d5Lj+dWRmsoGBBP2M4rsp3tKyMKXpd ePOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=T+1pIFBwxpLNL/VoMpzyTvuzZptHIhilPLYErQwUS8k=; b=lnWbgadT0o3joiCAmaOSGGfrv/bTWhBjZDXRTgAalN5xI3yRjauEuWKUL+J2vFIXtX ejJ+sTPCf7MQEzrqracvYPrA5N4qcb6GbRucszFDSjxkt0GGSVilzESrDAA+40EnrTeN W8i58oRqbM4BSVhMJwZOiLp4DD3Zl9WFa1j9DyEuf36+l1PsG7giFe4omHyqp7B5eijH rtbI4NEAaPpeNUlphWSn8KAIPA5SETXBHOjETxwVGGRZThR75YXfA/VfCqWoj9mpWy+j J8SLi1PgjewXQ1aCqvyC1PTs4lfS9esRKgVKTPeYwtqMOSkDmLd74wkMFvHkAJ44anQI mH/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=hAT1OlnZ; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y19-20020a63b513000000b005538a669b5fsi3610018pge.212.2023.06.23.07.23.48; Fri, 23 Jun 2023 07:24:01 -0700 (PDT) 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=@ziepe.ca header.s=google header.b=hAT1OlnZ; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232048AbjFWNu1 (ORCPT + 99 others); Fri, 23 Jun 2023 09:50:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232008AbjFWNuX (ORCPT ); Fri, 23 Jun 2023 09:50:23 -0400 Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58CA02699 for ; Fri, 23 Jun 2023 06:50:10 -0700 (PDT) Received: by mail-pg1-x533.google.com with SMTP id 41be03b00d2f7-52cb8e5e9f5so497344a12.0 for ; Fri, 23 Jun 2023 06:50:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1687528210; x=1690120210; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=T+1pIFBwxpLNL/VoMpzyTvuzZptHIhilPLYErQwUS8k=; b=hAT1OlnZCSwyNFydf13NvIycgXr5/iIfC6r8/nd0zLufzjnG76xScQ8fkAvjuDR9HA LKstTMkVB1IimZFBU+AILwUx2GaOikMy+PW2Eg7+k6BnlRwGKiPDbsTCp9VVgh0lD6bi 8QYBpzPAZyybBHinxa4YFTWPP0+n1bFlI15Wjv6yMRRcN1lRHOpBz63Iootsc/mjPBYf YMeoCsk0bHsnceZKYdKo46Nve3OJdWtoZevSnvjANuI1wSA0s6vRTB0FXzEE4I7M2vF+ lGRMvxSZ4U+bjAWHupE09pIQBGQgCvCiABu5+zuXGjJLJXB75Ua+e9EoKOR+y1vzr1qk UKig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687528210; x=1690120210; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=T+1pIFBwxpLNL/VoMpzyTvuzZptHIhilPLYErQwUS8k=; b=kWLM6Dv6TQf9qG3/bNeVo0tuViWqQRIm4vvfuR5uckAt2LPbf/sxsFa6u7z715kaHB xylpwvoo3WXwQoIWOYhzE56dGbwygzB9/uQiEJsywipgl3AxOWVGNmDxNmyoo1ZLjwZJ MQ1d8fRUQlXq5Zb5lnpsgekzwn+5OJ/JrdUf/FySK45jKh3BCIdrhwAVI3ubzPzJf+sf TCYtJzPJ6k6AqGc/CwtzGMBP/ixLauFw99/GZQdW6/JDWb91rq4Re5kK3jeGdqeG/wQ9 yNnyk8fQagLm1rJUtTqo69q2FX8OUgknBLoVwMnMHMIgQbgr+GylPEIxE8hh8gJp+qo1 UDJw== X-Gm-Message-State: AC+VfDzSZ/lxF8Eqx20nRq9/XIhRD1nGHqMXAzoz441kDv7LY+xy01zP 5SvlxFGb4kswc1c9Meq2TUqEPg== X-Received: by 2002:a17:90b:811:b0:25c:7d4:7cd with SMTP id bk17-20020a17090b081100b0025c07d407cdmr25932024pjb.24.1687528209792; Fri, 23 Jun 2023 06:50:09 -0700 (PDT) Received: from ziepe.ca (hlfxns017vw-142-68-25-194.dhcp-dynamic.fibreop.ns.bellaliant.net. [142.68.25.194]) by smtp.gmail.com with ESMTPSA id n59-20020a17090a2cc100b0025bdc3454c6sm1647744pjd.8.2023.06.23.06.50.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Jun 2023 06:50:09 -0700 (PDT) Received: from jgg by wakko with local (Exim 4.95) (envelope-from ) id 1qChAt-007z7M-Gb; Fri, 23 Jun 2023 10:50:07 -0300 Date: Fri, 23 Jun 2023 10:50:07 -0300 From: Jason Gunthorpe To: Baolu Lu Cc: Kevin Tian , Joerg Roedel , Will Deacon , Robin Murphy , Jean-Philippe Brucker , Nicolin Chen , Yi Liu , Jacob Pan , iommu@lists.linux.dev, linux-kselftest@vger.kernel.org, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: Re: [RFC PATCHES 00/17] IOMMUFD: Deliver IO page faults to user space Message-ID: References: <20230530053724.232765-1-baolu.lu@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 23, 2023 at 02:18:38PM +0800, Baolu Lu wrote: > struct io_uring ring; > > io_uring_setup(IOPF_ENTRIES, &ring); > > while (1) { > struct io_uring_prep_read read; > struct io_uring_cqe *cqe; > > read.fd = iopf_fd; > read.buf = malloc(IOPF_SIZE); > read.len = IOPF_SIZE; > read.flags = 0; > > io_uring_prep_read(&ring, &read); > io_uring_submit(&ring); > > // Wait for the read to complete > while ((cqe = io_uring_get_cqe(&ring)) != NULL) { > // Check if the read completed > if (cqe->res < 0) > break; > > if (page_fault_read_completion(cqe)) { > // Get the fault data > void *data = cqe->buf; > size_t size = cqe->res; > > // Handle the page fault > handle_page_fault(data); > > // Respond the fault > struct io_uring_prep_write write; > write.fd = iopf_fd; > write.buf = malloc(IOPF_RESPONSE_SIZE); > write.len = IOPF_RESPONSE_SIZE; > write.flags = 0; > > io_uring_prep_write(&ring, &write); > io_uring_submit(&ring); > } > > // Reap the cqe > io_uring_cqe_free(&ring, cqe); > } > } > > Did I understand you correctly? Yes, basically this is the right idea. There are more complex ways to use the iouring that would be faster still. And the kernel side can have support to speed it up as well. I'm wondering if we should be pushing invalidations on io_uring as well? Jason