Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp2960353rdh; Mon, 27 Nov 2023 03:30:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IED1JEeV6KI7+BW5Xd3AFwCxNGIQyanLeSsRBSj4V61BIy7VEz5Y0G3HQjHpFFaJ9S1lKZA X-Received: by 2002:a05:6a00:1a8c:b0:6be:4e6e:2a85 with SMTP id e12-20020a056a001a8c00b006be4e6e2a85mr12845862pfv.30.1701084648180; Mon, 27 Nov 2023 03:30:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701084648; cv=none; d=google.com; s=arc-20160816; b=be1kQN44h+7PKbSsshFb6PhLe4RWYuZ/FnBibbQmqY7JCPxiqQY4ZlegQ7k74BHdFT lj0VI5u6TjqQn+8zuAz3por9ylqrUBDkFwYQvgXJ9N2xZSHmqOeF9xneY/cXivd5lMly c93Yfb5RoULfkYcdM1KYlwmYWwq+bCqyzp9ircidmwEQ3yMxDwx0ZzkCKuOSuP5gxeEK kfER4rOd9j9UzTDu5owfsGG4WcZzXmOm0ucSx+GoMAA+ElXKMy+2QZ1U4m4nEPWfbwCG E0Jhr+oMsZAq9KPZIsHgzH1O3tIviyahAnRyQWaIxgm97bv77jAbl6/s0+Tk2IpZHfVn HRrg== 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 :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=X+Lu/e9HLgLB0g81f5IOf8+zX0BdNExlyd2FSnBHP6Y=; fh=T1vs46TCCoF4pbUyjBsdSzYx80GdyXOTIvnat0bBwqw=; b=A59e7ZIu9kSG9sSWKDYgbV4RgasjhwPxIL8LwaU9p3w6NcHJtF7HS1j8w2ceXcX99t M6oy4NN2XA1twHlaXWwhbs+ru4puM3IxxA5iRoTgjo6o3uGcUfPHjM9qNcrkqmiEChn+ EF1Y9nygpelnn7fBk4+F3oQI0HBagx8Y5nmkuzvBoLnoqTrStzpm/83rBgwZXNy5WkPk 3Stzw9hQQG2xm+EWu2fCxSWMxZHqueQcvbWNdic/82opXaxFSWaaBhKBylYyMR+u6SD/ m5BAbJjqaZiR1R3OAxArjo54gsrXReYfyh24vO8IPPmeFxiHsvYjrl2hPfBQw6hKdzUq tYDw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id l12-20020a056a00140c00b006cbb132d46dsi9437340pfu.244.2023.11.27.03.30.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 03:30:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 300F580C61B8; Mon, 27 Nov 2023 03:30:45 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233245AbjK0Lac (ORCPT + 99 others); Mon, 27 Nov 2023 06:30:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233258AbjK0La3 (ORCPT ); Mon, 27 Nov 2023 06:30:29 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5E772191 for ; Mon, 27 Nov 2023 03:30:35 -0800 (PST) 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> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=1.7 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SORTED_RECIPS,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Mon, 27 Nov 2023 03:30:45 -0800 (PST) X-Spam-Level: * 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 >