Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp2099304rwb; Thu, 27 Jul 2023 01:54:44 -0700 (PDT) X-Google-Smtp-Source: APBJJlHx0z6ALNKUm0hXSlDgxnm9fbVa7c2GNj98wksyV3i93vd+6GCQo3H7Mt2OA1jFr/VcW0Rc X-Received: by 2002:a17:906:cc0d:b0:983:cb6c:8aa3 with SMTP id ml13-20020a170906cc0d00b00983cb6c8aa3mr1256970ejb.59.1690448084461; Thu, 27 Jul 2023 01:54:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690448084; cv=none; d=google.com; s=arc-20160816; b=AHqRZQ0n/jzh4n0kF1G8/fViUv3eL/1UHLR2nsitRCLXIyTBfgp7K2dBtIMCginj0C KXU1ytl0Q4t4+hlOS6XI2Q/qFzkx/sKxf9bufQWrfYq0CTz/wvd4r4KfbAWTDpgh8TW+ SpiMuRT7fPK3yL3yfKsWjmXJVT6MracChb2HsC2JBZwQjBzIe5EHOXEP9ydc9pkWhCqb 33R8Es4G34f/UmfgQdgdQ2BYfDzvp3Pj/eKoPHwAY4ao4WjpMLrmxUUsL0oTqulWEPao DYtUKcxAhU3iyBPqds4gGfBH+ZKRHtOpr1y8mrvtH9msujV/QcXH1FV3BlF016DBTXIz nXxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :content-language:references:to:subject:cc:user-agent:mime-version :date:message-id:dkim-signature; bh=b6TIqQ5n+2m1sLJm7ClIOxiebf/HGnTDjoXSffF5ro4=; fh=xirjYJ0ONrj7Vx+svmCKD9xlGq+asENfsUsRcqAgKcw=; b=wT13oL2afKxD3cfVlDHEKRpO9H1wKugjL1KT/9kHiFLDCwyRJ/Y50GyqbJfIWjQVqz FW4Qy8tiQjA/VMVwKKsCh5B/aEOq/g/upyD9Bgw76bW06OE8YIzy4bOrRy800f18s/H/ yVyPa/ppym9L4xZJ1Y2c7dypaE5We0O4k61v0HYuSxjg+Y6gwiTHUjDC5fpEI5qoc+Fo SFmM0oz1pV+GSrDeTInvKCckxSVfQQxaMk+DmAs3m0/S9WJ37CxzYJg0QNQgRtpHmRQb ZziNeV+v9wXUlG8IeiB9U0HK+H5yQPb8qvSYtozP8593q7sMlQSohTYS0XiBJZru5YIx KCPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=DJzXf0kz; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j25-20020a170906255900b0098f99532db7si750343ejb.673.2023.07.27.01.54.19; Thu, 27 Jul 2023 01:54:44 -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=@collabora.com header.s=mail header.b=DJzXf0kz; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233768AbjG0IHT (ORCPT + 99 others); Thu, 27 Jul 2023 04:07:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233786AbjG0IG6 (ORCPT ); Thu, 27 Jul 2023 04:06:58 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFB3BC3; Thu, 27 Jul 2023 01:03:24 -0700 (PDT) Received: from [192.168.100.7] (unknown [59.103.218.24]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: usama.anjum) by madras.collabora.co.uk (Postfix) with ESMTPSA id 93E0E6607123; Thu, 27 Jul 2023 09:03:16 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1690445003; bh=dW1Iw2fW6OgCt1ybA/3F16Se6r7KV+IdGvqNyOupjdI=; h=Date:Cc:Subject:To:References:From:In-Reply-To:From; b=DJzXf0kz3lRWuRFEQS8dTSgtxQvhEzEEPapXsYHDsEWxjW2Ym4qqvPYJsJ+smye+W pZQaaMjEHn4QXqIl7dZ/0v720T7XU889U57N8aNmLfhEn5z97KaUd+aSLPJ3+XkR9R UNc86yz7zNuqLYpSCIUsMueQJDLZhJ084zBoqP+jZwjeGclHm9U2uNGeE8mIfib7F2 h5n4lxgHhpbU2lNOR+CKGNEdnjPQybGqCyH+lbfwkicViEWibFWLxJ+rOY8AbV2G3p aJQAPpSnoylfpx0raqcbFnwBFmvr+C7kNGkpR1sCZYVxULwWnYrYPVG6n9A6UcSJ1Q WKC+00iUYfIzw== Message-ID: <89c09085-19ab-462b-e3be-b4e492a85899@collabora.com> Date: Thu, 27 Jul 2023 13:03:11 +0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 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 , 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 Subject: Re: [v3] fs/proc/task_mmu: Implement IOCTL for efficient page table scanning To: =?UTF-8?B?TWljaGHFgiBNaXJvc8WCYXc=?= 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> Content-Language: en-US From: Muhammad Usama Anjum In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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 7/27/23 2:10 AM, Michał Mirosław wrote: > On Wed, 26 Jul 2023 at 10:34, Muhammad Usama Anjum > wrote: >> On 7/25/23 11:05 PM, Michał Mirosław 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? PAGE_IS_WPALLOWED seems appropriate. > >>> 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 return >> 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. We shouldn't overwrite the start if we aren't gonna put the correct tag. So I've resorted to adding another variable `walk_end` to return the walk ending address. > >>> 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 = 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ł Mirosław I'll send v26 in next hour. -- BR, Muhammad Usama Anjum