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 64764C76196 for ; Fri, 7 Apr 2023 10:50:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C4DE2900003; Fri, 7 Apr 2023 06:50:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BD5CD900002; Fri, 7 Apr 2023 06:50:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A4FCB900003; Fri, 7 Apr 2023 06:50:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 92B65900002 for ; Fri, 7 Apr 2023 06:50:29 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 6982CACCBD for ; Fri, 7 Apr 2023 10:50:29 +0000 (UTC) X-FDA: 80654276178.25.C1321A2 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by imf28.hostedemail.com (Postfix) with ESMTP id 77C50C000B for ; Fri, 7 Apr 2023 10:50:27 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=collabora.com header.s=mail header.b=jwsJ0V8H; spf=pass (imf28.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=1680864627; 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=RCgeiwinU6gDzISOrV79nXfpLNrMp17VfnPq7XIqmJY=; b=XLX4M/Hn1/4kpPRiCoGEwOPAP+LMlHdoxewhGZMivvE02iHwH5fgcVsFI1nPrRo0Vds5Eo euomDlWwIHAZ1Ct5kElMnSeAS4y9/cgOV6c6IlrRHid3U9uNdPW8srtSHTXjNCw1lw31jx e2/tv51l2TMX7yPq/26G407keW+tf3U= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=collabora.com header.s=mail header.b=jwsJ0V8H; spf=pass (imf28.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1680864627; a=rsa-sha256; cv=none; b=WBguYG2xEObvib7VlUUZypJmI0rEVpg6n3OUoZyP3DG5XLSXZtnteAGmuV46PGQUIrnB0f hZQ/WQHVUxcigCICHdmZ3reAP7pXh72opTRbkGrElpZbfpSTTgLLk6CgUHHd6kygPYPFUt rHm2IZpX0F7iljBAu7m6uWN78fUaV3k= Received: from [192.168.10.39] (unknown [119.155.57.40]) (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 88EE466031A4; Fri, 7 Apr 2023 11:50:19 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1680864625; bh=P8yF/E8G1GvIUrwOi1mexCebBBHEtFanTu2WunsLvz4=; h=Date:Cc:Subject:To:References:From:In-Reply-To:From; b=jwsJ0V8HH/MiLKUqPJXwtPH6Cl83QV0xaT69QVX8eGPFiWvWj8onH2k5LGYcN4h8w XfloZVX9ALnP7RHZEPNb2uxErVmxGpCvgPU1ffnVok7cBtsgxlQ35pcDL2nAFMJi8P GwqeZprQyFMOK2RDiGC8gLvsUEiYqpZF/AFsPUvY5/2Gj95lm0KzBA1IbaJ7vXJxIu kxb21+y0GPZ3FQs4IastwAuTWZMp57lfLSQPC8yf/TE3oW12EX2SvQ8B3JpsSLmHhv qjWxUWksyd9RvWdjYnAT+MoupIMjYuGVrfL+QEJfXraDttUg/ZVa7FUi1pVrqXzUDR m0yoRpQKaxJ2g== Message-ID: <2992d40c-ddac-ed5f-ca80-8d3fc08b10e6@collabora.com> Date: Fri, 7 Apr 2023 15:50:14 +0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.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 v12 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: <20230406074005.1784728-1-usama.anjum@collabora.com> <20230406074005.1784728-3-usama.anjum@collabora.com> From: Muhammad Usama Anjum In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 77C50C000B X-Stat-Signature: f6yxfqgua9cznfrq4uojdnk9rhd8fizt X-Rspam-User: X-HE-Tag: 1680864627-269627 X-HE-Meta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Ui95x7k/6Hr2MizAd2meh9r93mTMd46pvlIPJTOt1/fsSITX9wA+2o/3laO5UVZ3PKODJU5K+AcPqzfOCGmjS7i6OteejF4w2C4e10AW63oQn/091DQsnXM/C25GarH8YDnr9/IPkhTTEtJQ8ad1p5aF2ejfPZsyZxgfB00wLtKkMYuJ0vEoYAiruVyUhpL+yUwSWm6OYpZ0N6SDT72FU51HdwgoNgsc0hc+ZloW78Ns4Rrf7Om6w/Hr8+Q2D5YM6G6JZ7J7GJpV86u+S8dfazLW 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 4/7/23 3:21 PM, Michał Mirosław wrote: > On Fri, 7 Apr 2023 at 12:15, Muhammad Usama Anjum > wrote: >> On 4/7/23 3:04 PM, Michał Mirosław wrote: >>> On Fri, 7 Apr 2023 at 11:35, Muhammad Usama Anjum >>> wrote: >>>> On 4/7/23 12:23 PM, Michał Mirosław wrote: >>>>> On Thu, 6 Apr 2023 at 23:12, Muhammad Usama Anjum >>>>> wrote: >>>>>> On 4/7/23 1:12 AM, Michał Mirosław wrote: >>>>>>> On Thu, 6 Apr 2023 at 09:40, Muhammad Usama Anjum >>>>>>> wrote: >>>>>>> [...] >>>>>>>> --- a/fs/proc/task_mmu.c >>>>>>>> +++ b/fs/proc/task_mmu.c >>>>>>> [...] >>>>>>>> +static int pagemap_scan_pmd_entry(pmd_t *pmd, unsigned long start, >>>>>>>> + unsigned long end, struct mm_walk *walk) >>>>>>>> +{ >>>>> [...] >>>>>>>> +#ifdef CONFIG_TRANSPARENT_HUGEPAGE >>>>>>>> + ptl = pmd_trans_huge_lock(pmd, vma); >>>>>>>> + if (ptl) { >>>>>>> [...] >>>>>>>> + return ret; >>>>>>>> + } >>>>>>>> +process_smaller_pages: >>>>>>>> + if (pmd_trans_unstable(pmd)) >>>>>>>> + return 0; >>>>>>> >>>>>>> Why pmd_trans_unstable() is needed here and not only after split_huge_pmd()? >>>>>> I'm not entirely sure. But the idea is if THP is unstable, we should >>>>>> return. As it doesn't seem like after splitting THP can be unstable, we >>>>>> should not check it. Do you agree with the following? >>>>> >>>>> The description of pmd_trans_unstable() [1] seems to indicate that it >>>>> is needed only after split_huge_pmd(). >>>>> >>>>> [1] https://elixir.bootlin.com/linux/v6.3-rc5/source/include/linux/pgtable.h#L1394 >>>> Sorry, yeah pmd_trans_unstable() is need after split. But it is also needed >>>> in normal case when ptl is NULL to rule out the case if pmd is unstable >>>> before performing operation on normal pages: >>>> >>>> ptl = pmd_trans_huge_lock(pmd, vma); >>>> if (ptl) { >>>> ... >>>> } >>>> if (pmd_trans_unstable(pmd)) >>>> return 0; >>>> >>>> This file has usage examples of pmd_trans_unstable(): >>>> >>>> https://elixir.bootlin.com/linux/v6.3-rc5/source/fs/proc/task_mmu.c#L634 >>>> https://elixir.bootlin.com/linux/v6.3-rc5/source/fs/proc/task_mmu.c#L1195 >>>> https://elixir.bootlin.com/linux/v6.3-rc5/source/fs/proc/task_mmu.c#L1543 >>>> https://elixir.bootlin.com/linux/v6.3-rc5/source/fs/proc/task_mmu.c#L1887 >>>> >>>> So we are good with what we have in this patch. >>> >>> Shouldn't we signal ACTION_AGAIN then in order to call .pte_hole? >> I'm not sure. I've not done research on it if we need to signal >> ACTION_AGAIN as this function pagemap_scan_pmd_entry() mimics how >> pagemap_pmd_range() handles reads to the pagemap file. pagemap_pmd_range() >> isn't doing anything if pmd is unstable. Hence we also not doing anything. > > Doesn't this mean that if we scan a file-backed vma we would miss > non-present parts of the mapping in the output? I'm trying to mimic the same information through ioctl which is attained by reading the file. We'll only miss the unstable VMA here. I'm don't know about how often the PMD is unstable and its effects. > > Best Regards > Michał Mirosław -- BR, Muhammad Usama Anjum