Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto PR from release/0.8 to main #577

Merged
merged 7 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions .github/workflows/ci.linux.arm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
branches: [ "main", "release/*" ]

jobs:
centos8-gcc921-epoll-release:
gcc921:
runs-on: [self-hosted, Linux, ARM64]

container:
Expand Down Expand Up @@ -40,7 +40,7 @@ jobs:
cd build
ctest -E test-lockfree --timeout 3600 -V
centos8-gcc921-epoll-debug:
gcc921-build-debug:
runs-on: [self-hosted, Linux, ARM64]

container:
Expand All @@ -67,8 +67,3 @@ jobs:
-D PHOTON_ENABLE_FUSE=ON \
-D PHOTON_ENABLE_EXTFS=ON
cmake --build build -j $(nproc) -- VERBOSE=1
- name: Test
run: |
cd build
ctest -E test-lockfree --timeout 3600 -V
4 changes: 2 additions & 2 deletions common/alog.h
Original file line number Diff line number Diff line change
Expand Up @@ -595,8 +595,8 @@ struct __LogAppender : public Builder {
using Builder::logger;
using Builder::done;
Append append;
explicit __LogAppender(Builder&& rhs, Append&& append)
: Builder(std::move(rhs)), append(std::move(append)) {}
explicit __LogAppender(Builder&& rhs, Append&& append_)
: Builder(std::move(rhs)), append(std::move(append_)) {}
__LogAppender(__LogAppender&& rhs)
: Builder(std::move(rhs)), append(std::move(rhs.append)) {}
~__LogAppender() {
Expand Down
24 changes: 12 additions & 12 deletions common/iovector.h
Original file line number Diff line number Diff line change
Expand Up @@ -1008,24 +1008,24 @@ class IOVectorEntity : public iovector
}
};

