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 73D4AEB64D9 for ; Thu, 15 Jun 2023 15:16:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0BC5F6B0072; Thu, 15 Jun 2023 11:16:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 06D016B0078; Thu, 15 Jun 2023 11:16:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E77468E0002; Thu, 15 Jun 2023 11:16:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id D576A6B0072 for ; Thu, 15 Jun 2023 11:16:24 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 95A6F4095E for ; Thu, 15 Jun 2023 15:16:24 +0000 (UTC) X-FDA: 80905333488.29.8479C8B Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by imf14.hostedemail.com (Postfix) with ESMTP id 3F2B5100018 for ; Thu, 15 Jun 2023 15:16:21 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=collabora.com header.s=mail header.b="biOA/gL+"; spf=pass (imf14.hostedemail.com: domain of usama.anjum@collabora.com designates 46.235.227.172 as permitted sender) smtp.mailfrom=usama.anjum@collabora.com; dmarc=pass (policy=quarantine) header.from=collabora.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686842182; 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=CP7AzKKCujx3rQ/4RAt2G9arnmtRWEa1ud20aOzPNrc=; b=d8LchVo/XqyJ0u3dVEGX13IhWErQxf6uI0CIH78r3FScgrgtgp2vfpahqH3epHfEY1Rf9v Jb0BkCYzWaoZEcXFrC4n7sV/spt83mPPWoDRly+GcK/8THGBjf9KLotc0zDcLH/S5Cl3fL ZTITUVFjZRgWCQD21LJehtnBw1krrWI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686842182; a=rsa-sha256; cv=none; b=mzgBDtLdrskH5BubrTfF85hrD2ggs7/KCz3cPzv5+Qi4dvA77O4iOhZK4tICH+mRZGdUMm P0GdCGwt88NfimSoDFzmJpW+Rf3kpkk7QayMqrXLQLdbqAQPioPzsg9H6xK+8ul4CQhoLN QHHoDQKfyZJ8cH9WlMa8l++es3QD3P0= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=collabora.com header.s=mail header.b="biOA/gL+"; spf=pass (imf14.hostedemail.com: domain of usama.anjum@collabora.com designates 46.235.227.172 as permitted sender) smtp.mailfrom=usama.anjum@collabora.com; dmarc=pass (policy=quarantine) header.from=collabora.com Received: from [192.168.10.55] (unknown [119.155.33.163]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: usama.anjum) by madras.collabora.co.uk (Postfix) with ESMTPSA id E82676606F67; Thu, 15 Jun 2023 16:16:13 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1686842180; bh=C0LEQtiOTpGeaCKA+5bOCExcFaAsKTYF2+EXB06sxLI=; h=Date:Cc:Subject:To:References:From:In-Reply-To:From; b=biOA/gL+FCKC1STuGTkA27txM7KGqLoOY5QAg/CEkPhfmvwgSp4HyueREBL5JRNqo qj12DWxyl8+iwhbx1is/3rVI2TgwihjblFnKhEiwT0CRQe3bsZ3A7MLBi5IYFik1CN bWkEmO3IjEfyzzb4s4qY6hubBX69vPgsH1+O+Tarr0UCdZyItIpbnGFzdV4YDfksk8 NqAoN9vn37M6FC8PW9CQdX98oLmDNfisTmkUh5PmujzhkiCnydIez85QLaRm9IvmpL u2atqKkAwbY2FkCQs5XbUXDoZYn6hm32m9VEfdXIvulNOYgh4UaDN+Cmu/vG2VaUM/ +x8t9wZ93KyZA== Message-ID: <43c96533-8009-e42f-721c-4b2d1e142f5d@collabora.com> Date: Thu, 15 Jun 2023 20:16:10 +0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Cc: Muhammad Usama Anjum , Peter Xu , David Hildenbrand , Andrew Morton , Andrei Vagin , 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 Subject: Re: [PATCH v18 2/5] fs/proc/task_mmu: Implement IOCTL to get and optionally clear info about PTEs Content-Language: en-US To: =?UTF-8?B?TWljaGHFgiBNaXJvc8WCYXc=?= References: <20230613102905.2808371-1-usama.anjum@collabora.com> <20230613102905.2808371-3-usama.anjum@collabora.com> <0db01d90-09d6-08a4-bbb8-70670d3baa94@collabora.com> <34203acf-7270-7ade-a60e-ae0f729dcf70@collabora.com> <96b7cc00-d213-ad7d-1b48-b27f75b04d22@collabora.com> From: Muhammad Usama Anjum In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-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VTC63eD8pEiqe/F66 eAqkpAAa ITG61Aq7j7fbc03FNFxY89JzaiSuWPDCrVKiuI7opDDVsKKo01DwgCeHzXJXnnnfjyXJXVU6eXMjhIB77fEImgggnqddzt7M2WgOGfSbCCRSsl37W9IfFpS8PJVUVsozxGCkvt/43+aaywKjA7cCPqF3YMfzk7LuZc2m09M13xldE/UMzqWKFbd/HWur7nUTrJ8t0cZgFxe+X6yFuWH9ojkDBYgFt1n3ddaTRj3evd8Rfog9jDQ0LDB+dt2gLAk+SkuWsDGBS8gCd9na4CpNP7L+ebuF3F1OEoXJsD1/evSEnGq79VytYZ7fIZ5XYHFAxEHF380H2Nb2eo3k= 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: Please review the v19. I hope to get your reviewed by tag soon. On 6/15/23 7:58 PM, Michał Mirosław wrote: > On Thu, 15 Jun 2023 at 16:52, Michał Mirosław wrote: >> On Thu, 15 Jun 2023 at 15:58, Muhammad Usama Anjum >> wrote: >>> I'll send next revision now. >>> On 6/14/23 11:00 PM, Michał Mirosław wrote: >>>> (A quick reply to answer open questions in case they help the next version.) >>>> >>>> On Wed, 14 Jun 2023 at 19:10, Muhammad Usama Anjum >>>> wrote: >>>>> On 6/14/23 8:14 PM, Michał Mirosław wrote: >>>>>> On Wed, 14 Jun 2023 at 15:46, Muhammad Usama Anjum >>>>>> wrote: >>>>>>> >>>>>>> On 6/14/23 3:36 AM, Michał Mirosław wrote: >>>>>>>> On Tue, 13 Jun 2023 at 12:29, Muhammad Usama Anjum >>>>>>>> wrote: >>>>>>>> For flags name: PM_REQUIRE_WRITE_ACCESS? >>>>>>>> Or Is it intended to be checked only if doing WP (as the current name >>>>>>>> suggests) and so it would be redundant as WP currently requires >>>>>>>> `p->required_mask = PAGE_IS_WRITTEN`? >>>>>>> This is intended to indicate that if userfaultfd is needed. If >>>>>>> PAGE_IS_WRITTEN is mentioned in any of mask, we need to check if >>>>>>> userfaultfd has been initialized for this memory. I'll rename to >>>>>>> PM_SCAN_REQUIRE_UFFD. >>>>>> >>>>>> Why do we need that check? Wouldn't `is_written = false` work for vmas >>>>>> not registered via uffd? >>>>> UFFD_FEATURE_WP_ASYNC and UNPOPULATED needs to be set on the memory region >>>>> for it to report correct written values on the memory region. Without UFFD >>>>> WP ASYNC and UNPOUPULATED defined on the memory, we consider UFFD_WP state >>>>> undefined. If user hasn't initialized memory with UFFD, he has no right to >>>>> set is_written = false. >>>> >>>> How about calculating `is_written = is_uffd_registered() && >>>> is_uffd_wp()`? This would enable a user to apply GET+WP for the whole >>>> address space of a process regardless of whether all of it is >>>> registered. >>> I wouldn't want to check if uffd is registered again and again. This is why >>> we are doing it only once every walk in pagemap_scan_test_walk(). >> >> There is no need to do the checks repeatedly. If I understand the code >> correctly, uffd registration is per-vma, so it can be communicated >> from test_walk to entry/hole callbacks via a field in >> pagemap_scan_private. > > Actually... this could be exposed as a page category for the filter > (e.g. PAGE_USES_UFFD_WP) and then you could just make the ioctl() to > work for your usecase without tracking the ranges at the userspace > side. I'm not sure about page category. ASAIK the current check isn't bad when we already mention in documentation that memory must be registered with UFFD WP before using write feature of the IOCTL. Just like mincore mentions in documentation that user buffer will be filled with values based on the length of the region. Kernel doesn't care if user had provided smaller buffer and kernel overwrites because of user's own issue. I want to follow the same path. If user doesn't read documentation and follow it, he should be punished with the error. > > Best Regards > Michał Mirosław -- BR, Muhammad Usama Anjum