From patchwork Tue Nov 10 18:12:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Shi X-Patchwork-Id: 11895009 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 D9AC616C1 for ; Tue, 10 Nov 2020 18:13:11 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 742F420674 for ; Tue, 10 Nov 2020 18:13:11 +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="rMAhKmz2" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 742F420674 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 D267C6B0070; Tue, 10 Nov 2020 13:13:09 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id CFEA66B0071; Tue, 10 Nov 2020 13:13:09 -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 B9C5A6B0072; Tue, 10 Nov 2020 13:13:09 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0145.hostedemail.com [216.40.44.145]) by kanga.kvack.org (Postfix) with ESMTP id 8ECBF6B0070 for ; Tue, 10 Nov 2020 13:13:09 -0500 (EST) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 2F7FB1EE6 for ; Tue, 10 Nov 2020 18:13:09 +0000 (UTC) X-FDA: 77469305298.15.tramp01_3e0f4eb272f7 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin15.hostedemail.com (Postfix) with ESMTP id EAFAC1814B0C9 for ; Tue, 10 Nov 2020 18:13:08 +0000 (UTC) X-Spam-Summary: 1,0,0,6c1f8cc221274ced,d41d8cd98f00b204,shy828301@gmail.com,,RULES_HIT:41:355:379:541:800:960:973:988:989:1202:1260:1311:1314:1345:1359:1437:1515:1534:1541:1711:1730:1747:1777:1792:2198:2199:2393:2559:2562:3138:3139:3140:3141:3142:3353:3865:3867:3870:3871:3874:4250:4321:4605:5007:6117:6120:6261:6653:7514:7901:8957:9413:10004:11026:11473:11658:11914:12043:12048:12296:12297:12438:12517:12519:12555:12895:13069:13161:13229:13311:13357:13894:14096:14181:14384:14687:14721:21060:21080:21444:21627:21666:21990:30003:30054,0,RBL:209.85.210.194:@gmail.com:.lbl8.mailshell.net-66.100.201.100 62.50.0.100;04yg7tszyiqpzx9zbq7dp89krapepyczeducy9pk9kweccos78byg8pismiozuz.njyczmjtg995eny3qxrr5rt1r8f6199c6uf4b3e5tes71pgwxb8ump99wofcthi.n-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:69,LUA_SUMMARY:none X-HE-Tag: tramp01_3e0f4eb272f7 X-Filterd-Recvd-Size: 4920 Received: from mail-pf1-f194.google.com (mail-pf1-f194.google.com [209.85.210.194]) by imf33.hostedemail.com (Postfix) with ESMTP for ; Tue, 10 Nov 2020 18:13:08 +0000 (UTC) Received: by mail-pf1-f194.google.com with SMTP id 10so12172151pfp.5 for ; Tue, 10 Nov 2020 10:13:08 -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=wzTkN8x60Q0XiW8/C8IsngN4jAgjA+AlmtZ3C3KQcFM=; b=rMAhKmz2stnt0OpVWI6QWLFxn/frb0pncgv+GV3PkKEKdC+qq81GLDHnQj6s1cISfg 7tbs7uTQ7qP5lVTVOMNcs7we8EfQ9a3knrthROKacF0iCS4pF5XeFxgbZrDpG8WuXErQ 61lolt0ZG+qJjRyqn7pVHenNxdszmg4JizQFfiYEsf3resqysh/T7Hw7BXC23CGH6PPE fD0VeNXrPG3mvJAvqsxEpTn7g3M5I+C7F5IIMgL2CPmB6XW0lSkgRzlvEh7fB0whTsLx lr0StdAwIW5GEkh49kanqDjL6T8B8amgBl+wMBHMQJpHjzLb8rdWIJaJMRL/UP4QFt+O BGiw== 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=wzTkN8x60Q0XiW8/C8IsngN4jAgjA+AlmtZ3C3KQcFM=; b=rIuIZCc+x1nl9ibiS+HVWamSJg1DiorYGrIcwfps5oGZbV+VOa5yhqiUzCCO4dvnlQ fUMo0+P5kkXA3kc7Cv2epD4LtEgl1tN/7uaadBZIJqZRmHAnBRLCfCa6/bh07wU2jqGB PllRsCMEwRNyDAwMgHkraToMZnVifBNwDDvn6zUhtKvDISDoDYE6aBU4NBzc8OqDkoFW qjOWJU/idj9HLVAEf50RwkIjjtwy4KCnpAuJKD4YAJBELSGrOBpilp0JtNQ+duzDYob4 TOfrXRBMofblW6zqRd83iraNrHjbvXyoMMZ7wSrxzjbJR1Z/8uXl0NkbMlZ2UNjVvoEj Gi6g== X-Gm-Message-State: AOAM533YVkKKkTGve+PjIjB6rMpXxoEm9oE1X2cZthBRRFuTnlbo2r5J O1xGtdqjK/RHk+DHTc6hAV4= X-Google-Smtp-Source: ABdhPJz9D38r5ZlM0UCBJXLFJsDSccwf+fHgs+pPgH8XmWGxY4AeJC3hVCEadRPQImntasuJMlolaw== X-Received: by 2002:a17:90a:df8f:: with SMTP id p15mr367490pjv.29.1605031987645; Tue, 10 Nov 2020 10:13:07 -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 k5sm4157369pjj.37.2020.11.10.10.13.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Nov 2020 10:13:06 -0800 (PST) From: Yang Shi To: mhocko@suse.com, ziy@nvidia.com, songliubraving@fb.com, mgorman@suse.de, jack@suse.cz, akpm@linux-foundation.org Cc: shy828301@gmail.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [v2 PATCH 3/5] mm: migrate: skip shared exec THP for NUMA balancing Date: Tue, 10 Nov 2020 10:12:48 -0800 Message-Id: <20201110181250.264394-4-shy828301@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201110181250.264394-1-shy828301@gmail.com> References: <20201110181250.264394-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. 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..1b103e801fe4 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -2069,6 +2069,16 @@ 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->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 +2096,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 +2151,10 @@ 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_ENABLED(CONFIG_READ_ONLY_THP_FOR_FS) && + 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; }