1.1 --- a/libfsserver/lib/pipes/pipe_paging.cc Fri Sep 16 22:59:39 2022 +0200
1.2 +++ b/libfsserver/lib/pipes/pipe_paging.cc Sat Sep 17 00:03:45 2022 +0200
1.3 @@ -1,7 +1,7 @@
1.4 /*
1.5 * A pipe paging coordinator, permitting memory sharing pipe endpoints.
1.6 *
1.7 - * Copyright (C) 2021 Paul Boddie <paul@boddie.org.uk>
1.8 + * Copyright (C) 2021, 2022 Paul Boddie <paul@boddie.org.uk>
1.9 *
1.10 * This program is free software; you can redistribute it and/or
1.11 * modify it under the terms of the GNU General Public License as
1.12 @@ -19,6 +19,8 @@
1.13 * Boston, MA 02110-1301, USA
1.14 */
1.15
1.16 +#include <algorithm>
1.17 +
1.18 #include <mem/memory_preallocated.h>
1.19
1.20 #include "page_queue_partitioned.h"
1.21 @@ -27,8 +29,12 @@
1.22
1.23
1.24 PipePaging::PipePaging(Memory *memory, offset_t size)
1.25 -: NotificationSupport(2), _memory(NULL), _size(size)
1.26 +: NotificationSupport(2), _memory(NULL)
1.27 {
1.28 + /* Employ a region size compatible with the configured page size. */
1.29 +
1.30 + _size = std::max<offset_t>(size, PAGE_SIZE);
1.31 +
1.32 /* Reserve space for two pipe regions. */
1.33
1.34 _memory = new MemoryPreallocated(memory, round(size, memory->region_size()) * 2);