Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp1970472rdb; Sun, 19 Nov 2023 19:28:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IEfRFAj9dFwn+SDOBA4Nxd7KQBO+Zyt7mBCZPFJf9z0S7sBXCbhAdlNJDY9J6BOoi2NZpMA X-Received: by 2002:a05:6a20:7490:b0:188:9de:9eed with SMTP id p16-20020a056a20749000b0018809de9eedmr5420752pzd.13.1700450904452; Sun, 19 Nov 2023 19:28:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700450904; cv=none; d=google.com; s=arc-20160816; b=A4hSQlr3P3yZRoqgayaUWLg2/3VbpTN8AFC41bIH7uxYQt8B8nxKKErarmn/z5BCCB jfhS1ZzMVvKtPxyMZ5iEpU40gYRfPQe+wqJb0NfdQ/mDcg4bgge8DQlQIGNeKXXkxsph 3SBWnsbDGXDXUZsFI9qbE8kUW1fQSMtOO2dQzLtx0dIwKDpsqz7G+Mmq4HLFXYuLYSOY XIW+slyoJhKtQa3+ctzMl+3fXV/Yik2D1lkpZfAGIZoVUhYZuxKPxT5wlLSDvrbKhaR2 4kSYiMxAa929KIQvszJll4mqjSK5QAuJ+Ljlw+SGn0qEYJ++ccAG4+UsRNItnLO2Avm0 2DZA== 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:subject:user-agent:mime-version:date:message-id; bh=fJzANmAtk3e32UaRA10q1QbfAkjqSbKPDwdq6Es0aCs=; fh=/JOyF5W1vXJEhSOysC5fdauXfM7YjmiHxDAtlFn4SF4=; b=xoThukOFo5ui0qsZDBVRLRY8bE4Y3SdZloHnaR5slunFosOwGTTDlNWk22r9DzuYs5 AqH2ftYTbWxNpALxStVlLq4EfRgsQdOMsJnNdiVfogM4Uumpo9x9JjzWKdaMosUVslKr /2sn4JbZfupixyZMvZ+QhFurZN1mOoOb6dkELkoc4NEDIGqTqGKhVDBGB8CN9q7/eGoT eGxLCs1x8hdWZJ+rM3tHR0h7n8+XXg36UeUGNIexwV5//HGAzywFLuCBqfcYzrxg4mn5 cnhstSWHhFHwXF3E2sh+1151TIZTal6y1FKQRMoVoTjxyeOpBHVicvd7cge/sqivQGy8 4umw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id bj12-20020a170902850c00b001cc38a6cb77si6995374plb.204.2023.11.19.19.28.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Nov 2023 19:28:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id C077F809AFD7; Sun, 19 Nov 2023 19:28:19 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231775AbjKTD2H (ORCPT + 99 others); Sun, 19 Nov 2023 22:28:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231805AbjKTD2G (ORCPT ); Sun, 19 Nov 2023 22:28:06 -0500 Received: from out30-110.freemail.mail.aliyun.com (out30-110.freemail.mail.aliyun.com [115.124.30.110]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1A2D1A6 for ; Sun, 19 Nov 2023 19:28:00 -0800 (PST) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R821e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046060;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=7;SR=0;TI=SMTPD_---0Vwg4JdO_1700450877; Received: from 30.97.48.46(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0Vwg4JdO_1700450877) by smtp.aliyun-inc.com; Mon, 20 Nov 2023 11:27:58 +0800 Message-ID: Date: Mon, 20 Nov 2023 11:28:11 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC PATCH] mm: support large folio numa balancing To: David Hildenbrand , akpm@linux-foundation.org Cc: ying.huang@intel.com, wangkefeng.wang@huawei.com, willy@infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <05dbc7b8-2e4a-4762-a6a6-278985d89928@redhat.com> From: Baolin Wang In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.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 (fry.vger.email [0.0.0.0]); Sun, 19 Nov 2023 19:28:20 -0800 (PST) On 11/15/2023 6:47 PM, David Hildenbrand wrote: > On 15.11.23 11:46, David Hildenbrand wrote: >> On 13.11.23 11:45, Baolin Wang wrote: >>> Currently, the file pages already support large folio, and supporting >>> for >>> anonymous pages is also under discussion[1]. Moreover, the numa >>> balancing >>> code are converted to use a folio by previous thread[2], and the >>> migrate_pages >>> function also already supports the large folio migration. >>> >>> So now I did not see any reason to continue restricting NUMA >>> balancing for >>> large folio. >>> >>> [1] https://lkml.org/lkml/2023/9/29/342 >>> [2] >>> https://lore.kernel.org/all/20230921074417.24004-4-wangkefeng.wang@huawei.com/T/#md9d10fe34587229a72801f0d731f7457ab3f4a6e >>> Signed-off-by: Baolin Wang >>> --- >> >> I'll note that another piece is missing, and I'd be curious how you >> tested your patch set or what I am missing. (no anonymous pages?) I tested it with file large folio (order = 4) created by XFS filesystem. >> change_pte_range() contains: >> >> if (prot_numa) { >>     ... >>     /* Also skip shared copy-on-write pages */ >>     if (is_cow_mapping(vma->vm_flags) && >>         folio_ref_count(folio) != 1) >>         continue; >> >> So we'll never end up mapping an anon PTE-mapped THP prot-none (well, >> unless a >> single PTE remains) and consequently never trigger NUMA hinting faults. >> >> Now, that change has some history [1], but the original problem has been >> sorted out in the meantime. But we should consider Linus' original >> feedback. >> >> For pte-mapped THP, we might want to do something like the following >> (completely untested): Thanks for pointing out. I have not tried pte-mapped THP yet, and will look at it in detail. >> diff --git a/mm/mprotect.c b/mm/mprotect.c >> index 81991102f785..c4e6b9032e40 100644 >> --- a/mm/mprotect.c >> +++ b/mm/mprotect.c >> @@ -129,7 +129,8 @@ static long change_pte_range(struct mmu_gather *tlb, >>                                   /* Also skip shared copy-on-write >> pages */ >>                                   if (is_cow_mapping(vma->vm_flags) && >> -                                   folio_ref_count(folio) != 1) >> +                                   (folio_maybe_dma_pinned(folio) || >> +                                    folio_estimated_sharers(folio) != >> 1)) > > Actually, > 1 might be better if the first subpage is not mapped; it's a > mess. >