From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933811AbdBQL0X (ORCPT ); Fri, 17 Feb 2017 06:26:23 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:52139 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933741AbdBQL0V (ORCPT ); Fri, 17 Feb 2017 06:26:21 -0500 From: Anshuman Khandual To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: mhocko@suse.com, vbabka@suse.cz, mgorman@suse.de, minchan@kernel.org, aneesh.kumar@linux.vnet.ibm.com, bsingharora@gmail.com, srikar@linux.vnet.ibm.com, haren@linux.vnet.ibm.com, jglisse@redhat.com, dave.hansen@intel.com, dan.j.williams@intel.com, zi.yan@cs.rutgers.edu Subject: [PATCH 4/6] mm/migrate: Add new migrate mode MIGRATE_MT Date: Fri, 17 Feb 2017 16:54:51 +0530 X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170217112453.307-1-khandual@linux.vnet.ibm.com> References: <20170217112453.307-1-khandual@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 17021711-0052-0000-0000-00000217CB59 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17021711-0053-0000-0000-000007CBD585 Message-Id: <20170217112453.307-5-khandual@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-02-17_09:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=3 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1612050000 definitions=main-1702170108 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Zi Yan This change adds a new migration mode called MIGRATE_MT to enable multi threaded page copy implementation inside copy_huge_page() function by selectively calling copy_pages_mthread() when requested. But it still falls back using the regular page copy mechanism instead the previous multi threaded attempt fails. It also attempts multi threaded copy for regular pages. Signed-off-by: Zi Yan Signed-off-by: Anshuman Khandual --- include/linux/migrate_mode.h | 1 + mm/migrate.c | 25 ++++++++++++++++++------- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/include/linux/migrate_mode.h b/include/linux/migrate_mode.h index 89c1700..d344ad6 100644 --- a/include/linux/migrate_mode.h +++ b/include/linux/migrate_mode.h @@ -12,6 +12,7 @@ enum migrate_mode { MIGRATE_SYNC_LIGHT = 1<<1, MIGRATE_SYNC = 1<<2, MIGRATE_ST = 1<<3, + MIGRATE_MT = 1<<4, }; #endif /* MIGRATE_MODE_H_INCLUDED */ diff --git a/mm/migrate.c b/mm/migrate.c index 63c3682..6ac3572 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -594,6 +594,7 @@ static void copy_huge_page(struct page *dst, struct page *src, { int i; int nr_pages; + int rc = -EFAULT; if (PageHuge(src)) { /* hugetlbfs page */ @@ -610,10 +611,14 @@ static void copy_huge_page(struct page *dst, struct page *src, nr_pages = hpage_nr_pages(src); } - for (i = 0; i < nr_pages; i++) { - cond_resched(); - copy_highpage(dst + i, src + i); - } + if (mode & MIGRATE_MT) + rc = copy_pages_mthread(dst, src, nr_pages); + + if (rc) + for (i = 0; i < nr_pages; i++) { + cond_resched(); + copy_highpage(dst + i, src + i); + } } /* @@ -624,10 +629,16 @@ void migrate_page_copy(struct page *newpage, struct page *page, { int cpupid; - if (PageHuge(page) || PageTransHuge(page)) + if (PageHuge(page) || PageTransHuge(page)) { copy_huge_page(newpage, page, mode); - else - copy_highpage(newpage, page); + } else { + if (mode & MIGRATE_MT) { + if (copy_pages_mthread(newpage, page, 1)) + copy_highpage(newpage, page); + } else { + copy_highpage(newpage, page); + } + } if (PageError(page)) SetPageError(newpage); -- 2.9.3