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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1E644C001E0 for ; Wed, 26 Jul 2023 21:10:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0C4266B0071; Wed, 26 Jul 2023 17:10:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 074306B0072; Wed, 26 Jul 2023 17:10:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E7DF26B0074; Wed, 26 Jul 2023 17:10:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id DA8206B0071 for ; Wed, 26 Jul 2023 17:10:48 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id AABE6C0386 for ; Wed, 26 Jul 2023 21:10:48 +0000 (UTC) X-FDA: 81055007376.29.F54915C Received: from mail-ed1-f48.google.com (mail-ed1-f48.google.com [209.85.208.48]) by imf26.hostedemail.com (Postfix) with ESMTP id C1B19140005 for ; Wed, 26 Jul 2023 21:10:46 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=eLu+gNof; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf26.hostedemail.com: domain of emmir@google.com designates 209.85.208.48 as permitted sender) smtp.mailfrom=emmir@google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1690405846; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=qwlPGFA6Wt4wHaQbg7XU0SaMv13PMQh8DDGdrKpf/oA=; b=4uqhgy30JeJziwplCv3OZthGTC0qzDk44cgjT+0ECnILt8KJ1Ybred/uk4wDe0hGCly7n1 lOBQwY64ssH5ckEmddJfrrzI+OwuqwsOJ/kXVFGaNHGb+4e08oOAEIgMPyYj0ZW3U9frfu qomq/TfdRl6wh73zjsygVgHqWnkQZLQ= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=eLu+gNof; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf26.hostedemail.com: domain of emmir@google.com designates 209.85.208.48 as permitted sender) smtp.mailfrom=emmir@google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1690405846; a=rsa-sha256; cv=none; b=Oe7REUm7Zg9BYXpLwRYNgLV/RT0x2LZQ3plVyumOk61rcz63nAFxq7yrwbe6MVaoztnWo3 0gnMdGOvj99R58q34rKQ1Bp2oL47repngx5oFK5ybclxh5NBU06CZCkjsNrLRmGAhk8Vxt A72tUwD8hoMjBP9S6MHmdHHMeusm8lo= Received: by mail-ed1-f48.google.com with SMTP id 4fb4d7f45d1cf-516500163b2so1463a12.1 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=H/fjiFZp6ESKrutws22o67E2VO7Xbjl7T2/QVi+cE0dIeq5TQ7JseDkuwSoFB/YCrU dLbDf5oP1mKG/2NyKxz8m2ZjT3RSuIqvSh9gYVkcWXwnHXu4eINQfZwcYvB15kK0pmw+ AJLeBpuvcaK/qjdIGXZu0pZepeXkPt7+jEEdMQlOjt8+1fZiTgM+XMNrr9I3yoP/skoK 0kELt0VAz+GHv2Le4xCO72+htpNdxdpfBb0t7Q2ttzUgBnqniMReyCqWZNtWEspg9i28 oF5JoMQfTYfxgWWXhfwKEOGbW7iMG2yeW07D+WeYLDEBLc+08myO1zG8XhktP4LFazOJ Mssg== X-Gm-Message-State: ABy/qLYhXCZ++EuVB0hxK6PFhrdRqiJAj8wGFasLKzZZ4EazTw5uNiGG cXmRWMAcvEXTHfq8Vu/Ix8nB0dHIM/Wgf3MRgMrvfw== X-Google-Smtp-Source: APBJJlHivbRzuJT8P6p6jbxegWClyIOonCFtye/wSfmGogOINZRhaBvz2SCuEPMI1MLUCqxE5bFrkaSD3dQXAy/1y34= 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-Rspamd-Queue-Id: C1B19140005 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: ecfc13wptpm5hxbo5wdta1qau5qa8feu X-HE-Tag: 1690405846-698914 X-HE-Meta: U2FsdGVkX1/BnTt+4jQVPPiveh6b2vAvhLVOwj7nWuIY9NEYKdNdmU4pffeVu3+0at8dNQXd3/QHVvw3v57nJtEC4mbEw7UQPMnwQ64VlObhiLgDgIAY6G4eu1tyDYpDiq4sC1JJVn6U6Kp274DHFGv86DCTO6AcoXxFR0F+pAIoYHtATVXkLqxd1i/dFlyTCwW2ks5p99PdXp231vrldqCD69K7iwA9Eapgxalb/42yf3ZHUtoMRfC5ANMtgXvsPJCraMz0zi6L3Gzq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kULri8xefJiK7kAQtopSsA08T4wJI3vuCagBu8OqvCjT0wj56UgCA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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