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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0CB9CC4167B for ; Mon, 27 Nov 2023 11:29:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To: Subject:MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=rQ3KrHpvTMhYMHbKiDM7SAZS16nl+vi+EH/9WBZ/xXI=; b=qldIFj6cHqqL+s 9+/1aUtBustW4xpOvW+yDLYCMk4bbkM1z/NLnJ1jB3dIqA+mxLKfcDzLYgru3eqpBZhJN+Cxns7/R QIot1kXFO5CsCoMRrQNtBCiBa74OR/0THbimBUAb14PHcsdhdAVP3gwmZOYm8TVXnFNfYZfZaf2UD 7dgKAs/MqTv3HvXiNXa4TPAyPcPx8YOTSjj/zzHPyPPuPRnG/MFPoIwb/RtRuAIc8DMuJgQasAxhD Dq91J4b0ZiBVO9vVFjAYp5Q4vk9d/MFTJnTWuLZthoB2zUOgnWeWh4EgD2IKY7tY4Vu5ycarl6dSM LdXH8fVxUL39GSz8BULw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r7ZnM-002DcX-28; Mon, 27 Nov 2023 11:28:56 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r7ZnJ-002Dbn-0l for linux-arm-kernel@lists.infradead.org; Mon, 27 Nov 2023 11:28:54 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id DF9142F4; Mon, 27 Nov 2023 03:29:39 -0800 (PST) Received: from [10.57.73.191] (unknown [10.57.73.191]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id F21143F73F; Mon, 27 Nov 2023 03:28:48 -0800 (PST) Message-ID: <4785ad95-7af7-4d41-9997-e97b2a8e9666@arm.com> Date: Mon, 27 Nov 2023 11:28:47 +0000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RESEND PATCH v7 04/10] mm: thp: Support allocation of anonymous small-sized THP Content-Language: en-GB To: Barry Song <21cnbao@gmail.com> Cc: akpm@linux-foundation.org, anshuman.khandual@arm.com, catalin.marinas@arm.com, david@redhat.com, fengwei.yin@intel.com, hughd@google.com, itaru.kitayama@gmail.com, jhubbard@nvidia.com, kirill.shutemov@linux.intel.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, mcgrof@kernel.org, rientjes@google.com, shy828301@gmail.com, vbabka@suse.cz, wangkefeng.wang@huawei.com, willy@infradead.org, ying.huang@intel.com, yuzhao@google.com, ziy@nvidia.com References: <20231122162950.3854897-5-ryan.roberts@arm.com> <20231127034135.6754-1-v-songbaohua@oppo.com> From: Ryan Roberts In-Reply-To: <20231127034135.6754-1-v-songbaohua@oppo.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231127_032853_322060_18586140 X-CRM114-Status: GOOD ( 12.80 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 27/11/2023 03:41, Barry Song wrote: >> + if ((nr_pages == 1 && vmf_pte_changed(vmf)) || >> + (nr_pages > 1 && !pte_range_none(vmf->pte, nr_pages))) { >> + for (i = 0; i < nr_pages; i++) >> + update_mmu_tlb(vma, addr + PAGE_SIZE * i, vmf->pte + i); >> goto release; >> } > > Hi Ryan, > what has stopped nr_pages == 1 from using !pte_range_none(vmf->pte, 1) > directly, then the code can become, > + if (!pte_range_none(vmf->pte, nr_pages)) { > + for (i = 0; i < nr_pages; i++) > + update_mmu_tlb(vma, addr + PAGE_SIZE * i, vmf->pte + i); > goto release; > } > > for both 1 and > 1 cases? We can get to do_anonymous_page() from 2 routes: - page fault on unallocated memory (pte_none()) - page fault on uffd_wp pte marker In the latter case, we guarrantee that we are only operating on nr_pages == 1 because when uffd is in the picture we need to preserve any uffd state per-pte. It also means we can't just check the pte is none because in this case it is not none, it has a pte marker so we need to check it hasn't changed. I was previously abstracting this in vmf_pte_range_changed() but there were complaints [1] about the semantic being different based on the number of pages, so this was my attempt to make it more understandable. [1] https://lore.kernel.org/linux-mm/a6fa0847-a950-4044-972c-e5dc8cbc7922@arm.com/ Thanks, Ryan > > Thanks > Barry > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel