Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp342198pxk; Thu, 24 Sep 2020 07:01:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz8DUWkH+HxEiIeNFjdEelTGUZNwSBfXqcE02mIAw3GUt7ZyPpvgzhDx+mtBqFwVIk1G838 X-Received: by 2002:aa7:d04d:: with SMTP id n13mr28531edo.354.1600956073357; Thu, 24 Sep 2020 07:01:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600956073; cv=none; d=google.com; s=arc-20160816; b=ca0VsWwV3kyfz5N7wGqcpOoQ9PY6RO0hd/fowKh0HF4USpUFZxRfMnWzTZ4bOK/4B/ F/l3XCc+5oTzUsKYmEHyYoDXm28GAgGpVGYnPQeCIZ846YFxlQPpc0+gB5T2xWUhJ4bK z+FMEYpX1cboOhiQTCYrf0ZiofCR5Yz6PDuA0NJ65B7D37ItJm6bN/weUQM9tr/St98Z Y0pqn5gM2pSaIFFoD44D4jd4pruG/KUneVh589uok9+1P/WMHx2Fo33R2dl+pvJscCAG X4eqcc6+TIz9awDqTYm+I/IoGWHPWjHZT7XTkR8k4Hk0EVZjXcigfR1Sqfj7QZtiII/g BQIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=UWYn4Nj1UDYUydETnuqo3HBArWRG9IThEGqk2ovW3VY=; b=zUraGoCOWCIpg5sVHcfD3dezECOpC9VIX+fTW4Nde1u/9PUD82AnVQ+VAZsjtGycjt UtOTOmM5NtiC+5ljz5gwVNEwWDY5U/VJEyE+TdiYs3qkfYlP3oNpxstxD732JFQ6UalB GiN6/tnObIHZwmF/huJ3w+i7lezNwZO2c3Uiuuv9fn4AjlVK9JYzUsNAKnDhl4c6tNGH xrw5h+V00Sr9DmaN1Pp/71X12a1mokKHsEthQQM9AQ3vFXgDn4zzHZuuib5qS7hUs+Sq hgGpaFKfEuCp9pUJxkQLDn/5jTqV0fj/nj8rXEHEoTHNoYymqnp1XcSMr7eO1kjgmpXW khIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=TvZtpxPO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p11si1566008eja.34.2020.09.24.07.00.42; Thu, 24 Sep 2020 07:01:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=TvZtpxPO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728191AbgIXN7Y (ORCPT + 99 others); Thu, 24 Sep 2020 09:59:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727970AbgIXN7Q (ORCPT ); Thu, 24 Sep 2020 09:59:16 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69196C0613CE for ; Thu, 24 Sep 2020 06:59:16 -0700 (PDT) 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=UWYn4Nj1UDYUydETnuqo3HBArWRG9IThEGqk2ovW3VY=; b=TvZtpxPOZCFUh4PI7qnzVJeNGD bhPYLwAeN/vXPcxGQpRnhRk49qWu22f+ZFmvyyyxmDLbK6EfC3SA44P+coCfczuEdWylHw4x4g7h4 JTtyRHJPuvGq8DMzaeQ6qjal6a4KlnXT5PCHxCz+lkem/GJjTXQTjZ9Yf5NkiZFTFXZIKGJ1mTAoG eHJLyYtEgwHGsaswedTRA0CGz7/0iXCBLZyLsx8624XtfKmusp2n221qrAgtVtc4GrCZp1tmy5FfO CY57PLHtO0HMT5NghXvHOsoqfgmBBkenquNKp9xe9KQuDg+F2dG0hWvWf8ln/kEjNCia/Bk/7noAR GDN6H8EQ==; Received: from p4fdb0c34.dip0.t-ipconnect.de ([79.219.12.52] helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1kLRly-0003vJ-PO; Thu, 24 Sep 2020 13:58:59 +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/11] mm: allow a NULL fn callback in apply_to_page_range Date: Thu, 24 Sep 2020 15:58:46 +0200 Message-Id: <20200924135853.875294-5-hch@lst.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200924135853.875294-1-hch@lst.de> References: <20200924135853.875294-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 469af373ae76e1..a60136046d7fcc 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -2231,13 +2231,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(); -- 2.28.0