The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/vm/vm_phys.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
    3  *
    4  * Copyright (c) 2002-2006 Rice University
    5  * Copyright (c) 2007 Alan L. Cox <alc@cs.rice.edu>
    6  * All rights reserved.
    7  *
    8  * This software was developed for the FreeBSD Project by Alan L. Cox,
    9  * Olivier Crameri, Peter Druschel, Sitaram Iyer, and Juan Navarro.
   10  *
   11  * Redistribution and use in source and binary forms, with or without
   12  * modification, are permitted provided that the following conditions
   13  * are met:
   14  * 1. Redistributions of source code must retain the above copyright
   15  *    notice, this list of conditions and the following disclaimer.
   16  * 2. Redistributions in binary form must reproduce the above copyright
   17  *    notice, this list of conditions and the following disclaimer in the
   18  *    documentation and/or other materials provided with the distribution.
   19  *
   20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
   21  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
   22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
   23  * A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT
   24  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
   25  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
   26  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
   27  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
   28  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   29  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
   30  * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   31  * POSSIBILITY OF SUCH DAMAGE.
   32  *
   33  * $FreeBSD: releng/12.0/sys/vm/vm_phys.h 339939 2018-10-31 02:02:12Z markj $
   34  */
   35 
   36 /*
   37  *      Physical memory system definitions
   38  */
   39 
   40 #ifndef _VM_PHYS_H_
   41 #define _VM_PHYS_H_
   42 
   43 #ifdef _KERNEL
   44 
   45 /* Domains must be dense (non-sparse) and zero-based. */
   46 struct mem_affinity {
   47         vm_paddr_t start;
   48         vm_paddr_t end;
   49         int domain;
   50 };
   51 #ifdef NUMA
   52 extern struct mem_affinity *mem_affinity;
   53 extern int *mem_locality;
   54 #endif
   55 
   56 struct vm_freelist {
   57         struct pglist pl;
   58         int lcnt;
   59 };
   60 
   61 struct vm_phys_seg {
   62         vm_paddr_t      start;
   63         vm_paddr_t      end;
   64         vm_page_t       first_page;
   65         int             domain;
   66         struct vm_freelist (*free_queues)[VM_NFREEPOOL][VM_NFREEORDER];
   67 };
   68 
   69 extern struct vm_phys_seg vm_phys_segs[];
   70 extern int vm_phys_nsegs;
   71 
   72 /*
   73  * The following functions are only to be used by the virtual memory system.
   74  */
   75 void vm_phys_add_seg(vm_paddr_t start, vm_paddr_t end);
   76 vm_page_t vm_phys_alloc_contig(int domain, u_long npages, vm_paddr_t low,
   77     vm_paddr_t high, u_long alignment, vm_paddr_t boundary);
   78 vm_page_t vm_phys_alloc_freelist_pages(int domain, int freelist, int pool,
   79     int order);
   80 int vm_phys_alloc_npages(int domain, int pool, int npages, vm_page_t ma[]);
   81 vm_page_t vm_phys_alloc_pages(int domain, int pool, int order);
   82 int vm_phys_domain_match(int prefer, vm_paddr_t low, vm_paddr_t high);
   83 int vm_phys_fictitious_reg_range(vm_paddr_t start, vm_paddr_t end,
   84     vm_memattr_t memattr);
   85 void vm_phys_fictitious_unreg_range(vm_paddr_t start, vm_paddr_t end);
   86 vm_page_t vm_phys_fictitious_to_vm_page(vm_paddr_t pa);
   87 void vm_phys_free_contig(vm_page_t m, u_long npages);
   88 void vm_phys_free_pages(vm_page_t m, int order);
   89 void vm_phys_init(void);
   90 vm_page_t vm_phys_paddr_to_vm_page(vm_paddr_t pa);
   91 void vm_phys_register_domains(int ndomains, struct mem_affinity *affinity,
   92     int *locality);
   93 vm_page_t vm_phys_scan_contig(int domain, u_long npages, vm_paddr_t low,
   94     vm_paddr_t high, u_long alignment, vm_paddr_t boundary, int options);
   95 void vm_phys_set_pool(int pool, vm_page_t m, int order);
   96 boolean_t vm_phys_unfree_page(vm_page_t m);
   97 int vm_phys_mem_affinity(int f, int t);
   98 
   99 /*
  100  *
  101  *      vm_phys_domain:
  102  *
  103  *      Return the index of the domain the page belongs to.
  104  */
  105 static inline int
  106 vm_phys_domain(vm_page_t m)
  107 {
  108 #ifdef NUMA
  109         int domn, segind;
  110 
  111         /* XXXKIB try to assert that the page is managed */
  112         segind = m->segind;
  113         KASSERT(segind < vm_phys_nsegs, ("segind %d m %p", segind, m));
  114         domn = vm_phys_segs[segind].domain;
  115         KASSERT(domn < vm_ndomains, ("domain %d m %p", domn, m));
  116         return (domn);
  117 #else
  118         return (0);
  119 #endif
  120 }
  121 
  122 #endif  /* _KERNEL */
  123 #endif  /* !_VM_PHYS_H_ */

Cache object: 485dccac05fbce9f6e59465e07a9ee12


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.