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=-9.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 69149C43331 for ; Tue, 24 Mar 2020 01:15:17 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0F6C32070A for ; Tue, 24 Mar 2020 01:15:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="RoM/tzGF" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0F6C32070A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id E81506B0071; Mon, 23 Mar 2020 21:15:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DE41D6B0073; Mon, 23 Mar 2020 21:15:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CD34C6B0078; Mon, 23 Mar 2020 21:15:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0177.hostedemail.com [216.40.44.177]) by kanga.kvack.org (Postfix) with ESMTP id B3C3B6B0071 for ; Mon, 23 Mar 2020 21:15:13 -0400 (EDT) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 93E66BDE00 for ; Tue, 24 Mar 2020 01:15:13 +0000 (UTC) X-FDA: 76628487306.11.cakes36_4aa87ec932c54 X-HE-Tag: cakes36_4aa87ec932c54 X-Filterd-Recvd-Size: 12033 Received: from mail-qt1-f175.google.com (mail-qt1-f175.google.com [209.85.160.175]) by imf48.hostedemail.com (Postfix) with ESMTP for ; Tue, 24 Mar 2020 01:15:12 +0000 (UTC) Received: by mail-qt1-f175.google.com with SMTP id c9so6716951qtw.7 for ; Mon, 23 Mar 2020 18:15:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=V1IgTDmslkV/D1CqLLp/7w94tK/gghqP4j2p3uIw/xU=; b=RoM/tzGFA5ED2yXIEDyLh3I5kBEf3ZNyQDZNe59jeBLgXfeXpmuHUHZBUZiLIZANVj aqi6GiciKWpBXzWNErSLcL/51cL+7wq/XbsjYzdgXh4NEgifRLSdRVCEv6IQ8ovcYsJQ VxJLcdrQAVlW8PcNm9SXoTd3sUs9Ylc4zdLVHxLohBHNze8v+Ngp2T15BlDb9jLJWM+c h/FefIU/pwV3xwp+D7ybRk4OMcxoDAx+kTj/DBXKyazLeumE/yJm66W0S3IuCt/98QOw Y1tITuHzZP06NxBTPitWYr7xfyJHtLSwb19ptMh79tElXPYLbe5PGd6XrA8eM/MwcNPR cmUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=V1IgTDmslkV/D1CqLLp/7w94tK/gghqP4j2p3uIw/xU=; b=cgcJMEr08Ct3v9T7n1ziBHWQYSxmXkAlh9RpmhN0kdTotksE8TPt71g0FyXCJlry00 4Ph9tFmdAxGWXnyNYgOxR8dHYc2G05A9QrBKIEi5jZvTnpGEZVXlBew+5u5Kz4M7ARwC 2BbvmngnWm/fK5kLx+0xHUOFj/ikC1jDNCAaIse2GidMYp39Sc2Xvn+T5nZvesfsIZuL H9l5ULUQr5ozwZaH0+w3v7PbthFBJ3rZZm85dv1KcBOGTkJECRtvL1bBmxuNX0ZrgtNA k6yc5MoRVYpV8M2O70Ww4h4GRwU/vXEuGJl/h7kgtdpwT6FQQTo/tB0/e67h6J83xQvp JuAQ== X-Gm-Message-State: ANhLgQ2ryQO3zPJJHKVKufE400UFvUS6GULxSapdl84RlB6lquWX0Tq/ 3qIAuPJPmaGwaB5Omq6cYWPoJw== X-Google-Smtp-Source: ADFU+vvVg6zpq1wS6Q/R9N/Ff9hbXPMDDRJM2yCjU/ohHi3AiuZa6ZEErM6AFdhzdmfmbvy2d3WTyA== X-Received: by 2002:aed:31c1:: with SMTP id 59mr18789590qth.370.1585012512050; Mon, 23 Mar 2020 18:15:12 -0700 (PDT) Received: from ziepe.ca (hlfxns017vw-142-68-57-212.dhcp-dynamic.fibreop.ns.bellaliant.net. [142.68.57.212]) by smtp.gmail.com with ESMTPSA id s63sm3538860qkh.64.2020.03.23.18.15.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Mar 2020 18:15:10 -0700 (PDT) Received: from jgg by mlx.ziepe.ca with local (Exim 4.90_1) (envelope-from ) id 1jGY9u-0000r0-5O; Mon, 23 Mar 2020 22:15:10 -0300 From: Jason Gunthorpe To: Jerome Glisse , Ralph Campbell , Felix.Kuehling@amd.com Cc: linux-mm@kvack.org, John Hubbard , dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, Christoph Hellwig , Philip Yang , Jason Gunthorpe Subject: [PATCH v2 hmm 3/9] mm/hmm: remove unused code and tidy comments Date: Mon, 23 Mar 2020 22:14:51 -0300 Message-Id: <20200324011457.2817-4-jgg@ziepe.ca> X-Mailer: git-send-email 2.25.2 In-Reply-To: <20200324011457.2817-1-jgg@ziepe.ca> References: <20200324011457.2817-1-jgg@ziepe.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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: From: Jason Gunthorpe Delete several functions that are never called, fix some desync between comments and structure content, toss the now out of date top of file header, and move one function only used by hmm.c into hmm.c Signed-off-by: Jason Gunthorpe --- include/linux/hmm.h | 104 +------------------------------------------- mm/hmm.c | 24 +++++++--- 2 files changed, 19 insertions(+), 109 deletions(-) diff --git a/include/linux/hmm.h b/include/linux/hmm.h index bb6be4428633a8..daee6508a3f609 100644 --- a/include/linux/hmm.h +++ b/include/linux/hmm.h @@ -3,58 +3,8 @@ * Copyright 2013 Red Hat Inc. * * Authors: J=C3=A9r=C3=B4me Glisse - */ -/* - * Heterogeneous Memory Management (HMM) - * - * See Documentation/vm/hmm.rst for reasons and overview of what HMM is = and it - * is for. Here we focus on the HMM API description, with some explanati= on of - * the underlying implementation. - * - * Short description: HMM provides a set of helpers to share a virtual a= ddress - * space between CPU and a device, so that the device can access any val= id - * address of the process (while still obeying memory protection). HMM a= lso - * provides helpers to migrate process memory to device memory, and back= . Each - * set of functionality (address space mirroring, and migration to and f= rom - * device memory) can be used independently of the other. - * - * - * HMM address space mirroring API: - * - * Use HMM address space mirroring if you want to mirror a range of the = CPU - * page tables of a process into a device page table. Here, "mirror" mea= ns "keep - * synchronized". Prerequisites: the device must provide the ability to = write- - * protect its page tables (at PAGE_SIZE granularity), and must be able = to - * recover from the resulting potential page faults. * - * HMM guarantees that at any point in time, a given virtual address poi= nts to - * either the same memory in both CPU and device page tables (that is: C= PU and - * device page tables each point to the same pages), or that one page ta= ble (CPU - * or device) points to no entry, while the other still points to the ol= d page - * for the address. The latter case happens when the CPU page table upda= te - * happens first, and then the update is mirrored over to the device pag= e table. - * This does not cause any issue, because the CPU page table cannot star= t - * pointing to a new page until the device page table is invalidated. - * - * HMM uses mmu_notifiers to monitor the CPU page tables, and forwards a= ny - * updates to each device driver that has registered a mirror. It also p= rovides - * some API calls to help with taking a snapshot of the CPU page table, = and to - * synchronize with any updates that might happen concurrently. - * - * - * HMM migration to and from device memory: - * - * HMM provides a set of helpers to hotplug device memory as ZONE_DEVICE= , with - * a new MEMORY_DEVICE_PRIVATE type. This provides a struct page for eac= h page - * of the device memory, and allows the device driver to manage its memo= ry - * using those struct pages. Having struct pages for device memory makes - * migration easier. Because that memory is not addressable by the CPU i= t must - * never be pinned to the device; in other words, any CPU page fault can= always - * cause the device memory to be migrated (copied/moved) back to regular= memory. - * - * A new migrate helper (migrate_vma()) has been added (see mm/migrate.c= ) that - * allows use of a device DMA engine to perform the copy operation betwe= en - * regular system memory and device memory. + * See Documentation/vm/hmm.rst for reasons and overview of what HMM is. */ #ifndef LINUX_HMM_H #define LINUX_HMM_H @@ -120,9 +70,6 @@ enum hmm_pfn_value_e { * * @notifier: a mmu_interval_notifier that includes the start/end * @notifier_seq: result of mmu_interval_read_begin() - * @hmm: the core HMM structure this range is active against - * @vma: the vm area struct for the range - * @list: all range lock are on a list * @start: range virtual start address (inclusive) * @end: range virtual end address (exclusive) * @pfns: array of pfns (big enough for the range) @@ -130,8 +77,7 @@ enum hmm_pfn_value_e { * @values: pfn value for some special case (none, special, error, ...) * @default_flags: default flags for the range (write, read, ... see hmm= doc) * @pfn_flags_mask: allows to mask pfn flags so that only default_flags = matter - * @pfn_shifts: pfn shift value (should be <=3D PAGE_SHIFT) - * @valid: pfns array did not change since it has been fill by an HMM fu= nction + * @pfn_shift: pfn shift value (should be <=3D PAGE_SHIFT) * @dev_private_owner: owner of device private pages */ struct hmm_range { @@ -171,52 +117,6 @@ static inline struct page *hmm_device_entry_to_page(= const struct hmm_range *rang return pfn_to_page(entry >> range->pfn_shift); } =20 -/* - * hmm_device_entry_to_pfn() - return pfn value store in a device entry - * @range: range use to decode device entry value - * @entry: device entry to extract pfn from - * Return: pfn value if device entry is valid, -1UL otherwise - */ -static inline unsigned long -hmm_device_entry_to_pfn(const struct hmm_range *range, uint64_t pfn) -{ - if (pfn =3D=3D range->values[HMM_PFN_NONE]) - return -1UL; - if (pfn =3D=3D range->values[HMM_PFN_ERROR]) - return -1UL; - if (pfn =3D=3D range->values[HMM_PFN_SPECIAL]) - return -1UL; - if (!(pfn & range->flags[HMM_PFN_VALID])) - return -1UL; - return (pfn >> range->pfn_shift); -} - -/* - * hmm_device_entry_from_page() - create a valid device entry for a page - * @range: range use to encode HMM pfn value - * @page: page for which to create the device entry - * Return: valid device entry for the page - */ -static inline uint64_t hmm_device_entry_from_page(const struct hmm_range= *range, - struct page *page) -{ - return (page_to_pfn(page) << range->pfn_shift) | - range->flags[HMM_PFN_VALID]; -} - -/* - * hmm_device_entry_from_pfn() - create a valid device entry value from = pfn - * @range: range use to encode HMM pfn value - * @pfn: pfn value for which to create the device entry - * Return: valid device entry for the pfn - */ -static inline uint64_t hmm_device_entry_from_pfn(const struct hmm_range = *range, - unsigned long pfn) -{ - return (pfn << range->pfn_shift) | - range->flags[HMM_PFN_VALID]; -} - /* Don't fault in missing PTEs, just snapshot the current state. */ #define HMM_FAULT_SNAPSHOT (1 << 1) =20 diff --git a/mm/hmm.c b/mm/hmm.c index 2a0eda1534bcda..c298c936469bbb 100644 --- a/mm/hmm.c +++ b/mm/hmm.c @@ -38,6 +38,18 @@ enum { HMM_NEED_ALL_BITS =3D HMM_NEED_FAULT | HMM_NEED_WRITE_FAULT, }; =20 +/* + * hmm_device_entry_from_pfn() - create a valid device entry value from = pfn + * @range: range use to encode HMM pfn value + * @pfn: pfn value for which to create the device entry + * Return: valid device entry for the pfn + */ +static uint64_t hmm_device_entry_from_pfn(const struct hmm_range *range, + unsigned long pfn) +{ + return (pfn << range->pfn_shift) | range->flags[HMM_PFN_VALID]; +} + static int hmm_pfns_fill(unsigned long addr, unsigned long end, struct hmm_range *range, enum hmm_pfn_value_e value) { @@ -544,7 +556,7 @@ static const struct mm_walk_ops hmm_walk_ops =3D { =20 /** * hmm_range_fault - try to fault some address in a virtual address rang= e - * @range: range being faulted + * @range: argument structure * @flags: HMM_FAULT_* flags * * Return: the number of valid pages in range->pfns[] (from range start @@ -558,13 +570,11 @@ static const struct mm_walk_ops hmm_walk_ops =3D { * only). * -EBUSY: The range has been invalidated and the caller needs to wait f= or * the invalidation to finish. - * -EFAULT: Invalid (i.e., either no valid vma or it is illegal to acces= s - * that range) number of valid pages in range->pfns[] (from - * range start address). + * -EFAULT: A page was requested to be valid and could not be made v= alid + * ie it has no backing VMA or it is illegal to access * - * This is similar to a regular CPU page fault except that it will not t= rigger - * any memory migration if the memory being faulted is not accessible by= CPUs - * and caller does not ask for migration. + * This is similar to get_user_pages(), except that it can read the page= tables + * without mutating them (ie causing faults). * * On error, for one virtual address in the range, the function will mar= k the * corresponding HMM pfn entry with an error flag. --=20 2.25.2