From patchwork Fri Nov 13 20:53:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Shi X-Patchwork-Id: 11904563 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4BA44697 for ; Fri, 13 Nov 2020 20:54:23 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id EA2232224D for ; Fri, 13 Nov 2020 20:54:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hNK0lFKC" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EA2232224D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id EF7B26B0073; Fri, 13 Nov 2020 15:54:21 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id EA4E16B0074; Fri, 13 Nov 2020 15:54:21 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D200E6B0075; Fri, 13 Nov 2020 15:54:21 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0091.hostedemail.com [216.40.44.91]) by kanga.kvack.org (Postfix) with ESMTP id 9D83A6B0073 for ; Fri, 13 Nov 2020 15:54:21 -0500 (EST) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 47482181AEF07 for ; Fri, 13 Nov 2020 20:54:21 +0000 (UTC) X-FDA: 77480597922.07.mouth58_0013dd127312 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin07.hostedemail.com (Postfix) with ESMTP id 2F3C31803F9A9 for ; Fri, 13 Nov 2020 20:54:21 +0000 (UTC) X-Spam-Summary: 1,0,0,d21dc6d18fbb8844,d41d8cd98f00b204,shy828301@gmail.com,,RULES_HIT:41:355:379:541:800:960:973:988:989:1202:1260:1311:1314:1345:1359:1437:1515:1535:1542:1711:1730:1747:1777:1792:2198:2199:2393:2559:2562:3138:3139:3140:3141:3142:3353:3865:3867:3868:3870:3871:3872:3874:4037:4250:4321:4605:5007:6117:6119:6120:6261:6653:7514:7901:7903:7974:8957:9413:10004:11026:11473:11658:11914:12043:12048:12296:12297:12438:12517:12519:12555:12895:12986:13161:13229:13894:14096:14181:14687:14721:21060:21080:21444:21627:21666:21990:30003:30054,0,RBL:209.85.210.195:@gmail.com:.lbl8.mailshell.net-66.100.201.100 62.50.0.100;04yftwwbk3uans1j5hsjgw1paiap1ycqbpr9u4d4opxyt1zb5eiowcpzrbpkunm.79go73ot1k8aft3wxgqgoeu3d1ohundfbk86tiy5wuht7r64aak1moadozrcymw.s-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:68,LUA_SUMMARY:none X-HE-Tag: mouth58_0013dd127312 X-Filterd-Recvd-Size: 5327 Received: from mail-pf1-f195.google.com (mail-pf1-f195.google.com [209.85.210.195]) by imf40.hostedemail.com (Postfix) with ESMTP for ; Fri, 13 Nov 2020 20:54:20 +0000 (UTC) Received: by mail-pf1-f195.google.com with SMTP id w14so8638132pfd.7 for ; Fri, 13 Nov 2020 12:54:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=J1P7rD6yvIgCZ2SrjtB9V6g8Qq2F/GDvh/5dKEAS9Os=; b=hNK0lFKC6nrx+tBMO9lk+1vmT9F08322YNvttvN+TBDGtouldHpOscthUXqKDNVHVr 39ysPpyqSm1lDQ93/cayV8KFIA+qKqhyRdhhTSxcUqi8co2gH/vwOPdp/zXd2QHwYUgH S/V1npOa1IuvYQLFjzpZ273DTPRBdw7njr6pv0MHUYyehwq9mgKYnoQFqPg8kEhX5z2f xYbo+wrPYW2GVrqIk4tv9pWoWTsDomBKvMFjQCEPZM+uRCPoXQizEPEPZxwIDl9lMzsO zu/3yGs1KR+vLxypceipMjRyW3flcp1OT4yC+sNZZGJtXwA6o9df/yUtjibB2CuSvKsC cugQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=J1P7rD6yvIgCZ2SrjtB9V6g8Qq2F/GDvh/5dKEAS9Os=; b=X6M3W9wMVpz4sTVEeOVIzn6otJzKtYMHnbi8eWP1F8GzhyLYEIbf+TEkJER7LusfGJ tgsLNyzoNVrlOSbzOD8XSQ3Hgv0sxTADtGE2GMP9/Fc/YauYCiVV/DajjkC43zCWDUhJ taZqgV19n3RX3nNiGX1DDAS6b1DHFiGf4183zDmL6GH/M68hI5ZmyiJn4+47G/HY4UYJ 08CLEhvMuA/eK01PqIv0fmRODzsZ5SO8p4l73XFKcvq6PP6djmRxPdcjSLDpUrVKkbA7 qcMVkZuKtjoKp1fDLbTcqmb3QI/xcfebS0xj3xhCJCHuitfr9maBBeutZC34tMWKGXj7 c7zg== X-Gm-Message-State: AOAM530ujQmh5Y9UK0RRs1m2h0oEbDp9OYpdkQX5N+NQY9xe3a2L5hOv TpAMHsNpqv/Of9eC3WFHgFg= X-Google-Smtp-Source: ABdhPJyvFIGq1ULa6iDB24RGSIbicOzPOjE2He5AGIoNQnd8H5VxYQovwey2oBqWJlwIH2HJQi6RZw== X-Received: by 2002:a63:f951:: with SMTP id q17mr3208392pgk.199.1605300860028; Fri, 13 Nov 2020 12:54:20 -0800 (PST) Received: from localhost.localdomain (c-107-3-138-210.hsd1.ca.comcast.net. [107.3.138.210]) by smtp.gmail.com with ESMTPSA id a18sm3780234pfa.151.2020.11.13.12.54.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Nov 2020 12:54:18 -0800 (PST) From: Yang Shi To: mhocko@suse.com, ziy@nvidia.com, songliubraving@fb.com, mgorman@suse.de, jack@suse.cz, willy@infradead.org, akpm@linux-foundation.org Cc: shy828301@gmail.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [v3 PATCH 3/5] mm: migrate: skip shared exec THP for NUMA balancing Date: Fri, 13 Nov 2020 12:53:57 -0800 Message-Id: <20201113205359.556831-4-shy828301@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201113205359.556831-1-shy828301@gmail.com> References: <20201113205359.556831-1-shy828301@gmail.com> MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: The NUMA balancing skip shared exec base page. Since CONFIG_READ_ONLY_THP_FOR_FS was introduced, there are probably shared exec THP, so skip such THPs for NUMA balancing as well. And Willy's regular filesystem THP support patches could create shared exec THP wven without that config. In addition, the page_is_file_lru() is used to tell if the page is file cache or not, but it filters out shmem page. It sounds like a typical usecase by putting executables in shmem to achieve performance gain via using shmem-THP, so it sounds worth skipping migration for such case too. Signed-off-by: Yang Shi --- mm/migrate.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index d7167f7107bd..18cc1ef0e447 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -2069,6 +2069,17 @@ bool pmd_trans_migrating(pmd_t pmd) return PageLocked(page); } +static inline bool is_shared_exec_page(struct vm_area_struct *vma, + struct page *page) +{ + if (page_mapcount(page) != 1 && + (page_is_file_lru(page) || vma_is_shmem(vma)) && + (vma->vm_flags & VM_EXEC)) + return true; + + return false; +} + /* * Attempt to migrate a misplaced page to the specified destination * node. Caller is expected to have an elevated reference count on @@ -2086,8 +2097,7 @@ int migrate_misplaced_page(struct page *page, struct vm_area_struct *vma, * Don't migrate file pages that are mapped in multiple processes * with execute permissions as they are probably shared libraries. */ - if (page_mapcount(page) != 1 && page_is_file_lru(page) && - (vma->vm_flags & VM_EXEC)) + if (is_shared_exec_page(vma, page)) goto out; /* @@ -2142,6 +2152,9 @@ int migrate_misplaced_transhuge_page(struct mm_struct *mm, int page_lru = page_is_file_lru(page); unsigned long start = address & HPAGE_PMD_MASK; + if (is_shared_exec_page(vma, page)) + goto out; + new_page = alloc_pages_node(node, (GFP_TRANSHUGE_LIGHT | __GFP_THISNODE), HPAGE_PMD_ORDER); @@ -2253,6 +2266,7 @@ int migrate_misplaced_transhuge_page(struct mm_struct *mm, out_unlock: unlock_page(page); +out: put_page(page); return 0; }