Commit Graph

481 Commits

Author SHA1 Message Date
Avi Kivity
90e77cc3a0 semaphore: support for breaking a semaphore
Tell all waiters that something bad happened and they should all go away.

Can be used only once; waiters should clean up and there must not be any
new waiters.
2015-01-20 11:29:48 +02:00
Avi Kivity
a6dea57f5b semaphore: add missing include 2015-01-20 11:29:26 +02:00
Avi Kivity
811fba9bc1 Merge branch 'align'
Aligned allocation facility.
2015-01-19 20:15:51 +02:00
Avi Kivity
93ae11cf63 resource: fix off-by-type getting number of processing units
Effect was to lose hyperthreads on NUMA machines.
2015-01-19 16:11:11 +02:00
Avi Kivity
e0d5bd2fb8 collectd: improve default hostname 2015-01-19 15:58:24 +02:00
Avi Kivity
45f9c86943 memory: provide C++ facilities for aligned allocation
new (with_alignment(64)) foo(...)   // cache aligned foo
  std::vector<foo, aligned_allocator<foo, 64>> // cached aligned foo vector
2015-01-19 09:49:32 +02:00
Avi Kivity
b22186e623 memory: fix small aligned allocations
When size > align, we simply call the small allocator with the provided size,
but that does not guarantee any alignment above the default.

Round the allocation size to the nearest power of two in that case, to
guarantee alignment.
2015-01-19 09:49:32 +02:00
Gleb Natapov
e3915cfcf8 reactor: call pause instruction in idle loop 2015-01-18 12:37:05 +02:00
Gleb Natapov
2ff006da4a core: calculate system load and report it via collectd 2015-01-18 12:37:05 +02:00
Gleb Natapov
1ef2808750 reactor: return proper value from pollers
Currently most of them return true no matter if any work was actually
done. Fix it to return true only if poll did any work.
2015-01-18 12:37:05 +02:00
Avi Kivity
80bcf3f973 memory: provide virt-to-phys translation API
Convert virtual addresses to physical addresses.  Only works when
--hugepages is in effect.
2015-01-15 18:23:19 +02:00
Avi Kivity
d77d0cddca posix: implement pread() interface 2015-01-15 18:22:07 +02:00
Avi Kivity
e746eb7f84 future: fix make_exception_future build error
Add missing std::.
2015-01-15 15:19:02 +02:00
Avi Kivity
311e1c834e future: fix future::then_wrapped() in exception case
Calling state.get() will throw the exception instead of calling the function,
thus denying the called function the chance to deal with the exception.

Fix by constructing the future directly from state.
2015-01-15 15:19:02 +02:00
Avi Kivity
809c6edee2 reactor: periodically call into allocator to drain cross-cpu free items 2015-01-15 15:19:02 +02:00
Avi Kivity
e57be410b5 memory: support cross-cpu freeing
Currently we require that memory be freed on the same cpu it was allocated.
This does not impose difficulties on the user code, since our code is already
smp-unsafe, and so must use message-passing to run the destructor on the
origin cpu, so memory is naturally freed there as well.

However, library code does not run under our assumptions, specifically
std::exception_ptr, which we do transport across cores.

To support this use case, add low-performance support for cross-cpu frees,
using an atomic singly linked list per core.
2015-01-15 15:19:00 +02:00
Avi Kivity
30aa81819a app: handle command line parsing errors 2015-01-15 10:46:44 +02:00
Asias He
8ed3584a5e app: Allow -h to show help message
It only supports -help at the moment. It is quite annoying to see:

   $ ./httpd -h
   terminate called after throwing an instance of
   'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::program_options::unknown_option> >'
     what():  unrecognised option '-h'
   Aborted

Support both -h and --help.
2015-01-15 10:31:31 +02:00
Gleb Natapov
c6c6c6055d core: add various statistics about smp communication 2015-01-14 16:50:49 +02:00
Gleb Natapov
354280fd7c core: scollectd: use move instead of forward on rvalue reference 2015-01-14 16:50:48 +02:00
Gleb Natapov
340a871a98 core: use seastar shared ptr in scollectd 2015-01-14 16:50:48 +02:00
Gleb Natapov
660434c3a0 core: change collectd to be a namespace instead of class
Class was used because it provides better encapsulation, but namespace
is easier to deal with.
2015-01-14 16:50:48 +02:00
Avi Kivity
1ecc678857 reactor: fix potential allocations in syscall thread pool
Throwing an exception may allocate memory, which we don't want to do
in the syscall thread pool (only reactor threads support allocation, for now).

