From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 157E8C433E0 for ; Fri, 10 Jul 2020 06:35:24 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D122F2072E for ; Fri, 10 Jul 2020 06:35:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D122F2072E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 5A2AD6B0006; Fri, 10 Jul 2020 02:35:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 553716B0007; Fri, 10 Jul 2020 02:35:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 442696B0008; Fri, 10 Jul 2020 02:35:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0162.hostedemail.com [216.40.44.162]) by kanga.kvack.org (Postfix) with ESMTP id 2BE3D6B0006 for ; Fri, 10 Jul 2020 02:35:23 -0400 (EDT) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id B020512E8 for ; Fri, 10 Jul 2020 06:35:22 +0000 (UTC) X-FDA: 77021204484.17.hour51_1310fcd26ecc Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin17.hostedemail.com (Postfix) with ESMTP id 72814180D0194 for ; Fri, 10 Jul 2020 06:35:22 +0000 (UTC) X-HE-Tag: hour51_1310fcd26ecc X-Filterd-Recvd-Size: 5490 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by imf36.hostedemail.com (Postfix) with ESMTP for ; Fri, 10 Jul 2020 06:35:21 +0000 (UTC) Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 06A6WFYu068012; Fri, 10 Jul 2020 02:35:20 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 326bpk9pvm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Jul 2020 02:35:19 -0400 Received: from m0098410.ppops.net (m0098410.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 06A6ZCY2083047; Fri, 10 Jul 2020 02:35:19 -0400 Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0a-001b2d01.pphosted.com with ESMTP id 326bpk9put-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Jul 2020 02:35:19 -0400 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 06A6RTVO028249; Fri, 10 Jul 2020 06:35:17 GMT Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by ppma06ams.nl.ibm.com with ESMTP id 326bahrb5k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Jul 2020 06:35:16 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 06A6ZE2d57213088 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 10 Jul 2020 06:35:14 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 44EEC4C04E; Fri, 10 Jul 2020 06:35:14 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4D1DC4C046; Fri, 10 Jul 2020 06:35:12 +0000 (GMT) Received: from in.ibm.com (unknown [9.199.35.16]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Fri, 10 Jul 2020 06:35:12 +0000 (GMT) Date: Fri, 10 Jul 2020 12:05:09 +0530 From: Bharata B Rao To: Ralph Campbell Cc: linux-mm@kvack.org, kvm-ppc@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Jerome Glisse , John Hubbard , Christoph Hellwig , Jason Gunthorpe , Shuah Khan , Andrew Morton Subject: Re: [PATCH 1/2] mm/migrate: optimize migrate_vma_setup() for holes Message-ID: <20200710063509.GE7902@in.ibm.com> Reply-To: bharata@linux.ibm.com References: <20200709165711.26584-1-rcampbell@nvidia.com> <20200709165711.26584-2-rcampbell@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200709165711.26584-2-rcampbell@nvidia.com> X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235,18.0.687 definitions=2020-07-10_01:2020-07-09,2020-07-10 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 phishscore=0 lowpriorityscore=0 clxscore=1015 priorityscore=1501 bulkscore=0 impostorscore=0 mlxscore=0 mlxlogscore=612 spamscore=0 malwarescore=0 suspectscore=1 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007100040 X-Rspamd-Queue-Id: 72814180D0194 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 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: On Thu, Jul 09, 2020 at 09:57:10AM -0700, Ralph Campbell wrote: > When migrating system memory to device private memory, if the source > address range is a valid VMA range and there is no memory or a zero page, > the source PFN array is marked as valid but with no PFN. This lets the > device driver allocate private memory and clear it, then insert the new > device private struct page into the CPU's page tables when > migrate_vma_pages() is called. migrate_vma_pages() only inserts the > new page if the VMA is an anonymous range. There is no point in telling > the device driver to allocate device private memory and then not migrate > the page. Instead, mark the source PFN array entries as not migrating to > avoid this overhead. > > Signed-off-by: Ralph Campbell > --- > mm/migrate.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/mm/migrate.c b/mm/migrate.c > index b0125c082549..8aa434691577 100644 > --- a/mm/migrate.c > +++ b/mm/migrate.c > @@ -2204,9 +2204,13 @@ static int migrate_vma_collect_hole(unsigned long start, > { > struct migrate_vma *migrate = walk->private; > unsigned long addr; > + unsigned long flags; > + > + /* Only allow populating anonymous memory. */ > + flags = vma_is_anonymous(walk->vma) ? MIGRATE_PFN_MIGRATE : 0; > > for (addr = start; addr < end; addr += PAGE_SIZE) { > - migrate->src[migrate->npages] = MIGRATE_PFN_MIGRATE; > + migrate->src[migrate->npages] = flags; I see a few other such cases where we directly populate MIGRATE_PFN_MIGRATE w/o a pfn in migrate_vma_collect_pmd() and wonder why the vma_is_anonymous() check can't help there as well? 1. pte_none() check in migrate_vma_collect_pmd() 2. is_zero_pfn() check in migrate_vma_collect_pmd() Regards, Bharata.