inline size_t iovector_view::memcpy_to(iovector_view* iov, size_t size) const {
IOVectorEntity<32, 0> co_iov(this->iov, iovcnt);
return co_iov.view().memcpy_to(iov, size);
inline size_t iovector_view::memcpy_to(iovector_view* iov_, size_t size) const {
IOVectorEntity<32, 0> co_iov(iov, iovcnt);
return co_iov.view().memcpy_to(iov_, size);
}

inline size_t iovector_view::memcpy_from(iovector_view* iov, size_t size) const {
IOVectorEntity<32, 0> co_iov(this->iov, iovcnt);
return co_iov.view().memcpy_from(iov, size);
inline size_t iovector_view::memcpy_from(iovector_view* iov_, size_t size) const {
IOVectorEntity<32, 0> co_iov(iov, iovcnt);
return co_iov.view().memcpy_from(iov_, size);
}

inline size_t iovector_view::memcpy_to(const iovector_view* iov, size_t size) const {
IOVectorEntity<32, 0> co_iov(this->iov, iovcnt);
return co_iov.view().memcpy_from(iov, size);
inline size_t iovector_view::memcpy_to(const iovector_view* iov_, size_t size) const {
IOVectorEntity<32, 0> co_iov(iov, iovcnt);
return co_iov.view().memcpy_from(iov_, size);
}

inline size_t iovector_view::memcpy_from(const iovector_view* iov, size_t size) const {
IOVectorEntity<32, 0> co_iov(this->iov, iovcnt);
return co_iov.view().memcpy_from(iov, size);
inline size_t iovector_view::memcpy_from(const iovector_view* iov_, size_t size) const {
IOVectorEntity<32, 0> co_iov(iov, iovcnt);
return co_iov.view().memcpy_from(iov_, size);
}


Expand Down
2 changes: 1 addition & 1 deletion common/retval.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ struct retval : public retval_base {

template<>
struct retval<void> : public retval_base {
retval(int _errno = 0) : retval_base{(uint64_t)_errno} { }
retval(int errno_ = 0) : retval_base{(uint64_t)errno_} { }
retval(const retval_base& rvb) : retval_base(rvb) { }
void get() const { }
retval_base base() const {
Expand Down
1 change: 1 addition & 0 deletions include/photon/thread/arch.h
2 changes: 1 addition & 1 deletion io/kqueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class KQueue : public MasterEventEngine, public CascadingEventEngine, public Res
struct kevent entry;
EV_SET(&entry, _kq, EVFILT_USER, EV_ONESHOT, NOTE_TRIGGER, 0, nullptr);
struct timespec tm{0, 0};
return kevent(_kq, _events, _n, nullptr, 0, &tm);
return kevent(_kq, &entry, 1, nullptr, 0, &tm);
}

// This vector is used to filter invalid add/rm_interest requests which may affect kevent's
Expand Down
3 changes: 1 addition & 2 deletions photon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ int __photon_init(uint64_t event_engine, uint64_t io_engine, const PhotonOptions
const uint64_t ALL_ENGINES =
INIT_EVENT_EPOLL | INIT_EVENT_EPOLL_NG |
INIT_EVENT_IOURING | INIT_EVENT_KQUEUE |
INIT_EVENT_SELECT | INIT_EVENT_IOCP |
INIT_EVENT_EPOLL_NG;
INIT_EVENT_SELECT | INIT_EVENT_IOCP;
if (event_engine & ALL_ENGINES) {
bool ok = false;
for (auto x : recommended_order) {
Expand Down
23 changes: 23 additions & 0 deletions thread/arch.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
Copyright 2022 The Photon Authors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

#include "arch.h"

namespace photon {

uint32_t PAGE_SIZE = 0;

}
26 changes: 26 additions & 0 deletions thread/arch.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
Copyright 2022 The Photon Authors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

#pragma once

#include <cstdint>

namespace photon {

// Only available after photon::init() or photon::vcpu_init()
extern uint32_t PAGE_SIZE;

}
3 changes: 1 addition & 2 deletions thread/stack-allocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ limitations under the License.
#include <errno.h>
#include <photon/common/alog.h>
#include <photon/common/utility.h>
#include <photon/thread/arch.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <unistd.h>
Expand All @@ -28,8 +29,6 @@ limitations under the License.

namespace photon {

const static size_t PAGE_SIZE = getpagesize();

template <size_t MIN_ALLOCATION_SIZE = 4UL * 1024,
size_t MAX_ALLOCATION_SIZE = 64UL * 1024 * 1024>
class PooledStackAllocator {
Expand Down
21 changes: 19 additions & 2 deletions thread/std-compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ inline uint64_t __duration_to_microseconds(const ::std::chrono::duration<Rep, Pe

class thread {
public:
using id = photon::thread*;

thread() = default;

~thread() {
Expand Down Expand Up @@ -93,6 +91,17 @@ class thread {
return m_th != nullptr;
}

class id {
public:
id() = default;
id(photon::thread* th_id) : th_id_(th_id) {}
bool operator==(const id& rhs) const { return th_id_ == rhs.th_id_; }
bool operator!=(const id& rhs) const { return !(rhs == *this); }
uint64_t value() const { return uint64_t(th_id_); }
private:
photon::thread* th_id_ = nullptr;
};

id get_id() const noexcept {
return m_th;
}
Expand Down Expand Up @@ -424,4 +433,12 @@ inline void swap(photon_std::unique_lock<Mutex>& lhs, photon_std::unique_lock<Mu
lhs.swap(rhs);
}

template<>
struct hash<photon_std::thread::id> {
size_t operator()(const photon_std::thread::id& x) const {
hash<uint64_t> hasher;
return hasher(x.value());
}
};

}
11 changes: 7 additions & 4 deletions thread/thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ inline int posix_memalign(void** memptr, size_t alignment, size_t size) {
#include <photon/common/alog.h>
#include <photon/common/alog-functionptr.h>
#include <photon/thread/thread-key.h>
#include <photon/thread/arch.h>

/* notes on the scheduler:

Expand Down Expand Up @@ -86,8 +87,6 @@ inline int posix_memalign(void** memptr, size_t alignment, size_t size) {
#name": "
#endif

static const size_t PAGE_SIZE = getpagesize();

namespace photon
{
inline uint64_t min(uint64_t a, uint64_t b) { return (a<b) ? a : b; }
Expand Down Expand Up @@ -929,6 +928,8 @@ R"(
stack_size = least_stack_size;
}
char* ptr = (char*)photon_thread_alloc(stack_size);
if (unlikely(!ptr))
return nullptr;
uint64_t p = (uint64_t)ptr + stack_size - sizeof(thread) - randomizer;
p = align_down(p, 64);
auto th = new ((char*)p) thread;
Expand Down Expand Up @@ -1660,8 +1661,8 @@ R"(
int ret = thread_usleep_defer(timeout, q, unlock, m);
auto en = ret < 0 ? errno : 0;
while (true) {
int ret = lock(m);
if (ret == 0) break;
int lock_ret = lock(m);
if (lock_ret == 0) break;
LOG_ERROR("failed to get mutex lock, ` `, try again", VALUE(ret), ERRNO());
thread_usleep(1000, nullptr);
}
Expand Down Expand Up @@ -1884,6 +1885,8 @@ R"(
}

int vcpu_init() {
if (unlikely(PAGE_SIZE == 0))
PAGE_SIZE = getpagesize();
RunQ rq;
if (rq.current) return -1; // re-init has no side-effect
char* ptr = nullptr;
Expand Down
Loading