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 F365EC0015E for ; Thu, 27 Jul 2023 11:22:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 89D5B6B0074; Thu, 27 Jul 2023 07:22:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 84D636B0075; Thu, 27 Jul 2023 07:22:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 715116B007D; Thu, 27 Jul 2023 07:22:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 5BB1D6B0074 for ; Thu, 27 Jul 2023 07:22:10 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 1B09B1CA1D3 for ; Thu, 27 Jul 2023 11:22:10 +0000 (UTC) X-FDA: 81057152820.20.305CC49 Received: from mail-ed1-f42.google.com (mail-ed1-f42.google.com [209.85.208.42]) by imf20.hostedemail.com (Postfix) with ESMTP id 322821C0020 for ; Thu, 27 Jul 2023 11:22:07 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=RuZ+CMuh; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf20.hostedemail.com: domain of emmir@google.com designates 209.85.208.42 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=1690456928; 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=pQEYdNvZMX6Etgo1t+7RDnKc5/X0V/U1VxFaQxCChgs=; b=fhvr3whjDAZK1FePKG4FS8kvjiyxXJyfkushz5AqhaUqLI84c4cA5V5A318/MrIL+Xe0LC TNSL8PcH0mz8PZ1cp0PpUmTu4k2774WPkwvl44jXvl2miMNcM4t7yawTaq042rAWJntj7e NVbWolHLJj2nhG63IavXO8ZIbX7/9t0= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=RuZ+CMuh; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf20.hostedemail.com: domain of emmir@google.com designates 209.85.208.42 as permitted sender) smtp.mailfrom=emmir@google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1690456928; a=rsa-sha256; cv=none; b=0JUDd46Kf4K2VA0uG/vJSUj7OZ9V0QCU8ghC07s0J/ps/oep16BqZx2anCYakC+rEmQB0S zKrK5Xc6XEA/QxFasfHzm3BZ7vVkp+3D60mYSqi42uDaub9BJYfUaoAP4GySYtkPrCNArZ VSWtwcdvLdDWuTZ4jOXzjKN7/MU0W1g= Received: by mail-ed1-f42.google.com with SMTP id 4fb4d7f45d1cf-5223910acf2so11243a12.0 for ; Thu, 27 Jul 2023 04:22:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1690456926; x=1691061726; 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=pQEYdNvZMX6Etgo1t+7RDnKc5/X0V/U1VxFaQxCChgs=; b=RuZ+CMuhY2GR/2JwXCGB9HPfr3Gfcaa0YbOYJp+zdkPA13cAwXi10wUP9fct76LtRp 088LwhB7lIRf3nsqlKP8wNe8EvCWQMn4k3d7pvOWHep9Hvm3Hff5YXTQLWaXdbcb/2Nj J8cGgooQQt2Pl5P8UACstz0AiBDAtdwD7C7FqTT/IrIh/Ft+MLgFTq3Cqn6bUPa0uXXu HgP/mhQAOCS/e1mFlm1L+qKumDvSbL2WSuruzdbdMlblir5AaPrxH8PmzVx0Q7OTmOhd nJQTge6J+xvWdR+XQsWazjtgl81zzoOKdRvvP+qsbTgXI7voyqqrXSNSzM7bCtN4pPro RRTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690456926; x=1691061726; 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=pQEYdNvZMX6Etgo1t+7RDnKc5/X0V/U1VxFaQxCChgs=; b=bT4m1vnqkqn3F9CijpDZv19wv9zvdIllmtcvcQTmYX3S+JcUjkxoS7bB2kz9coAXL1 9jhRI0lIAJ2REY/Uvk2Pne/TI96SDseSKcvMSMfF1zIYfh/X5PbReryIEXsWTVkIHvxw lp3pIrscRp1CdwU/4IbV6Y7dnUAkN8NHY4vUsWTZzoPzff+W5ga2RgJZZ5+PYkel5jBN AWZKJ7sh4yFaJ9lL9Yvhz99rRXSOOXneymOPFDmcDl/0QUmf5Y6lWc6q5d9Is5lpor2b otJxppU3GMyJeQxE8wqIb4VBdkxTeyz2tv4qdLGJ7/4wy/WbsG8asdCOzNzZlMk/OOQF uh+g== X-Gm-Message-State: ABy/qLYKN75f/FTJJUCbKr3FjWtXduo6FB/vy94CjseI7+ayVvOuw2/A zmoRzjWf4zz3c2rRg/aaWcmyrfqiL0N5fDNB3jE/QA== X-Google-Smtp-Source: APBJJlEKCU8y+i7yNjlzwM0W832RMv2M+/GkpbNF5mrtr7hkF1oVjo2BBhHfuYu274luOCGaIK1Syj5qH3V1YiEVi1Q= X-Received: by 2002:a50:d4c2:0:b0:522:28a1:2095 with SMTP id e2-20020a50d4c2000000b0052228a12095mr79473edj.3.1690456926488; Thu, 27 Jul 2023 04:22:06 -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> <94c6b665-bbc2-5030-f9b1-d933791008b8@codeweavers.com> In-Reply-To: From: =?UTF-8?B?TWljaGHFgiBNaXJvc8WCYXc=?= Date: Thu, 27 Jul 2023 13:21:54 +0200 Message-ID: Subject: Re: [v3] fs/proc/task_mmu: Implement IOCTL for efficient page table scanning To: Paul Gofman Cc: Muhammad Usama Anjum , "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 , 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-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 322821C0020 X-Stat-Signature: 16qytojw7my16p7nkk9adi5omwauawhi X-HE-Tag: 1690456927-192037 X-HE-Meta: U2FsdGVkX18dfg77qMFDl1dt3O6nNj+1W7ntjKh3Ho47NOXCIv4lObyMbDYue1ikKMyQ/dRv4k+WxvklrJyVkRgK00bfnrU3SmYGSODx4m8ZXKrsLNii3Ahxf/4d2heszq2CMcg3qpke9lzh6DVLFgg1Y+gcJ3b5HZrSi4eg1RowUtCWDoaPas0so9JxiCj33PuKV+/VNfi8AnwyRLA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SOgJcnZPa7hjfshvQP34JJDjBA5HpP4w5jsau2w2FRKPnlIu6dm1EyX0uCbyBTh1RzzjaazvQ0Bik8EZjv5K+qUS+GPaviLoDu77NTb8sgM/j7Lsdu4n7D4WOE+gEiOQX6w5lnj99Hv8= 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 Thu, 27 Jul 2023 at 13:18, Micha=C5=82 Miros=C5=82aw = wrote: > On Thu, 27 Jul 2023 at 01:06, Paul Gofman wrote= : > > Hello Micha=C5=82, > > > > I was looking into that from the Wine point of view and did a bit > > of testing, so will try to answer the question cited below. > > Thanks for the extensive explanation! > > > Without Windows large pages I guess the only way to make this work > > correctly is to disable THP with madvise(MADV_NOHUGEPAGE) on the memory > > ranges allocated with MEM_WRITE_WATCH, as the memory changes should not > > only be reported but also tracked with 4k page granularity as Windows > > applications expect. > > > > Currently we don't implement MEM_LARGE_PAGES flag support in Wine > > (while of course might want to do that in the future). On Windows using > > this flag requires special permissions and implies more than just using > > huge pages under the hood but also, in particular, locking pages in > > memory. I'd expect that support to be extended in Windows though in the > > future in some way. WRT write watches, the range is watched with large > > page granularity. GetWriteWatch lpdwGranularity output parameter return= s > > the value of "large page minimum" (returned by GetLargePageMinimum) and > > the returned addresses correspond to those large pages. I suppose to > > implement that on top of Linux huge pages we'd need a way to control > > huge pages allocation at the first place, i. e., a way to enforce the > > specified size for the huge pages for the memory ranged being mapped. > > Without that I am afraid the only way to correctly implement that is to > > still disable THP on the range and only adjust our API output so that > > matches expected. [...] The THP case we can leave it to userspace, as it can madvise() if the optimization lost due to dirty tracking of THP is more than THP adds. (BTW, the WP-watch is done via uffd - the default change would need to happen there). Best Regards > Micha=C5=82 Miros=C5=82aw