Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1385878ybl; Fri, 6 Dec 2019 16:39:35 -0800 (PST) X-Google-Smtp-Source: APXvYqyc1b3wsYeaIIhO8p8Txs62OsMUBBcWpx8zAGdlkRlVqe0GDpPHFkferRyI1KA3GtOxTlr2 X-Received: by 2002:a9d:774e:: with SMTP id t14mr12913489otl.358.1575679175061; Fri, 06 Dec 2019 16:39:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575679175; cv=none; d=google.com; s=arc-20160816; b=S7sQX0s6qDe44M1w/GostoxEwG5TGQiddxuzQxnC9dEaJjLLiMWpzgfIeR8cNKECf6 sVWa51/Lway21e6iLOHB1xNp/AjLCe3hBfJqbnA6dPQs4edfsGCAe9r+CgWOKEJbC6ek 1CtX7PlIPkvFXaK6nL6NaROkOUvagfyUG8VRboWRkmwz8Cf+TUv6a5TQTXAh4KlIiTlR pdX9RfDAjeWByhfmXosc+A/I4THuxiLZbmI5TBSJ7rf8+xiLZey/yk43WH3s2EwFmuGh TSJtI8mLhiPdnZyt28aLq24jv2SrZgrX7e1dSZHOTuBGvXhjTJaeCmCVT8dUvohXkOG/ DMCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=KFPuf+Pz/ScKeXGkS2fIEbfT+VrM5gDgvXP706XhsIc=; b=z4s+YfKl6eEZbr0m44K5d6WZP+o63UcJru326zTkvugEyflAq27dSMlPSXUHPW8xoT AOrVApIDmVl0lrjqEIMiN914pNyHfKbEUBofq4K4IzdO1Ep7vvjQZF+SBiEc28uDeUAY KpjJCGDHzLD459ANBcUQqq//3//FzBWyqSBJTFNdBhK4+/oE600QTlIcOA4UFFZh6L0g q8KzG4vx1HV3qqxRyl2eoFdhln2puyg0q7VM3udVyXEgBNfjq8lDCImY66KoEM1Vi6gg BymqZvRa/l0/L+uirKeRlQSGJSR7UfXK6PgOl7IJcVlK/R0St+WKLaWK8+ljwGNKO/4e w91g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gOYIIK+P; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t11si8023499oib.23.2019.12.06.16.39.23; Fri, 06 Dec 2019 16:39:35 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gOYIIK+P; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726414AbfLGAiz (ORCPT + 99 others); Fri, 6 Dec 2019 19:38:55 -0500 Received: from mail.kernel.org ([198.145.29.99]:39642 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726375AbfLGAiz (ORCPT ); Fri, 6 Dec 2019 19:38:55 -0500 Received: from localhost.localdomain (c-73-231-172-41.hsd1.ca.comcast.net [73.231.172.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 555CC217F4; Sat, 7 Dec 2019 00:38:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1575679134; bh=pXgE5bJzghH5mG4jiwsiWhC/T97HlG8oVxO+qHwaLtg=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=gOYIIK+Pufb0FTzfOJJIZVX9AevjAXpf2Gwym20jWFIoUoXfk+qI9BEPAkynHMXzD lhztH0y2SyYKYFuCX5aS8W70c+aHV3gy47mr2w45LgvIimNT+wDD/PIDRh+rZssSn3 49Wn9C8bzZnwSdoV/p11WeyWl+iMWBjoA6FfKt1A= Date: Fri, 6 Dec 2019 16:38:53 -0800 From: Andrew Morton To: Daniel Axtens Cc: kasan-dev@googlegroups.com, linux-mm@kvack.org, aryabinin@virtuozzo.com, glider@google.com, linux-kernel@vger.kernel.org, dvyukov@google.com, daniel@iogearbox.net, cai@lca.pw Subject: Re: [PATCH 1/3] mm: add apply_to_existing_pages helper Message-Id: <20191206163853.cdeb5dc80a8622fb6323a8d2@linux-foundation.org> In-Reply-To: <20191205140407.1874-1-dja@axtens.net> References: <20191205140407.1874-1-dja@axtens.net> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 6 Dec 2019 01:04:05 +1100 Daniel Axtens wrote: > apply_to_page_range takes an address range, and if any parts of it > are not covered by the existing page table hierarchy, it allocates > memory to fill them in. > > In some use cases, this is not what we want - we want to be able to > operate exclusively on PTEs that are already in the tables. > > Add apply_to_existing_pages for this. Adjust the walker functions > for apply_to_page_range to take 'create', which switches them between > the old and new modes. Wouldn't apply_to_existing_page_range() be a better name? --- a/include/linux/mm.h~mm-add-apply_to_existing_pages-helper-fix-fix +++ a/include/linux/mm.h @@ -2621,9 +2621,9 @@ static inline int vm_fault_to_errno(vm_f typedef int (*pte_fn_t)(pte_t *pte, unsigned long addr, void *data); extern int apply_to_page_range(struct mm_struct *mm, unsigned long address, unsigned long size, pte_fn_t fn, void *data); -extern int apply_to_existing_pages(struct mm_struct *mm, unsigned long address, - unsigned long size, pte_fn_t fn, - void *data); +extern int apply_to_existing_page_range(struct mm_struct *mm, + unsigned long address, unsigned long size, + pte_fn_t fn, void *data); #ifdef CONFIG_PAGE_POISONING extern bool page_poisoning_enabled(void); --- a/mm/memory.c~mm-add-apply_to_existing_pages-helper-fix-fix +++ a/mm/memory.c @@ -2184,12 +2184,12 @@ EXPORT_SYMBOL_GPL(apply_to_page_range); * Unlike apply_to_page_range, this does _not_ fill in page tables * where they are absent. */ -int apply_to_existing_pages(struct mm_struct *mm, unsigned long addr, - unsigned long size, pte_fn_t fn, void *data) +int apply_to_existing_page_range(struct mm_struct *mm, unsigned long addr, + unsigned long size, pte_fn_t fn, void *data) { return __apply_to_page_range(mm, addr, size, fn, data, false); } -EXPORT_SYMBOL_GPL(apply_to_existing_pages); +EXPORT_SYMBOL_GPL(apply_to_existing_page_range); /* * handle_pte_fault chooses page fault handler according to an entry which was _