Commit Graph

242 Commits

Author SHA1 Message Date
Glauber Costa
9fa8124ade xen: evtchn support
This patch enables xen event channels. It creates the placeholder for the
kernel evtchns when we move to OSv as well.

The main problem with this patch, is that evtchn::pending can return more than
one evtchn, so this that I am doing here is technically wrong. We should probably
call keep_doing() in pending() itself, and have that to store the references to
futures equivalent to the possible event channels, that would then be made ready.

I am, however, having a bit of a hard time coding this, since it's still
unclear how, once the future is consumed, we would generate the next.

Please note: All of this is moot if we disable "split event channels", which
can be done by masking that feature in case it is even available. In that case,
only one event channel will be notified, and when ready, we process both tx and
rx. This is yet another reason why I haven't insisted so much in fixing this properly

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2014-11-05 15:09:03 +02:00
Glauber Costa
891b40a2af xen: gntalloc device
This patch creates a seastar enabled version of the xen gntalloc device.

TODO: grow the table dynamically, and fix the index selection algorithm. Shouldn't
just always bump 1.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2014-11-05 15:09:03 +02:00
Glauber Costa
7963eb026c header functions for osv + xen
Should come from OSv, we should fix this soon.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2014-11-05 15:09:03 +02:00
Avi Kivity
6a2532fb00 print: add log() function
Like print(), but with time information prepended.
2014-11-05 11:35:50 +02:00
Gleb Natapov
f0416f44b1 keep_doing: remove infinite loop
Prevent keep_doing() from monopolizing the cpu.
2014-11-04 15:19:01 +02:00
Gleb Natapov
e5dfd8e863 future: limit number of ready futures that are executed without scheduling a task
Otherwise stack may overflow if a very long chain of ready futures is
executed.
2014-11-04 15:18:32 +02:00
Gleb Natapov
f8575a1745 reactor: limit number of tasks the reactor runs between polling fds
If there is a task that always adds another task to a ready task list
epoll_wait will never run.
2014-11-04 15:18:23 +02:00
Asias He
dbbd9865ad core: Fix read_exactly
Return an empty tmp buf if eof.
2014-11-03 09:53:31 +02:00
Glauber Costa
9a86af9543 xen: xenstore communication
This patch enables to interact with xenstore. Since now OSv now fakes the
presence of libxenstore, the code is the same for userspace and kernel.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2014-11-02 16:41:19 +02:00
Avi Kivity
c845606a2d Merge branch 'join'
Rewrite http connection termination management to support the
various cases dictated by the HTTP spec: client-side connection
close, server-side connection close, and header specified connection
close.
2014-11-01 19:38:09 +02:00
Avi Kivity
55f3a03e1d reactor: make more internal variables private 2014-11-01 17:34:45 +02:00
Avi Kivity
7a1f84a556 reactor: replace references to reactor::_id by its accessor cpu_id() 2014-11-01 17:34:43 +02:00
Raphael S. Carvalho
d382a314b3 core: sstring: move initialized_later to be a public member
It's required for instantiating a sstring with the constructor
basic_sstring(initialized_later, size_t size).

Signed-off-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
2014-11-01 15:36:28 +02:00
Raphael S. Carvalho
6188745a98 core: introduce size method into file_impl
Signed-off-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
2014-11-01 15:36:28 +02:00
Avi Kivity
79e8497e1d queue: add size() accessor 2014-10-30 14:08:23 +02:00
Avi Kivity
3d414111eb future: make .rescue() require an rvalue reference for its future
This makes it harder to misuse.
2014-10-30 14:07:42 +02:00
Avi Kivity
7f91f1b937 future: add when_all(future...)
when_all(f1, f2) returns a future that becomes ready when all input futures
are ready.  The return value is a tuple with all input futures, so the values
and exceptions can be accessed.
2014-10-30 13:59:17 +02:00
Avi Kivity
c4bc67414e future: add then_wrapped()
Unlike future::then(), which unwraps the value, then_wrapped() keeps it
wrapped in a future<>, so if it is exceptional, it can still be accessed.

