Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp1567301rwb; Wed, 26 Jul 2023 14:53:29 -0700 (PDT) X-Google-Smtp-Source: APBJJlEnWjgTWqCgp2GjLEJwDxkBNT5tbiAZmGGuEFy58ZAhNhA4pCIojXUncht7ulzEYLRbKuJh X-Received: by 2002:a17:902:8f95:b0:1b8:6987:de84 with SMTP id z21-20020a1709028f9500b001b86987de84mr3084273plo.48.1690408408741; Wed, 26 Jul 2023 14:53:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690408408; cv=none; d=google.com; s=arc-20160816; b=KJnbUTYT1tL6KaYJY+bXf3apANGffas25x7DZHS62kqZfqK9udcQPqgdDFjxaio0ux ZGwAVECNuxKiClD/hZfgMJyMxv4cedv922nzKu3hp4wTXEcdJ9f5EK7R9JGmkNLhoIq+ lF+Gm+hsOBw4P1YIDLNxIFJ27qmPwtEoHnI+I+VPumSlJoGwb0olHAeXvdMU/ve10GbB AbQAe1jFVHCNjRI8/ABOTxvL0RiVyqH7XxHeSq4sWvIwEggbrCK3qEQ6JsTOhcxXGJqj 81P391nymE4Osp5ozWr5wNsE2qmibbAa7C/94V8llQvN2zmGYPXElJjH46GRjy94B91d e5Vw== 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=qwlPGFA6Wt4wHaQbg7XU0SaMv13PMQh8DDGdrKpf/oA=; fh=xJBPVEo8pKozIwNgX6RqAfq+LFi+65+8EY7Rz0aCm9o=; b=sDTTXL9iIQbg+GxdgL6QAV4d2SHJ7Wqm+g67r/op2lXWUf+gKjDugy9+HpXcGujuVx QdSTzVnqMKW+fJtXs7EdTk9o+NSO7PjLgPhq/m/qwZRuc+Q14WQPArNZ0HibCGiOUI9t itsOWmp8WEr1GbLU3DvB3xbzgscsOMgFnHShysbjO879UXp5fswcUYjOXvwdESBbAzly 9iBa4yC0llDLGEPIQglGT045M6poO0c4DAVekF57oMKdlou+HQx/0wW50v3hz60gceTi 6IWsn3XVweiUssOI3zvj8dyLqgK+IlShpZr6S+Roenty29d/e4a4kWbtXX/U39Ygj/7R 8pGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=eLu+gNof; 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 ko11-20020a17090307cb00b001b895fc0cfdsi36820plb.388.2023.07.26.14.53.15; Wed, 26 Jul 2023 14:53:28 -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=eLu+gNof; 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 S231238AbjGZVKt (ORCPT + 99 others); Wed, 26 Jul 2023 17:10:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229820AbjGZVKs (ORCPT ); Wed, 26 Jul 2023 17:10:48 -0400 Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D0651BFB for ; Wed, 26 Jul 2023 14:10:46 -0700 (PDT) Received: by mail-ed1-x52c.google.com with SMTP id 4fb4d7f45d1cf-5223910acf2so4643a12.0 for ; Wed, 26 Jul 2023 14:10:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1690405845; x=1691010645; 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=qwlPGFA6Wt4wHaQbg7XU0SaMv13PMQh8DDGdrKpf/oA=; b=eLu+gNofp9wRbALE2bkVYGmwGJxPl36LCy1T4+1JgQnamYSfKJ9xDY86bimfkqoGIQ zvgmsb7odQAULMETzbuIwLSJWIQ/Fwquxp67SYVP8fIfPzevZLwU33RjsCF5loWfigIi D8J4p2w/m17TwgF7ZjEcVORxUQWSKgUpBlnqLCLO4uiCN/AITyww9rYNx7N4V3GnnYo0 HquyCXm2Odan4UPZidq5GwLDJdEDg9GXDQmUCnqz6MGT0lKOyrxtKU8w/LD8/mwZSugI gH5NOFaIeUr6rA5zO0GBlWhk+rwHe8158VQtUck3GyvOBRGBVJ8hg9PlIx1e1hVSXqyV yI3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690405845; x=1691010645; 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=qwlPGFA6Wt4wHaQbg7XU0SaMv13PMQh8DDGdrKpf/oA=; b=G8clbRUXD0qoMoXW/Duq2+DP9xolH+xoJH68EB/2K5g0oePLyLb0Io9iw9EqflIT2p a+y8T3mr0qNbzk/rSRqhejSwi3ei3Qac7Da1aGvyY2BMAQ1+2wCTs5b7ER6xMcZTLSBv tdDKoOnOexXzqWlVearFqA2ukjUB8cAqS0hWyhy8NBIQaoXibnZ2lQqmKJpnX+uJSmwC jBeoRaQiYUntY9I1gyu3jXYjsD25hguhE+Fo1zRc+533qTZVw65DVktVcI4Wco+rtPTM JAiUEMp0cZpCVbDMJLjtYYiEfE2J34NV/sSgMCMLz0rVeTg88ahmaGAXReXnRqtFZYtH Wv0w== X-Gm-Message-State: ABy/qLZ6l2D4wDef3Tj/RQknZbx9/A5YErgRm5L9r+vtuQLPjbxkC+EW c7D48wXTH5Rx7mCD76Ln1jzILKDTjkYgfPFL8325ow== X-Received: by 2002:a50:d797:0:b0:522:4741:d992 with SMTP id w23-20020a50d797000000b005224741d992mr34619edi.4.1690405844799; Wed, 26 Jul 2023 14:10:44 -0700 (PDT) MIME-Version: 1.0 References: <20230713101415.108875-6-usama.anjum@collabora.com> <7eedf953-7cf6-c342-8fa8-b7626d69ab63@collabora.com> <382f4435-2088-08ce-20e9-bc1a15050861@collabora.com> <44eddc7d-fd68-1595-7e4f-e196abe37311@collabora.com> <1afedab8-5929-61e5-b0da-9c70dc01c254@collabora.com> In-Reply-To: From: =?UTF-8?B?TWljaGHFgiBNaXJvc8WCYXc=?= Date: Wed, 26 Jul 2023 23:10:33 +0200 Message-ID: Subject: Re: [v3] fs/proc/task_mmu: Implement IOCTL for efficient page table scanning To: Muhammad Usama Anjum Cc: "Kirill A. Shutemov" , =?UTF-8?B?TWljaGHFgiBNaXJvc8WCYXc=?= , Andrei Vagin , Danylo Mocherniuk , Alex Sierra , Alexander Viro , Andrew Morton , Axel Rasmussen , Christian Brauner , Cyrill Gorcunov , Dan Williams , David Hildenbrand , Greg KH , "Gustavo A . R . Silva" , "Liam R . Howlett" , Matthew Wilcox , Mike Rapoport , Nadav Amit , Pasha Tatashin , Paul Gofman , Peter Xu , Shuah Khan , Suren Baghdasaryan , Vlastimil Babka , Yang Shi , Yun Zhou , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, 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 Wed, 26 Jul 2023 at 10:34, Muhammad Usama Anjum wrote: > On 7/25/23 11:05=E2=80=AFPM, Micha=C5=82 Miros=C5=82aw wrote: > > On Tue, 25 Jul 2023 at 11:11, Muhammad Usama Anjum > > wrote: > >> > >> ---- > >> Michal please post your thoughts before I post this as v26. > >> ---- > > [...] > > > > Looks ok - minor things below. > > > > 1. I'd change the _WPASYNC things to something better, if this can > > also work with "normal" UFFD WP. > Yeah, but we don't have any use case where UFFD WP is required. It can be > easily added later when user case arrives. Also UFFD WP sends messages to > userspace. User can easily do the bookkeeping in userspace as performance > isn't a concern there. We shouldn't name the flags based on the use case but based on what they actually do. So if this checks UFFD registration for WP, then maybe PAGE_IS_WPALLOWED or something better describing the trait it matches? > > 2. For the address tagging part I'd prefer someone who knows how this > > is used take a look. We're ignoring the tag (but clear it on return in > > ->start) - so it doesn't matter for the ioctl() itself. > I've added Kirill if he can give his thoughts about tagged memory. > > Right now we are removing the tags from all 3 pointers (start, end, vec) > before using the pointers on kernel side. But we are overwriting and > writing the walk ending address in start which user can read/use. > > I think we shouldn't over-write the start (and its tag) and instead retur= n > the ending walk address in new variable, walk_end. The overwrite of `start` is making the ioctl restart (continuation) easier to handle. I prefer the current way, but it's not a strong opinion. > > 3. BTW, One of the uses is the GetWriteWatch and I wonder how it > > behaves on HugeTLB (MEM_LARGE_PAGES allocation)? Shouldn't it return a > > list of huge pages and write *lpdwGranularity =3D HPAGE_SIZE? > Wine/Proton doesn't used hugetlb by default. Hugetlb isn't enabled by > default on Debian as well. For GetWriteWatch() we don't care about the > hugetlb at all. We have added hugetlb's implementation to complete the > feature and leave out something. How is GetWriteWatch() working when passed a VirtualAlloc(..., MEM_LARGE_PAGES|MEM_WRITE_WATCH...)-allocated range? Does it still report 4K pages? This is only a problem when using max_pages: a hugetlb range might need counting and reporting huge pages and not 4K parts. Best Regards Micha=C5=82 Miros=C5=82aw