Skip to content

Commit

Permalink
ABD optimized page allocation code
Browse files Browse the repository at this point in the history
* Convert ABD to use the Linux Kernel scatterlist implementation
  instead of the hand rolled one from illumos.

* Scatter ABDs are preferentially populated with higher order
  compound pages from a single zone.  Allocation size is
  progressively decreased until it can be satisfied without
  performing reclaim or compaction.

* An alternate page allocator is provided for kernels older
  than 3.6 and for CONFIG_HIGHMEM systems.  This allocator
  is designed as a fallback for maximum compatibility.

* Extended abdstats to provide visibility in the the allocator.

* Add cached value for PAGESIZE in userspace.

Contributions-by:
Chunwei Chen <david.chen@osnexus.com>
Gvozden Neskovic <neskovic@gmail.com>
Jinshan Xiong <jinshan.xiong@intel.com>
Isaac Huang <he.huang@intel.com>
David Quigley <david.quigley@intel.com>
Brian Behlendorf <behlendorf1@llnl.gov>
  • Loading branch information
Chunwei Chen authored and behlendorf committed Nov 29, 2016
1 parent 4f60152 commit 9829574
Show file tree
Hide file tree
Showing 5 changed files with 457 additions and 136 deletions.
8 changes: 5 additions & 3 deletions include/sys/abd.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ extern "C" {
typedef enum abd_flags {
ABD_FLAG_LINEAR = 1 << 0, /* is buffer linear (or scattered)? */
ABD_FLAG_OWNER = 1 << 1, /* does it own its data buffers? */
ABD_FLAG_META = 1 << 2 /* does this represent FS metadata? */
ABD_FLAG_META = 1 << 2, /* does this represent FS metadata? */
ABD_FLAG_MULTI_ZONE = 1 << 3, /* pages split over memory zones */
ABD_FLAG_MULTI_CHUNK = 1 << 4 /* pages split over multiple chunks */
} abd_flags_t;

typedef struct abd {
Expand All @@ -54,8 +56,8 @@ typedef struct abd {
union {
struct abd_scatter {
uint_t abd_offset;
uint_t abd_chunk_size;
struct page *abd_chunks[];
uint_t abd_nents;
struct scatterlist *abd_sgl;
} abd_scatter;
struct abd_linear {
void *abd_buf;
Expand Down
1 change: 1 addition & 0 deletions lib/libspl/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ USER_C = \
getmntany.c \
list.c \
mkdirp.c \
page.c \
strlcat.c \
strlcpy.c \
strnlen.c \
Expand Down
7 changes: 5 additions & 2 deletions lib/libspl/include/sys/param.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,11 @@
#define MAXUID UINT32_MAX /* max user id */
#define MAXPROJID MAXUID /* max project id */

#ifndef PAGESIZE
#define PAGESIZE (sysconf(_SC_PAGESIZE))
#ifdef PAGESIZE
#undef PAGESIZE
#endif /* PAGESIZE */

extern size_t spl_pagesize(void);
#define PAGESIZE (spl_pagesize())

#endif
34 changes: 34 additions & 0 deletions lib/libspl/page.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/

#include <unistd.h>

size_t pagesize = 0;

size_t
spl_pagesize(void)
{
if (pagesize == 0)
pagesize = sysconf(_SC_PAGESIZE);

return (pagesize);
}
Loading

0 comments on commit 9829574

Please sign in to comment.