This is similar to the proposed std::future::then(), so we should later
rename it to match (and rename the existing future::then() to future::next().
2014-10-30 13:55:31 +02:00
Calle Wilund
4b4f33c1ba collectd: add a few counters to reactor
Might be slightly useful for monitoring, and might also serve as an
example.

Signed-off-by: Calle Wilund <calle@cloudius-systems.com>
2014-10-29 19:23:42 +02:00
Asias He
04dd72efd3 tcp: Support close initiated on server side for posix stack
Fix hang with ab test on posix stack:

ab -n 1000 http://127.0.0.1/

Fixes #3
2014-10-28 12:42:47 +02:00
Calle Wilund
1891a7ab1f collectd: add gauge (absolute value) counter as well for #registered
Signed-off-by: Calle Wilund <calle@cloudius-systems.com>
2014-10-28 11:09:15 +02:00
Calle Wilund
66c2a62259 collectd: use low-res timestamps
Since hi-res seems to work poorly at least on my fedora and are a bit of
an overkill anyway.

Signed-off-by: Calle Wilund <calle@cloudius-systems.com>
2014-10-28 11:09:09 +02:00
Calle Wilund
774e48e42e collectd: enforce encoding as double/uint64_t depending on data_type
Signed-off-by: Calle Wilund <calle@cloudius-systems.com>
2014-10-28 11:09:04 +02:00
Calle Wilund
030709a3c9 collectd: fix bug with function value binding
Remove unneeded code in send loop (values don't need to be copied).

Signed-off-by: Calle Wilund <calle@cloudius-systems.com>
2014-10-28 11:08:57 +02:00
Calle Wilund
abb15db28f collectd: ensure the protocol writer is consistent ref. daemon
Also make it less talkative (lower byte overhead) by keeping track of IDs
sent.

Signed-off-by: Calle Wilund <calle@cloudius-systems.com>
2014-10-28 11:08:45 +02:00
Calle Wilund
8619bf2ba7 collectd: Modify the scollectd modules own counters to use well-known types
So it can be consumed by unmodified collectd server.

Signed-off-by: Calle Wilund <calle@cloudius-systems.com>
2014-10-28 11:08:19 +02:00
Calle Wilund
b42ec4caea collectd - typo in value list composition
Signed-off-by: Calle Wilund <calle@cloudius-systems.com>
2014-10-28 11:07:52 +02:00
Avi Kivity
6dcf24f98d Move contents of async-action.hh into future-util.hh 2014-10-27 19:28:10 +02:00
Tomasz Grabiec
eb84a3b78b core: fix future::forward_to()
It did not handle properly the case when the target promise's future gets dead
without installing a callback or the future was never installed. The
mishanlding of the former case was causing httpd to abort on SMP.
2014-10-27 15:58:57 +02:00
Gleb Natapov
0aee62c4ae smp: forward exception thrown by RPC callback back to a caller
If an exception is uncaught here it prevents smp_message_queue::listen()
from tail call itself so further RPC stops working.
2014-10-27 10:55:18 +02:00
Gleb Natapov
bfb1d17843 reactor: remove unused local variables 2014-10-26 18:35:56 +02:00
Avi Kivity
8818af1c23 core: move semaphore class into its own file 2014-10-26 15:52:01 +02:00
Avi Kivity
5fef739544 Merge branch 'distributed'
Infrastructure for services distributed across cpus.
2014-10-26 14:35:19 +02:00
Avi Kivity
5e4f649a57 semaphore: switch list -> circular_buffer
circular_buffer is much more efficient, since allocations are amortized.
2014-10-26 14:34:56 +02:00
Avi Kivity
0d745abf69 future: sprinke noexcept everywhere
When used correctly, noexcept allows containers to optimize their reallocation
code.
2014-10-26 14:34:56 +02:00
Avi Kivity
e7ce27ea32 smp: add distributed<>, infrastructure for distributed service
Summary:

  distributed<my_service> dist;

  dist.start() - constructs my_service on all cpus
  dist.stop() - destroys previously constructed instances
  dist.invoke(cpu, &my_service::method, args...) - run method on one cpu
  dist.invoke_on_all(cpu, &my_service::method, args...) - run method on all cpus
2014-10-26 13:34:31 +02:00
Avi Kivity
82321d435f future: add parallel_for_each() helper
Runs functions in paralllel, and returns a future<> that becomes ready
when all are complete.
2014-10-26 13:34:31 +02:00
Avi Kivity
2639c284f3 reactor: add cpu_id() accessor 2014-10-26 11:25:16 +02:00
Gleb Natapov
01a1c1c3c2 smp: delete non existent function declaration listen_one() 2014-10-26 10:30:48 +02:00
Avi Kivity
bb522a5592 Revert "keep_doing: fix memory leak"
This reverts commit 5a3e4f20e3.  After
74ac65a491 ("core: optimize future::forward_to()"), it is no longer
needed.
2014-10-24 22:25:46 +03:00
Avi Kivity
6b23750255 Merge branch 'avi/distributed' of github.com:cloudius-systems/seastar-dev
"Often, a function we wish to execute on another cpu will not be able to
complete immediatley.  This patchset allows it to return a future; the caller
will not be resumed until that future is ready."
2014-10-24 19:46:59 +03:00
Tomasz Grabiec
74ac65a491 core: optimize future::forward_to()
We can avoid extra allocation and chaining by linking the current
future's promise with the target promise's future, as if the target
promise was moved into the current future's promise.
2014-10-24 19:40:48 +03:00
Avi Kivity
5a3e4f20e3 keep_doing: fix memory leak
keep_doing() keeps chaining futures until it stops, usually never, resulting
in a de-facto memory leak (even though all the memory is still reachable).

Fix by avoiding the chainining, re-using the same promise over and over again.
2014-10-23 19:24:29 +03:00
Avi Kivity
7428717be9 keep_doing: cosmetics 2014-10-23 16:57:36 +03:00
Avi Kivity
1f80f7ee14 memory: fix realloc()
Because memcpy() is declared by gcc as receiving non-null attributes, gcc
assumes that ptr != null, as it is passed into memcpy() (though with a size
of zero).  As a result it ignores the null pointer check in ::free(), and
calls memory::free() directly, which does not expect a null pointer.

Fix by only calling memcpy() when the ptr is non-null.
2014-10-23 15:59:52 +03:00
Avi Kivity
6b84f666f7 smp: move smp::listen_one() into smp_message_queue class
All it does is access its internals.
2014-10-23 13:16:50 +03:00
Avi Kivity
1bdc2a1f6c smp: asynchronous functions
Allow functions run on another cpu to return a future.  In that case, the
result (or exception) is only returned when the future is resolved.

Note this has the potential for livelocks:

A: smp::submit_to(B, [] {
       ...
       return smp::submit_to(A, [] {
           ...
       });
    });

If this and its mirror image (B sending to A) happen concurrently, and if
both the A->B and B->A queue become full, the system will not be able to
make forward progress.  This can be fixed by making the inner submit_to()
use a different queue.
2014-10-23 13:04:52 +03:00
Asias He
d12e495653 tcp: Support close initiated on server side 2014-10-23 12:57:32 +03:00
Asias He
9aaaded894 app template: Put options for application in app options group
E.g.:

App options:
  --help                                show help message
  --port arg (=10000)                   HTTP Server port
2014-10-23 10:30:40 +03:00
Avi Kivity
1f34dc4b2a syscall_work_queue: remove submit<void>
Not used with syscalls - they almost always return a result.
2014-10-23 10:19:55 +03:00