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 0FA6FC4167B for ; Mon, 27 Nov 2023 11:31:04 +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=c0zy4YOUpxDRVYLvnjakJnn3He4oszC221kEM6tdKL4=; b=exG/SJMA89pKDp jiOU+zYZpl4ZXITN3G484dLFcqlmnn1jU3D9RWdTbN6MoFh9E5D2QC9K8rOQaw719pjI55ylOLp8d mgyuzML0bpmiKMaPp8JRltVyHf13mtKTdV5L0nGp07ZKp0ShWMUPPxS9RO1y+hu47KHZcW7XTqE63 7o4AHSEfacxo7zPxFG2V1d+ky0n33EZNl/ViDaSa3xDUqTbytzT03EgCdTVcwKBE1DtWclZ80IE5G CEuJi1fBG4zmzrHoBF/XyqLFAQZCo9u71dtQIfwTu1o0Nbs/GAs16xG3UoBDgNsbPz/0hL0xlzRyn AgVqNbTfFThZijkd70cQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r7Zp1-002Drz-0N; Mon, 27 Nov 2023 11:30:39 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r7Zox-002Dqy-35 for linux-arm-kernel@lists.infradead.org; Mon, 27 Nov 2023 11:30:37 +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 983052F4; Mon, 27 Nov 2023 03:31:22 -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 3885B3F73F; Mon, 27 Nov 2023 03:30:32 -0800 (PST) Message-ID: <45d0aa4c-e438-476e-a0b2-a129ba1975b4@arm.com> Date: Mon, 27 Nov 2023 11:30:31 +0000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RESEND PATCH v7 02/10] mm: Non-pmd-mappable, large folios for folio_add_new_anon_rmap() 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-3-ryan.roberts@arm.com> <20231127043644.8072-1-v-songbaohua@oppo.com> From: Ryan Roberts In-Reply-To: <20231127043644.8072-1-v-songbaohua@oppo.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231127_033036_038260_DB051CD9 X-CRM114-Status: GOOD ( 15.41 ) 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 04:36, Barry Song wrote: >> void folio_add_new_anon_rmap(struct folio *folio, struct vm_area_struct *vma, >> unsigned long address) >> { >> - int nr; >> + int nr = folio_nr_pages(folio); >> >> - VM_BUG_ON_VMA(address < vma->vm_start || address >= vma->vm_end, vma); >> + VM_BUG_ON_VMA(address < vma->vm_start || >> + address + (nr << PAGE_SHIFT) > vma->vm_end, vma); >> __folio_set_swapbacked(folio); >> + __folio_set_anon(folio, vma, address, true); >> >> - if (likely(!folio_test_pmd_mappable(folio))) { >> + if (likely(!folio_test_large(folio))) { >> /* increment count (starts at -1) */ >> atomic_set(&folio->_mapcount, 0); >> - nr = 1; >> + SetPageAnonExclusive(&folio->page); >> + } else if (!folio_test_pmd_mappable(folio)) { >> + int i; >> + >> + for (i = 0; i < nr; i++) { >> + struct page *page = folio_page(folio, i); >> + >> + /* increment count (starts at -1) */ >> + atomic_set(&page->_mapcount, 0); >> + SetPageAnonExclusive(page); > > Hi Ryan, > > we are doing an entire mapping, right? what is the reason to > increase mapcount for each subpage? shouldn't we only increase > mapcount of subpage in either split or doublemap case? > > in page_add_anon_rmap(), are we also increasing mapcount of > each subpage for fork() case where the entire large folio > is inheritted by child processes? I think this is all answered by the conversation we just had in the context of the contpte series? Let me know if you still have concerns. > >> + } >> + >> + atomic_set(&folio->_nr_pages_mapped, nr); >> } else { >> /* increment count (starts at -1) */ >> atomic_set(&folio->_entire_mapcount, 0); >> atomic_set(&folio->_nr_pages_mapped, COMPOUND_MAPPED); >> - nr = folio_nr_pages(folio); >> + SetPageAnonExclusive(&folio->page); >> __lruvec_stat_mod_folio(folio, NR_ANON_THPS, nr); >> } >> >> __lruvec_stat_mod_folio(folio, NR_ANON_MAPPED, nr); >> - __folio_set_anon(folio, vma, address, true); >> - SetPageAnonExclusive(&folio->page); >> } > > Thanks > Barry > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel