From patchwork Mon Nov 13 10:45:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolin Wang X-Patchwork-Id: 164402 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b909:0:b0:403:3b70:6f57 with SMTP id t9csp1118265vqg; Mon, 13 Nov 2023 02:47:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IHaVUJuOcArbpY9OBeUxYd8vZ6oZONgAVhuvMMGfP94b4e/qkou/jAiINuNstyFvU9Zl6Ws X-Received: by 2002:a05:6808:211b:b0:3a7:b011:8960 with SMTP id r27-20020a056808211b00b003a7b0118960mr9106301oiw.40.1699872439397; Mon, 13 Nov 2023 02:47:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699872439; cv=none; d=google.com; s=arc-20160816; b=vNBdbQWPayvgh/h3Xeszb9aTNMnWVICDzPsc4bG6iYS9nknbDIHfuPtwGU4f+p/MY0 RuTfrrCQtG97fg/91R6PV2q39R5hBAHe19ljlVUOY9cMLgRvCBw8X5A+BjJ6+K7y8Ich fqU3a0VeVG7kh2PhNVLL5vc+0cQRHHPSTWvQOCVEvXcDvwxZ3/983UzBJOiZvYHF0FmJ oPBCFU9vDRHKs0Ibiv2Ga093uamAzu2YI3GqDrHc/Z04H5pxH/qk46FHWGRukyyDi3l/ BwXDS42nEPsfRbyo5iCl6W6OS+Cw3TZIvv5l1bKSrg94iqlwF8EeaZw8EnhWsDwMBGOM XC/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=EJuCvPTt7gsmjc4lzpZPE+QeHWhhLBf2a1LKQN43V5E=; fh=4tqgNFNfoZov83pY26LoG87h5J0r0CHhWc2zkUlKGnQ=; b=yB89egYc179cxuHd10dgPVCiSlHofnyVpqjwjeaY6qSVykq0lz+xo64CzBLDBouW6+ s4OCQlzL7VacdW8BWNZ9u6LbmnOvS8bUDB0ojqIELKQplb935evXzwef3WxnnWerrjkM Op4tO/28c2WK2V+8ZpiTgBrh+q2xa1Q2aX+eO/2gjPf8WZEegzACkYmYqTUDwgk8c2t1 bdX8m0qy8oRF3fpGOcEH/156V80sWmxvwQG5mftd9bqJGzd/Syk+rnlKFzUKM9AaHlFE avE0iBiqtb9WePbPjeohoSOvrVUs0HRiN3jsyP4LaaY6HN0RBD3snMmo+52kIPH+enRX A5Ug== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id b26-20020a63715a000000b005c1ae100435si26802pgn.34.2023.11.13.02.47.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Nov 2023 02:47:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id E58A38068965; Mon, 13 Nov 2023 02:46:09 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229470AbjKMKpx (ORCPT + 29 others); Mon, 13 Nov 2023 05:45:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229462AbjKMKpu (ORCPT ); Mon, 13 Nov 2023 05:45:50 -0500 Received: from out30-124.freemail.mail.aliyun.com (out30-124.freemail.mail.aliyun.com [115.124.30.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF1E210CE for ; Mon, 13 Nov 2023 02:45:46 -0800 (PST) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R161e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046050;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=8;SR=0;TI=SMTPD_---0VwJPEby_1699872343; Received: from localhost(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0VwJPEby_1699872343) by smtp.aliyun-inc.com; Mon, 13 Nov 2023 18:45:44 +0800 From: Baolin Wang To: akpm@linux-foundation.org Cc: david@redhat.com, ying.huang@intel.com, wangkefeng.wang@huawei.com, willy@infradead.org, baolin.wang@linux.alibaba.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH] mm: support large folio numa balancing Date: Mon, 13 Nov 2023 18:45:31 +0800 Message-Id: X-Mailer: git-send-email 2.39.3 MIME-Version: 1.0 X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Mon, 13 Nov 2023 02:46:09 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782445443322140554 X-GMAIL-MSGID: 1782445443322140554 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 --- mm/memory.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index c32954e16b28..8ca21eff294c 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -4804,7 +4804,7 @@ static vm_fault_t do_numa_page(struct vm_fault *vmf) int last_cpupid; int target_nid; pte_t pte, old_pte; - int flags = 0; + int flags = 0, nr_pages = 0; /* * The "pte" at this point cannot be used safely without @@ -4834,10 +4834,6 @@ static vm_fault_t do_numa_page(struct vm_fault *vmf) if (!folio || folio_is_zone_device(folio)) goto out_map; - /* TODO: handle PTE-mapped THP */ - if (folio_test_large(folio)) - goto out_map; - /* * Avoid grouping on RO pages in general. RO pages shouldn't hurt as * much anyway since they can be in shared cache state. This misses @@ -4857,6 +4853,7 @@ static vm_fault_t do_numa_page(struct vm_fault *vmf) flags |= TNF_SHARED; nid = folio_nid(folio); + nr_pages = folio_nr_pages(folio); /* * For memory tiering mode, cpupid of slow memory page is used * to record page access time. So use default value. @@ -4893,7 +4890,7 @@ static vm_fault_t do_numa_page(struct vm_fault *vmf) out: if (nid != NUMA_NO_NODE) - task_numa_fault(last_cpupid, nid, 1, flags); + task_numa_fault(last_cpupid, nid, nr_pages, flags); return 0; out_map: /*