From patchwork Wed Sep 30 17:51:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11810007 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 67235618 for ; Wed, 30 Sep 2020 17:53:27 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3837920706 for ; Wed, 30 Sep 2020 17:53:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="YkJ+uCPt" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3837920706 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.856.2939 (Exim 4.92) (envelope-from ) id 1kNgGw-0005Vg-Eb; Wed, 30 Sep 2020 17:52:10 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 856.2939; Wed, 30 Sep 2020 17:52:10 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kNgGw-0005VY-BN; Wed, 30 Sep 2020 17:52:10 +0000 Received: by outflank-mailman (input) for mailman id 856; Wed, 30 Sep 2020 17:52:08 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kNgGu-0005QF-OW for xen-devel@lists.xenproject.org; Wed, 30 Sep 2020 17:52:08 +0000 Received: from casper.infradead.org (unknown [2001:8b0:10b:1236::1]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 6611b02e-7acd-4bbd-82b9-86ba6f155f72; Wed, 30 Sep 2020 17:51:56 +0000 (UTC) Received: from [2001:4bb8:180:7b62:c70:4a89:bc61:4] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1kNgGS-0001C3-Jg; Wed, 30 Sep 2020 17:51:41 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kNgGu-0005QF-OW for xen-devel@lists.xenproject.org; Wed, 30 Sep 2020 17:52:08 +0000 X-Inumbo-ID: 6611b02e-7acd-4bbd-82b9-86ba6f155f72 Received: from casper.infradead.org (unknown [2001:8b0:10b:1236::1]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 6611b02e-7acd-4bbd-82b9-86ba6f155f72; Wed, 30 Sep 2020 17:51:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=/d6+Dk3KKsbjd+NK9IaRJO1MZ62p/5JmeyWovJ8r20c=; b=YkJ+uCPtqA1Td8zeKp//6WB4ex 2L7PhMeNNVChodci0VbKBYP/+QMdhLPZmUoFLFcWhehk7/nZO4O/VTTSj/QJlXD0APsmA6FpQr4K0 tySIUrS8BaaMaf2oLTkKi08nizfzKbfYWDmfJuahykiGnY6uF1SWzgQhXSGFIrEcoECNAmcOt43oz 6M55bJ9RMrTV6WBCPR+ciE5DFex6s6zi/bRyqqcbzrY4leTjDRFayj4JdF7yAaOvbAQ7YEkqfeI/W PkxY3VTS6b0FSlKz4CAebXcFshlnG6UuA9qZWLczS1dJqPlXeEZkAYKr+VvP9KJpwM8OvPSsRsxpP lPs56omQ==; Received: from [2001:4bb8:180:7b62:c70:4a89:bc61:4] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1kNgGS-0001C3-Jg; Wed, 30 Sep 2020 17:51:41 +0000 From: Christoph Hellwig To: Andrew Morton Cc: Peter Zijlstra , Boris Ostrovsky , Juergen Gross , Stefano Stabellini , Jani Nikula , Joonas Lahtinen , Tvrtko Ursulin , Chris Wilson , Matthew Auld , Rodrigo Vivi , Minchan Kim , Matthew Wilcox , Nitin Gupta , x86@kernel.org, xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-mm@kvack.org Subject: [PATCH 04/10] mm: allow a NULL fn callback in apply_to_page_range Date: Wed, 30 Sep 2020 19:51:27 +0200 Message-Id: <20200930175133.1252382-5-hch@lst.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200930175133.1252382-1-hch@lst.de> References: <20200930175133.1252382-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Besides calling the callback on each page, apply_to_page_range also has the effect of pre-faulting all PTEs for the range. To support callers that only need the pre-faulting, make the callback optional. Based on a patch from Minchan Kim . Signed-off-by: Christoph Hellwig --- mm/memory.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index fcfc4ca36eba80..dcf2bb69fbf847 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -2420,13 +2420,15 @@ static int apply_to_pte_range(struct mm_struct *mm, pmd_t *pmd, arch_enter_lazy_mmu_mode(); - do { - if (create || !pte_none(*pte)) { - err = fn(pte++, addr, data); - if (err) - break; - } - } while (addr += PAGE_SIZE, addr != end); + if (fn) { + do { + if (create || !pte_none(*pte)) { + err = fn(pte++, addr, data); + if (err) + break; + } + } while (addr += PAGE_SIZE, addr != end); + } *mask |= PGTBL_PTE_MODIFIED; arch_leave_lazy_mmu_mode();