From patchwork Tue Nov 3 13:03:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Shi X-Patchwork-Id: 11885097 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 26BC6697 for ; Thu, 5 Nov 2020 20:53:52 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B029020724 for ; Thu, 5 Nov 2020 20:53:51 +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="N04RTqwe" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B029020724 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 67E336B0196; Thu, 5 Nov 2020 15:53:50 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 62CC36B0197; Thu, 5 Nov 2020 15:53:50 -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 4854C6B0198; Thu, 5 Nov 2020 15:53:50 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0074.hostedemail.com [216.40.44.74]) by kanga.kvack.org (Postfix) with ESMTP id 1588D6B0196 for ; Thu, 5 Nov 2020 15:53:50 -0500 (EST) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id AFE73180AD806 for ; Thu, 5 Nov 2020 20:53:49 +0000 (UTC) X-FDA: 77451566178.15.hole76_48122ee272cc Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin15.hostedemail.com (Postfix) with ESMTP id 88F151814B0C1 for ; Thu, 5 Nov 2020 20:53:49 +0000 (UTC) X-Spam-Summary: 1,0,0,3c31ed50dcd597fd,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:14394:14687:14721:21060:21080:21444:21627:21666:21990:30003:30054,0,RBL:209.85.215.193:@gmail.com:.lbl8.mailshell.net-66.100.201.100 62.50.0.100;04yfe96y89se14z5xhcjyk6qbr8a7oczeducy9pk9kweccos78byg8pismiozuz.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:68,LUA_SUMMARY:none X-HE-Tag: hole76_48122ee272cc X-Filterd-Recvd-Size: 4924 Received: from mail-pg1-f193.google.com (mail-pg1-f193.google.com [209.85.215.193]) by imf23.hostedemail.com (Postfix) with ESMTP for ; Thu, 5 Nov 2020 20:53:49 +0000 (UTC) Received: by mail-pg1-f193.google.com with SMTP id h6so2188725pgk.4 for ; Thu, 05 Nov 2020 12:53:48 -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=/qtr9tzhjtOBdYsDnn5cndcKy8GoT20c7Eybegwt5Kk=; b=N04RTqweYUFrqnV9gmhke51hG75fIh7p4gQzA6MwJPqIaC2mKQ3CzsQEx5z/IzCjDz G4QkNnM1CeDqPXGZj4jywlCmDW5xVx5pMSVWwTLvQ+ZAcKxkQv9IifxUEDqB+bh6hQ3s PSTC4hO6cT2myU0l+PJTqeO9OED2FCBWf1yF5Jj9cZCvFzxUHPcqtdFwxyswwJLPmC2R 0P3Y/mVDtvDQrgA2g/rnAxnc9TKfeRmSrpuI0DC2peCMtkQk+9XI7N6fpAGKAD2gIBtk fhXl4UxagPZgmvJdhghG8XDXVhrSBIIXC6fcG4Xp4u6QGWT1bKsp8fJ56OobRzWwICvs r4gA== 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=/qtr9tzhjtOBdYsDnn5cndcKy8GoT20c7Eybegwt5Kk=; b=s7vechp8uxCk2peeZV+ZPP2XCfPl0KrQgSOEdpMJjPNA/bn0YBuZ0FbUDlFrQam04a Rubvf5Zagk7u+Bhu5/qCULy7Syf5dRN6WVwEele+fjofVUjqsQo5uELqAQh7JmsRn26q 9lYH8k/OPavd2t6RGC5a7odU+k6mV1H92nNYGBk8qbCNXJN/Mjr5POwPpIvL61IDzRpB 4DKgBw3afEsgnwXLkxwlKUGqWF1BqeBFdMlfSNRe/apmj6wH/p6THNPDVL1N0lpDcPiD SDtpRHNKfjyeZCZDrIPlHnVWrg3cOYSu8jOLJ1WlF8GEv9JwKGh79hfi6+M00C0642KZ yswA== X-Gm-Message-State: AOAM532vSSu8R/Xa8uM8VwALAV57XVaZ5xLYgHSVtsJbsAEqbWsq4zE0 o7jYChQUVk79cly2sjGBmQJgrwN0uosJlg== X-Google-Smtp-Source: ABdhPJyU8XB5H0ovDjvdw4jXwbLqGN5AhkJzXvc3653T26+Rg5FqPVlkgLslhxXhoXQoKSONpx8lxA== X-Received: by 2002:a63:4866:: with SMTP id x38mr3994157pgk.228.1604609628372; Thu, 05 Nov 2020 12:53:48 -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 u22sm3265528pgf.24.2020.11.05.12.53.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2020 12:53:47 -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: [PATCH 3/5] mm: migrate: skip shared exec THP for NUMA balancing Date: Tue, 3 Nov 2020 05:03:32 -0800 Message-Id: <20201103130334.13468-4-shy828301@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201103130334.13468-1-shy828301@gmail.com> References: <20201103130334.13468-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 c33c92495ead..9a32bb128f31 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -2061,6 +2061,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 @@ -2078,8 +2088,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; /* @@ -2134,6 +2143,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); @@ -2245,6 +2258,7 @@ int migrate_misplaced_transhuge_page(struct mm_struct *mm, out_unlock: unlock_page(page); +out: put_page(page); return 0; }