Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp12202092rwd; Fri, 23 Jun 2023 02:52:23 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7TE8u94THKrY32Qj9+U+dHvHMuiXsHq/MLAyaUjheY/l/fSHy+oe/YJyL0HhINT+9YqoaG X-Received: by 2002:a17:902:eac2:b0:1b1:ae33:30de with SMTP id p2-20020a170902eac200b001b1ae3330demr17306319pld.13.1687513942792; Fri, 23 Jun 2023 02:52:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687513942; cv=none; d=google.com; s=arc-20160816; b=GUiopKoBWFlwLT5y/JJrLSaWwJE5JlMyNQIDlCtWbidGik4rfMSss492HbJq7Q1mpb tFHE25C+OgeF1HYl5aciV0eGEHrdt722rPxD51YwSracLj7ru+t6vxg282tthNeG6UB4 Gr2s4tGblGJy3SLagQuoNmIpeiZQqWc6BCfIYsFoyIkyZMJMt0Bx34dhvsFLIQjgZjYK VBN8amsYz2SIWMoI6G2j54QYuTvEnu2Lqf+YmW2NFs9rSU5Tczi9Mv+cb+eVfbp1Y3X4 aL9Ri9+8hgh4j+xl2Cnk2NU2o3CLn9d4kXROQoEUAAVz1eDGFR6/IDk+57kFBXx7CPeg UQNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=uECgceGWceBpnEwgVEt1AFSmdXNTa/+8ZyNWq8IpWMk=; b=UDUyuXvS8l6Yp5Yv4atGtblfsHv8keilyEeyuK+1YF2DcaS0dGw889HvxhvX05IMAD pexfoY3ELIC71ZT2XJydKtLhXuwhDC4yZQ+iAR/cZIcEdHdvMKsmv99Bu9cmTbUX+QiI yce1l5ZOdwXryhGgfeqGoZvxOcNeBlAOGJ9dYEvScqtxxICCa01Lp9U+vnf34fz7gxp4 PwymXn3JoCDswLnKk8lxK109GR5X09rw+UWIQ2QObYsihcrPsUYdVOi8srkDC6XepXRk vJLi73HJ7LSTIkzGWVLH4B8LMg9qzrwcl6Gyq+7vyYXcRbfwRyjvenO4hgly02GQBgwj QcjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=Kbr+ZwwH; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y20-20020a170902ed5400b001b241f8a865si8275408plb.117.2023.06.23.02.52.10; Fri, 23 Jun 2023 02:52:22 -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=@google.com header.s=20221208 header.b=Kbr+ZwwH; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231181AbjFWJoe (ORCPT + 99 others); Fri, 23 Jun 2023 05:44:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229853AbjFWJoc (ORCPT ); Fri, 23 Jun 2023 05:44:32 -0400 Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F658E75 for ; Fri, 23 Jun 2023 02:44:27 -0700 (PDT) Received: by mail-ed1-x534.google.com with SMTP id 4fb4d7f45d1cf-514ad92d1e3so5604a12.1 for ; Fri, 23 Jun 2023 02:44:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1687513466; x=1690105466; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=uECgceGWceBpnEwgVEt1AFSmdXNTa/+8ZyNWq8IpWMk=; b=Kbr+ZwwHYHvA0TCLJ0MdIwK/ccEwxx5KSPma0dmAvQIY6kj9M5JLiT59I+c/izkmv2 n9pmwQxDJQNjmwworyPbaKeC3Ld8nQ4YzJQUl81n0uzJKWW+y1YBMTq+bAxjaNy+2Uk1 2+c6VxKT2l9oN0UJs9rmXFiz2wziDEW+FMecIVeRpyPC+3p6h7YtB2bWAnfvkjFG019s SvcL3SBhcYvAVeuiLFX4CwomKL1yZfd3JUWKnS/0/hgwcAMoHAZfCNAKfXwtIiCjg6jh Ae993CrxqBpmSq0aTmVtiKkCd/JgjSefymLwf4R5lFK8ec0c85cp6c0CFc3gblvcnhWa 1m6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687513466; x=1690105466; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uECgceGWceBpnEwgVEt1AFSmdXNTa/+8ZyNWq8IpWMk=; b=jeuG1gfaT/isleZits9+KvWTJr4crp9P4P6IUFUZEG9yHMU4fNSYrzfgkc56EZEhO0 st+DdigZksuvwGCdlmiscdL22Vy5js085iaQSmLSHNsybodsb5HgAN2Rok2lgBpwoCSd Q1DxoMSs4mn8lsMiVNfOHEFGwRAwLI4Hayz1RYesslZ6eBOIZQYOtonUgL+cR8h1Ye0O NUW8CVeR/baWpBX6Boxkw+K3Z0wsbVsLBN25eSwUmU+1N5Fvwb6byG99e4y0zFrxICQB g8Ty5QZoovLdN0lFayyhJUuJhu+Kg7rQNYNUjcIKBldeqb6NQYbjFhQayfDXK8Ml885q d0hg== X-Gm-Message-State: AC+VfDwosRj779/pOlsFYeNzwcG0ioe9ZmZVDQuQtaueVoCMPzovSLr9 6M47+uqcyknYIPWziynq3VvFnnkEbZZvCEEQMo2fiA== X-Received: by 2002:a50:d08c:0:b0:516:6453:1b76 with SMTP id v12-20020a50d08c000000b0051664531b76mr51906edd.5.1687513465752; Fri, 23 Jun 2023 02:44:25 -0700 (PDT) MIME-Version: 1.0 References: <20230615141144.665148-1-usama.anjum@collabora.com> <20230615141144.665148-3-usama.anjum@collabora.com> <1c1beeda-ceed-fdab-bbf5-1881e0a8b102@collabora.com> In-Reply-To: From: =?UTF-8?B?TWljaGHFgiBNaXJvc8WCYXc=?= Date: Fri, 23 Jun 2023 11:44:14 +0200 Message-ID: Subject: Re: [PATCH v19 2/5] fs/proc/task_mmu: Implement IOCTL to get and optionally clear info about PTEs To: Muhammad Usama Anjum Cc: Andrei Vagin , Peter Xu , David Hildenbrand , Andrew Morton , Danylo Mocherniuk , Paul Gofman , Cyrill Gorcunov , Mike Rapoport , Nadav Amit , Alexander Viro , Shuah Khan , Christian Brauner , Yang Shi , Vlastimil Babka , "Liam R . Howlett" , Yun Zhou , Suren Baghdasaryan , Alex Sierra , Matthew Wilcox , Pasha Tatashin , Axel Rasmussen , "Gustavo A . R . Silva" , Dan Williams , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, Greg KH , kernel@collabora.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable 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 Thu, 22 Jun 2023 at 12:21, Muhammad Usama Anjum wrote: > On 6/22/23 12:45=E2=80=AFAM, Andrei Vagin wrote: > > On Wed, Jun 21, 2023 at 11:34:54AM +0500, Muhammad Usama Anjum wrote: > >> On 6/20/23 11:03=E2=80=AFPM, Andrei Vagin wrote: [...] > >>> should it be PM_SCAN_FOUND_MAX_PAGES? Otherwise, it fails the ioctl e= ven > >>> if it has handled some pages already. > >> It is a double edge sword. If we don't return error, user will never k= now > >> that he needs to specify more max_pages or his output buffer is small = and > >> not coverig the entire range. The real purpose here that user gets awa= re > >> that he needs to specify full hugetlb range and found pages should cov= er > >> the entire range as well. > > > > but if PM_SCAN_OP_WP is set, this error will be fatal, because some > > pages can be marked write-protected, but they are not be reported to > > user-space. > > > > I think the ioctl has to report back the end address of the handled > > region. It is like read and write syscalls that can return less data > > than requested. > This is good point. I'll abort the walk here instead of retuning the erro= r > to user. It would be great if the ioctl returned the address the walk finished at. This would remove the special case for "buffer full after full page was added" and if it happens that despite `max_pages` limit was reached but no more pages would need to be added the caller would not have to call the ioctl again on the remaining range. [...] > >>> How long can it take to run this loop? Should we interrupt it if a > >>> signal has been queued? > >> I'm following mincore and pagemap_read here. There is no such thing th= ere. > >> IOCTL is performing what user has requested. > > > > In case of pagemap, its buffer is limited by MAX_RW_COUNT (0x7ffff000), > > so it can handle maximum 0xffffe00 pages in one iteration. Do you have= any > > limits for input parameters? > > > >> If the execution time is a > >> concern, user should have called the IOCTL on shorter address range. > > > > It doesn't work this way. There can be many users and signals has to be > > delivered in a reasonable time. One of the obvious examples when a sign= al > > has to be delivered asap is OOM. > This IOCTL is just like mincore, but with other flags and functionalities= . > Mincore doesn't put any limit like this. I don't think we should put any > limit here as well. I don't think we should treat mincore() as a good API example. Its interface has similar performance problems to what select() or poll() does. In this ioctl's case, we can limit the output at this end (large anyway) as it won't affect the performance if for x TiB of memory the call is made twice instead of once. (Returning the end of the walk reached would be much help here.) Best Regards Micha=C5=82 Miros=C5=82aw