Move the conversion of negative syscall results to exceptions to a separate
task, running in the reactor thread, to avoid this.
2015-01-14 16:49:04 +02:00
Gleb Natapov
ceeab9a330 replace ad-hoc index list generator with standard one 2015-01-14 14:59:02 +02:00
Takuya ASADA
e1552ad3b6 core: rename smp.hh to distributed.hh
Signed-off-by: Takuya ASADA <syuu@cloudius-systems.com>
2015-01-14 11:16:09 +02:00
Calle Wilund
58f614d858 Make align methods constexpr for usage in statics/constexprs 2015-01-13 19:35:48 +02:00
Avi Kivity
7596819034 file: define move assignment operator 2015-01-13 19:08:48 +02:00
Avi Kivity
8135865ad6 Merge branch 'takuya/reuseportv3' of github.com:cloudius-systems/seastar-dev
Use SO_REUSEPORT to let the kernel distribute accepted connections, from
Takuya.
2015-01-13 17:38:38 +02:00
Gleb Natapov
98c9a7f52f core: make sconnectd.hh include file list more reasonable
Currently it include the whole reactor.hh, but it needs only a small part
of what it brings.
2015-01-13 17:28:40 +02:00
Gleb Natapov
2b4a309ad6 core: do not start smp queue to self 2015-01-13 17:28:39 +02:00
Gleb Natapov
d4db9493ae core: remove unused smp code 2015-01-13 17:28:39 +02:00
Takuya ASADA
fde6c412c2 reactor: Add SO_REUSEPORT availability check method
Signed-off-by: Takuya ASADA <syuu@cloudius-systems.com>
2015-01-13 20:01:43 +09:00
Avi Kivity
16c8414523 sstring: add literal + sstring concatentation overload 2015-01-13 10:12:36 +02:00
Avi Kivity
a52a3dd5ca sstring: add standard member typedefs
Add standard member typedefs, so that standard algorithms looking for
them using their standard names can find them and not spew error messages.
2015-01-12 20:25:21 +02:00
Glauber Costa
66a6a3b50e add a header to file.hh
I am currently unable to use core/file.hh in a fresh include file. Type
conflicts arise, which probably don't happen in other existing files because
of existing includes that end up getting the environment all right beforehand.

FAILED: g++ -MMD -MT build/release/db/db.o -MF build/release/db/db.o.d -std=gnu++1y -g  -Wall -Werror -fvisibility=hidden -pthread -I.   -DHAVE_XEN -DHAVE_HWLOC -DHAVE_NUMA -O2 -I build/release/gen -c -o build/release/db/db.o db/db.cc
In file included from ./sstables.hh:4:0,
                 from ./database.hh:22,
                 from db/composites/composite.hh:27,
                 from db/db.cc:8:
./core/file.hh:35:64: error: ‘iovec’ was not declared in this scope
     virtual future<size_t> write_dma(uint64_t pos, std::vector<iovec> iov) = 0;

Adding <sys/uio.h> to the include list of file.hh makes it includable (apparently) anywhere.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-01-12 18:59:11 +02:00
Gleb Natapov
f58926acd1 core: fix circular_buffer::emplace_(back|front) to take universal references 2015-01-12 17:30:45 +02:00
Gleb Natapov
20d2725ed9 core: shared_ptr add noexcept
Add missing noexcepts. Those on constructors are needed to be able to
store shared pointers in growable containers efficiently.
2015-01-12 17:29:02 +02:00
Takuya ASADA
902b5b00a4 Make pollable_fd::_s as private variable
We can use pollable_fd::writeable/readable instead.

Signed-off-by: Takuya ASADA <syuu@cloudius-systems.com>
2015-01-08 12:07:16 +02:00
Avi Kivity
c95e452a3a Merge branch 'directory'
Directory listing support, using subscription<sstring> to represent the
stream of file names produced by the directory lister running in parallel
with the directory consumer.
2015-01-08 11:14:52 +02:00
Avi Kivity
3be04e7009 reactor: implement open_directory(), list_directory()
open_directory() is similar to open_file_dma() with just the O_ flags adjusted.

list_directory() returns a subscription(), so that both the producer and
the consumer can be asynchronous.
2015-01-08 11:09:25 +02:00
Avi Kivity
f26e74b1ff Merge branch 'takuya/tcp-clientv16' of github.com:cloudius-systems/seastar-dev
TCP client, from Takuya.

Reviewed-by: Asias He <asias@cloudius-systems.com>
2015-01-08 10:46:35 +02:00
Takuya ASADA
b9a2541c7e Add reactor::connect(), client_socket definition and network stack stub code
Signed-off-by: Takuya ASADA <syuu@cloudius-systems.com>
2015-01-08 01:26:36 +09:00
Takuya ASADA
7730ef29cd Add readable()/writeable() method on pollable_fd 2015-01-08 01:26:36 +09:00
Takuya ASADA
24820543ff Add reactor::posix_connect()
Signed-off-by: Takuya ASADA <syuu@cloudius-systems.com>
2015-01-08 01:26:30 +09:00
Takuya ASADA
d3e83dde8b Add file_desc::getsockopt() 2015-01-07 23:48:53 +09:00
Avi Kivity
8101c1f2a6 stream/subscription: fix build error in stream::close() 2015-01-07 15:12:23 +02:00
Pekka Enberg
fa8d120d70 core: Fix shared_ptr pointer casts
Fix compilation errors in the shared_ptr pointer cast functions and
update shared_ptr constructor to take shared_ptr_count_base.

Suggested by Avi.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-01-07 13:50:59 +02:00
Takuya ASADA
c01e9dc8d6 Add file_desc::connect()
Signed-off-by: Takuya ASADA <syuu@cloudius-systems.com>
2015-01-06 22:54:38 +09:00
Gleb Natapov
3f483b22bc future: add missing std::forward() in do_until_continued() 2015-01-06 14:43:34 +02:00
Avi Kivity
66eea763bf shared_ptr: add comparison operators 2015-01-05 13:24:07 +02:00